Skip to main content

Exploring Calculus with Maple Introductory Calculus

Section 10.3 Solving an Equation of One Variable

The parameters of solve() and fsolve() are the same in most cases. You must include the equation to be solved and you can specify the variable that you wish to solve for.
> solve(x^2 = 5, x);
\begin{equation*} \displaystyle \sqrt{5},\,- \sqrt{5} \end{equation*}
> fsolve(x^2 = 5, x);
\begin{equation*} \displaystyle - 2.236067977,\, 2.236067977 \end{equation*}
If there is only one variable in the equation, then it is not necessary to specify the desired variable.

Aside

> solve(x^2 = 5);
\begin{equation*} \displaystyle \sqrt{5},\,- \sqrt{5} \end{equation*}
> fsolve(x^2 = 5);
\begin{equation*} \displaystyle - 2.236067977,\, 2.236067977 \end{equation*}
If you provide solve() or fsolve() with an expression rather than an equation, then the solver will set that expression equal to \(0\) and solve the resulting equation.

Aside

> solve(x^2 - 5, x);
\begin{equation*} \displaystyle \sqrt{5},\,- \sqrt{5} \end{equation*}
> fsolve(x^2 - 5, x);
\begin{equation*} \displaystyle - 2.236067977,\, 2.236067977 \end{equation*}
Maple will give complex solutions using \(\displaystyle I= \sqrt{-1}\) when using solve(). Typically, fsolve() will not display complex solutions.
> poly := 12*x^3-14*x^2+13*x-6;
\begin{equation*} \displaystyle poly\, := \,12\,{x}^{3}-14\,{x}^{2}+13\,x-6 \end{equation*}
> factor(poly = 0);
\begin{equation*} \displaystyle \left( 4\,{x}^{2}-2\,x+3 \right) \left( 3\,x-2 \right) =0 \end{equation*}
> solve(poly = 0, x);
\begin{equation*} \displaystyle 1/4-I/4 \sqrt{11},\,1/4+I/4 \sqrt{11},\,2/3 \end{equation*}
> fsolve(poly = 0, x);
\begin{equation*} \displaystyle 0.6666666667 \end{equation*}
When trying to solve high-degree polynomials, solutions may be displayed symbolically using solve(), while fsolve() may display a more useful output.
> high := x^4 + 133*x + 200;
\begin{equation*} \displaystyle high\, := \,{x}^{4}+133\,x+200 \end{equation*}
> solve(high);

Aside

\begin{equation*} \displaystyle \begin{array}{l} RootOf \left( {\_Z}^{4}+133\,\_Z+200,index=1 \right) \\ RootOf \left( {\_Z}^{4}+133\,\_Z+200,index=2 \right) \\ RootOf \left( {\_Z}^{4}+133\,\_Z+200,index=3 \right) \\ RootOf \left( {\_Z}^{4}+133\,\_Z+200,index=4 \right) \end{array} \end{equation*}
This output is Maple’s way of representing four solutions to the quartic symbolically. Switching to fsolve(), we see only two real solutions. The other two solutions are either complex or were not found using the methods used in fsolve().
> fsolve(high);
\begin{equation*} \displaystyle - 4.448682310,\,- 1.546800745 \end{equation*}
When using the fsolve() command, you may also specify an interval in which to look for a solution. In this example, solutions will only be found on the interval \([5,10]\text{.}\)
> fsolve(cos(x) = tan(x), x = 5..10);
\begin{equation*} \displaystyle 6.949424740 \end{equation*}

Example 10.1. Finding the Intersection of Two Functions.

In this example, we will find the intersection point of \(f(x) = x\ln(x)\) and \(g(x) = \sin(x)\text{.}\)

Aside

> f(x) := x*ln(x);
\begin{equation*} \displaystyle f\, := \,x\mapsto x\ln \left( x \right) \end{equation*}
> g(x) := sin(x);
\begin{equation*} \displaystyle g\, := \,x\mapsto \sin \left( x \right) \end{equation*}
Equating \(f(x) = g(x)\text{,}\) we can use either solve() or fsolve() to obtain a solution. Since this is an equation in \(x\) only, we will get the \(x\)-coordinate of the point.
> solve(f(x) = g(x));
\begin{equation*} \displaystyle \textit{RootOf} \left( \textit{\_Z}\,\ln \left( \textit{\_Z} \right) -\sin \left( \textit{\_Z} \right) \right) \end{equation*}
> fsolve(f(x) = g(x));
\begin{equation*} \displaystyle 1.752677281 \end{equation*}
We can use this result and substitute into \(f(x)\) or \(g(x)\) to determine the corresponding \(y\)-coordinate.
> f(%);
\begin{equation*} \displaystyle 0.9835052055 \end{equation*}
So, the point of intersection is \((1.752677281,0.9835052055)\text{.}\) This can be verified by plotting both functions.
> plot( [f(x), g(x)], x=0..2);
Note that while it appears that there is another intersection point at \(x=0\text{,}\) \(f(0)\) is undefined.