Testwiki:Reference desk/Archives/Mathematics/2023 April 1

From testwiki
Jump to navigation Jump to search

Template:Error:not substituted

{| width = "100%"

|- ! colspan="3" align="center" | Mathematics desk |- ! width="20%" align="left" | < March 31 ! width="25%" align="center"|<< Mar | April | May >> ! width="20%" align="right" |Current desk > |}

Welcome to the Wikipedia Mathematics Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


April 1

Solving sums of powers

Consider the equation 2x+3x=13. The solution, of course, is x=2. What I am trying to understand is how to approach the general case; given Ax+Bx=C, for any known A,B,C, what is the value of x? I just can't wrap my head around a reasonable approach. I tried taking the natural log on both sides, but that didn't seem to help. Had it been a single term on the left-hand-side of the equation, I could have extracted the exponent and solved it without much fuss. Any suggestions/pointers on how to proceed? Earl of Arundel (talk) 02:17, 1 April 2023 (UTC)

In the following, I assume that A,B, and C are all positive. In only a few cases can equations with a sum of powers with the unknown x in the exponents be solved easily, by trial and error or analytically. If C=2, the solution is given by x=0. If B=1, we find x=logA(C1). But there is no analytical way to solve this in general, so we have to resort to a numerical approach. I think Newton's method will do well, using
f(x)=Ax+BxC,
f(x)=AxlogA+BxlogB,
and repeatedly computing
xn+1=xnf(xn)f(xn)
until a desired level of convergence. For the initial estimate, we can use, assuming wlog that |logA||logB|,
x0=logAC  if  C<2,
x0=logBC  otherwise.
Convergence is not guaranteed, though. When A and B are not at opposite sides of 1, the equation may not have a solution or may have two solutions. The computation may also fail by dividing by 0, as when A=B=1. If there is an integer solution, it will be found.  --Lambiam 07:32, 1 April 2023 (UTC)
Convergence to high precision may also fail due to the lack of precision in floating point arithmetic. For 2x+3x=60073, which is solved by x=10, numerical computation (using exponentiation by zx=exp(xlogz)) results in x4=10.0 on the dot, but then computing f(x4) does not result in zero but produces 1.3096723705530171010.  --Lambiam 08:04, 1 April 2023 (UTC)
In general there are several ways for Newton's method to fail; see the section "Failure analysis" in that article. I think the main point though is that the equation is not solvable in closed form and one must resort to numerical methods to get an approximate value. Of course nowadays you can plug an equation in Wolfram Alpha and get a numerical answer. --RDBury (talk) 17:00, 1 April 2023 (UTC)
The issue above is not among the failure modes mentioned in that section, which are mathematical in nature. Mathematically, 210+31060073 is exactly equal to 0. But the actual computed value is not; we get
310.0=exp(10×log3)=exp(10×1.09861228866810956...)=
=exp(10.9861228866810956...)=59048.99999999986...<59049=310.
 --Lambiam 20:04, 1 April 2023 (UTC)
Thanks, Lambiam, I had no idea this was such a difficult problem to solve for the general case! I wonder if there is some way to guarantee convergence (for most cases anyway) by dividing through by C? Playing with that idea I even found an interesting approximation for x:
Ax+Bx=C
Ax/C+Bx/C=1
Ax/C=1Bx/C
xln(A)ln(C)=ln(CBx)ln(C)
xln(A)=ln(CBx)

Template:Strikethroughdiv Earl of Arundel (talk) 18:58, 1 April 2023 (UTC)

Whoops, that isn't right! Earl of Arundel (talk) 19:14, 1 April 2023 (UTC)
You can get to faster to your fifth line without dividing by C:
Ax+Bx=C
Ax=CBx
ln(Ax)=ln(CBx)
xlnA=ln(CBx).
It appears plausible that using f(x)=xlnAln(CBx) gives faster convergence, or, when |logA||logB|, swapping A and B and using f(x)=xlnBln(CAx). I have not investigated this, though. If A and B are similar in size and not at opposite sides of 1, we can approximate Ax+Bx by 2(12(A+B))x and use
x0=lnCln2ln(A+B)ln2.
For the case of 2x+3x=13, we then get x02.04280.  --Lambiam 19:38, 1 April 2023 (UTC)
Nice! That does seem to work pretty well. Where does the ln2 term come from though? It seems to randomly pop up in a lot of equations, come to think of it. Why is that, I wonder? Earl of Arundel (talk) 20:58, 1 April 2023 (UTC)
Instead of solving Ax+Bx=C, we set off by solving
2(12(A+B))x0=C
(12(A+B))x0=12C
x0ln(12(A+B))=ln(12C)
x0(ln(A+B)ln2)=lnCln2
--Lambiam 21:21, 1 April 2023 (UTC)
Ah, right. Subtracting ln2 has the same effect as dividing by 2 in that context. Thanks again! Earl of Arundel (talk) 21:39, 1 April 2023 (UTC)