Results 1 to 2 of 2
Thread: Help with solving an equation
 04242017, 07:43 AM #1Member
 Join Date
 Apr 2017
 Posts
 3
 Rep Power
 0
Help with solving an equation
I wanted to find all of the solutions to sin(x^2)  cos(x^3) = 0 for 0<= x <= pi and have this program. I used the bisection method to find the first solution but obviously I want to find the other solutions as well. How can I modify it to display other solutions in addition to the single one it gives me?
Java Code:public class BisectionEquation { public static void main(String[] args){ // error margin final double step = 0.0000001; // variables double begin = 0; // range from 0 to pi double end = 3.14159; double mid; double midFunc; double beginFunc; // bisection loop to find result while ( (endbegin) > step ){ mid = (begin+end)/2; // middle value (halfway between begin and end values midFunc = Math.sin(mid*mid) Math.cos(mid*mid*mid); // function values at begin and mid beginFunc = Math.sin(begin*begin) Math.cos(begin*begin*begin); // if solution is between beginning and middle if ( (midFunc > 0 && beginFunc < 0)  (midFunc < 0 && beginFunc > 0) ){ // Set the new end as the middle end = mid; } //if solution is between mid and end else{ begin = mid; } } //prints the solution System.out.println("The first solution of x: " + (begin+end)/2 ); } }
 04242017, 12:05 PM #2Member
 Join Date
 Jan 2017
 Posts
 46
 Rep Power
 0
Similar Threads

Help with Equation
By TJRedeemer in forum New To JavaReplies: 11Last Post: 09282013, 12:10 AM 
Solving a quadratic equation using java
By Khanak in forum New To JavaReplies: 6Last Post: 06032013, 03:20 PM 
Solving linear equation systems including sparse matrices
By GregXel in forum Advanced JavaReplies: 4Last Post: 11262012, 11:15 AM 
Help with equation
By _Jk_ in forum New To JavaReplies: 10Last Post: 03172011, 08:15 PM 
equation
By bobo67 in forum New To JavaReplies: 5Last Post: 09062010, 06:40 PM
Bookmarks