Here is the code for your question
public class secant_method {
public static double Function(double x) {
return Math.cos((x*x)/3.0) - (1.0/20.0);
}
public static void main(String[] args) {
double x1, x0,x2,x3, precision,check;
int iter=0;
precision = 0.000000001;
x0 = 2;
x1 = 3;
if (Function(x0) Function(x1) < 0)
{
do {
//Intermediate value
x2 = (x0 Function(x1) -
x1*Function(x0))/(Function(x1)-Function(x0));
//Checking is x2 a root
check = Function(x0) Function(x2);
// update the value of interval
x0 = x1;
x1 = x2;
// update number of iteration
iter++;
//if check is 0 then we will break the loop because we got
//the root
if (check == 0)
break;
x3 = (x0 Function(x1) -
x1*Function(x0))/(Function(x1)-Function(x0));
System.out.println("Iteration :" + iter);
System.out.println("Approx value of x :" + x3);
System.out.println("Value of f(x) :"+ Function(x3));
//repeat untill we get to the precision
} while (Math.abs(x3 - x0) >= precision);
System.out.println("Root is "+ x1);
System.out.println("No of iterations are "+ iter);
}
else
System.out.print("Once check the interval");
}
}
Screenshots of the work
JAVA programming: Construct a computer program that uses the Secant Method to solve the problem: fox)cos(3.0)-...
Design and construct a computer program in Java. The following is a plot of the function f(x) = sin(x3) + x2 : In order to illustrate the effects of the two major error sources, rounding and truncation, attempt to determine an approximation to the derivative of f(x) at x = 2.0 radians using the difference approximation given below. (The true answer is 4 + 12 cos(8) or about 2.2539995942966376896). Use the formula: f'(x) ≃ (f(x+h) - f(x)) / h with...
Problem: Write a computer program to implement the Fourth Order Runge-Kutta method to solve the differential equation x=x2 (1) cos(x(1))-4fx(t), x(0)=-0.5 Use h-0.01. Evaluate and print a table of the solution over the interval [O, 1 x(t) 0
Programming Language: JAVA Construct a program that uses an agent to solve a Sudoku puzzle as a Constraint Satisfaction Problem, with the following guidelines: 1. Since 3 x 3 puzzles are too trivial for a computer, your program should use 4 x 4 puzzles (also known as Super Sudoku puzzles; see Figure 2 for an example). 2. The program should read a Sudoku puzzle from a text file. The user should be able to browse the file system to select...