Comp Sci FORTRAN Help: Concept of User Defined Functions

AI Thread Summary
The discussion focuses on creating a user-defined function in FORTRAN and using it within a subroutine that implements the bisection method to find zeros. The user initially struggles with calling the function to evaluate specific values, such as the lower bound 'a', upper bound 'b', and midpoint 'm'. A key point is that the function can be called in the subroutine using syntax like Y1 = F1(A) to assign the result to a variable. The user resolves their confusion regarding variable passing after receiving clarification. Overall, the thread emphasizes the importance of understanding function calls in FORTRAN programming.
mattmac.nuke
Messages
22
Reaction score
0
Alright, I have a situation where I need to create a user defined function (I've done that) next I need to write a subroutine that uses the bisection method to find the zeros of said function (I've also done that) but I can't figure out how to call on the user defined function to evaluate at different values... more specifically, I have a function, f1 (x), where it takes a value x and makes some computations with it, but I need that same function to be called on to evaluate 'a' (the lower bound) and 'b' (the upper bound) and the 'm' (the midpoint), but I'm not sure how to do that... my textbook doesn't cover it, and my professor didn't provide any useful direction. I haven't conceptualized some of this material well enough to draw logical solutions.
 
Physics news on Phys.org
In the calling program or subroutine, if you wanted to evaluate f1(x) at a particular value, you would write something like

Y1 = F1 (A)

where the function F1 (x) is evaluated at x = A and the result assigned to the variable Y1.
 
Thank you! I figured out where the error was, in passing the variables, but after reading that I was reaffirmed on what I thought the program should be doing.
 

Similar threads

Replies
1
Views
2K
Replies
5
Views
2K
Replies
3
Views
7K
Replies
4
Views
10K
Replies
1
Views
3K
Replies
13
Views
3K
Back
Top