Matlab Assignment. I don\'t know how to do this in MATLAB. Very simple math eqau
ID: 3184223 • Letter: M
Question
Matlab Assignment. I don't know how to do this in MATLAB. Very simple math eqautions, need help with putting them into MATLAB
• Start MATLAB. • Type diary assignment1 in the Command Window. • Type in the header comments (see below). • Write the question number of each problem as a comment, e.g., Q1(a). • Type in the required expression(s) for solving the problems. • After finishing the assignment, type diary off.
(1) Compute the following quantities:
(a) e^14 and 382801 to 15 digits each. Which is bigger?
(b) the fractions 2709 / 1024, 10583 / 4000, and 2024 / 765. Which of these is the best approx. for 7?
(2) Solve (symbolically) the system of linear equations
3x + 4y + 5z = 2
2x 3y + 7z = 1
x 6y + z = 3
Check your answer using matrix multiplication.
(3) Factor the polynomial x^4 y^4
(4) Use simplify to simplify the following expressions:
(a) 1 / (1 + (1 / 1 + 1/x))
(b) cos^2 (x ) sin^2 (x )
(5) Use either solve or fzero, as appropriate, to solve the following equations:
(a) 67x + 32 = 0 (exact solution)
(b) 67x + 32 = 0 (numerical solution to 15 places)
(c) x^3 + px + q = 0 (solve for x in terms of p and q)
(d) e^x = 8x 4 (all real solutions)
(6) Find the derivatives of the following functions and if possible, simplify each answer.
(a) f (x ) = 6x^3 5x^2 + 2x 3
(b) f (x ) = 2x-1/x^2+1
(c) f (x ) = sin (3x^2 + 2)
(d) f (x ) = (1 + x^4)
(e) f (x ) = x^r
(7) See whether MATLAB can do the following integrals symbolically, and for indefinite integrals, check the result by differentiating:
(a) cos(x ) dx from 0 to pi/2
(b) x sin (x^2 ) dx
(c) sin (3x ) (1 cos(3x )) dx
(d) x^2 (x + 4) dx
(e) e^x^2 dx from - to + infinity
Explanation / Answer
matlab code
% (1)
fprintf('e^14 = %.15f ', exp(14));
fprintf('382801 = %.15f ', 382801*pi);
fprintf('Therefore, 382801 > e^14 ');
fprintf('2709 / 1024 = %f ', 2709 / 1024);
fprintf('10583 / 4000 = %f ', 10583 / 4000);
fprintf('2024 / 765 = %f ', 2024 / 765);
fprintf('sqrt(7) = %f ', sqrt(7));
fprintf('Therefore, 2024 / 765 is the best approximation for sqrt(7) ');
% (2)
A = [3 4 5; 2 -3 7; 1 -6 1];
b = [2 -1 3]';
x = pinv(A)*b;
fprintf('Solution: [%f,%f,%f] ', x);
% (3)
syms x y;
F = factor(x^4 - y^4);
% (4)
syms x; simplify( 1 / (1 + (1 / 1 + 1/x)))
syms x; simplify(cos(x)^2 - sin(x)^2)