Matlab Question
Only do parts c, d, and g. Parts a and b are for reference.
This is a Matlab Question (Multipart-I already got someone to do a and b but they said I need to use another one of my questions to get c,d and g answered).
The Maclaurin series expansion for e^x is e^x=1 + x/1! + x^2/2! + x^3/3! +x^4/4!... and it can be expressed in summation form as e^x = x^(k-1)/((k-1)!)
The MATLAB function [exVal]=findEX(x,n) shown below can be used to calculate the value of the above series using the first n terms:
function [exVal]=findEX(x,n)
exVal=0;
for k=1:n
exVal=exVal+x.^(k-1)./factorial(k-1);
end;
a.) Using the above function approximate the value of e^(0.5), the absolute value of the true percentage relative error and the absolute value of the approximate percentage relative error for the first 5, 10, 15 and 20 terms.
b.) Modify the above function so it now calculates the absolute value of the true percentage relative error and outputs it as a second output ie. the new function should be [exVal, et] =findEX2(x,n) where et is the absolute value of the true percentage relative error. The true value of e^x can be obtained in MATLAB using exp (x)
Note: When a function has more than one output (in this case findEX2() has two outputs - exVal, et), then you need to call/execute the function with all the outputs in the command window. E.g. if you want to get exVAL and et for x=0.1 and n=3, you should call/execute the function as:
>>[exVal, et] = findEX2 (0.1,3)
It would be inadvisable to call/execute as >>findEX2 (0.1,3) because then, MATLAB will just show you the first output (and second and subsequent outputs will be lost)
c.) Using the function findEX2, check the absolute value of the true percentage relative error found in (a) for 5, 10, 15, and 20 terms.
d.) Modify the above function so that it now calculates the absolute value of the approximate percentage relative error and outputs it as a third output i.e. the new function should be [exVal, et, ea] =findEX3 (x,n) where ea is the absolute value of the approximate percentage relative error. Keep in mind note from (b)
g.) Using the function findEX3, check the absolute value of the approximate percentage relative error found in (a) for 5, 10, 15, and 20 terms.
`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
c)
clc% helps in clearing screen
clear all% helps in clearing history
close all% helps in closing files if any
x=0.1;
for n=[5,10,15,20]
[~,et]=findEX(x,n);
fprintf('Absolute true percent relative error for n=%d terms is
%.6e\n',n,et);
end
function [exVal,et]=findEX(x,n)
exVal=0;
for k=1:n
exVal=exVal+x.^(k-1)./factorial(k-1);
end
et=abs((exVal-exp(x))/exp(x))*100;
end

d)
function [exVal,et,ea]=findEX3(x,n)
ea=0;
exVal=0;
prev=0;
for k=1:n
exVal=exVal+x.^(k-1)./factorial(k-1);
ea=abs((exVal-prev)/exVal)*100;
prev=exVal;
end
et=abs((exVal-exp(x))/exp(x))*100;
end
g)
clc% helps in clearing screen
clear all% helps in clearing history
close all% helps in closing files if any
x=0.1;
for n=[5,10,15,20]
[~,~,ea]=findEX3(x,n);
fprintf('Approximate percent relative error for n=%d terms is
%.6e\n',n,ea);
end
function [exVal,et,ea]=findEX3(x,n)
ea=0;
exVal=0;
prev=0;
for k=1:n
exVal=exVal+x.^(k-1)./factorial(k-1);
ea=abs((exVal-prev)/exVal)*100;
prev=exVal;
end
et=abs((exVal-exp(x))/exp(x))*100;
end

Kindly revert for any queries
Thanks.
Matlab Question Only do parts c, d, and g. Parts a and b are for reference....
Q3. Find the largest value of t > 0 such that on your computer system (a) e'>0 (b) e' is a finite number The Matlab function exp gives the exponential function. Q4. Using integration by parts the integral J, = ſx"et-'dx can be evaluated as (1) Jo = e ', J, =1 – n.J =1 (1) Using Equation (1) calculate Jn for n=1, 2,...10 (a) with the approximate value e'= 0.367879. (b) with the value él = exp(-1) provided by...
someone please do this corrcetly using matlab and following
all instructions
1. (30 Points) It is known that the sine function can be expressed as: x(2k+1) sin(x) = (-1) +(2k + 1)! k=0 Truncate the series to compute the first seven estimates (ie, for k = 0,1,2,3,4,5, and 6) for x = You must use a for loop. All calculations and printing the table described below should be done from within the loop. For each estimate, determine the magnitude of...
please do this problem in matlab and show me the code.
Thanks.
please do this problem in matlab and show me the code.
Thanks.
please do this problem in matlab and show me the code.
Thanks.
please do this problem in matlab and show me the code.
Thanks.
please do this problem in matlab and show me the code.
Thanks.please do this problem in matlab
and show me the code. Thanks.
please do this problem in matlab and show me...
please do this problem in matlab and show me the code.
Thanks.
please do this problem in Matlab and show
me the code. Thanks.
Problem #1: Circuits and linear-systems In the last HW you developed the governing equations for the “Wheatstone”-bridge circuit used extensively in engineering applications (shown below). B R R2 A D G m RA с E The resulting equations were solved for the output voltage and currents using the function: function [V_out, I_vector] =Wheatstone_bridge (v_in, R_vector) In...
Submission Items: (1) A Word document in which you: a. Describe in brief the problem you are solving and the numerical method used. b. Snapshot of the output, when you run the program for the conditions mentioned in the questions. c. Discuss your results. (2) MATLAB code (m) file() Question 1: [10 points) Write a MATLAB function that calculates the approximate value of arctan(x) using the Maclaurin series approximation: arctan(x) = x- + +... The function should accept 3 parameters:...
1. For the series below, use Excel to generate a table with columns of absolute true error, absolute approximate error, absolute percent relative true error, and absolute percent relative approximate error and plots of absolute percent true error and absolute percent approximate error vs number of terms calculated for x - 0.75. Calculate up to 10 terms. Use Excel's Inx function to generate a true value.
6. If < 1, it is known that Write a function seriesapprox to perform the following tasks. Starting with the simplest approximation 1/ (1-x) 1, add terms one at a time to improve this estimate. After each term is added, compute the absolute error between the approximate and true values. (Use MATLAB to determine the true value.) Continue to add terms until this error is less than 0.0001. Your function must take as the input and must return two output...
Implement MATLAB code that calculates sin(x) using the following formula, and measure the absolute error from the MATLAB provided function. The Taylor's formula is given as follows: sin(x) = 0+12 + 0x² + 5123 + 0.x4 + ... 23 25 27 -3! + 5- 7 + ... Plot both (1) the approximated value, and (2) absolute error. The following example uses x = 3 * pi, and k = 50. You may choose your own x, and k values. Approximation:...
1. [12 marks] In the following parts of this question, write a MATLAB code to solve a linear system A b (A is a square nonsingular matrix) using Jacobi and Gauss-Seidel algorithms. Do not use the built-in Matlab functions for solving linear systems (a) Write a Matlab function called Jacobi that consumes a square n x n matrix A, and an n x 1 vector b, and uses the Jacobi technique to solve the system Ax-b, starting with the zero...