/** If a television has an aspect ratio of 16:9, and a diagonal size of
55 inches, how wide is it?
*/
use systemSolver2.frink
symbolicMode[true]
showApproximations[false]
showDimensionName[false]
// Create a system of simultaneous equations and let Frink rearrange
// and solve it.
tv = new System[[width / height === aspect ,
diagonal^2 === height^2 + width^2], // Pythagorean theorem (in natural form!)
[]]
// Show all solutions to show off
//println[join["\n",tv.solveAll[]]]
tv.solveAll[]
// Plug in exact numbers and solve for the wall's cross section.
println["Solutions:"]
values = [["aspect", 16/9],
["diagonal", 65 in]]
dsols = tv.solveForValues["width", values]
//println["dsols is $dsols"]
println[positive[eval[dsols]]->"in"]