Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fadsgedfsg;
- public class Program {
- public static void main(String[] args) {
- double x,y,z=y=x=20,
- epsmax=0.001,
- alpha=0.1;
- int itermax=100;
- for(int iter=1;iter<itermax;++iter){
- double u=(x-2)*(x-2)+(y-5)*(y-5)+(z+4)*(z+4);
- double dfdx=2*(x-2);
- double dfdy=2*(y-5);
- double dfdz=2*(z+4);
- double xn=x-alpha*dfdx;
- double yn=y-alpha*dfdy;
- double zn=z-alpha*dfdz;
- double eps=(xn-x)*(xn-x)+(yn-y)*(yn-y)+(zn-z)*(zn-z);
- if(eps<epsmax)break;
- x=xn;
- y=yn;
- z=zn;
- System.out.println(iter+" "+xn+" "+yn+" "+zn+" "+u);
- }
- System.out.println("Koniec");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement