Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please fix the comments bellow, using MAtLab You are required to have a user input for the number of points to plot, so

Can you please fix the comments bellow, using MAtLab

You are required to have a user input for the number of points to plot, so that you can explore the effects of this value on the check. Make the prompt more meaningful. You need an array of x values to check your calculation. You should not "hardwire" the number of points in your x array. Instead, the number of points should be defined by the user. The range of x should be from -4 to 4. Use "x" as the variable name. Find a more efficient way of defining R(x) and the terms of the partial fraction expansion. For instance, define the denominators (x-1), (x-2), and (x-3), and use each multiple times. Your check is wrong. You need to use the ABS function. Create an array that should be zero if R(x) = R1(x) + R2(x) + R3(x). If you sum your array of values, the result can be very small even if all of the values are not very small, because some positive values can cancel negative values, which means the check is not very convincing. The explanation of why the check does not always work is missing. Try more values of n until you see a pattern of what works and what doesn't. Output the check to the Command Window. Run your script multiple times, with many different values of N, such that the check works sometimes but doesn't work at other times. Once you see the pattern you can answer the question of why the check does not always work.

%--------------------------------------------- function []=test() R=@(x) (2+3*x+4*x^2)/((x-1)*(x-2)*(x-3)); % R(x)=N(x)/D(x) as an anonymous function xtemp=[-3, -2, -1]; % some random x value in x=[-4, 4] y=[]; % stores R(x) for different value of x for(i=1:3) % for x=xtemp, y is calculated y(i)=R(xtemp(i)); end A=[]; % 3x3 matrix, for 1/(x-1), 1/(x-2), 1/(x-3) % A*c=y and then c=inverse(A)*y, where c=[c1, c2, c3] %for xtemp, A is calculated for(i=1:3) xi=xtemp(i); row=[1/(xi-1), 1/(xi-2), 1/(xi-3)]; A(i, :)=row; end c=inv(A)*y'; % c=[c1, c2, c3] % Rx=R1(x)+R2(x)+R3(x)=c1/(x-1)+c2/(x-2)+c3/(x-3) Rx=@(x) c(1)/(x-1)+c(2)/(x-2)+c(3)/(x-3); Rxx=[]; % stores Rx(x) when x=xtemp to see if y is equal to Rxx % if they are equal then R1=c1/(x-1), R2=c2/(x-2), R3=c3/(x-3) for(i=1:3) Rxx(i)=Rx(xtemp(i)); end % As expected Rxx is same as y, therefore, R1, R2 and R3 are correct. %Value of c=[c1, c2, c3] c end

image text in transcribed

Consider the following ratio of two polynomials in x: 2 R(x)-Nx) N(x)2+3x +4x D(x) (x-1) (x-2)(x-3) When functions of this form are inside an integral, it is impossible to evaluate the integral analytically without changing the form. With the method of partial fraction expansion, we can rewrite this ratio as a sum of simpler terms: C. C. C. x-1 x-2 x-3 which puts the function into a form that can be used in the integral. You will write a script to find the three coefficients, c,, cz, and c.. Then you will check your answer and study some peculiarities of the checking process. In particular, sometimes the check works and sometimes it doesn't. It will be your job to find out why. 1' 2' DESIGN SPECIFICATIONS 1. Build an efficient script to compute c, c,, and ca using matrix operations. 2. Compute R(x) in its given form, then compute R1(x), R2(x), and R3(x), all from x--4 to x = 4 checking to make sure R(x)-R,(x) + R2(x) R2x), point by point. 3. Let n = the number of points in your x array, and make n a user-defined variable. Try different values of n, finding some that work and some that don't. Explain To solve for the coefficients, multiply both sides of the equation by the denominator D(x), thern collect terms of the same power of x on the right side, i.e., constant terms, linear terms, and quadratic terms. In order for the left side to be equal to the right side for every value of x, the constant term on the left must be equal to the sum of the constant terms on the right. This is your first equation. Similarly, the linear term on the left must be equal to the sum of linear terms on the right, and the quadratic term on the left must be equal to the sum of quadratic terms on the right. These are your second and third equations. With three equations each having three unknowns, you can set up a matrix equation and solve for the unknowns relatively easily. To compute the functions needed for Spec #2, it is useful to define three denominators, e.g D^(x)-x-1, then use them to build all four functions. To check that R(x)- R,(x) +R2(x) + R2(x) construct a function that should be an array of very small numbers, then sum their absolute values. If the function is an array of very small numbers, this sum should also be very small. Depending on what value of n you choose initially, this check might not work as expected. Therefore, usen - INPUT (prompt) to allow you to easily change the number of points in your arrays. You should be able to find some that work and some that don't. Explain why some work and some don't. It might help to plot the functions, though this is not required, and you should not include any figures in your solution. Output the Command Window showing 10 or more cases. You may "hardwire" everything but the number of points in array x

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

Students also viewed these Databases questions

Question

manageremployee relationship deteriorating over time;

Answered: 1 week ago