solve.frink

Download or view solve.frink in plain text format


// Program to demonstrate solving using the solvingTransformations.frink file.
// This wee program will do your algebra for you.

use allTransforms.frink

showApproximations[false]
symbolicMode[true]
while (text = input["Enter expression: "])
{
   expr = parseToExpression[text]

//   println["expr is $expr"]
// This version shows without trace.
//   res = transformExpression[expr]
//   println["\n$res"]

   // This version shows trace
   res = transformExpressionTrace[expr]
   println["\n" + join["\n",res]]
   last = res@(length[res]-1)

   // Evaluate right-hand sides of solved expressions like a === solution
   for eq = toArray[last]
   {
      if structureEquals[_a === _b, eq]
      {
         println["\nSymbolic: " + eq]
         println["Numeric:  " + getChild[eq, 0] + " = " + eval[getChild[eq, 1]]]
      } else
      {
         println["Not solved?"]
         println[eq]
         println[eval[eq]]
      }
   }

 


Download or view solve.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, 6 hours, 37 minutes ago.