Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. %% Example 1. Newton interpolating polynomial
  2. clear all, clc ,close all, format compact, format
  3. xnodes=[1:7]; ynodes=[2.3,3.4,5.1,6.3,7.5,8.2,7.4];
  4. ๐’‡ ๐’™๐Ÿ, ๐’™๐Ÿ =
  5. ๐’‡๐Ÿ โˆ’ ๐’‡๐Ÿ
  6. ๐’™๐Ÿ โˆ’ ๐’™๐Ÿ
  7. โ€ฆโ€ฆ โ€ฆ. โ€ฆ.
  8. ๐’‡ ๐’™๐Ÿ, ๐’™๐Ÿ, ๐’™๐Ÿ‘ =
  9. ๐’‡ ๐’™๐Ÿ, ๐’™๐Ÿ‘ โˆ’ ๐’‡ ๐’™๐Ÿ, ๐’™๐Ÿ
  10. ๐’™๐Ÿ‘ โˆ’ ๐’™๐Ÿ
  11. โ€ฆโ€ฆ โ€ฆ. โ€ฆ.
  12. 4
  13. Newton interpolating polynomial
  14. coef=ynodes; % determination of ๐’‚๐Ÿ, ๐’‚๐Ÿ, โ€ฆ
  15. for k = 2:7
  16. coef(k:7) = (coef(k:7) - coef(k-1:6))./โ€ฆ
  17. (xnodes(k:7) - xnodes(1:8-k));
  18. end
  19. syms x
  20. pol= coef(7); % coefficients of the polynomial
  21. for k = 6:-1:1
  22. pol=pol*(x-xnodes(k))+coef(k);
  23. end
  24. ๐’™๐’‹ ๐’‡๐’‹ ๐’‡ ๐’™๐’‹
  25. , ๐’™๐’‹+๐Ÿ ๐’‡ ๐’™๐’‹
  26. , ๐’™๐’‹+๐Ÿ, ๐’™๐’‹+๐Ÿ ๐’‡ ๐’™๐’‹
  27. , ๐’™๐’‹+๐Ÿ, ๐’™๐’‹+๐Ÿ, ๐’™๐’‹+๐Ÿ‘
  28. ๐’™๐Ÿ ๐’‚๐Ÿ = ๐’‡๐Ÿ
  29. ๐’‚๐Ÿ = ๐’‡ ๐’™๐Ÿ, ๐’™๐Ÿ
  30. ๐’™๐Ÿ ๐’‡๐Ÿ ๐’‚๐Ÿ‘ = ๐’‡ ๐’™๐Ÿ, ๐’™๐Ÿ, ๐’™๐Ÿ‘
  31. ๐’‡ ๐’™๐Ÿ, ๐’™๐Ÿ‘ ๐’‚๐Ÿ’ = ๐’‡ ๐’™๐Ÿ, ๐’™๐Ÿ, ๐’™๐Ÿ‘, ๐’™๐Ÿ’
  32. ๐’™๐Ÿ‘ ๐’‡๐Ÿ‘ ๐’‡ ๐’™๐Ÿ, ๐’™๐Ÿ‘, ๐’™๐Ÿ’
  33. ๐’‡ ๐’™๐Ÿ‘, ๐’™๐Ÿ’
  34. ๐’™๐Ÿ’ ๐’‡๐Ÿ’
  35. polyn=collect(pol)
  36. coefpol=sym2poly(polyn) % coefficients of the polynomial (format double)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement