Question

this is the function in matlab function [yint] = Newtint(x, y, xx) n= length(x); if length(y)...

this is the function in matlab

function [yint] = Newtint(x, y, xx)
n= length(x);
if length(y) ~=n , error('x and y must be same length');
end
b= zeros(n,n);
b(:,1) = y(:);
  
%{
b(1,2)=b(2,1)-b(1,1)/x(2)-x(1)
  
%}
for j= 2:n
for i= 1:n-j+1
b(i, j) = (b (i+1, j-1)-b(i, j-1))/(x(i+j-1)-x(i));
end
end
xt = 1;
yint = b (1,1);
for j = 1:n-1
xt = xt* (xx-x(j));
yint = yint+b(1, j+1) *xt;
end   

end

this is the input:

>> x = [1 4 6 5]';
>> y = log(x);
>> xx=2

>> yint(x,y,xx)

this is output:

ans =

0.6288

-----------------------------------------------------

Question:

Follow the
for j= 2:n
for i= 1:n-j+1
b(i, j) = (b (i+1, j-1)-b(i, j-1))/(x(i+j-1)-x(i));
end
end

and write it step step for end
like this

step 1:
j=2 ,i=1
b(1,2)=b(2,1)-b(1,1)/x(2)-x(1)

step2 :

.....

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Considering the value of n is 4 from the input data the steps are as follows:

Step 1:

j=2,i=1

b(1,2)=(b (2, 1)-b(1, 1))/(x(2)-x(1))

Step 2:

j=2,i=2

b(2,2)=(b (3, 1)-b(2, 1))/(x(4)-x(2))

Step 3:

j=2,i=3

b(3,2)=(b (4, 1)-b(3, 1))/(x(4)-x(3))

Step 4:

j=3,i=1

b(1,3)=(b (2, 2)-b(1, 2))/(x(3)-x(1))

Step 5:

j=3,i=2

b(2,3)=(b (3, 2)-b(2, 2))/(x(4)-x(2))

Step 6:

j=4,i=1

b(1,4)=(b (2, 3)-b(1, 3))/(x(4)-x(1))

Add a comment
Know the answer?
Add Answer to:
this is the function in matlab function [yint] = Newtint(x, y, xx) n= length(x); if length(y)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The first two parts should be solved by Matlab. This is from an intro to Numerical...

    The first two parts should be solved by Matlab. This is from an intro to Numerical Analysis Class and I have provided the Alog 3.2 in below. Please write the whole codes for me. Alog3.2 % NEWTONS INTERPOLATORY DIVIDED-DIFFERENCE FORMULA ALGORITHM 3.2 % To obtain the divided-difference coefficients of the % interpolatory polynomial P on the (n+1) distinct numbers x(0), % x(1), ..., x(n) for the function f: % INPUT: numbers x(0), x(1), ..., x(n); values f(x(0)), f(x(1)), % ...,...

  • Need help with MATLAB, what code should be added to print the graph of the trapezoid rule code be...

    Need help with MATLAB, what code should be added to print the graph of the trapezoid rule code below? %%Matlab code for Question 5. syms X y intlx exp(x),0,2); %integration of x*exp(x) fprintf("htlntegration of x"2*exp(x) for [O 3] is %2.5f.\n,y) %Integration using Trapizoidal rule nn [100 1000]; for ii 1:2 a:0; b-3; %Integration limit ns-1:nn(i) integral Values-zeros(size(ns)); ourFunction-@(x) x.*2.*exp(x); for n-ns val(n)-trapizoidal (ourFunction,a,b,nn(i); end fprintf nlntegration of x 2*exp(x) using Trapizoidal rule for [O 3]\n') fprintf('1tTrapizoidal integration value for n-%d...

  • I need to create a MATLAB function, bvp_solve.m, to approximate the solution y(x). The function takes...

    I need to create a MATLAB function, bvp_solve.m, to approximate the solution y(x). The function takes the number of grid points n as an input. The outputs are grid vector x and the solution vector y %% This is the function i have so far: function [xi, yi] = bvp_solve(n) % BVP_SOLVE computes the solution y(x) of a two-point boundary value problem % using finite difference method (FDM). % The governing equation is % y''' = -y + (x -...

  • Preferences J. There are two goods, I and 12, and the possible combinations (bundles) are X...

    Preferences J. There are two goods, I and 12, and the possible combinations (bundles) are X = {(1,1),(1,2), (1,3), (2.1). (2.2), (2,3)}. For the following two preferences fill in the set <= {(1, y) EX XX:13 y}. 1. Lexi's preferences, 3, over these goods can be described by "More of good 2 is always better than any amount of good 1, but given two bundles with the same amount of good 2, more of good 1 is better than less."...

  • Given z = 2(x,y),X = x(s,t),y = y(s,t), and zx(-1,1)= 3, zy(-1,1)= 2, xs(-1,1)= -1, x,(-1,1)=...

    Given z = 2(x,y),X = x(s,t),y = y(s,t), and zx(-1,1)= 3, zy(-1,1)= 2, xs(-1,1)= -1, x,(-1,1)= 3, ys(-1,1)= 1, z (1,2)=5, z (1,2)=3, x(1,2)= -1, y(1,2)= 1, y,(-1,1)= 4, xs(1,2)=3, xx(1,2)= -2, x(-1,1)= 1, y(- 1,1)=2, 7(1,2)=7, vs(1,2)=2, a. compute ( cas ? )ats = 1,t =2, b. if we plot the surface Z as a function of 5 and t, then at the point (1,2) in the st-plane, how fast is Z changing in the direction (-1,1) in the...

  • please provide matlab solution too 3. Butterball recommends the following cooking times for turkeys at 325...

    please provide matlab solution too 3. Butterball recommends the following cooking times for turkeys at 325 °C. size, (lbs) un-stuffed t, (h) stuffed t, (h) 2.00 2.25 6. 2.50 2.75 10 3.00 3.50 18 3.50 4.50 22 4.00 5.00 24 4.50 5.50 30 5.00 6.25 (a) Plot the recommended cooking time as a function of turkey size for un-stuffed and stuffed turkeys on the same plot. (b) For each of the two menu options, find the third-order interpolating polynomial (by...

  • 1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector...

    1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector containing the values of the integral (A) for n= 1,2,3,..., n. The function must use the relation (B) and the value of y(1). Your function must preallocate the array that it returns. Use for loop when writing your code. b) Write MATLAB script that uses your function to calculate the values of the integral (A) using the recurrence relation (B), y(n) for n=1,2,... 19...

  • Problem 7. [MAILABⓒproblem] Write a short MATLAB script to construct the transfer function of a system...

    Problem 7. [MAILABⓒproblem] Write a short MATLAB script to construct the transfer function of a system that is described by the following poles, zeros, and gain zeros =-1,1 ±2j poles =-2土2,-0.4 k = 1.28 and plot its response to a step input with amplitude 5 (meaning, u(t)-5 × 1(t). Determine the system's (1) time constant and (2) rise time from the plot of the step response. (Submit the MATLABO script and the plot; both should fit into one page. You...

  • MATLAB I need Matlab ouput 4. Solve the following linear set of equations using the script...

    MATLAB I need Matlab ouput 4. Solve the following linear set of equations using the script given below. 53 1 1] x) A=1 3 1 X=(x₂ , B={10} [1 1 3] (45) x=zeros(3,1); AB=[A B] n=size(A,1); for i=1:n-1 P=-(AB(+1:end,i)/AB(1,1)) AB(i+1:end,i:end)=AB(i+1:end,i:end)+P*AB(i,i:end) end for i=n:-1:1 x(1,:)-(AB(i,n+1:end)-AB(1,i+1:n)*x(i+1:n:)YAB(1,1) end

  • The discrete random vector (X, Y) has a joint probability mass function fx.y(x, y) described in t...

    The discrete random vector (X, Y) has a joint probability mass function fx.y(x, y) described in the following table: or, written more succinctly, 4 4 Note that the support of (X,Y) is X = {(1,1), (1,2), (2,1), (2.2). The parameter space is 9-10 : _름 (X, Y) (a) Show that both X and Y are ancillary statistics (b) Show that U- X +Y is not ancillary. (c) Show that V = |X-Y| is a sufficient statistic for θ. (d) Show...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT