solve.fsp - Frink Server Pages highlighter

[Try solve.fsp]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
<HTML LANG="en">
 <HEAD>
  <TITLE>Frink Solver</TITLE>
  <META NAME="viewport" CONTENT="width=device-width, initial-scale=1.0">
  <META HTTP-EQUIV="Default-Style" CONTENT="Spaceship"> 
  <LINK REL="StyleSheet" HREF="/frinkdocs/spaceship.css"
        TYPE="text/css" TITLE="Spaceship">
  <LINK REL="Alternate StyleSheet" HREF="/frinkdocs/apeairy.css" 
        TYPE="text/css" TITLE="APE Airy"> 
  <LINK REL="Alternate StyleSheet" HREF="/frinkdocs/style.css" TYPE="text/css"
        TITLE="APE Classic">
  <LINK REL="Alternate StyleSheet" HREF="/frinkdocs/style2.css" TYPE="text/css"
        TITLE="Compact"> 
  <LINK REL="icon" HREF="/images/futureboyicon.png" TYPE="image/png">
  <LINK REL="canonical" HREF="https://frinklang.org/fsp/solve.fsp">
 </HEAD>
<% 
    use ../derivatives.frink
    use ../solvingTransformations.frink
    use ../integrals.frink
    use ../BooleanTransformations.frink
    use ../HTMLUtils.frink

//    showApproximations[false]
    symbolicMode[true]

    if ! isVariableDefined["equation"]
       if isVariableDefined["eq"]
          equation = eq  // Moving to use variable "eq" for shorter URLs.
 
    equation = equation ? equation : "x^2 + 3x - 2 + 4y + 3y^2 = 3x - y + 10"
    eqStr = HTMLEncode[equation]
    solveFor = solveFor ? solveFor : "x"
    solveStr = HTMLEncode[solveFor]
    wchecked = w ? "CHECKED" : ""
    fchecked = f ? "CHECKED" : ""
%>

 <BODY>
  <H1>Frink Solver</H1>
  <DIV CLASS="back">
    <FORM ACTION="solve.fsp" METHOD="GET">
      <TABLE BORDER="0" SUMMARY="Equation input">
        <TR><TD><LABEL FOR="eq">Equation:</LABEL>
        <INPUT TYPE="text" NAME="eq" SIZE="40" ID="eq" VALUE="$eqStr" STYLE="width:100%">
        <TR><TD><LABEL FOR="solveFor">Solve&nbsp;for:&nbsp;</LABEL><INPUT TYPE="text" SIZE="3"
        NAME="solveFor" ID="solveFor" VALUE="$solveStr">
        <TR><TD COLSPAN="2"><INPUT TYPE="CHECKBOX" NAME="w" ID="w" $wchecked
        onChange="this.form.submit();"><LABEL FOR="w">Show work</LABEL>
        <TR><TD COLSPAN="2"><INPUT TYPE="CHECKBOX" NAME="f" ID="f" $fchecked
    onChange="this.form.submit();"><LABEL FOR="f">Output in raw Frink notation</LABEL>
        <TR><TD COLSPAN="2"><INPUT TYPE="Submit" VALUE="Solve">
      </TABLE>
   </FORM>      
  </DIV>        
<%
    if (equation)
    {
        if (equation =~ %r/=/)
        {
           equation =~ %s/=/===/
           expr = parseToExpression["solve[$equation,$solveFor]"]
        } else
        {
           println["<P><I>No equals sign present.  Will not solve equation, but just evaluate the expression.</I></P>"]
           expr = parseToExpression[equation]
        }

        println["<P><B>Solution:</B></P><P CLASS=\"code\"><CODE>"]
        if w  // Show work?
        {
           res = transformExpressionTrace[expr]
           if f
              println[removeApproximations[join["<BR><BR>",array[res]]]]
           else
              println[formatExpressionSymbolic[join["<BR><BR>",array[res]]]]
        } else
        {  // Don't show work
           res = transformExpression[expr]
           if f
              println[removeApproximations[join["<BR>",array[res]]]]
           else
              println[formatExpressionSymbolic[join["<BR>",array[res]]]]
        }
        println["</CODE></P>"]
     }
%>

  <HR>
  <P>
   View source of <A HREF="highlight.fsp?f=solve.fsp">this FSP page</A> or the <A HREF="colorize.fsp?f=solvingTransformations.frink">transformation rules</A> that solve these equations.
  </P>
  <P>
   <I><A HREF="mailto:eliasen@mindspring.com">Alan Eliasen</A></I> was born
   <%= round[now[] - #1969-08-19 04:54 PM Mountain#, minute] -> ["days", "hours", "minutes"] %> ago.
  </P>

  <P>
   Back to <A HREF="/frinkdocs/fspdocs.html">Frink Server Pages
    documentation.</A>
  </P>  
 </BODY>
</HTML>

[Try solve.fsp]


Alan Eliasen was born 17536 days, 5 hours, 58 minutes ago.

Back to Frink Server Pages documentation.