On Wed, Oct 26, 2011 at 6:02 AM, Rupert Swarbrick <rswarbrick at gmail.com>wrote:
> Daniel Dalton <daniel.dalton47 at gmail.com> writes:
> > Hello,
> >
> > I need to solve the following.
> >
> > 3^x=x+4
> >
> > My text book tells me to graph it and see where the graphs (y=x+4, and
> > y=3^x) meet. Unfortunately, I'm blind and can't read very accurately off
> > the graph, and thus am using maxima instead of the recommended devices
> > by my school.
> >
> > I tried this:
> > solve([y=x+4, y=3^x],[x,y]);
> >
> > Obtaining this:
> >
> > algsys: tried and failed to reduce system to a polynomial in one
> variable; give up.
> > -- an error. To debug this try: debugmode(true);
> >
> > Can anyone recommend a way I should solve this question with maxima?
>
> Hi,
>
> The reason that your textbook recommends solving this by looking at a
> graph is that the equation isn't easy to solve symbolically. (Indeed, I
> suspect that there isn't a solution that can be written in elementary
> functions, but I'm not sure how to prove that).
>
> As such, you're going to have to use some numerical method (staring at a
> graph basically gives you low-tech numerical root finding). Maxima has a
> function called find_root that will do the job for you nicely, but it
> needs to know where to look and it only copes with functions of one
> variable.
>
> Firstly, we can turn this into a problem of only one variable since
> y=x+4 means that x=y-4 so y=3^x gives us y = 3^(y-4). Functions like
> find_root actually want an expression that they can test for zero, so
> let's look at y - 3^(y-4).
>
> Now we need to know where to look for a root. Notice that if y < 0 the
> expression must be negative since 3^(anything) is positive and is being
> subtracted from a negative number. If y = 1, the expression is
> definitely positive, since 3^(-3) < 1. If y is large, the expression
> will be negative since 3^(y-4) grows exponentially.
>
> As a result (since the expression gives a continuous function of y), we
> know there must be at least two roots. Indeed, there really are only two
> roots, which you could check by differentiating (then the expression
> becomes easier to solve, because the "y" term becomes constant and you
> can take logarithms).
>
> Now we can finally use find_root:
>
> (%i18) find_root (y - 3^(y-4), y, 1, 10);
> (%o18) 5.56191876632454
> (%i19) find_root (y - 3^(y-4), y, 0, 1);
> (%o19) .01251661588402949
>
> Tada!
>
> Incidentally, I suspect that was slightly more information than your
> textbook expected you to need. In particularly, if you can look at the
> graph, it becomes "obvious" that there are two roots. Of course, for
> weirder functions, even those with perfect eyesight would need to use
> this sort of argument...
>
>
> Rupert
>
>
Rupert did an excellent reply, but let me point out that the answer that he
gave is the Y value at the points where they cross.
To find the x value directly you could do:
(%i1) find_root(3^x-x-4,x,0,10);
(%o1) 1.56191876632454
and
(%i4) find_root(3^x-x-4,x,-100,00);
(%o4) - 3.987483384115971
HTH
Doug