%% Lab #2 - Solutions %% Introduction %% % % Back to lab exercises. % format long %% Exercise 1 f = @(x) tanh(x/10) %% f(2*pi) %% f(-exp(1)) %% Exercise 2 h = @(x) (3*x^3 - 1)/(x^2 + 3) %% h(sqrt(3)*i) %% h(nthroot(1/3,3)) %% Exercise 3 s = @(t) cos(t) %% q = @(t) 1/(s(t)^2 + 1) %% q(pi) %% Exercise 4 T = @(x,y) 5/x^2 - 1 + y + 0.5*x^2/y %% T(exp(pi),nthroot(5,4)) %% Exercise 5 f = @(x) cos(x) %% g = @(x) x^2 %% h = @(x) f(x)*g(x) %% fp = @(x) -sin(x) %% gp = @(x) 2*x %% hp = @(x) f(x)*gp(x) + fp(x)*g(x) %% hp(-4.561) %% Exercise 6 distance = @(x1,y1,x2,y2) sqrt((x1-x2)^2 + (y1-y2)^2) %% distance(0,cos(0),pi,cos(pi)) %% Exercise 7 % % * Earth : 1.0832e+12 or 1.08 trillion cubic meters % * Mars : 1.63190e+11 or 163 billion cubic meters % * Jupiter : 1.4313e+15 or 1.43 quadrillion cubic meters %% Exercise 8 % Density of dry air at sea level for different temperatures % % * 0 C : 1.2922 % * 10 C : 1.2466 % * 20 C : 1.2041 % * 30 C : 1.1644