Matlab 7

# Matlab 7 - >> odecoeff2eq='6*a3-2*a1=0>>...

This preview shows pages 1–4. Sign up to view the full content.

MATLAB Assignment 7 Series Solutions Exercise 7.1 >> syms x >> taylor(exp(x),x,1,0) ans = 1 >> taylor(exp(x),x,9,0) ans = 1+x+1/2*x^2+1/6*x^3+1/24*x^4+1/120*x^5+1/720*x^6+1/5040*x^7+1/40320*x^8 Exercise 7.2 (a) >> syms x a0 a1 a2 a3 a4 >> a=[a0 a1 a2 a3 a4]; >> y=sum(a.*(x).^[0:4]) y = a0+a1*x+a2*x^2+a3*x^3+a4*x^4 >> dy=diff(y); >> d2y=diff(dy); >> ode=collect(d2y-x*dy-y,x) ode = -5*a4*x^4-4*a3*x^3+(12*a4-3*a2)*x^2+(6*a3-2*a1)*x+2*a2-a0 >> initcond1=strcat(char(subs(y,x,0)),'=3') initcond1 = a0=3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
>> initcond2=strcat(char(subs(dy,x,0)),'=1') initcond2 = a1=1 >> odecoeff1eq='2*a2-a0=0';

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: >> odecoeff2eq='6*a3-2*a1=0'; >> odecoeff3eq='12*a4-3*a2=0'; >> [a0 a1 a2 a3 a4]=solve(initcond1,initcond2,odecoeff1eq,odecoeff2eq,odecoeff3eq) a0 = 3 a1 = 1 a2 = 3/2 a3 = 1/3 a4 = 3/8 >> soln=subs(y) soln = 3+x+3/2*x^2+1/3*x^3+3/8*x^4 (b) >> fplot(char(soln),[-5 5],'r--')-5-4-3-2-1 1 2 3 4 5 50 100 150 200 250 300 350 Exercise 7.3 >> syms x; >> f=formalseries(x,6,0) f = a0+a1*x+a2*x^2+a3*x^3+a4*x^4+a5*x^5+a6*x^6 >> f=sersol('d2y-x*y',x,6,[1,0]) f = 1+1/6*x^3+1/180*x^6-6-5-4-3-2-1 1 2-2-1.5-1-0.5 0.5 1 1.5 2...
View Full Document

## This note was uploaded on 10/04/2008 for the course MATH 20D taught by Professor Mohanty during the Fall '06 term at UCSD.

### Page1 / 4

Matlab 7 - >> odecoeff2eq='6*a3-2*a1=0>>...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online