Anda di halaman 1dari 11

ASSIGNMENT NO.

1
NAME :DESH DEEPAK LAWANIA SUBJECT : MATHS-II
ID : 2019PEV5110 DATE : 21/09/2019

Q1. Find Pade approximations for the following functions, with numerators and
denominators each of the third degree- (a) Cos2x, (b) x.exp(x)
Ans. Matlab Code:

clear all;
clc;
close all;
syms x;
n = input('Enter the value of degree=')
f(x) = cos(x)^2;
g(x) = x*exp(x);
pade(f(x),'order',n)
pade(g(x),'order',n)
Result:-
Enter the value of degree=3
ans =-(2*x^2 - 3)/(x^2 + 3)
ans =-(3*x*(x^2 + 8*x + 20))/(x^3 - 9*x^2 + 36*x - 60)

Q2. Duplicate Example 4.3 and Figures 4.5 and 4.6, but for f(x) = (x + 1)^2.
Ans. Matlab Code:
clc
clear all
close all
N=100;
pi = 3.14;
w=1;
deltax = (2*pi)/(N-1);
syms x t
f(x) = (x+1)^2;
a0 = 1/(2*pi)*(double(int(f,[-pi pi])))
x = -pi:deltax:pi;
subplot(2,1,1)
plot(x,f(x));
xlabel('x');
ylabel('f(x) = (x+1)^2')
grid on
for N=2:2:6
for n = 1:N
an = 2/(2*pi)*int(f(t)*cos(n*w*t),[-pi pi]);
F1 = an*cos(n*w*t);
bn = 2/(2*pi)*int(f(t)*sin(n*w*t),[-pi pi]);
F2 = bn*sin(n*w*t);
end
subplot(2,1,2);
F = a0+F1+F2;
q=double(subs(F,t,x))
plot(x,q);
hold on
end
xlabel('x');
ylabel('Fourier Series approximations')
legend('N=2','N=4','N=8','Location','best')
grid on
Q3. Duplicate the plot of Figure 4.6, but for the extended range of [- 10, 10].
Ans. Matlab Code:
clc
clear all
close all
pi = 3.14;
w=2*pi/20;

syms x t
f(x) = (x+1)^2;
a0 = 1/20*(double(int(f,[-10,10])))
x = -10:0.01:10;

for N=2:2:6
for n = 1:N
an = 2/20*int(f(t)*cos(n*w*t),[-10,10]);
F1 = an*cos(n*w*t);
bn = 2/20*int(f(t)*sin(n*w*t),[-10,10]);
F2 = bn*sin(n*w*t);
end

F = a0+F1+F2;
q=double(subs(F,t,x))
plot(x,q);
hold on
end

xlabel('x');
ylabel('Fourier Series approximations')
legend('N=2','N=4','N=6','Location','best')
grid on
Q4. Find the Fourier coefficients for f(x) = x3 if it is periodic and one period
extends from x= - l to x = 2.
Ans. Matlab Code:
clear all;
close all;
clc;
syms x n t
pi = 3.14;
f(x) = x^3;
w = 2*pi/3;

a0 = double((1/3)*int(f(t),[-1,2]))
an = (2/3)*int(f(t)*cos(n*w*t),[-1,2]);
bn = (2/3)*int(f(t)*sin(n*w*t),[-1,2]);
vpa(an,4)
vpa(bn,4)

Result:
a0 = 1.2500
an = (8.229e-8*(2.531e6*cos(2.093*n) + 5.299e6*n*sin(2.093*n) -
5.546e6*n^2*cos(2.093*n) - 3.87e6*n^3*sin(2.093*n)))/n^4 - (8.229e-
8*(2.531e6*cos(4.187*n) + 1.06e7*n*sin(4.187*n) - 2.218e7*n^2*cos(4.187*n) -
3.096e7*n^3*sin(4.187*n)))/n^4
bn = 0.6667*sin(2.093*n)*(0.6846/n^2 - 0.3125/n^4) -
0.6667*cos(2.093*n)*(0.4777/n - 0.6541/n^3) - 0.6667*(2.0*cos(2.093*n)^2 -
1.0)*(3.822/n - 1.308/n^3) + 1.333*cos(2.093*n)*sin(2.093*n)*(2.738/n^2 -
0.3125/n^4)

Q5. What are the plots of the functions for x=-1 to x=2, (a) f(x) = x3 (b) f(x) = (x2
-1) when reflected about the x-axis? When reflected about x = - l? When reflected
about x = 2? Are any of these odd functions?
Ans. Matlab Code:
syms x y y1 y2 y3 z z1 z2 z3
x=-1:0.01:2;
y=x.^3;
z=x.^2-1;
y1=-y;
x2=-x-2;
x3=-x+4;
z1=-z;
subplot(2,3,1)
plot(x,y)
hold on
plot(x,y1)
xlabel('x');
ylabel('y=x^3 and reflected about x axis')
grid on
subplot(2,3,2)
plot(x,y)
hold on
plot(x2,y)
xlabel('x');
ylabel('y=x^3 and reflected about x=-1 axis')
grid on
subplot(2,3,3)
plot(x,y)
hold on
plot(x3,y)
hold on
xlabel('x');
ylabel('y=x^3 and reflected about x=2 axis')
grid on
subplot(2,3,4)
plot(x,z)
hold on
plot(x,z1)
xlabel('x');
ylabel('z=x^2-1 and reflected about x axis')
grid on
subplot(2,3,5)
plot(x,z)
hold on;
plot(x2,z)
xlabel('x');
ylabel('z=x^2-1 and reflected about x=-1 axis')
grid on
subplot(2,3,6)
plot(x,z)
hold on;
plot(x3,z)
xlabel('x');
ylabel('z=x^2-1 and reflected about x=2 axis')
grid on;

Reflected about X axis of y=x^3 is a odd Function.


Q6. Repeat Q5 but reflect about the y-axis. Are the results even or odd?
Ans. Matlab Code:
syms x y y1 y2 y3 z z1 z2 z3
x=-1:0.01:2;
y=x.^3;
z=x.^2-1;
x1=-x;
y2=-y-2;
y3=-y+4;
z2=-z-2;
z3=-z+4;
subplot(2,3,1)
plot(x,y)
hold on
plot(x1,y)
xlabel('x');
ylabel('y=x^3 and reflected about y axis')
grid on
subplot(2,3,2)
plot(x,y)
hold on
plot(x,y2)
xlabel('x');
ylabel('y=x^3 and reflected about y=-1 axis')
grid on
subplot(2,3,3)
plot(x,y)
hold on
plot(x,y3)
hold on
xlabel('x');
ylabel('y=x^3 and reflected about y=2 axis')
grid on
subplot(2,3,4)
plot(x,z)
hold on
plot(x1,z)
xlabel('x');
ylabel('y=x^2-1 and reflected about y axis')
grid on
subplot(2,3,5)
plot(x,z)
hold on
plot(x,z2)
xlabel('x');
ylabel('y=x^2-1 and reflected about y=-1 axis')
grid on
subplot(2,3,6)
plot(x,z)
hold on
plot(x,z3)
xlabel('x');
ylabel('y=x^2-1 and reflected about y=2 axis')
grid on

Reflected about Y axis of y=x^3 is a odd Function.


Reflected about Y axis of y=x^2-1 is a Even Function.
Reflected about Y=-1 of y=x^2-1 is a Even Function.
Reflected about Y=-2 of y=x^2-1 is a Even Function.
Q7. Suppose we are interested in f(x) = e-x sin(2x - 1) only in the interval [0,2].
Sketch the half-range extensions that give (a) An even function. (b) An odd
function.
Ans. Matlab Code:
clc
clear all
close all
syms x y
x=0:0.01:2;
y1=exp(-x).*sin(2*x-1);
subplot(3,1,1)
plot(x,y1)
xlabel('x');
ylabel('f(x)=exp(-x).*sin(2*x-1)');
grid on
y2=fliplr(y1);
y3=[y2(1:200),y1];
x2=-6:0.01:6;
y=[y3(1:400),y3,y3(1:400)];
subplot(3,1,2)
plot(x2,y)
xlabel('x');
ylabel('even function');
grid on
z2=-y1;
z3=fliplr(z2);
z4=[z3(1:200),y1];
z5=[z4(1:400),z4,z4(1:400)];
subplot(3,1,3)
plot(x2,z5)
xlabel('x');
ylabel('odd function');
grid on

Anda mungkin juga menyukai