Recursive relation

13 views (last 30 days)
Jack
Jack on 8 Apr 2012
Hi,
I'ld like to plot the solution of dy/dx - y² = -exp(-x) on MATLAB. I assumed the solution was in the form of a Taylor series. I found that Yk+1 = sum (Y(k-l) * Y(l) / (k+1)), from 0 to l, with Y(0) = 1. How can I plot those Y vs. r = 1:500 ?

Answers (4)

Walter Roberson
Walter Roberson on 8 Apr 2012
If my calculation is correct, then you effectively cannot plot past r = 44, even using the symbolic toolbox. At that point you get terms beyond 2 * 10^(2*10^10) and so beyond reasonable hope of representation.
But let's make sure we are working on the same problem. I was working with Diff(y(x), x)-y(x)^2 = -exp(x)
The solution I get is nothing like a Taylor series.
  1 Comment
Walter Roberson
Walter Roberson on 8 Apr 2012
Ah, I missed the - in exp(-x) . Okay, the form does _not_ go off to infinity like I thought.
I am reaching a closed form solution with the Bessel functions. It is positive at x = 0 and x = 1, but x = 2 on to infinity are increasing negative numbers, with the most-negative being at x = 2 and each successive one after that being less negative (a smaller absolute value.)

Sign in to comment.


Kye Taylor
Kye Taylor on 8 Apr 2012
If I assume a power series solution of the form y(x) = \sum_{k = 0}^\infty\alpha_kx^x, I arrive at the recursion
(n+1)\alpha_{n+1} - \sum_{j = 0}^n \alpha_j\alpha_{n-j} = \frac{(-1)^{n+1}}{n!}
Double check how you're representing y^2 after assuming a power series solution. See
I would then solve the recursion sequentially starting from the initial conditions because it doesn't look like there's an obvious closed form solution for \alpha_n.

Jack
Jack on 8 Apr 2012
If I assume y(x)= sum(xk y^k), then dy/dx = k sum(xk * y^{k-1}) and y²(x) = sum ( sum (y(k-l)*y(l))) * x^k, the first sum being k from 0 to the infinite and the second one from l to k, right ? Then by using Taylor series for the exponential and expressing everything as a factor of x^n, I get my recursive relation on y(k+1) and yk. I only have y(0) = 1 as an initial condition.

Kye Taylor
Kye Taylor on 8 Apr 2012
First, if y depends on the variable x, it would help if you renamed the coefficients in the power series expansion for y from x_k to y_k, for instance. In addition, the y^k makes no sense inside the series expansion for y(x). I assume you mean
y(x) = \sum_{k = 0}^\infty y_k x^k
Now, the series representing dy/dx actually goes from k = 1 to infinity. See http://en.wikipedia.org/wiki/Formal_power_series#Formal_differentiation_of_series. You need to then reindex it so it goes from k = 0 to infinity so that you can combine series on the left hand side of the equation to eventually,as you said, compare with the series of -exp(-x). You'll find that formal differentiation of the series for y(x) leads to the series for dy/dx, given by
\frac{dy}{dx} = \sum_{k = 1}^\infty k y_k x^{k-1}
which, after reindexing, is equivalent to
\frac{dy}{dx} = \sum_{k = 0}^\infty (k+1) y_{k+1}x^k
Furthermore, your series for y^2(x) is not exact. The outer some does, as you said, go from k = 0 to infinity. However, the inner some goes from l = 0 to k.
As a check point, you'll notice that the right hand side of the recursion from my earlier answer is the coefficient for the series of -exp(-x)...

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!