BISECTION3

!Program name: BISECTION3

!Function: x^3-9

!Initial x value is 1.0

!Tolerance 1E-06

!initial Interval dx=0.5

!The number of bisections is 100

!Root is 2.08008382

 

module finding_roots

implicit none

Real :: xl, xr

 

contains

   subroutine init()

    !Root between x=0 and x=3

    xl=0.

    xr=3.

    write (*,5) "iter", "x", "y(x)", "fl", "fl*y(x)"

5  format (a5X,a10X,a20X,a20X,a15X)

   end subroutine init

  

   function func(x) result(y)

    implicit none

    Real :: x

    Real :: y !dummy argument

    y=x**3-9

   end function func

  

   subroutine bisect(xl,xr,x,func,f)

    implicit none

    integer :: i

    real :: xl, xr, x, func, toly

    real :: fl, fr, f       !dummy arguments

 

    call init()

 

    fl=func(xl)

    fr=func(xr)

    toly=1.E-06

 

    do i=1,100

      x=0.5*(xl+xr)

      f=func(x)

      if (f*fl .lt. 0) then

       xr=x

       fr=f

      else

       xl=x

       fl=f

      end if

      Write (*,*) i, x, f, fl, f*fl

      if (abs(f) .lt. toly) exit

   end do

   end subroutine bisect

 

end module finding_roots

 

use finding_roots

 

call bisect(xl,xr,x,func,f)

 

print *, x, func(x)

stop

end 

Comentários

  1. Wagering necessities embody a rollover of 35x, which is a fair playthrough amount for this measurement of a deposit bonus. The most guess allowed is $10, and the max payout is 30x the deposit amount. What’s really nice right here is that the wagering necessities are just 25x. https://casino.edu.kg/tag/%EB%B4%84%EB%B9%84-%EB%B2%B3 On your subsequent 4 deposits, use code WILD100 for a 100% match a lot as} $1,000 on each deposit.

    ResponderExcluir

Postar um comentário

Postagens mais visitadas deste blog

HYDROGEN-RADIAL

HYDROGEN-POTENTIAL

ONE_PART_QHO