To solve this numerically :

90 Views Asked by At

$$0.5 = 1 −{0.955}^n − {0.005}^n{0.995}^{n −1}n − {0.005}^2{0.995}^{n −2}\left(\frac{n(n−1)}{2}\right)$$

I'm using MatLab but should I use a for-loop? Can anyone work me through the steps?

Thank you!

3

There are 3 best solutions below

3
On BEST ANSWER

In Matlab and Octave fsolve is a nice function for finding roots to functions.

First you need a "function handle" for your function, you can do this defining it as a lambda expression and assigning it a name, say f:

f = @(n)1-(0.955^n) - (0.005^n)*(0.995^(n-1))*n - (0.005^2)*(0.995^(n-2))*n*((n−1)/2) - 0.5;

now typing

n_solved = fsolve(f, n_guess);

will probably find the numerical solution closest to your guess.

2
On

You could use Newton's Method to solve the equation numerically:

Set $f(n) = 1−0.955^n −0.005^n\cdot0.995^{n −1}\cdot n− 0.005^2\cdot0.995^{n −2}\cdot \frac{n(n−1)}{2} -0.5$

Then $n$ is a solution of your equation exactly when $n$ is a root of $f$,that is $f(n) = 0$.

Newton's method goes like this:

$x_{m+1} = x_m - \frac{f(x_m)}{f'(x_m)}$

where $f'(n)$ is the derivative of $f$ with respect to $n$. Choose some starting value $x_0$ to get started with the iteration.

Edited:

As Michael said, you could plot the function and get an approximate value $x_0$ for $n$, which you could use as the starting value of the Newton iteration if the value of $x_0$ is not accurate enough for your needs.

1
On

I would plot the function:

n=0.001:0.001:20;  
plot(n,1-(0.995.^n) - (0.005.^n).*(0.995.^(n-1)).*n - (0.005^2)*(0.995.^(n-2)).*(n.*(n-1))/2)

Then see where the graph cuts 0.5.