tvaspect.frink

View or download tvaspect.frink in plain text format


/**  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", 55 in]]
dsols = tv.solveForValues["width", values]

//println["dsols is $dsols"]
println[positive[eval[dsols]]->"in"]


View or download tvaspect.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 17649 days, 5 hours, 46 minutes ago.