Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ga.t0;
- import java.util.Random;
- import static java.lang.Math.pow;
- public class GAT0 {
- public double Beale(double x1,double x2)
- {
- double rez;
- rez= (double) (double) ((double) pow((1.5-x1+x1*x2),2) + pow((2.25-x1+x1*x2*x2),2) + pow((2.625-x1+x1*x2*x2*x2),2));
- System.out.print("Rezultatul functiei Beale este:");
- System.out.println(rez);
- System.out.println('\n');
- return rez;
- }
- public Random random = new Random();
- public double nextDouble(double min, double max)
- {
- double x = min + random.nextDouble() * (max - min);
- System.out.print("Numar Generat:");
- System.out.println(x);
- return x;
- //System.out.print(min + random.nextFloat() * (max - min));
- }
- public static void main(String[] args)
- {
- GAT0 d = new GAT0();
- //d.Beale(0, 0);
- double min=1000000,max=-1000000;
- for(int i=1;i<=3;i++)
- {
- double p = d.Beale(d.nextDouble(-4.5,4.5),d.nextDouble(-4.5,4.5));
- if(p>max)
- max = p;
- else
- if(p<min)
- min = p;
- // d.Beale(d.nextDouble(-4.5,4.5),d.nextDouble(-4.5,4.5));
- }
- System.out.print("Minimul functiei este ");
- System.out.println(min);
- System.out.print("Maximul functiei este ");
- System.out.println(max);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement