Solving an equation with summation in Matlab

176 Views Asked by At

I have to solve the equation below in MATLAB. Both $u$ and $\lambda$ are vectors of same size. How do I do this?

$\displaystyle f(\tau)=1+ \sum_{i=1}^n{\frac {u_i^2}{\lambda_i-\tau} = 0}$

1

There are 1 best solutions below

0
On BEST ANSWER

Equation

$$\tag{0}\displaystyle f(\tau)=1+ \sum_{i=1}^n{\frac {u_i^2}{\lambda_i-\tau} = 0}$$

can be considered as giving the abscissas of intersection points of the curve of function $g$ defined as follows:

$$g(\tau):=y=\sum_{i=1}^n \frac {u_i^2}{\lambda_i-\tau} \ \ \text{with horizontal line (H):} \ \ y=-1.$$

See an example on the figure below, with $\lambda_i=2,3,5,8$ and $u_i^2=1,4,9,1$.

One can check easily that $g$ is increasing, because $g'(\tau)=\sum_{i=1}^n \frac {u_i^2}{(\lambda_i-\tau)^2} >0$ on all intervals on which it is defined; and that also $\lim_{\tau \rightarrow \infty}g(\tau)=0$ and $\lim_{\tau \rightarrow -\infty}g(\tau)=0.$

There are always $n$ real roots to such an equation, for a kind of "topological" reason (due to the properties of $g$), that I give in a rather sketchy way, :

There are $n$ vertical asymptotes. Thus the curve has $n+1$ branches. $n$ of these branches cut the horizontal line (H) with equation $y=-1:$

  • the $(n-1)$ branches in the open intervals $I_k=(\lambda_k,\lambda_{k+1})$ vary from $-\infty$ to $+\infty$

  • the rightmost branch in $(\lambda_n, + \infty).$

  • (the leftmost one does not intersect line (H)).

Thus, use Newton's method (or plainly "fsolve" in Matlab) $n$ times

  • in each of the $(n-1)$ intervals $I_k$, for example with initial point $\dfrac{\lambda_k+\lambda_{k+1}}{2}$.

  • for interval $(\lambda_n, + \infty)$, for example with initial point $\lambda_n+1$. enter image description here