Skip to content
rwenhPublic

About

A Fortran-based scientific calculator built with recursive-descent parsing and evaluation. Though Fortran’s string handling isn’t its strength, this project embraces the challenge—an intentional exercise in pushing boundaries. Crafted not despite the complexity, but because it makes the endeavor meaningful.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Fortran Numerical Methods Toolkit

A small, modular Fortran project demonstrating five classic numerical methods. Built and tested with gfortran (GNU Fortran 13, but any Fortran 2008+ compiler will work).

Files

File Purpose
numerical_methods.f90 Module containing all five methods
main.f90 Driver program that runs each method on a worked example
README.md This file

How to compile and run

gfortran -o numerical_toolkit numerical_methods.f90 main.f90
./numerical_toolkit

(The module file must be compiled before main.f90, since main.f90 depends on it — listing them in that order in the command above handles this automatically.)

Expected output

==========================================
   FORTRAN NUMERICAL METHODS TOOLKIT
==========================================

--- Root finding: f(x) = x^3 - x - 2 ---
 Bisection:      root =   1.521380  (19 iterations)
 Newton-Raphson: root =   1.521380  (3 iterations)

--- Integration: f(x) = 4/(1+x^2) on [0,1]  (exact = pi) ---
 Trapezoidal rule: integral =   3.141576
 Simpson's rule:   integral =   3.141593
 True value (pi):              3.141593

--- Gauss elimination: solving A*x = b ---
 Solution:
   x(1) =   2.000000
   x(2) =   3.000000
   x(3) =  -1.000000

==========================================

What each method does

  • Bisection method — repeatedly halves an interval [a, b] where the function changes sign, narrowing in on a root. Slow but always converges if the starting interval is valid.
  • Newton-Raphson method — uses the function's derivative to jump toward the root much faster than bisection, starting from a single guess. Converges quickly but needs a decent starting point and a derivative.
  • Trapezoidal rule — approximates the area under a curve by summing trapezoids between sample points.
  • Simpson's 1/3 rule — fits parabolas through pairs of intervals instead of straight lines, which is why it lands closer to the true value of pi (3.141593) than the trapezoidal rule does above.
  • Gauss elimination — solves a system of linear equations by reducing the matrix to upper-triangular form (forward elimination), then solving from the last equation upward (back substitution).

Notes / possible extensions

  • The root-finding and integration routines currently work on fixed demo functions (f_root and f_integrand in numerical_methods.f90). To try a different function, edit those two functions directly.
  • gauss_elimination does not use partial pivoting, so it assumes no zero pivots turn up during elimination — fine for the demo system here, but worth mentioning as a limitation if this goes in a report.
  • Natural next steps if you want to extend the project: add partial pivoting, let the user type in their own function or matrix at runtime, or add another method (e.g. Runge-Kutta for ODEs, or Lagrange interpolation).

About

A Fortran-based scientific calculator built with recursive-descent parsing and evaluation. Though Fortran’s string handling isn’t its strength, this project embraces the challenge—an intentional exercise in pushing boundaries. Crafted not despite the complexity, but because it makes the endeavor meaningful.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages