0% found this document useful (0 votes)
18 views26 pages

Assignment 1

The document contains MATLAB code that plots various functions. It includes: 1) Plotting cosine and Taylor series approximations of cosine up to orders 3, 5, and 10. 2) Plotting a Taylor series approximation of log(3+4x) up to orders 3, 4, and 5. 3) Generating surfaces and isosurfaces for different functions of x, y, and z. 4) Plotting curves for functions involving inverse cube root terms.

Uploaded by

Bird 0f Hermes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views26 pages

Assignment 1

The document contains MATLAB code that plots various functions. It includes: 1) Plotting cosine and Taylor series approximations of cosine up to orders 3, 5, and 10. 2) Plotting a Taylor series approximation of log(3+4x) up to orders 3, 4, and 5. 3) Generating surfaces and isosurfaces for different functions of x, y, and z. 4) Plotting curves for functions involving inverse cube root terms.

Uploaded by

Bird 0f Hermes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Code:

syms x n s;
x = linspace(-3*pi, 3*pi);
plot(x, cos(x), '-');
hold on;
x = linspace(-2*pi, 2*pi);
s = 0;
for n = 0:3
s = s + ( (-1)^n * ( x.^(2*n) / factorial(2*n) ) );
end
plot(x, s, '--');
hold on;
s = 0;
for n = 0:5
s = s + ( (-1)^n * ( x.^(2*n) / factorial(2*n) ) );
end
plot(x, s, '--');
s = 0;
for n = 0:10
s = s + ( (-1)^n *( x.^(2*n) / factorial(2*n) ) );
end
plot(x, s, '--');
grid on;
ylim([-9 9]);
xlim([-9 9]);
Code:

syms x n
x = linspace(-15, 15);
s = 0;
for n = 0:10
s = s + ( ((-1)^n) * (x.^(2*n)) ) / ( (2^(2*n)) * factorial((n)^2) ) ;
end
plot(x, s);
hold on;
grid on;
Code:
syms x
x = -0.74:0.01:3;
fx = log(3 + 4.*x);
plot(x, fx);

hold on;
t3x = log(3) + 4.*x/ 3 - ( ( 8*(x.^2) )/ 9 ) + ( ( 64*(x.^3) )/ 81 );
plot(x, t3x, '--');

t4x = log(3) + 4.*x/ 3 - ( ( 8.*(x.^2) )/ 9 ) + ( ( 64*(x.^3) )/ 81 ) - ( ( 64*(x.^4) )/ 81 );


plot(x, t4x, '--');

t5x = log(3) + 4.*x/ 3 - ( ( 8.*(x.^2) )/ 9 ) + ( ( 64.*(x.^3) )/ 81 ) - ( ( 64.*(x.^4) )/ 81 ) + ( (1024.*(x.^5) )/


729 );
plot(x, t5x, '--');

grid on;
ylim([-15 80]);
Code:

[x,y] = meshgrid(-6:0.2:6);
Z = 16-(x-3).^2-(y-2).^2;
surf(x,y,z)
Code:
(a)

[x,y,z] = meshgrid(1:0.2:15);
fx = x.*y.*log(z) + 3.*tan(z./2);
isosurface(x,y,z,fx,5)
grid on;

(b)
[x,y,z] = meshgrid(1:0.2:15);
gx = log(25-5.*x.^2-5.*y.^2-z.^2);
isosurface(x, y, z, gx, 5);
grid on;
Code:

x = 0.1:0.01:2;
y = 1280./( x.^(3/2));
plot(x,y);
grid on;
hold on;

y1 = 1100./(x.^(3/2));
plot(x,y1,'--');
y2 = 1000./(x.^(3/2));
plot(x,y2,'--');
y3 = 900./(x.^(3/2));
plot(x,y3,'--');

You might also like