Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program which finds an approximate solution to an equation f(x)= 0 for s

ID: 3635683 • Letter: W

Question

Write a program which finds an approximate solution to an equation f(x)= 0 for some function f. Use the bisection method. To solve the problem using this method first find two values of x, A, and B, such that when evaluated in the function f(x) they give opposites signs for the y value. If f(x) is continuous between these two values then we know that there is at least one x which evaluates to a 0 y value, which is between these two values A and B. Treat the positive value as an upper bound and the negative value as a lover bound . Divide the space between A and B in half and evaluate the function at that new point. If the value is positive that it replaces the existing upper-bound and if it is negative it replaces the existing lower-bound. Continue dividing the space between the upper-bound and lower-bound in half and evaluating this new value and generating new upper and lower bounds the case may be. Continue the evaluation process until the x value that you plugging in to the function evaluates to a y value that is zero plus of minus .0000001

Explanation / Answer

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; } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote