Assessment 2: Answer 1
Assessment 2: Answer 1
Answer 1
Code:
clear
clc
syms x
f(x)=x^2-2*x;
g(x)=x;
I=[0,3];
a=I(1); b=I(2);
A=int(f(x)-g(x),a,b);
disp('Area bounded by the curves f(x) and g(x) is:' );
disp(A);
fplot(f(x),[a,b]);grid on;hold on;
fplot(g(x),[a,b]);
hold off
xlabel('x-axis');ylabel('y-axis');
legend('y=f(x)','y=g(x)');
Output:
Answer 2
Code:
clear all
clc
syms x
f(x)=4/(4+x^2);
yr=0;
I=[0,2];
a=I(1);b=I(2);
vol=pi*int((f(x)-yr)^2,a,b);
disp('Volume of solid of revolution is: ');
disp(vol);
fx=matlabFunction(f);
xv = linspace(a,b,101);
[X,Y,Z] = cylinder(fx(xv)-yr);
Z = a+Z.*(b-a);
surf(Z,Y+yr,X)
hold on;
plot([a b],[yr yr],'-r','LineWidth',2);
view(22,11);
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis');
Output:
Answer 3
Code:
clear all
clc
syms s
F=input('Enter the function of s: ');
f=ilaplace(F);
disp('f(t) = ');
disp(f);
Output:
Code:
clear all
clc
syms t
f=input('Enter the function of t: ');
F=laplace(f);
F=simplify(F);
disp('Laplace transform of f(t) = ');
disp(F);
Output:
Answer 4
Code:
clear all
clc
syms s
F=input('Enter the function of s: ');
f=ilaplace(F);
disp('f(t) = ');
disp(f);
Output: