Skip to main content
19-Tanzanite
October 3, 2023
Question

Different values when calculating the symbolic and numerical value for the same integral. Is it ok?

  • October 3, 2023
  • 2 replies
  • 3324 views

Hello,

Why do I have 2 different values ​​when calculating the symbolic and numerical value for the same integral like below example?


Symbolic calculation:

Cornel_2-1696346586456.png

 

Numeric calculation:

Cornel_1-1696346490903.png

 

Symbolic calculation first then numeric calculation:

Cornel_3-1696346748482.png

2 replies

25-Diamond I
October 3, 2023

Did you really expect a finite result?

You may consider opening a support case with PTC support, giving them the opportunity to improve their symbolic engine.

Here are the results with muPad in MC15

Werner_E_0-1696355180818.png

 

14-Alexandrite
October 3, 2023

When I split the integral in two, with limits -1 to 0 and 0 to 1, the numeric result sums to 3.14159269837176, while the symbolic result matches your single integral.  The numeric integrator in the Free42 Plus app (an enhanced simulation of the HP-42S calculator) gives 3.14153108100.  Both of my numeric results are much closer to pi than yours.  I haven't played around much with integrals for several decades and I don't know this particular one at all.  Is pi the correct answer?

25-Diamond I
October 3, 2023

Yes, it look like the correct result would be pi.

The numeric result of Mathcad can also be improved if the integral is split

Werner_E_0-1696359568351.png

 

Normally you also can improve the numeric result of a definite integral by decreasing the value of the system variable TOL. But if we set it lower than 10^-7 the algorithm fails ("calculation not converging") because the funcion simply is not defined at the end values +-1. So the correct way to calculate the integral is with variable limits +-a and lim a->1. Unfortunately the symbolics in Mathcad is not capable enough to come up with a meaningful result.

 

Also Uncle Wolfram does not provide a symbolic result, just a numeric one which indeed is quite close to pi

Werner_E_1-1696359629804.png

Best result so far possibly by Prime's symbolics -> pi*(1-2i)

 

14-Alexandrite
October 3, 2023

A 4-piece integral with the limits -1 to -0.98, -0.98 to 0, 0 to 0.98449, and 0.98449 to 1 produces a sum of 3.14159265358989.  So, all but the last two decimal places are correct with respect to pi.  I could probably get closer to pi with more trials, but this is enough.

 

It seems to me that this function's very steep tails gives Mathcad fits, both numerically and symbolically.  I suspect that the steep tails and the very large ratio between the tops of the tails and the bottom middle of the curve pushes up against floating point limitations, which is why a 4-piece integral produces a better numerical result than a 2-piece integral, which is in turn better than a 1-piece integral.  I wonder if doubling (or more) the numerical precision that Mathcad works with might result in a better 1-piece integral solution.

 

I don't know enough about the symbolic solver to comment on its behavior.