This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

FortranForm

FortranForm[expr]
prints as a Fortran language version of expr.
  • Standard arithmetic functions and certain control structures are translated.
  • FortranForm acts as a "wrapper", which affects printing, but not evaluation.
  • The width of output lines must be set explicitly by giving the option PageWidth->n for the relevant output stream.
  • No declarations are generated.
A Fortran language version of a polynomial:
A mixed numeric and symbolic expression:
A Fortran language version of a polynomial:
In[1]:=
Click for copyable input
Out[1]//FortranForm=
A mixed numeric and symbolic expression:
In[2]:=
Click for copyable input
Out[2]//FortranForm=
Fortran formatting for an arbitrary function:
A composite power:
Compute terms of the analytic Hessian for a multivariate function for use in Fortran code:
FortranForm formats expressions like Fortran code:
CForm formats expressions like C code:
Splice can be used to convert expressions in a file:
The following Fortran file contains the unevaluated integral:
Splice inserts the result of the integral:
The resulting output file:
Additional Fortran function definitions may be needed to run the code:
New in 1