here is what i have: public class Bisection2 { public static void main(String ar
ID: 3632178 • Letter: H
Question
here is what i have:public class Bisection2
{
public static void main(String args[])
{
}
private double precision = .000001;
private double cubic(double x)
{
double Fn = ((Math.pow(x,3)) - (7 * (Math.pow(x,2))) + (5 * x) + 3);
return (Fn);
}
private double bisector(double left, double right)
{
double midpoint;
while (Math.abs(right - left) > precision)
{
// Find the Midpoint of the funtion
midpoint = ((left + right) / 2);
System.out.print(midpoint);
System.out.print(" ");
//determine the appropriate half to search in
if ((cubic(left) * cubic(midpoint)) > 0)
left = midpoint;
else
right = midpoint;
}
return ((left + right) / 2);
}
private int Main()
{
System.out.print(bisector(0, 2));
System.out.print(" ");
System.out.print(bisector(5, 7));
System.out.print(" ");
return 0;
}
}
My assignment is to write a program which finds an approximate solution to an equation f(x)=0 for some function f. Use the bisection method. I am supposed to use at least 3 methods.
Explanation / Answer
use the system console to ask for the coefficients of x^whatever power. and if the x raised to that power does not exist enter in a zero for the coefficient. This should allow you to use the bisector method to approximate a solution for and function f(x).
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.