Asked by Andrew Rizk
on 23 Nov 2011

Hey guys so this is the question. I just need the matlab code for neville's method and newton's divided differences method because i always get errors on matlab.

For general cases, IL can be calculated by IL = integration from λ min to λ max of F (λ)dλ.

For example, Table is the set of data: F (λ) vs. λ.

values of λ (×10^−7) = 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3

values of F (λ) (×10^3) = 2.6 2.3 1.8 1.5 0.9 0.2 −0.7 −1.4 −2.

Calculate P8(λ) at λ = 4.55, 4.65, 4.75, 4.85, 4.95, 5.05, 5.15, 5.25 (×10^−7) by Neville’s algorithm and Newton’s divided diﬀerences with the data given in the Table, where P8(λ) is the Lagrange interpolating polynomial of degree ≤ 8. Which one is faster? Hint: Commands tic and toc can be used to record the CPU time in Matlab.

Please I need help as I didn't use matlab before. I just need the matlab codes for these. Thanks

*No products are associated with this question.*

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 6 Comments

## Walter Roberson (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/22109#comment_48204

Writing the code for Neville's algorithm and Newton's divided differences method, would appear to be almost the entire assignment, with the rest of it just being specific test data to use.

Your posting would tend to give people the impression that you have asked other people to do nearly all of your homework assignment.

http://www.mathworks.com/matlabcentral/answers/8026-best-way-s-to-master-matlab

http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer

## Andrew Rizk (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/22109#comment_48207

well i just need the code... i have the algorithm but it always gives me errors on matlab

## Wayne King (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/22109#comment_48208

You should post the relevant portions of your MATLAB code and the errors you are getting.

## Walter Roberson (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/22109#comment_48210

Quite a lot of programming involves implementing known algorithms, and a lot of the rest of programming involves first inventing new algorithms and then implementing them.

If your version of the code is giving problems, then it is time to start to learn how to understand error messages and to read reference material, and to learn how to debug problems.

Start with the first error message that you are having difficulty understanding. Have you search mathworks.com for more information about what that particular error message means?

## Andrew Rizk (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/22109#comment_48533

ok I have freemat.. i want to find P8(λ) by neville's algorithm...

the input is numbers x0, x1, x2 ..... xn and values f(x0), f(x1), .....f(xn) as the first column Q0,0 Q1,0 .... Qn,0

I want to input some values of x and some values of f(x) but I dont know how to.

so the input would

For i = 1, 2, 3, 4, 5, 6, 7, 8, 9

for j = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

set Qi,j = [(x - xi,j) * Qi,j-1 - (x-xi) * Qi-1,j-1] / xi - xi,j

OUTPUT (Q);

STOP.

## Daniel (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/22109#comment_48606

You might have better luck asking in a FreeMat forum, because that syntax doesn't look anything like MATLAB syntax.