Problem:
f = @(x) exp(x);% Function to integrate N = 20;% Number of trapezoids a = 0;% Lower limit b = 2;% Upper limit %% Trapezoidal Rule h = abs((b - a)/N); sum = 0; for i = 1:(N-1) x = a + i * h; sum = sum + f(x); end approxValue = (h/2) * (f(a) + 2 * sum + f(b)); trueValue = exp(2) - 1; relativeError = (approxValue - trueValue)/trueValue; fprintf('Approximate value = %f\n', approxValue); fprintf('True value = %f\n', trueValue); fprintf('Relative error = %f\n', relativeError);
OUTPUT:
Complete the following problems in Matlab environment. Copy your com mand and final answer from MATLAB command window a...
Solve the following problems in the MATLAB Command Window. Show all of your work and add comments to distinguish each problem. Include your name as a comment at the top of the MATLAB Command Window. Copy the solutions from the MATLAB Command Window into Microsoft Word. Submit your Microsoft Word file in Blackboard by the due date. 1. (5-20/7+2.53)2 2. 6 x 3.1+ 120/5-155/3 3. 8+80/2.6+ e3.5 4. [sin(0.2T)]/[cos(n/6)] + tan 72° 5. Set t-3.2 and evaluate 0.5e3t+3.82t3 6. Define...
MATLAB ONLY!! PLEASE WRITE IN COMPUTER SO I CAN COPY PASTE!!! ANSWER COMPLETELY, USE FOR LOOPS. THE PROGRAM TO BE MODIFIED IS THE NEXT ONE: clc clear % Approximate the value of e ^ x using the Taylor Series x = input( 'Enter the value of x for e^x. x = ' ); t = input( 'Enter the amount of desired terms. t = ' ); i = 1; e_taylor = 0; % initializing the variable for the accumulator while...