Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package internewt;
  7.  
  8. /**
  9. *
  10. * @author Student
  11. */
  12. public class InterNewt {
  13.  
  14.  
  15. public static void main(String[] args) {
  16. double tabx[]={0,2,3,4,6};
  17. double taby[]={1,3,2,5,7};
  18. int x=1,f=0,g=1;
  19. double w=0;
  20. int q=tabx.length;
  21. int qq=q;
  22. double tabt[]= new double[q-1];
  23. double tabfx[]= new double[q];
  24. double tabwx[]= new double[q-1];
  25. tabfx[0]=taby[0];
  26. for (int k=0;k<q-1;k++){
  27. tabt[k]=(taby[k+1]-taby[k])/(tabx[k+1]-tabx[k]);
  28. if(g==1){
  29. tabfx[g]=tabt[k];
  30. g++;
  31. }
  32. }
  33.  
  34.  
  35. for (int i=0;i<qq;i++){
  36. for (int j=0; j<qq-2;j++){
  37. tabt[j]=(tabt[j+1]-tabt[j+0])/(tabx[j+f+2]-tabx[0+j]);
  38. if(j==0){
  39. tabfx[g]=tabt[j];
  40. g++;
  41. }
  42. }
  43. f+=1;
  44. qq-=1;
  45. }
  46.  
  47. for (int i=0;i<q-1;i++){
  48. if(i==0)
  49. tabwx[i]=x-tabx[i];
  50. else if(i>0)
  51. tabwx[i]=tabwx[i-1]*(x-tabx[i]);
  52. }
  53.  
  54. for (int i=0;i<q;i++){
  55. if (i==0)
  56. w+=taby[0];
  57. else
  58. w+=tabfx[i]*tabwx[i-1];
  59.  
  60. }
  61.  
  62.  
  63. System.out.println(w);
  64.  
  65. }
  66.  
  67.  
  68.  
  69.  
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement