Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.Math; // headers MUST be above the first class
- // one class needs to have a main() method
- public class HelloWorld
- {
- // arguments are passed using the text field below this editor
- public static void main(String[] args)
- {
- int size = 4;
- double [] x = { 0.6, 0.65, 0.7, 0.75};
- double [] y = {0.56464, 0.60519, 0.64422,0.68164};
- double xn = 0.64;
- double yn = 0;
- for (int i =0; i<size; ++i)
- {
- double temp = 1;
- for(int j = 0; j < size; ++j )
- if( j!=i) temp*=(xn-x[j])/(x[i]-x[j]);
- yn += temp * y[i];
- }
- System.out.println(yn);
- System.out.println(Math.sin(xn));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment