perihelion.frink

View or download perihelion.frink in plain text format

// Calculates perihelion time.  This may not be quite accurate because
// I may not be running enough terms in the position of the sun.

use sun.frink

mindist = 2 au
maxdist = 0 au

starttime =  #2016#
endtime =  #2017# 
mintime = starttime
maxtime = starttime

tint = new interval[starttime, endtime]
println["Interval guess is: " + (sunDistance[tint]->"km")]

for time = starttime to endtime step minute
{
   dist = sunDistance[time]
//   println[dist]
   if (dist < mindist)
   {
      mindist = dist
      mintime = time
   }
   if (dist > maxdist)
   {
      maxdist = dist
      maxtime = time
   }
}

println["Minimum distance is " + (mindist -> "km") + ", " + (mindist -> "au") + ", " + (mindist-> "miles") + " at $mintime."]
println["Maximum distance is " + (maxdist -> "km") + ", " + (maxdist -> "au") + ", " + (maxdist-> "miles") + " at $maxtime."]

tint = new interval[starttime, endtime]
println["Interval guess is: " + (sunDistance[tint]->"km")]


View or download perihelion.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 17684 days, 20 hours, 22 minutes ago.