User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » fortran help, got it started, cant finish, outlab9 Page [1]  
bigdawg
New Recruit
32 Posts
user info
edit post

program bisection
implicit none
character::choice
real::lower, upper
write(*,*)"************************************"
write(*,*)"* F. f(x) = x^3 - 3*x +1 *"
write(*,*)"* G. f(x) = x^2 - 1 *"
write(*,*)"* H. f(x) = x^3 *"
write(*,*)"* I. f(x) = x + 1 *"
write(*,*)"* J. f(x) = x^2 + 2x *"
write(*,*)"* K. f(x) = x^3 + 3x^2 + 3x + 3 *"
write(*,*)"* x. Main Menu *"
write(*,*)"************************************"
write(*,*)"Make a selection from the menu."
read(*,*)Choice
write(*,*)"Enter the lower bound"
read(*,*)lower
write(*,*)"Enter the upper bound"
read(*,*)upper
write(*,*)"Iteration
Case(f,F)
REAL FUNCTION f(x)
IMPLICIT NONE
REAL,INTENT(IN):: x
f = x^3-3*x+1
call root
END FUNCTION
Case(g,G)
REAL FUNCTION f(x)
IMPLICIT NONE
REAL,INTENT(IN):: x
f = x**2-1
call root
END FUNCTION
case(h,H)
REAL FUNCTION f(x)
IMPLICIT NONE
REAL,INTENT(IN):: x
f = x**3
call root
END FUNCTION
Case(i,I)
REAL FUNCTION f(x)
IMPLICIT NONE
REAL,INTENT(IN):: x
f = x + 1
call root
END FUNCTION
case(j,J)
REAL FUNCTION f(x)
IMPLICIT NONE
REAL,INTENT(IN):: x
f = x**2 + 2*x + 2
call root
END FUNCTION
Case(k,K)
REAL FUNCTION f(x)
IMPLICIT NONE
REAL,INTENT(IN):: x
f = x**3 + 3*x**2 + 3*x + 3
call root
END FUNCTION
case(x,X)
stop
end program bisection
RECURSIVE SUBROUTINE root(f,answer)
IMPLICIT NONE

real, INTENT(in)::f
real, INTENT(out)::answer
real::lower,upper

11/10/2005 2:36:33 PM

Wraith
All American
27257 Posts
user info
edit post

It would help a lot if you told us what the program is supposed to do. I know documentation is a bitch, but it makes things a lot easier for those of us that aren't familiar with what the program does.

11/10/2005 3:13:41 PM

bigdawg
New Recruit
32 Posts
user info
edit post

this is what the program is suppose to do

Program Definition:
! Write a FORTRAN program that finds the root of a function between
! two bounds defined by the user using the method of recursive
! bisection.
!
! You can only use Bisection if you assume that there is only 1
! root between the upper and lower bounds. Given a function that
! crosses the x axis only once between the upper and lower bounds,
! the root can be found by bisecting the interval between the
! bounds and testing the bisection point for which side of the x
! axis f(x) lies on. If the value at the lower bound f(lb) is
! of the same sign as f(x), then the new lower bound would be x.
! Likewise, if the value of the upper bound f(ub) is of the same
! sign as f(x), then the new upper bound would be x.
!
! This process can be accomplished through a DO loop and through
! recursion. To understand the problem better, you may want to code
! the problem using a DO loop first and then code it using
! recursion. Let the root be located at the point where
! abs(f(x)) <0.5E-6
!
! Enable the program to find the roots for the 6 equations below
! using a menu.
!
! *******************************************
! * F. f(x) = x^3 - 3*x + 1 *
! * G. f(x) = x^2 - 1 *
! * H. f(x) = x^3 *
! * I. f(x) = x + 1 *
! * J. f(x) = x^2 + 2x *
! * K. f(x) = x^3 + 3x^2 + 3x + 3 *
! * *
! * X. Main Menu *
! *******************************************

11/10/2005 3:57:29 PM

clalias
All American
1580 Posts
user info
edit post

what exactly do you need help with. I don't think anyone here is going to write the code for you. If you have a specific question then I'll try to help.

11/10/2005 5:45:14 PM

tl
All American
8430 Posts
user info
edit post

write(*,*)"Iteration

need a close quote?

11/10/2005 5:51:15 PM

Ernie
All American
45943 Posts
user info
edit post

ahaha

this guy is like

HERE'S MY HOMEWORK

SOMEBODY FINISH IT FOR ME

11/10/2005 7:13:42 PM

 Message Boards » Study Hall » fortran help, got it started, cant finish, outlab9 Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.39 - our disclaimer.