Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
BiseccionJava
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; class Rextester{ // Usando el método de bisección, halla la raíz de la función // x^3 + 4x^2 - 10 = 0 public static Scanner sc = new Scanner(System.in); static float errorRelativo = (float) 0.0001; static int iteraciones = 0; static double funcion(double x) { return x * x * x + 4 * x * x - 10; } static void biseccion(double a, double b) { double c = a; while ((b - a) >= errorRelativo) { c = (a + b) / 2; if (funcion(c) == 0.0) { break; } else if (funcion(c) * funcion(a) < 0) { b = c; } else { a = c; } iteraciones++; } System.out.print("Después de " + iteraciones + " iteraciones, "); System.out.printf("la raíz de la función f es %.9f.", c); System.out.println(" "); } public static void main(String[] args) { double a = 1, b = 2; biseccion(a, b); } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Search substring
Coding Challenge - 01 (Even numbers)
innerclss
Add Two Numbers saved in linked lists
classwork
Remove duplicates in string
ZonedDateTime testing
pow binary
JAVA # Cümleye Boşluk Bırakma 2
reverse Linked List
Please log in to post a comment.