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

Design and construct a computer program in one of he ollowing anguages e g C C C

ID: 3745624 • Letter: D

Question

Design and construct a computer program in one of he ollowing anguages e g C C C# ava Pasca or Pv Be sure to follow the documentation and programming style policies of the Computer Science Department. on that will a trat ee ects round ng erors and truncation errors. The following is a plot of the function fx)- sinxx2 10 In order to illustrate the effects of the two major error sources, rounding and truncation, attempt to determine an approximation to the derivative of fx) at x-2.0 radians using the difference approximation given below. (The true answer is 4 +12 cos(S) or about 2.2539995942966376896). Use the formula: f(x) (f (x+h) -x) h with h-1, 0.5,0.25, 1.8189894035459e-12 i.e., keep halving h until it is less than 2.0e-12.) Print out the values of h, your approximation tofbx), and the error in the approximation for each value of h used. This error will include the effects of both truncation and rounding Write down (in your output file or in another file submitted with your program) any conclusions that you can make from these experiments

Explanation / Answer

Since the user is asking for the answer in JAVA ,here is the code(save this code in a file named 'Approximation.java'):

public class Approximation{
   public static double function(double x){
       return Math.sin(x*x*x)+(x*x);
   }


   public static void main(String[] args){
       System.out.println("This program seeks to find the error b/w true derivative and real derivative ");
       System.out.println("Given function: sin(x^3)+x^2"+" ");
       for(double i=1;i>Math.pow(10,-12);i/=2){
           System.out.println("h= " + i);
           System.out.print("Approximate derivative: ");
           System.out.print((function(i+2)-function(2))/i);
           System.out.print(' ');
           System.out.print("Real derivative: ");
           System.out.print(12*Math.cos(8)+4);
           System.out.print(' ');
           System.out.print("Error: ");
           System.out.print((12*Math.cos(8)+4)-((function(i+2)-function(2))/i));
           System.out.print(" ");
       }

       System.out.println("Inference : The error b/w the real and the approximate derivative computed decreases as the value of h decreases");
   }
}

Though most of the code is obvious ,here are some important points:

Hope that helps :) .

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