What technique to integrate this function?

  • Context: Mathematica 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Function Integrate
Click For Summary

Discussion Overview

The discussion revolves around the integration of a function with varying parameters, specifically comparing the results obtained using different representations of a parameter. Participants explore the implications of numerical integration techniques, the sensitivity of the function to parameter changes, and the precision of calculations in Mathematica.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant notes that two representations of a parameter, ##a=89.9## and ##a=89+9/10##, yield significantly different integration results, prompting questions about their correctness.
  • Another participant suggests checking the difference between the two parameter values to see if they are effectively the same in binary representation.
  • Concerns are raised about the large amplitudes of the functions and their sensitivity to the parameter, suggesting that re-scaling may be necessary to maintain precision.
  • Some participants express skepticism about the meaningfulness of the integrals given the sensitivity of the integrand and the large numerical outputs.
  • Discussion includes the importance of output precision in Mathematica, with references to adjusting the number of digits used in calculations and the impact on results.
  • One participant mentions that despite using different representations of the parameter, the same eigenvalue was obtained, raising questions about the underlying behavior of the integrals.
  • Suggestions are made to plot variations of the function to assess the meaningfulness of the results.
  • A participant provides information about Mathematica's WorkingPrecision parameter, which can affect numerical calculations.

Areas of Agreement / Disagreement

Participants express various viewpoints regarding the sensitivity of the integrand and the implications for numerical integration. There is no consensus on the correctness of the integration results or the best approach to take, indicating ongoing debate and exploration of the topic.

Contextual Notes

Limitations include potential issues with numerical precision, the sensitivity of the functions to parameter changes, and the need for careful handling of floating-point calculations in Mathematica.

member 428835
Hi PF!

Attached are two plots of the same function, one uses a parameter ##a=89.9## and the other uses ##a=89+9/10##. As you can see both functions are very different. Also, using NIntegrate over each gives two different outputs respectively, ##-6.91846*10^{12},-6.91949*10^{19}##.

My question is, how do I know if either is right, and if so which one? I'm obviously leaning towards the non-floating point ##a=89+9/10## as the more correct, but how do I know this integral is even right at all?

Are there other numerical integration strategies I should look at besides NIntegrate?
 

Attachments

  • Float.png
    Float.png
    9.1 KB · Views: 410
  • Non-Float.png
    Non-Float.png
    11.6 KB · Views: 470
Physics news on Phys.org
You could compare the two a values. While they may appear the same, they may instead be subtly different in the lowest bits.

Try a1 - a2 and see if it’s a zero or some small number. Base 10 numbers don’t always map to binary well.
 
jedishrfu said:
You could compare the two a values. While they may appear the same, they may instead be subtly different in the lowest bits.

Try a1 - a2 and see if it’s a zero or some small number. Base 10 numbers don’t always map to binary well.
Mathematica outputs 0. (the decimal after the zero indicates a float.) I tell Mathematica to output more digits and it does not output anything. There has to be some difference though, at least in how the function reads each.
 
Could you give the expressions for the functions which are compared or are they only known explicitly (e.g. a solution to an equation)?
Also, it seems like the functions have very large amplitudes. Perhaps, you should do some re-scaling. Otherwise, you might loose precision.
It looks like the amplitudes of the functions are very sensitive to the parameter ##a##.
 
eys_physics said:
Could you give the expressions for the functions which are compared or are they only known explicitly (e.g. a solution to an equation)?
Also, it seems like the functions have very large amplitudes. Perhaps, you should do some re-scaling. Otherwise, you might loose precision.
It looks like the amplitudes of the functions are very sensitive to the parameter ##a##.
I could give the expressions but they're way too many terms to be meaningful. A bunch of sines and cosines. But there are s TON of them.
Yes, I agree that the functions are very sensitive to ##a##.
 
With such a sensitive integrand and such large numbers it is unlikely that either integral is meaningful.
 
Dale said:
With such a sensitive integrand and such large numbers it is unlikely that either integral is meaningful.
Is there a way to get a good feel for when an integral is not meaningful? See, the integral is a matrix component of an algebraic eigenvalue problem ##K = \lambda M##, which for this case was the ##1,1## component of a ##5\times 5## matrix. It turns out it did not matter whether I used the float or exact number, because I received the same ##\lambda## for each case.

What's happening?
 
Plot lots of variations and see if the results make sense. If they do then it is probably meaningful.
 
joshmccraney said:
I tell Mathematica to output more digits and it does not output anything.

What does this mean? You made Mathematica do all floating point calculations with more (decimal) digits? You did not change the number of digits for calculations, but you displayed more output digits?

I am unfamiliar with Mathematica, but I have used Maple extensively. Maple has a control variable, Digits, that sets the number of digits used in floating point calculations. The default value of Digits is 10. I have found that setting Digits to 20 or 30 can wildly change the value of a sensitive sum in which terms have different signs.
 
  • #10
George Jones said:
What does this mean? You made Mathematica do all floating point calculations with more (decimal) digits? You did not change the number of digits for calculations, but you displayed more output digits?
Yea, I displayed more digits for the 89+9/10 - 89.9, but did not send a command about the amount of digits to be used for floats.

George Jones said:
I am unfamiliar with Mathematica, but I have used Maple extensively. Maple has a control variable, Digits, that sets the number of digits used in floating point calculations. The default value of Digits is 10. I have found that setting Digits to 20 or 30 can wildly change the value of a sensitive sum in which terms have different signs.
Does anyone know how to do this in Mathematica, and what the default is set to?
 
  • #12
eys_physics said:
Yes, Mathematica has a parameter called WorkingPrecision, see https://reference.wolfram.com/language/ref/WorkingPrecision.html. One suggestion to joshmccraney could be to play a bit with that parameter.
Thanks. I'll look into that. Do you know if this is at all similar to setting accuracy goals for numerical integration, say MaxRecursion for example?
 

Similar threads

  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 58 ·
2
Replies
58
Views
7K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 2 ·
Replies
2
Views
5K