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

(4pts) Given a function of your own choice, find any of its fixed points and sho

ID: 3702788 • Letter: #

Question

(4pts) Given a function of your own choice, find any of its fixed points and show how to numerically compute the fixed point using a code. * You can choose Java, C/C++, Matlab or any other high-level languages to write 3. your code * You need to submit your code, the fixed point (one is good enough), and the execution result from your code. In some situations, different initial values may lead to different fixed points, or find no fixed point at all. Try your best to explain this. To address the above issue, you should be careful about how to let the code stop (instead of running forever) . . Bonus: Finding more than one fixed point. Bonus: Creating some figures to illustrate the process of obtaining the fixed point(s)

Explanation / Answer

//  FixedPointFunctionClass.java

//import Scanner class
import java.util.Scanner;
//main class
public class FixedPointFunctionClass {
//main driver method for main function
public static void main(String[] args) {
//scanner object creation
Scanner scanner = new Scanner(System.in);
double p, p0, tol;
int i=1;
int number;
  
System.out.println("Enter approximate Double value: ");
p0 = scanner.nextDouble();

System.out.println("Enter Desired Tolerance value : ");
tol = scanner.nextDouble();

System.out.println("Enter Maximum nNumber of Iterations: ");
number = scanner.nextInt();
  
while (i<=number){
p = function_g(p0);

if(Math.abs(p-p0) < tol)
break;

System.out.printf("Iteration %d: Current value %f ", i, p);

i++;
p0 = p;

if(i>number)
System.out.printf("Method failed after %d iterations ", number);
}
}
static double function_g(double x){
//change equation according to problem
return Math.pow(3*x*x+3, .25);
}
static double function_f(double x){
//change equation according to problem
return x*x*x*x-3*x*x-3;
}
}

Sample Output :

Enter approximate Double value: 14.3498
Enter Desired Tolerance value : 2

Enter Maximum nNumber of Iterations:  1

Iteration 1: Current value 4.991479
Method failed after 1 iterations