$$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!
$$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!
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.
In Matlab and Octave
fsolveis 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:now typing
will probably find the numerical solution closest to your guess.