Integrals involving NORMALD_CDF  possible CAS bug?

02232020, 10:47 PM
Post: #1




Integrals involving NORMALD_CDF  possible CAS bug?
I tried to evaluate the integral \[\int_{10}^{10} \hbox{NORMALD}(X)*\hbox{NORMALD_CDF}(X)\,{\rm d}X \] in the Home screen, expecting to get an answer close to \(0.5\). Instead I got an error message  "Error: Undefined result". This was strange  the integrand is perfectly wellbehaved and gives a smooth graph in the Function app.
Switching to CAS mode cast some light on the situation. Copying and pasting the above integral to the CAS screen, with Exact mode selected, gave a different error message: "Error while checking exact value with approximate value  returning both!" The calculator then returned the following list: \[\left[{1\over2}*{\rm erf}(5*\sqrt{2}){1\over2}*{\rm erf}(5*\sqrt{2})\qquad 0.5\right].\] Evaluation of the exact expression returns 1, which is very different to 0.5! Assuming that the Home screen asks the CAS to help with the integral, it is not surprising that it is unable to return a result. The exact expression in the above list is incorrect. It is the value of the integral without the NORMAL_CDF function. This is, presumably, a CAS bug. An easy workaround is to turn off exact evaluation in the CAS settings. All errors then vanish. Curiously, entering \[\int_{10}^{10} \hbox{NORMALD}(X)*\hbox{normald_cdf}(X)\,{\rm d}X \] in CAS mode (note the lowercase letters!) returns an unevaluated but correctly expanded integral in exact mode. Strange! All of this works in the same way both on my actual G1 calculator and on the Windows Prime. Both are running firmware 20200116. Nigel (UK) 

02242020, 12:35 AM
(This post was last modified: 02242020 01:42 AM by Albert Chan.)
Post: #2




RE: Integrals involving NORMALD_CDF  possible CAS bug?
(02232020 10:47 PM)Nigel (UK) Wrote: I tried to evaluate the integral \[\int_{10}^{10} \hbox{NORMALD}(X)*\hbox{NORMALD_CDF}(X)\,{\rm d}X \] in the Home screen, expecting to get an answer close to \(0.5\). Instead I got an error message  "Error: Undefined result". This was strange  the integrand is perfectly wellbehaved and gives a smooth graph in the Function app. XCas also unable to symbolically evaluate the integral. But, numerical integration is easy, using either romberg, or gaussquad, both returning 0.5 BTW, this integral is trivial if you let c = normald_cdf(x) → dc = normald(x) dx I(c) = ∫ c dc = c²/2 Let lower limit z = normald_cdf(10), upper limit = normald_cdf(10) = 1z Integral = I(1z)  I(z) = (1z+z)(1zz)/2 = ½  z ≈ ½ 

02242020, 07:47 PM
Post: #3




RE: Integrals involving NORMALD_CDF  possible CAS bug?
(02242020 12:35 AM)Albert Chan Wrote:Thanks for the XCAS information. I was carrying out the original integral as a prelude to integrals of the form \[\int_{10}^{10} \hbox{NORMALD}(X)\times\hbox{NORMALD_CDF}(\mu, \sigma; X)\,{\rm d}X, \] the idea being to find the probability that a number chosen from a distribution with \(\mu=0\) and \(\sigma=1\) will be greater than a number chosen from a distribution with different \(\mu\) and \(\sigma\). I don't see a way of doing this more general integral analytically (though I may be wrong!) but in any event a numerical answer is fine. The problem with the Prime is that the CAS integration function returns an incorrect analytical expression in exact mode, which stops the Home Screen integration from working.(02232020 10:47 PM)Nigel (UK) Wrote: I tried to evaluate the integral \[\int_{10}^{10} \hbox{NORMALD}(X)*\hbox{NORMALD_CDF}(X)\,{\rm d}X \] in the Home screen, expecting to get an answer close to \(0.5\). Instead I got an error message  "Error: Undefined result". This was strange  the integrand is perfectly wellbehaved and gives a smooth graph in the Function app. Nigel (UK) 

02252020, 07:24 AM
Post: #4




RE: Integrals involving NORMALD_CDF  possible CAS bug?
Some incomplete simplification prevented integration. However, since normald_cdf is evaled to erf, you will get a lot of erf that the CAS is unable to simplify to 1/2. Numeric evaluation correctly returns 0.5.


02252020, 03:18 PM
Post: #5




RE: Integrals involving NORMALD_CDF  possible CAS bug?
(02252020 07:24 AM)parisse Wrote: Some incomplete simplification prevented integration. However, since normald_cdf is evaled to erf, you will get a lot of erf that the CAS is unable to simplify to 1/2. Numeric evaluation correctly returns 0.5.The problem isn't that integration has been prevented; the problem is that it has been carried out incorrectly. The expression that the Prime returns involving erf (see the second expression in my first post) is not correct, even though the numeric evaluation is. The difference between the "exact" expression and the numeric expression is what confuses the Prime home screen integration routine. I accept that this is easy to work around, now that I know about it  just untick "Exact" in the CAS screen settings. But it would be nice if the incorrect integration did not take place. Thank you for looking at this. Nigel (UK) 

02262020, 06:46 AM
(This post was last modified: 02262020 06:47 AM by parisse.)
Post: #6




RE: Integrals involving NORMALD_CDF  possible CAS bug?
Yes, I was perhaps not clear, but I fixed the problem, now the expression returned in terms of erf evaluates numerically to 0.5.
By the way, inside CAS if you compute an integral and get two answers in a list, then the first one was computed with antiderivative, the second one was computed with quadratures. Most of the time, quadratures will be right. 

02262020, 07:02 PM
Post: #7




RE: Integrals involving NORMALD_CDF  possible CAS bug?
(02262020 06:46 AM)parisse Wrote: Yes, I was perhaps not clear, but I fixed the problem, now the expression returned in terms of erf evaluates numerically to 0.5.I understand now! Many thanks. Nigel (UK) 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)