optimumLaunch.frink

Download or view optimumLaunch.frink in plain text format


/** This program determines the optimal launch angle to achieve the maximum
    range. */


use systemSolver2.frink
symbolicMode[true]
showApproximations[false]
showDimensionName[false]

// Solve the system symbolically.
// h is height, v0 is initial velocity, t is time, 
// theta is angle above horizontal.
launcher = new System[[h === h0 + Integrate[v0 sin[theta] - gravity t, t],
                       h === 0,
                       d === Integrate[v0 cos[theta], t]],
                      ["gravity"]]

println["Symbolic solutions:"]
launcher.solveAll[]
dsols = launcher.solveForValues["d", [["v0", 30 mph], ["h0", 50 feet sin[theta]]]]
println[join["\n\n",dsols]]
println[]

// Print distances for each launch elevation.
for theta = 0 degrees to 90 degrees step 1 degree
   for sol = eval[dsols]
      if (sol conforms length) && (sol > 0.01 ft) // Only positive, full solutions
         println[format[theta,"deg",3] + "\t" + format[sol,"ft",2]]


Download or view optimumLaunch.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 20139 days, 7 hours, 45 minutes ago.