# Wikipedia:Reference desk archive/Mathematics/2006 August 23

< August 22 Mathematics desk archive August 24 >
 The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions at one of the pages linked to above.

## Solving an equation

How do I solve this? ${\displaystyle 2^{x}+x=6}$

(Please sign your posts using "~~~~".) One solution is obvious (it's a small integer). The challenge is to decide if it is unique (over the real numbers or complex numbers), and to show how it might be found other than by "inspection". Think of the task as finding any zero-crossings of 2x+x−6. Over the reals, explore the "shape" of the function; especially, is it monotonic? (Consider its terms, or plot it.) Since it is continuous, we should try to bracket a zero. For example, x = 0 gives −5, while x = 5 gives 31; the function must cross zero somewhere between. Since it is differentiable, we can search for that zero using Newton's method. If we want to get more sophisticated, we can approach solution using Lambert's W function.
This is not a question that is likely to arise "in the wild"; where did it come from? --KSmrqT 09:28, 23 August 2006 (UTC)

In general, how shall I solve this type of equations? ${\displaystyle a^{x}+x=b}$

I think , it should be like this:

${\displaystyle a^{x}=b-x}$

Now try integer values of x starting from 1 until (b-1).

If that fails, then start using real values for x between 1 and b.

If all else fails, plot the graph of ${\displaystyle a^{x}}$ and ${\displaystyle b-x}$ on the same graph. Ohanian 11:59, 23 August 2006 (UTC)

If b is a positive integer, most solutions for x will not be integers. A closed-form expression for general ax+xb = 0 is
${\displaystyle x=b-{\frac {W(a^{b}\log a)}{\log a}},}$
where "log" denotes the natural logarithm (base e), and "W" denotes Lambert's W function. We cannot allow a to be negative if ax is to be meaningful, and if a is 0 or 1 then the solution is trivially x = b or x = b−1.
But again, what makes you ask? --KSmrqT 14:06, 23 August 2006 (UTC)

I'm sorry if I gave that impression but I did not ask the original question. I merely tried to help the person who asked the original question. " how shall I solve this type of equations? " is just me talking to myself. Ohanian 23:33, 23 August 2006 (UTC)

If, as is quite likely, you are attempting to solve the problem from the point of view of, say, high-school or low-level university mathematics (as opposed to, say, the kind of mathematics where you actually understand the article on the W-function enough to appreciate its full significance), then the best method goes something like this: Try graphing y = 2^x and y = 6-x, to the best of your abilities, on a single set of axes, and see what the general shape of the solutions are (are there zero solutions? just the one? quite a few? infinitely many?). Then, using whatever techniques may be available to you, try and "hone in" on whichever solution you decide is most important (perhaps all of them). In this case, the graph suggests a single solution, somewhere between 0 and 10. Trialling the integers will give you that single answer. If the situation were a little trickier, and the solution not a simple integer (eg. if you were trying to solve 2^x + x = pi), then your best bet is to find an approximate solution using, for example, the bisection method or Newton's method. Confusing Manifestation 14:03, 25 August 2006 (UTC)

Thank you friends for the help. The quetion actually arised "in the wild". --Vijaykcm 08:42, 26 August 2006 (UTC)

## Newton's Method Loop

Is it possible for Newton's Method to repeat two values, i.e: a=b-(f(b)/f'(b)) and b=a-(f(a)/f'(a)) (a and b are not equal)? All I can reduce this to is f(a)/f'(a)=f(b)/f'(b). --Alexs letterbox 10:03, 23 August 2006 (UTC)

[before edit conflict] The equation you have reduced this to is a necessary but not a sufficient condition, and you forgot a minus sign. The correct condition is:
${\displaystyle {\frac {f(a)}{f'(a)}}=-{\frac {f(b)}{f'(b)}}=a-b}$
Constructing examples of this is easy. Any function satisfying, for example, f(1) = f(-1) = 1, f '(1) = 0.5, f '(-1) = -0.5, will do. Say, ${\displaystyle {\frac {x^{2}+3}{4}}}$. -- Meni Rosenfeld (talk) 10:55, 23 August 2006 (UTC)
Here's a nicer example: ${\displaystyle f(x)={\sqrt {x^{2}+1}}}$. For every given ${\displaystyle x\neq 0}$, the method will alternate between x and −1/x. -- Meni Rosenfeld (talk) 11:09, 23 August 2006 (UTC)
Did you mean f(x) = – (x2 + 2)? --LambiamTalk 02:45, 24 August 2006 (UTC)
No... I don't see what's wrong with my examples, or for that matter, what's right with your example (it does alternate for ${\displaystyle \pm {\sqrt {2/3}}}$, but that seems needlessly complicated). -- Meni Rosenfeld (talk) 09:51, 24 August 2006 (UTC)
Yes, this is easily arranged. For example, let h(−1) = −4, h(1) = 4, and h′(−1) = h′(1) = 2. (The function h(x) = 5xx3 will suffice.) Then with a = −1 and b = 1 we have
${\displaystyle 1-{\frac {4}{2}}=-1;}$
${\displaystyle -1-{\frac {-4}{2}}=1.}$
With exact arithmetic Newton's method will never find the zero at x = 0; it bounces endlessly between −1 and +1. Besides this pathology, Newton's method can go shooting off away from a bounded zero. Thus, in practice, we embed Newton's method in a more robust safeguard, such as Brent's method. --KSmrqT 11:22, 23 August 2006 (UTC)

Thanks for the examples, but none of them have zeros anyway, so it is unlikely that one would run into this problem while using the method, isn't it? --Alexs letterbox 10:29, 24 August 2006 (UTC)

How about this for an example that has zeros: f(x)=x3-x. If you take ${\displaystyle x_{0}=1/{\sqrt {5}}}$, then you get into a non-trivial loop between ${\displaystyle \pm 1/{\sqrt {5}}}$. Madmath789 10:39, 24 August 2006 (UTC)
KSmrq's example has a zero, a fact which is apparent and that he explicitly stated. And I thought it was quite clear that solutions to the problem are so abundant, that of course one can find such functions with as many zeros as one likes. Take the conditions I've stated above (f(1) = f(-1) = 1, f '(1) = 0.5, f '(-1) = -0.5) and add the condition f(0) = 0. You'll get ${\displaystyle {\frac {7x^{2}-3x^{4}}{4}}}$, which exhibits the same behavior and has a zero at x = 0. Since you can set whatever conditions you want on a function and its derivatives (that is, their values at given points) and find a polynomial that satisfies them, any example you can think of is quite easy to generate. KSmrq also explained that Newton's method can cause problems in practice, and thus should not be applied naively. This particular problem is probably rare, since functions tend to have only a finite set of points where this occurs. -- Meni Rosenfeld (talk) 12:42, 24 August 2006 (UTC)
Please read my reply carefully - I was not stating that any of the previous examples did not have zeros - simply that mine did. Madmath789 13:27, 24 August 2006 (UTC)
My latest reply and accompanying request was not directed at you, but rather at Alexs letterbox. Maybe you didn't read it carefully :-) -- Meni Rosenfeld (talk) 16:55, 24 August 2006 (UTC)
I completely missed KSmrq's example. Sorry for the frustration. --Alexs letterbox 06:37, 25 August 2006 (UTC)
Consider the square root function. Extend it to negative numbers with absolute value:
${\displaystyle f(x)={\sqrt {|x|}}}$
or with modulus and sign function:
${\displaystyle g(x)=\operatorname {sgn}(x){\sqrt {|x|}}.}$
And a cube root might be even more fun. :) --CiaPan 18:40, 24 August 2006 (UTC)

## Prime Indicator Function

Wilson's Theorem gives a nice division between primes and composites. Do you know of any others, preferably that don't involve a factorial? Black Carrot 20:30, 23 August 2006 (UTC)

Do you mean you want to find other primality tests? The Lucas-Lehmer test is a rather nice and simple one. Dysprosia 22:28, 23 August 2006 (UTC)
The Agoh-Giuga conjecture is something similar. Fredrik Johansson 18:01, 25 August 2006 (UTC)

Thanks, those are excellent. I notice, though, that they all seem to involve factorials, exponentials, or both. What's up with that? Black Carrot 05:25, 29 August 2006 (UTC)

## Digits of Pi

Is there a website that displays Pi to, perhaps, the 1000th digit or more? thanks. Jamesino 23:22, 23 August 2006 (UTC)

A lot more than that! SEe Pi#External links. Melchoir 23:28, 23 August 2006 (UTC)

Why do you need more than 16 digits? Are you trying to calculate the circuference of the universe? Ohanian 23:38, 23 August 2006 (UTC)

What is significant about 16 digits? --Proficient 04:46, 24 August 2006 (UTC)
That is double precision in computers. (Igny 19:22, 24 August 2006 (UTC))
More accurate approximations are covered by export regulations. —Bromskloss 15:26, 25 August 2006 (UTC)