0% found this document useful (0 votes)
20 views5 pages

Lab 8

The document discusses Newton's divided difference polynomial interpolation technique. It begins by explaining that Newton's method uses differences in function values at data points to create a polynomial that approximates the points. The algorithm section states that the method computes division differences and the Newton interpolating polynomial to approximate values and determine estimates. Key advantages noted are more efficient updates and localized modifications when new data is added. Disadvantages include the polynomial being less visually intuitive than Lagrange polynomials and potential oscillations from uneven spacing.

Uploaded by

Fahad Sikandri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views5 pages

Lab 8

The document discusses Newton's divided difference polynomial interpolation technique. It begins by explaining that Newton's method uses differences in function values at data points to create a polynomial that approximates the points. The algorithm section states that the method computes division differences and the Newton interpolating polynomial to approximate values and determine estimates. Key advantages noted are more efficient updates and localized modifications when new data is added. Disadvantages include the polynomial being less visually intuitive than Lagrange polynomials and potential oscillations from uneven spacing.

Uploaded by

Fahad Sikandri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Numerical Computations

Name: shah fahad khan

Reg no: FA20-BEE-227

Lab 8 : Newton's Divided Difference


Polynomial
Introduction to Newton's divided difference polynomial

The split difference of Newton Using the differences in the function values at each point, a
polynomial is created as an interpolation technique to approximate a group of data points.
It provides a flexible tool for curve fitting and function approximation by offering a
methodical approach to effective polynomial interpolation.

Algorithm

Set the division differences for the specified data points to zero. To approximate the values
of the function at desired places, compute the Newton interpolating polynomial. To
determine the related y estimates, evaluate the Newton interpolating polynomial for a

range of x values.

Advantages

Effective Updates: Newton's divided difference polynomial updates more computationally


efficiently than the Lagrange polynomial when new data points are added. Newton's
approach is better for dynamic datasets since it involves less computation to add new
points.

Localized Modifications: In Newton's approach, changing a single data point adds or


subtracts only a localized portion of the polynomial; in Lagrange interpolation, changes
have a global effect. When working with huge datasets, its confined aspect can be helpful
because it reduces the computational effort required for modifications.

Disadvantages
Less Visually Intuitive Expression: Compared to the Lagrange polynomial, the Newton
interpolating polynomial is less visually intuitive. Newton's method involves coefficients
that are not immediately associated with corresponding data points, which complicates the
interpretation and communication of the interpolation formula.

Unequal Spacing Dependency: The Runge's phenomenon refers to the fact that more
oscillations in the interpolated polynomial can result from uneven data point spacing,
which is a prerequisite for Newton's method. In these situations, lagrange interpolation
might provide more stability, which would make it a better option for data that is
irregularly distributed.
Code In [11]: plt.plot(x_range, newton_y, label='Newton Interpolation')
plt.scatter(x_values, y_values, color='red', label='Data Points (Lagrange)')
plt.plot(x_range, lagrange_y, linestyle='dotted',color='black', label='Lagrange
plt.scatter(x_interp, lagrange_interpolation(x_values, y_values, x_interp), colo

plt.title('Combined Lagrange and Newton Interpolation')


plt.xlabel('x') plt.ylabel('P(x)') plt.legend()
plt.grid(True) plt.show()

# Take input from the user n = int(input("Enter the number


of data points: ")) x_values = [float(input(f"Enter x[{i}]:
")) for i in range(n)] y_values =
[float(input(f"Enter y[{i}]: ")) for i in range(n)] x_interp =
float(input("Enter the x value for interpolation: "))

# Plot the combined graph and display the polynomial expressions


plot_interpolation(x_values, y_values, x_interp)

# Display the common interpolation polynomial expression


polynomial_expression = interpolation_polynomial_expression(x_values, y_values)
value_at_x = lagrange_interpolation(x_values, y_values, x_interp) print(f'\
nInterpolation Polynomial: {polynomial_expression}') print(f'Value at x =
{x_interp}: {value_at_x}')

Enter the number of data points: 9


Enter x[0]: 1
Enter x[1]: 5
Enter x[2]: 9
Enter x[3]: 3
Enter x[4]: 8
Enter x[5]: 2
Enter x[6]: 6
Enter x[7]: 4
Enter x[8]: 7
Enter y[0]: 5
Enter y[1]: 8
Enter y[2]: 2
Enter y[3]: 4
Enter y[4]: 1
Enter y[5]: 6
Enter y[6]: 3
Enter y[7]: 7
Enter y[8]: 9
Enter the x value for interpolation: 4
Interpolation Polynomial: 9.0*x**8 - 335.0*x**7 + 5201.0*x**6 - 43800.0*x**5 +
21776
6.0*x**4 - 650571.0*x**3 + 1131391.0*x**2 - 1035458.0*x + 375802.0
Value at x = 4.0: 7.0 In [ ]:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy