# lab1 - out=taylor1(N) s=zeros(N-1,1); s(1,1)=1;...

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

Nick Paribello – Lab 1 #1) Geometric progression is defined as b0 = b; b1 = bq; b2 = bq 2 ; :::. a) Create a function that computes the partial sum SN = PN1 k=0 bk b) Let b = 1, and q = 0:5. Plot SN for N = 1; :::10. function out=geo(b,q,N); N=10; s=zeros(N-1,1); q=.5; b=1; s(1,1)=b; for i=1:N-1 s(i+1)=s(i,1)+b.*q.^i; end ; plot(s(:,1), 'x' ); xlabel( 'n' ); ylabel( 'sum value' ); #2 Taylor Series a) Plot the partial sums SN of the Taylor Series for the function e x2 against the true solution for N = 0; 2; 4; 6; 8, on the domain jxj < 1. 1 2 3 4 5 6 7 8 9 10 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 n sum value

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

View Full Document
b) Plot the error, jSN (x) e x 2 j for N = 0; 2; 4; 6; 8, again with jxj < 1 N=0 N=0 function
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: out=taylor1(N) s=zeros(N-1,1); s(1,1)=1; x=linspace(-1,1,1); for i=1:N-1 s(i+1,1)=s(i,1)-x.^2i/ factorial(i); end ; plot(s(:,1), 'x' ); xlabel( 'n' ); ylabel( 'sum value' ); N=2 N=4 N=6 N=8 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 n sum value 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 n 1 1.5 2 2.5 3 3.5 4-0.8-0.6-0.4-0.2 0.2 0.4 0.6 0.8 1 n 1 2 3 4 5 6 7 8-0.8-0.6-0.4-0.2 0.2 0.4 0.6 0.8 1 n 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6-0.8-0.6-0.4-0.2 0.2 0.4 0.6 0.8 1 n sum value...
View Full Document

## This document was uploaded on 12/05/2011.

### Page1 / 3

lab1 - out=taylor1(N) s=zeros(N-1,1); s(1,1)=1;...

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

View Full Document
Ask a homework question - tutors are online