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

The program must calculate the value of x needed to satisfy y=g(x) using Newtons

ID: 3650739 • Letter: T

Question

The program must calculate the value of x needed to satisfy y=g(x) using Newtons Method
where y is specified by the user. The function g(x) is defined below.
y=g(x)=0.09x^3 -0.2x^2 +10x -30
Specifically the program must do the following:
i) Write the function g(x) to the screen and inform the user this is the function
being solved.
ii) Request from the user the value of y for which x will be solved for. User will
input the value from the screen.
iii) Request from the user an initial guess of x. User will input the value from the
screen.
iv) Calculate the value of x needed to achieve y within a tolerance of y0.0001
using Newtons Method.
v) Write the value of x to the screen.
vi) Write the number of iterations required to reach the solution to the screen.
Part A. Write a flow chart for the program.
Part D. Create a FORTRAN 95 program for this program.

Explanation / Answer

please rate - thanks

       implicit none
       integer i
       real a,b,dl,dx,x1,x0,y,df,f
      dl=0.0001
      a = 1
      b = 2
      dx = b-a
      Write(*,*)"the function beig solved: y=g(x)=0.093x^3 -0.2x^2 +10x -30"
      Write(*,*)"Enter the value of y to solve for"
      Read(*,*)y
      WRITE(*,*)"enter the initial value of x:"
      READ (*,*) x0
      i=0
      DO 100 WHILE (ABS(dx).gt.Abs(y-dl))
       x1=x0-f(x0)/df(x0)
       dx =x1-x0
       x0 = x1
       i=i+1
100   END DO
       WRITE (*,*)"after ", i,"iterations x0=",x0," dx=",dx
       STOP
       end

      real FUNCTION F(X)
      F = (0.093* x0 * x0 * x0 -0.2* x0 * x0 +10* x0 -30)
      RETURN
      END

      real FUNCTION DF(X)
      DF = (0.279* x0 * x0 -0.4* x0 +10)
      RETURN
      END