Skip to content

Instantly share code, notes, and snippets.

@IlyaHalsky
Created March 9, 2017 12:10
Show Gist options
  • Save IlyaHalsky/144a9fe647613f4d8f621e0ca9d772ff to your computer and use it in GitHub Desktop.
Save IlyaHalsky/144a9fe647613f4d8f621e0ca9d772ff to your computer and use it in GitHub Desktop.
package com.company;
import java.util.function.Function;
/**
* Created by ilya2 on 02.03.2017.
*/
public class Meh {
public static void main(String[] args) {
new Meh().run();
}
double alpha = 10.0;
double lambda = 380.0;
double H = 0.003;
Function<Double, Double> f = pm -> pm * Math.sin(pm * H) - alpha/lambda * Math.cos(pm * H);
Function<Double, Double> fst = pm -> H * pm * Math.cos(pm * H) + (H * alpha * Math.sin (pm * H))/(lambda);
public void run(){
double eps = 0.00001;
double x = 1.2;
for (int i = 0; i< 5; i++) {
double xn = -10000;
double xn1 = x;
while (Math.abs(xn - xn1) >= eps) {
xn = xn1;
xn1 = xn - f.apply(xn) / fst.apply(xn);
}
System.out.println(xn);
x+=Math.PI/H;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment