manual:chapter8:numinteg

Numeric integration of symbolic expressions is performed in newRPL via the NUMINT command which implements the Adaptive Simpson's method.

NUMINT accepts four arguments:

  • the mono-variate function to integrate, either in symbolic or program form;
  • the lower integration limit;
  • the upper integration limit;
  • the error tolerance.

If the function to integrate is expressed in symbolic form it must respect a precise syntax:

  • it must be written as an equation;
  • the left side must be in the form func(var) where var is the integrating variable and func is the function's name;
  • the right side is a function, expressed in terms of var.

For example valid expressions are:

'F(X)=X*LN(X)'
'G(Z)=Z^2-2*COS(Z)'
'VEL(T)=ACC*T'

As shown above, the functions may refer to global or local variables; the function's name is only descriptive and bears no relevance to the calculation.

Alternatively, the function can be written as a program which accepts exactly one numeric argument and returns exactly one numeric result. The expressions above can be rewritten as:

« DUP LN * »
« DUP SQ SWAP COS 2 * - »
« 'ACC' RCL * »

The integration limits can be either real or complex finite numbers; symbolic constants are accepted and silently converted to numerical values.

The error tolerance is a real number used to specify the required precision of the calculation: when two successive iterations differ by a value which is less than the tolerance the calculation stops.


When a real number is input to a trigonometric function newRPL assumes that it is an angle expressed in the current angular mode; however the trigonometric functions are meant to process quantities expressed in radians. In other words the following transformations are implicitly applied:

  • in RAD mode θ=θr;
  • in DEG mode θ=π180θ°;
  • in GRAD mode θ=π200θg.

where θr, θ° and θg are the quantities entered by the user and θ is what is actually fed to the trigonometric functions.

From this, two important consequences derive:

  1. the antiderivative changes according to the angular mode. Let's consider e.g. the function f(θ)=sinθ and apply the transformations above:

    • in RAD mode f(θr) is equivalent to f(θ) which differentiates to f(θr)dθr=sinθdθ and whose antiderivative is F(θ)=cosθ;
    • in DEG mode f(θ°) is actually f(π180θ°) which differentiates to f(π180θ°)dθ°=180πsinθdθ and whose antiderivative is F(θ)=180πcosθ;
    • in GRAD mode f(θg) is actually f(π200θg) which differentiates to f(π200θg)dθg=200πsinθdθ and whose antiderivative is F(θ)=200πcosθ;

  2. no inverse transformation is applied to the resulting output: this is mathematically correct, but can be disconcerting if one is not immediately aware of the implicit variable substitution.


In conclusion, unless the user knows exactly what he/she is doing it's advisable to perform numeric integration of trigonometric expressions in RAD mode.


pic 20x10e(4x33x4)dx Input:
16 SETPREC
'F(X)=X^10*EXP(4*X^3-3*X^4)'
0
2
tol
NUMINT
tol=10-4 7.258 376 114 514 225 … |Δ| = 1.9·10-5
tol=10-8 7.258 395 173 115 920 … |Δ| = 2.5·10-9
tol=10-12 7.258 395 170 615 141 … |Δ| = 8.5·10-13
tol=10-16 7.258 395 170 614 323 … |Δ| = 3.2·10-14
Truncated at 16 digits 7.258 395 170 614 291

This integral is interesting because the shape of the function in the interval is flat almost everywhere except for a narrow peak which is however captured by the algorithm.




  • manual/chapter8/numinteg.txt
  • Last modified: 2021/10/01 12:35
  • by jojo1973