perihelion.frink

View or download perihelion.frink in plain text format

// Calculates perihelion time of Earth from the sun.

use sun.frink
use planets.frink
use binarySearch.frink

mindist = 2 au
maxdist = 0 au

starttime =  beginningOfYear[now[]]
endtime =    beginningOfYearPlus[now[], 1]

f = {|date| Planet.Earth.getCoordinates[date]@2}

[mintime, mindist] = findALocalMinimum[f, starttime, endtime, 1 s]
[maxtime, maxdist] = findALocalMaximum[f, starttime, endtime, 1 s]

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


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 18868 days, 2 hours, 24 minutes ago.