FORTRAN Help: Concept of User Defined Functions

Click For Summary
SUMMARY

This discussion focuses on creating user-defined functions in FORTRAN and utilizing them within subroutines, specifically for implementing the bisection method to find zeros of a function. The user successfully defined a function, f1(x), and encountered challenges in evaluating this function at specific points, namely the lower bound 'a', upper bound 'b', and midpoint 'm'. The solution involved correctly passing variables to the function, which was clarified through examples provided in the discussion.

PREREQUISITES
  • Understanding of FORTRAN programming language
  • Familiarity with user-defined functions in programming
  • Knowledge of the bisection method for root-finding
  • Basic concepts of subroutines in FORTRAN
NEXT STEPS
  • Study the implementation of user-defined functions in FORTRAN
  • Research the bisection method and its applications in numerical analysis
  • Learn about variable passing techniques in FORTRAN subroutines
  • Explore debugging techniques for FORTRAN programs
USEFUL FOR

This discussion is beneficial for FORTRAN programmers, students learning numerical methods, and anyone interested in implementing mathematical algorithms using user-defined functions.

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 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
10K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K