Загрузил Денис Гажю

izolarearadacinilor

реклама
package izolarearadacinilor;
import java.util.Scanner;
public class Izolarearadacinilor {
private static double x;
public static void main(String[] args) {
double a, b, c;
double y, y1;
System.out.println("Programul rezolva ecuatiile de gradul 3 de tipul:");
System.out.println("ax^3 + bx - c = 0;");
System.out.println("Introduce-ti a, b и c de la tastatura:");
Scanner in = new Scanner(System.in);
a = in.nextDouble();
b = in.nextDouble();
c = in.nextDouble();
System.out.println("Definim intervalele functiei unde: ");
System.out.println("y1 =a*x^3; y2=-bx-c;");
x = 0;
y1 = -b * x - c;
System.out.println("y2=" + y1);
y = 0;
x = -c / b;
System.out.println("x=" + x);
System.out.println("Solutiile se afla in intervalele de la z2=0 pina la z1=" + y1);
System.out.println("Introducem variabilile (n)-numarul de intervale si (h)-pasul");
int n = 10;
double h;
h = (b - a) / 2;
double z1, z2, y3, y4;
z1 = y1;
z2 = 0;
y3 = Math.pow(a, 3) + b * a - c;
System.out.println("y3=f(a)=" + y3);
x = a + h;
if (x <= b) {
y4 = Math.pow(x, 3) + b * x - c;
while (y3 * y4 < 0) {
x = h * x;
if (y3 = y4) {
}
}
}
}
// double a, b,x,y,h;
// int n=10;
// double e =0.0001;
// double f(x);
// f(x)=Math.pow(x, 3)+ 4*x+2=0;
// double y1=Math.pow(x, 3);
// double y2=-4*x+2;
}
Скачать