Search code examples
mathtrigonometryjulian-date

Daylight Hours Calculation


I am having problem to get a numerical value for this expression where I am trying to calculate the daylight hours using this formula. Its ending up giving a NaN when I evaluate this expression.

J stand for Julian day. (for e.g today J = 172;)

Any help will be highly valuable, Thanks

P = Math.asin(0.39795*Math.cos(0.2163108 + 2*Math.atan(0.9671396*Math.tan[0.00860*(J-186)])));

Solution

  • I tried it and got an answer ... :

    P = Math.Asin(0.39795 * Math.Cos(0.2163108 + 2 * Math.Atan(0.9671396 * Math.Tan(0.00860 * (J- 186)))));
    

    I changed the "[" to "(" in Math.tan[0.00860*(J-186)])))

    And I got a result ... (To test it I changed J to 172)

    Make sure the P is a Double