Asked by bbmw0
on 13 Jul 2019

The function y(t) obeys the differential equation: ( 𝑑 2𝑦 𝑑𝑡 2 + 3 𝑑𝑦 𝑑𝑡 − 2𝑦 = 0) =

with y(0) = 4 and y’(0) = 7.

Using McLaurin series approximate y(t) by a quartic function 𝑦(𝑡) = 𝑎𝑡 4 + 𝑏𝑡 3 + 𝑐𝑡 2 + 𝑑𝑡 + e

So far I have only differentiate diff(y,t,2)+3*diff(y,t)-2*y == 0;

syms y(t)

syms t nonnegative

syms B

assume(B>1)

ode = diff(y,t,2)+3*diff(y,t)-2*y == 0;

ySol(t) = dsolve(ode)#

how do you use the McLaurin series to solve it as it shown above?

Answer by John D'Errico
on 14 Jul 2019

Edited by John D'Errico
on 15 Jul 2019

What are you trying to do with the lines:

syms B

assume(B>1)

Which have nothing to do with the problem?

It looks like they are trash, left over from your last assignment.

Anyway, using dsolve does not seem to be the correct idea for this.

What do we know? That you want to solve the problem

y' ' + 3*y' - 2*y = 0

subject to the information that y(t) = a*t^4 + b*t^3 + c*t^2 + d*t + e

The initial conditions are simple to implement. y(0) = 4 implies that e is trivially 4.

y'(0) = 7 likewise implies that d is 7.

However, you have provided only one other piece of information, that the differential equation applies. This is ONE piece of information, and you have 3 unknown coefficients to learn, thus a,b,c.

syms t a b c

y(t) = a*t^4 + b*t^3 + c*t^2 + 7*t + 4;

eqn = diff(y,t,2) + 3*diff(y,t,1) - 2*y

eqn(t) =

2*c - 14*t + 6*b*t + 6*c*t + 12*a*t^2 + 12*a*t^3 - 2*a*t^4 + 9*b*t^2 - 2*b*t^3 - 2*c*t^2 + 13

And that last result needs to be identically zero for all t to satisfy the differential equation. But that cannot be true for more than 3 values of t.

So you cannot solve the problem exactly. We should have known that in advance anyway, because the polynomial you provide is not a solution to that differential equation, which would generally involve exponentials.

As such, I think the best you can do is to find some sort of best approximation, that would apply over some specified interval.

Here is the next problem, since no interval was indicated for the solution. If I pick, for example, the interval [0,1] to solve it over, then we might do this:

inteqn = int(eqn.^2,t,[0,1])

inteqn =

(26762*a^2)/315 + 121*a*b + (2476*a*c)/35 + (446*a)/15 + (1574*b^2)/35 + (169*b*c)/3 + (176*b)/5 + (302*c^2)/15 + (128*c)/3 + 157/3

Thus, integrate the square of the result. If that integral is identically zero, then you have found a solution to the differential equation.

So any real valued set of the parameters a,b,c that satisfies that one relation will solve your problem. However, I think it is true that no real valued set of the parameters a,b,c exist that satisfy that relation. (Claim made without a lot of thought invested.) So then at best you would need to choose a value of a,b,c that minimizes that relation.

abcfun = matlabFunction(inteqn);

abc = fminsearch(@(abc) abcfun(abc(1),abc(2),abc(3)),[1 1 1])

abc =

-1.59279872440389 5.35213580681714 -5.74895967322016

double(subs(inteqn,[a,b,c],abc))

ans =

0.207029889379897

fminsearch was not indeed able to find a solution that reduces the result to zero. However, the set of parameters we have found is one that minimizes the error of the polynomial approximation to the ODE posed, while still satisfying the initial conditions exactly.

fplot(subs(y,[a,b,c],abc),[0,1])

grid on

xlabel 't'

ylabel 'y(t)'

title 'Best approximate solution to the ODE'

Does it satisfy the ODE? Well, no.

yhat = subs(y,[a,b,c],abc);

fplot(diff(yhat,t,2) + 3*diff(yhat,t,1) - 2*yhat,[0,1])

xlabel 't'

ylabel 'Error of the ODE'

grid on

But the integral of the squared error over that interval is as small as I could make it.

Is this what was intended by the original question? I have no idea, because the question is posed pretty vaguely.

Answer by Torsten
on 15 Jul 2019

Edited by Torsten
on 15 Jul 2019

y(t) = sum_{i=0}^{Inf} a_i*t^i

y'(t) = sum_{i=1}^{Inf} i*a_i*t^(i-1)

y''(t) = sum_{i=2}^(Inf} i*(i-1)*a_i*t^(i-2)

Set y''(t)+3*y'(t)-2*y(t) = 0, insert the above infinite series and initial conditions at t=0 and compare coefficients up to degree 2.

This will give you a linear system of equations for the 5 unknowns a_0,a_1,a_2,a_3 and a_4.

https://www.wolframalpha.com/input/?i=Series%5B1%2F17+e%5E(-1%2F2+(3+%2B+sqrt(17))+t)+(34+-+13+sqrt(17)+%2B+(34+%2B+13+sqrt(17))+e%5E(sqrt(17)+t)),%7Bt,0,4%7D%5D

Best wishes

Torsten.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.