Numerical solution in Matlab or any other solver

I need to find x of this equation:

1.0221044505936159^x + 1.0446975079232772^x + 1.0677899723724409^x + 1.091392883061106^x + 1.1155175231229544^x + 1.140175425099138^x + 1.1653783764512973^x + 1.1911384251964328^x + 1.2174678856663448^x + 1.24437934439437^x + 1.2718856661322526^x + 1.3287357857717006^x + 1.3581067603002603^x + 1.3881269640841731^x + 1.4188107479794378^x + 1.3^x == 21

Most probably, it's not possible to solve it analytically but numerically...

I tried Mathematica, but the respond was like:

The equations appear to involve the variables to be solved for in an essentially non-algebraic way.

Any idea if there is a numerical solver online that could solve it? How about Matlab?

-
– user2468 Mar 17 '12 at 17:51

Using the information provided by @user1111261 in the comments, the question can more precisely be described as finding a solution to:

$$\sum_{i=1}^{16} (1.3^{i/12})^x = 21$$

Using some algebra, the summation can equivalently be written as

$$\sum_{i=1}^{16} (1.3^{i/12})^x = \sum_{i=1}^{16} 1.3^{ix/12} = \sum_{i=1}^{16} (1.3^{x/12})^i = \sum_{i=1}^{16} r^i, \quad (r = 1.3^{x/12})$$

This is a simple geometric series, so we can eliminate the summation and write it neatly as

$$\sum_{i=1}^{16} r^i = \frac{r^{17} - r}{r - 1}, \quad (r = 1.3^{x/12})$$

Since this has to equal $21$, we get

$$\frac{r^{17} - r}{r - 1} = 21 \ \Leftrightarrow \ r^{17} - r = 21r - 21 \ \Leftrightarrow \ r^{17} - 22r + 21 = 0, \quad (r = 1.3^{x/12})$$

This equation has three real roots: one at $r_1 = 1$, one negative root at $r_0 \approx -1.25$ and one positive root at $r_2 \approx 1.03$. I do not think you can find a nicer expression for this root $r_2$, but we need that root. We then get

$$1.3^{x/12} = r_2 \ \Leftrightarrow \ \frac{x}{12} \log 1.3 = \log r_2 \ \Leftrightarrow \ x = \frac{12 \log r_2}{\log 1.3}$$

So with one line in Mathematica,

In[1] := (12 Log[r] / Log[1.3]) /. FindRoot[r^17 - 22 r + 21 == 0, {r, 1.03}]

We get the result

Out[1] = 1.4091023318304141
-

I think that you should obtain solution using Mathematica NSolve command :

NSolve[1.0221044505936159^x + 1.0446975079232772^x +
1.0677899723724409^x + 1.091392883061106^x +
1.1155175231229544^x + 1.140175425099138^x +
1.1653783764512973^x + 1.1911384251964328^x +
1.2174678856663448^x + 1.24437934439437^x + 1.2718856661322526^x +
1.3287357857717006^x + 1.3581067603002603^x +
1.3881269640841731^x + 1.4188107479794378^x + 1.3^x ==
21, x, Reals]

$x=1.4091$

-

Another approach in Mathematica using FindRoot:

In[1]:= FindRoot[
1.0221044505936159^x + 1.0446975079232772^x + 1.0677899723724409^x +
1.091392883061106^x + 1.1155175231229544^x + 1.140175425099138^x +
1.1653783764512973^x + 1.1911384251964328^x +
1.2174678856663448^x + 1.24437934439437^x + 1.2718856661322526^x +
1.3287357857717006^x + 1.3581067603002603^x +
1.3881269640841731^x + 1.4188107479794378^x + 1.3^x == 21, {x, 1}]

Out[1]= {x -> 1.4091}

Since FindRoot is an implementation of Newton's method, you must provide a first approximation to the root. In this case I have chosen $1$.

-
------------------------------------------------------ – user1111261 Mar 17 '12 at 21:30
I do not know how to do it even for a simpler equation like $2^x+3^x=6$. What you can do is prove that for any $y>0$ there exists a unique solution of the equation $\text{"complicated LHS"}=y$. – Julián Aguirre Mar 17 '12 at 21:36

Here's a simple implementation of the bisection method in Mathematica, which uses the fact that the expression is (strictly) increasing in $x$. First we insert the function as $f$:

f[x_] := 1.0221044505936159^x + 1.0446975079232772^x +
1.0677899723724409^x + 1.091392883061106^x +
1.1155175231229544^x + 1.140175425099138^x +
1.1653783764512973^x + 1.1911384251964328^x +
1.2174678856663448^x + 1.24437934439437^x +
1.2718856661322526^x + 1.3287357857717006^x +
1.3581067603002603^x + 1.3881269640841731^x +
1.4188107479794378^x + 1.3^x;

Then set up two lists A = {0}; and B = {3}; with initial values $a_0 = 0$ and $b_0 = 3$, such that $16 = f(a_0) < 21 < f(b_0) = 29.236\ldots$. Now implement a loop that decreases the search space by a factor $2$ every time, for some number of iterations (in this case $30$), by checking if the solution is in the right half or in the left half of the interval formed by the last elements of A and B:

For[i = 1, i <= 30, i++,
m = (Last[A] + Last[B])/2;
If[f[m] < 21, AppendTo[A, m], AppendTo[B, m]];
];

Finally, we output the left side and the right side of the small interval where the solution can be found: {N[Last[A],10], N[Last[B],10]}. The output from Mathematica is $\{1.409102323, 1.409102325\}$. So the solution $x$ is given by $x = 1.40910232\ldots$

-
Btw, there is no way to solve it analytically? I've been thinking about it for 6 months now... – user1111261 Mar 17 '12 at 21:32
@user1111261: I don't think you will be able to solve it analytically. Unless you have some specific useful information about those numbers $1.022\ldots$ etc. – TMM Mar 17 '12 at 21:38
They are these numbers: (1.3)^16/12 , (1.3)^15/12, .... (1.3)^1/12. Altogether it's 16 numbers. – user1111261 Mar 17 '12 at 21:53

For MATLAB, you can use

x = fzero(fun,x0) tries to find a zero of fun near x0.. more in help page

First, define a function $f(x)$ with

f(x) = @(x) 1.0221044505936159^x + 1.0446975079232772^x +
1.0677899723724409^x + 1.091392883061106^x +
1.1155175231229544^x + 1.140175425099138^x +
1.1653783764512973^x + 1.1911384251964328^x +
1.2174678856663448^x + 1.24437934439437^x +
1.2718856661322526^x + 1.3287357857717006^x +
1.3581067603002603^x + 1.3881269640841731^x +
1.4188107479794378^x + 1.3^x - 21

Now solve $f(x) = 0$ using a guess $x_0 = 1$:

fzero(f, 1)

which gives the answer $$\boxed{x = 1.409102331830407}$$

The help page state the method is

The algorithm, which was originated by T. Dekker, uses a combination of bisection, secant, and inverse quadratic interpolation methods.

-