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

6 thoughts on “mXparser - user defined functions applied to Fundamental theorem of calculus

  1. Hello, i feel that i saw you visited my website so i got here to go back the
    prefer?.I'm trying to find issues to enhance my site!I assume its ok to use a few of your ideas!!

    1. Formula string is a String type - if limitation exist this is related to String class. Additionally internal iterators are "int" types, so forula length is definitely limited by max int 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *