Question

In: Advanced Math

f(x) = (x^2 )0 < x < 1, (2−x), 1 < x < 2 A) Solve...

f(x) = (x^2 )0 < x < 1, (2−x), 1 < x < 2

A) Solve this integral, writing An as an expression in terms of n. Write down the
values of A1,A2,A3,A4,A5 correct to 8 significant figures.

b) Use MATLAB to find the coefficients of the first five harmonics and compare the
results with those from part (e). Your solution should include a copy of the m-file
fnc.m which you use to obtain the coefficients

c) Using MATLAB, plot the function and its approximating five-term Fourier series.

Solutions

Expert Solution


%Matlab code for Fourier Series
clear all
close all
%function for which Fourier series have to find
%All time values
X=linspace(0,2,101);
for i=1:length(X)
    if X(i)>=0 && X(i)<1
        zz(i)=(X(i))^2;
    else
        zz(i)=(2-X(i))^2;
    end
end
figure(1)
%Plotting the function
plot(X,zz,'r','Linewidth',3)
xlabel('x')
ylabel('f(x)')
title('Fourier series for given equation')
a1=X(1); b1=X(end);
l=(b1-a1)/2;
%Fourier series of the function for finding a and b coefficients
for j=1:5
    ss1=zz.*cos(j*pi*X/l);
    %all a values of the Fourier series
    aa(j)=(1/l)*trapz(X,ss1);
    ss2=zz.*sin(j*pi*X/l);
    %all b values of the Fourier series
    bb(j)=(1/l)*trapz(X,ss2);
end

%a0 value of Fourier series
aa0=(1/l)*trapz(X,zz);
s=aa0/2;

%all an and bn terms
fprintf('Printing few terms for Fourier series for 1st function\n')
for i=1:5
    fprintf('\tThe value of a%d=%f and b%d=%f. \n\n',i,aa(i),i,bb(i))
end
X=linspace(-4,4,1001);
%Fourier series of the function
for i=1:5
  
    s=s+bb(i)*sin(i*pi*X/l)+aa(i)*cos(i*pi*X/l);
      
end
figure(1)
hold on
plot(X,s,'b')
box on
legend('Actual Data','5 terms','Location','best')
%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%
   


Related Solutions

Find f. f ''(x) = x−2,    x > 0,    f(1) = 0,    f(4) = 0 f(x)=
Find f. f ''(x) = x−2,    x > 0,    f(1) = 0,    f(4) = 0 f(x)=
Given f(x) = 1 x 2 − 1 , f 0 (x) = −2x (x 2...
Given f(x) = 1 x 2 − 1 , f 0 (x) = −2x (x 2 − 1)2 and f 00(x) = 2(3x 2 + 1) (x 2 − 1)3 . (a) [2 marks] Find the x-intercept and the y-intercept of f, if any. (b) [3 marks] Find the horizontal and vertical asymptotes for the graph of y = f(x). (c) [4 marks] Determine the intervals where f is increasing, decreasing, and find the point(s) of relative extrema, if any....
Let f(x, y) be a function such that f(0, 0) = 1, f(0, 1) = 2,...
Let f(x, y) be a function such that f(0, 0) = 1, f(0, 1) = 2, f(1, 0) = 3, f(1, 1) = 5, f(2, 0) = 5, f(2, 1) = 10. Determine the Lagrange interpolation F(x, y) that interpolates the above data. Use Lagrangian bi-variate interpolation to solve this and also show the working steps.
2. Let f(x) ≥ 0 on [1, 2] and suppose that f is integrable on [1,...
2. Let f(x) ≥ 0 on [1, 2] and suppose that f is integrable on [1, 2] with R 2 1 f(x)dx = 2 3 . Prove that f(x 2 ) is integrable on [1, √ 2] and √ 2 6 ≤ Z √ 2 1 f(x 2 )dx ≤ 1 3 .
Solve x′=x−8y, y′=x−3y, x(0)=2, y(0)=1
Solve x′=x−8y, y′=x−3y, x(0)=2, y(0)=1
Use separation of variables to solve uxx+2uy+uyy=0, u(x, 0) = f(x), u(x, 1) = 0, u(0,...
Use separation of variables to solve uxx+2uy+uyy=0, u(x, 0) = f(x), u(x, 1) = 0, u(0, y) = 0, u(1, y) = 0.
find the line tangent to graph of f(x) at x=0 1) f(x)=sin(x^2+x) 2)f(x)=e^2x+x+1
find the line tangent to graph of f(x) at x=0 1) f(x)=sin(x^2+x) 2)f(x)=e^2x+x+1
f ''(x) = −2 + 24x − 12x^2, f(0) = 7, f '(0) = 12
f ''(x) = −2 + 24x − 12x^2, f(0) = 7, f '(0) = 12
Solve the Sturn-Liouville problem, x^2X'' + lambda X =0 X(1)=X(2)=0
Solve the Sturn-Liouville problem, x^2X'' + lambda X =0 X(1)=X(2)=0
f(x)=0 if x≤0, f(x)=x^a if x>0 For what a is f continuous at x = 0...
f(x)=0 if x≤0, f(x)=x^a if x>0 For what a is f continuous at x = 0 For what a is f differentiable at x = 0 For what a is f twice differentiable at x = 0
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT