Tag Archives: Math Parser

mXparser – user defined functions applied to Fundamental theorem of calculus

Fundamental Theorem of Calculus is a kind of a link between two most important calculus concepts: derivative and integral.

Fundamental Theorem of Calculus – formal statement

For continuous real-valued function $$f:[a,b]\to\mathbb{R}$$ defined on closed interval $$[a,b]$$ let $$F:[a,b]\to\mathbb{R}$$ be the function given by

$$F(x)=\int_a^x f(t)\text{d}t$$

The $$F$$ is uniformly continuous on $$[a, b]$$, differentiable on the open interval $$(a, b)$$, and

$$F'(x)=f(x)$$

Fundamental Theorem of Calculus – mXparser test

import org.mariuszgromada.math.mxparser.*;
...
/* Function */
Function f = new Function("f(x) = sin(x)");
		
/* Antiderivative */
Function F = new Function("F(x) = int(f(t), t, 0, x)", f);
		
/* function = derivative ( antiderivative ) */
Argument x = new Argument("x = pi");
Expression e = new Expression("f(x) - der(F(x), x)", x, f, F);
mXparser.consolePrintln("Res : " + e.getExpressionString() + " = " + e.calculate());
mXparser.consolePrintln("Computing time = " + e.getComputingTime() + " s.");
Res : f(x) - der(F(x), x) = 6.237833817291525E-8
Computing time = 0.411 s.

Best regards,
Mariusz Gromada