rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

definite integral fails with messy integrand, indefinite succeeds #3137

Open rtoy opened 1 week ago

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 14:52:58 Created by racinej on 2013-05-28 13:25:50 Original: https://sourceforge.net/p/maxima/bugs/2581


Maxima version: "5.28.0" Maxima build date: "2013-04-30 22:52:43" Host type: "i386-apple-darwin12.3.0" Lisp implementation type: "SBCL" Lisp implementation version: "1.1.7"

Hi. First post to maxima (though user for many years) so filter accordingly. I am using maxima so solve a set of equations subject to integral constraints. I have a number of files using similar kernel (weight) functions that run flawlessly. But the attached hangs with a lisp error. Neither myself nor co-author on an R package that uses this input can detect the issue hence the post. The file tgauss_convolution.m crashes while a similar function epanechnikov_convolution.m runs smoothly but we don't see any substantive difference between the two (the first computes a `truncated gaussian convolution of a kernel with the data, the other an epanechnikov convolution of a kernel with the data' for what that is worth).

File attached, advice/guidance/suggestions most appreciated, and thanks in advance for your wonderful contributions to the community!

Attachments:

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 14:52:59 Created by racinej on 2013-05-28 17:15:10 Original: https://sourceforge.net/p/maxima/bugs/2581/#1dd5


First, let me apologize for submitting the wrong file! And the error is incorrect as well. Perhaps it is best to close this and start a new one?

Regardless, thanks for your patience. I attach the file that is causing issues (and it is not the Lisp error above).

Here is the minimal example that reproduces the problem.

If you set :

ker:gaussian$ b:inf$

the program works fine. the same goes for epanechnikov and sqrt(5).

if you do: ker:utgaussian$ b:3$

The integral on line 52 never terminates: kerfourth_k:integrate(kerfourth(Z)^2, Z, -b, b)$

Thanks again for your patience and suggestions....

Attachments:

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 14:53:03 Created by racinej on 2013-05-28 17:54:22 Original: https://sourceforge.net/p/maxima/bugs/2581/#1490


And I guess I would help myself by attaching the error!

Maxima encountered a Lisp error:

Too large to be represented as a DOUBLE-FLOAT: 152915732322976479918832002685040028630353131589337854665523688586554651989804484145284429606176260483012089810714857635393426910242585929625193162766631662533887571671482315278160628668446747723740057372495802285423395747186399634885489237057355215343517221347440959048674634893632288002476228124735680924446837968827712498353003646825426335990543880324738344073091376081333874850824650605170585413121705002840082407484507078448274262962645064540911722272204750285437923011389853734700785306342333106184700999656914651131100627516710137181175

Automatically continuing. To enable the Lisp debugger set debugger-hook to nil. 2 (%i40) kerfourth_k2 : integrate(Z kerfourth(Z), Z, - b, b) (%i41) kerfourth_k2_n : ev(kerfourth_k2, numer) 2 (%i42) kerfourth_k22 : integrate((Z kerfourth(Z)) , Z, - b, b) (%i43) kerfourth_k22_n : ev(kerfourth_k22, numer) Maxima encountered a Lisp error:

Too large to be represented as a DOUBLE-FLOAT: 283343791638905712426520319024732910283251797203367360290704070187204421938093708430393581267771791750121714702067335806187139874586293490181113744874368628761095325396608069208109253491742557048991061906906117489436664716063069829668589052415877927248709203306051364950731196799875432751141193805149182645623352590232562420509761289684976301066729444390080238244297190284564740760974250022901589584907291899687400776876140185772281803326437068079183405546405585756034265978946156759230072468403844466616799437037338730581673281396078498607631423447522266678290054326519649167901438677315368816357148583759162159875

Automatically continuing. To enable the Lisp debugger set debugger-hook to nil. 1 1 (%i44) kerfourth_km : integrate(kerfourth(- + Z) kerfourth(Z - -), Z, bml, bmh) 2 2 (%i45) kerfourth_km_n : ev(kerfourth_km, numer) (%i46) define(kerfourthder(Z), diff(kerfourth(Z), Z)) (%i47) define(kerfourthcdf(x), integrate(kerfourth(Z), Z, - b, x)) (%i48) define(kerfourthconvol_neg(v), integrate(kerfourth(u) kerfourth(u - v), u, - b, bvh)) Is v + 6 positive, negative, or zero?

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 14:53:07 Created by robert_dodier on 2013-06-17 07:19:50 Original: https://sourceforge.net/p/maxima/bugs/2581/#3c5e


rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 14:53:10 Created by robert_dodier on 2013-07-03 06:32:11 Original: https://sourceforge.net/p/maxima/bugs/2581/#dd11


rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 14:53:14 Created by robert_dodier on 2013-07-03 06:32:12 Original: https://sourceforge.net/p/maxima/bugs/2581/#988a


To the person who reported the bug: can you please attach a script which reproduces the bug that you see. I don't see any error in the attached script, except that it is malformed (it ends in an unterminated comment).

I've marked this report as pending -- it should be closed if no further information is forthcoming; there simply isn't anything useful we can do with it as it stands.

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 14:53:17 Created by racinej on 2013-07-03 09:31:35 Original: https://sourceforge.net/p/maxima/bugs/2581/#60c2


Dear Robert,

Apologies and script attached... you will notice that for the kernels epanechnikov and gaussian with supports sqrt(5) and inf the script runs perfectly, but with the truncated gaussian there is no progress...

Thank you ever so much for your contributions to the community!

-- Jeff

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 14:53:21 Created by robert_dodier on 2013-07-26 06:15:09 Original: https://sourceforge.net/p/maxima/bugs/2581/#7318


OK, I see now that kernel_error.max is attached to a comment instead of the original report. I've tried that script and I see the reported behavior (that integrate(kerfourth(Z)^2, Z, -b, b) seems to take forever).

It seems to be a problem in the definite integral code -- if I change the definite integral to (integrate(<stuff>, Z), ev(%%, Z=b) - ev(%%, Z=-b)) then it quickly produces a result. In fact I changed all the integrals in that way and they all produce results that way. So that's a way for you to get to a result, if it still matters.

The integrands in question are messy expressions containing a lot of exponential terms -- my guess is that these are being simplified or expanded in ways that cause them to get larger (more terms) instead of smaller. Not sure if it's a bug in the simplification code or in the definite integral code.

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 14:53:24 Created by robert_dodier on 2013-07-26 06:25:17 Original: https://sourceforge.net/p/maxima/bugs/2581/#8902


rtoy commented 1 week ago

Imported from SourceForge on 2024-07-07 14:53:28 Created by robert_dodier on 2021-05-23 19:08:43 Original: https://sourceforge.net/p/maxima/bugs/2581/#4a32