Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168731
Image: ubuntu2004

Solving an equation Picard's way

Introduction: Solving x2x1=0x^2-x-1=0

If we are trying to solve an equation like x2x1=0x^2-x-1=0, we could try x2=x+1x^2=x+1, so that x=1+1xx=1+\frac{1}{x}

And we can substitute the value of x again x=1+11+1xx=1+\frac{1}{1+\frac{1}{x}}

And again, and again...

x+1+11+11+1xx+1+\frac{1}{1+\frac{1}{1+\frac{1}{x}}}

We could, finally, now write

x=1+11+11+11+11+x=1 + \frac{1}{1 + \frac{1}{1 + \frac{1}{1 + \frac{1}{1 + \ldots}}}}

Picard's way

Hence to solve x2x1=0x^2-x-1=0

We first write it as x=1+1xx=1+\frac{1}{x}

And then we transform it as x1=1x_1=1 and xn+1=1+1xnx_{n+1}=1+\frac{1}{x_n}

And then we get...

x1=1x_1=1; x2=1+1x1x_2=1+\frac{1}{x_1}; x3=1+1x2x_3=1+\frac{1}{x_2}; x4=1+1x3x_4=1+\frac{1}{x_3}

x1=1x_1=1; x2=1+1/1x_2=1+1/1; x3=1+11+11x_3=1+\frac{1}{1+\frac{1}{1}}; x4=1+11+11+11x_4=1+\frac{1}{1+\frac{1}{1+\frac{1}{1}}}

If the sequence {xn}nN\{x_n\}_{n\in\mathbb{N}} converges, an exercise in calculus shows that limxxn=x\displaystyle{\lim_{x\rightarrow \infty} x_n=x} is a solution to the problem.

In this case the sequence converges, other problems like x=1xx=1-x lead to non-convergent sequences, and thus they do not lead to solutions...

Now, an interactive demonstration

#So we apply the next one. #Let's see how it works: def fromoldtonew(xold): return 1+1/xold @interact def f(initial=1,n=(1,20,1)): html('This program starts with $x_1='+str(initial)+'$ and then iterates applying the function $x_{n+1}=1+\\frac{1}{x_n}$') xold=initial for i in range(n-1): xnew=fromoldtonew(xold) xold=xnew print html(xold) print xold.n() print html('Notice that regardless of the initial value, the process approximates the real root $1.618$')

Solving a differential equation

In a similar way, lets try to solve the initial value problem

dydx=y\frac{dy}{dx}=y

y(0)=1y(0)=1

This corresponds to y(x)y(0)=0xy(s)dsy(x)-y(0)=\int_{0}^{x}y(s)ds

Solving, and substituing the value of y(0), we get:

y(x)=0xy(s)ds+1y(x)=\int_{0}^{x}y(s)ds+1

And we can substitute again...

y(s)=0x(0sy(s1)ds1+1)+sdsy(s)=\int_{0}^{x}\left(\int_{0}^{s}y(s_1)ds_1+1\right)+sds

Solving a Differential Equation in Picard's way

We can do again the same thing we did for the other equation

y1=1y_1=1; the constant function 1, which does satisfy that y(0)=1y(0)=1

yn+1=0xyn(s)ds+1y_{n+1}=\int_{0}^{x}y_n(s)ds+1

Now, an interactive demonstration

#Restart the worksheet s=var('s') y=var('y') #So we apply the next one. #Let's see how it works: @interact def g(fxy='y',x0=0,y0=1,initial=1,n=(1,9,1),assume_x_positive=True): fxy=sage_eval(fxy,locals={'x':x,'y':y}) if assume_x_positive: assume(x>0) fxy=fxy+x-x+y-y r=str(latex(fxy)) html('We are trying to solve the initial value problem') html(r'$\frac{dy}{dx}='+str(latex(fxy))+'$') html(r'$y('+str(x0)+')='+str(y0)+'$') html(r'Which is equivalent to the problem') html(r'$y=\int_{'+str(x0)+'}^x'+r.replace('y','y(x)').replace('x','s')+'ds+'+str(y0)) r=r.replace('y','y_n(x)') r=r.replace('x','s') def fromoldtonew(yold): return integrate(fxy(y=yold(x=s),x=s),s,x0,x)+y0 html('This program starts with $x_1='+str(initial)+'$') html(r'and then iterates applying $y_{n+1}=\int_{'+str(x0)+'}^x'+r+'ds+'+str(y0)) xold=initial+x-x print html(r'Initial=') show(initial) for i in range(n-1): xnew=fromoldtonew(xold) xold=xnew show(xold) print html(r'after $%s$ iterates we get'%str(n)) show(xold) print html(r'That is, we get') show(xold)

Notice that this, indeed converges to the power series expansion of exe^x, regardless of the initial functi

html(r'$\frac{1}{x}')
\frac{1}{x}