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.
\begin{equation*}
\displaystyle \sqrt{5},\,- \sqrt{5}
\end{equation*}
\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 It may not make sense to use
both solve() and
fsolve(). Choose the solver that produces the most useful output.
\begin{equation*}
\displaystyle \sqrt{5},\,- \sqrt{5}
\end{equation*}
\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 Note that
solve(x^2 - 5) is equivalent to typing
solve(x^2 - 5 = 0, x).
\begin{equation*}
\displaystyle \sqrt{5},\,- \sqrt{5}
\end{equation*}
\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*}
\begin{equation*}
\displaystyle \left( 4\,{x}^{2}-2\,x+3 \right) \left( 3\,x-2 \right) =0
\end{equation*}
\begin{equation*}
\displaystyle 1/4-I/4 \sqrt{11},\,1/4+I/4 \sqrt{11},\,2/3
\end{equation*}
\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*}
Aside Sometimes when Maple cannot solve an expression algebraically, the
solve() command will output a symbolic solution, using
RootOf() to describe the solution. In these cases, you may wish to try the
fsolve() command instead.
\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().
\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 An even more efficient way of finding the point of intersection of two functions is to solve a system of two variables simultaneously. An example of this can be found in
ExampleΒ 10.2 .
\begin{equation*}
\displaystyle f\, := \,x\mapsto x\ln \left( x \right)
\end{equation*}
\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.
\begin{equation*}
\displaystyle \textit{RootOf} \left( \textit{\_Z}\,\ln \left( \textit{\_Z} \right) -\sin \left( \textit{\_Z} \right) \right)
\end{equation*}
\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.
\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.