Converting equations to Fortran code

In summary, the conversation discusses the difficulty of translating an initial value problem into a code for numerical approximation. The person has some knowledge of numerical methods, but is looking for more resources on how to create their own code and understand the reasoning behind method choices. They ask for suggestions on books or websites, and someone mentions that most numerical analysis books have sample programs and tutorials. The example given is finding the area under a curve using a do-loop in FORTRAN with a smaller step size for more accuracy.
  • #1
jf22901
55
1
Hi everyone

I've been doing maths for quite a while now, but have never done any programming until recently. What I'm finding difficult is how you go from an initial value/boundary value problem on a bit of paper to a piece of code that will approximate the equation. I've done a bit of book work on numerical methods (Euler’s midpoint/trapezoidal methods, Runge–Kutta methods) so understand the basics, but would like a more thorough knowledge.

Can anyone suggest any good sites/documents/books that give examples or explanations? Searching online brings up loads of pre-prepared Fortran codes to solve all sorts of things, but I want to know how these codes were created, why they chose the methods they did etc.

Thanks very much in advance. :smile:
 
Technology news on Phys.org
  • #2
Most numerical analysis books offer pretty easy sample programs and tutorials on how to program those exact problems. Finding the area under the curve via an integral is simply a do-loop in FORTRAN. If you narrow your step size, you should get a reasonably accurate result.
 

1. How do I convert a mathematical equation to Fortran code?

To convert a mathematical equation to Fortran code, you will need to first identify the variables and constants involved in the equation. Then, you can use the appropriate Fortran syntax to assign values to these variables, perform mathematical operations, and output the results.

2. Are there any specific rules or guidelines for converting equations to Fortran code?

Yes, there are some important rules to keep in mind when converting equations to Fortran code. These include using the correct data types for variables, following proper syntax for mathematical operations, and using appropriate control structures to handle input and output.

3. How do I handle complex equations or functions in Fortran code?

Fortran has a variety of built-in functions and subroutines that can be used to handle complex equations or functions. These include mathematical functions like sine, cosine, and logarithms, as well as functions for handling arrays and matrices.

4. Can I use user-defined functions in Fortran code?

Yes, you can create your own custom functions in Fortran to handle specific equations or operations. These functions can be defined within your main program or in a separate module and can be called from different parts of your code.

5. Are there any resources or tools available to help with converting equations to Fortran code?

Yes, there are various resources and tools available to assist with converting equations to Fortran code. These include online tutorials, code libraries, and compilers with built-in equation solving capabilities. It can also be helpful to consult with other Fortran programmers or refer to Fortran documentation for further guidance.

Similar threads

  • Programming and Computer Science
Replies
4
Views
590
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
4
Views
15K
  • Programming and Computer Science
Replies
34
Views
3K
  • Programming and Computer Science
Replies
13
Views
4K
  • Programming and Computer Science
Replies
13
Views
3K
Replies
14
Views
199
Back
Top