accelerationSolver.frink

Download or view accelerationSolver.frink in plain text format


// Demonstration and test of solving systems of equations.

// This demonstrates symbolic integration as well.
// This particular example calculates the velocity and height reached by
// an exploding water heater on a Mythbusters episode.

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

heater = new System[[ a === -gee,
                     v === Integrate[a, t] + v0,
                     h === Integrate[v, t] + h0,
                     h0 === 0 ft],
                    ["gee", "ft"]]

println["All solutions:"]
println[join["\n", heater.solveAll[false]]]

println[]
println["Solution for initial velocity, incompletely specified"]
args = []
println[join["\n", heater.solveForValues["v0", args]]]
println[]

println[]
println["Solution for initial velocity, completely specified"]
args = [["t", 11.8 s], ["h", 0 ft]]
solutions = heater.solveForValues["v0", args]
println[" Raw solutions:"]
println[join["\n", solutions] + "\n"]
println[" Evaluated solutions:"]
println[eval[solutions]->"mph"]
println[]

println[]
println["Symbolic solution for height:"]
println[join["\n",heater.solveFor["h"]]]
println[]

// Find maximum height
for sol = solutions
{
   println["Sol is $sol"]
   args = [["v0", eval[sol]], ["t", 11.8/2 s]]
   println[eval[heater.solveForValues["h", args]] -> "feet"]
}
println[]




Download or view accelerationSolver.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 20217 days, 23 hours, 51 minutes ago.