Maxima在相对简单的积分上崩溃

bar*_*ter 3 wolfram-mathematica maxima

我正在尝试使用Maxima-fy我的Mathematica盒子选项公式(https://github.com/barrycarter/bcapps/blob/master/box-option-value.m),但是Maxima在一个相当简单的集成上崩溃了:

load(distrib); 
pdflp(x, p0, v, p1, p2, t1, t2) := pdf_normal(x,log(p0),sqrt(t1)*v); 
cdfmaxlp(x, p0, v, p1, p2, t1, t2) := 1-erf(x/(v*sqrt(t2-t1)/sqrt(2))); 

upandin(p0, v, p1, p2, t1, t2) :=  
 integrate( 
 float( 
 pdflp(x, p0, v, p1, p2, t1, t2)* 
 cdfmaxlp(log(p1)-x, p0, v, p1, p2, t1, t2) 
 ), 
 x, minf, log(p1)); 
Run Code Online (Sandbox Code Playgroud)

评估upandin w /某些值崩溃:

upandin(1, .15, 1.01, 1.02, 1/365.2425, 2/365.2425); 

rat: replaced -.00995033085316809 by -603/60601 = -.00995033085262619 

rat: replaced 2.718281828459045 by 23225/8544 = 2.718281835205993 

rat: replaced 8116.5 by 16233/2 = 8116.5 

rat: replaced 2.718281828459045 by 23225/8544 = 2.718281835205993 

rat: replaced -8116.5 by -16233/2 = -8116.5 

rat: replaced 1.0 by 1/1 = 1.0 

rat: replaced 1.792882852833688 by 4484/2501 = 1.792882846861255 

rat: replaced 180.1832400641081 by 126849/704 = 180.1832386363636 

rat: replaced 2.718281828459045 by 23225/8544 = 2.718281835205993 

rat: replaced -8116.5 by -16233/2 = -8116.5 

rat: replaced -1.0 by -1/1 = -1.0 

rat: replaced 1.792882852833688 by 4484/2501 = 1.792882846861255 

rat: replaced 180.1832400641081 by 126849/704 = 180.1832386363636 

rat: replaced 2.718281828459045 by 23225/8544 = 2.718281835205993 

rat: replaced -8116.5 by -16233/2 = -8116.5 

rat: replaced 1.0 by 1/1 = 1.0 

rat: replaced -1.0 by -1/1 = -1.0 
Maxima encountered a Lisp error: 

 The value 16090668801 is not of type FIXNUM. 
Run Code Online (Sandbox Code Playgroud)

没有float()in upandin,Maxima只是以原始形式留下积分.

有人可以帮忙吗?我认为将Mathematica转换为Maxima很容易,但现在我不太确定.

Mathematica版本工作正常:

pdflp[x_, p0_, v_, p1_, p2_, t1_, t2_] :=  
 PDF[NormalDistribution[Log[p0],Sqrt[t1]*v]][x] 

cdfmaxlp[x_, p0_, v_, p1_, p2_, t1_, t2_] := 1-Erf[x/(v*Sqrt[t2-t1]/Sqrt[2])]; 

(* NIntegrate below "equivalent" to Maximas float(); no closed form *) 

upandin[p0_, v_, p1_, p2_, t1_, t2_] :=  
 NIntegrate[pdflp[x, p0, v, p1, p2, t1, t2]* 
           cdfmaxlp[Log[p1]-x, p0, v, p1, p2, t1, t2], 
{x, -Infinity, Log[p1]}] 

upandin[1, .15, 1.01, 1.02, 1/365.2425, 2/365.2425] 

0.0998337 
Run Code Online (Sandbox Code Playgroud)

编辑:是否有任何开源Mathematica类程序将数字近似此函数?我真的想将开源代码发布到开源平台.

Dan*_*lau 6

(我可能没有业务回答这个,但......)

只是一个猜测,但似乎整合想要再次使输入准确,并且可能正在做一些涉及理性算术的困难的bignum计算.它使你的近似e(欧拉数)合理化,这意味着它的行为可能与积分(0与精确输入)不同.

可能想检查一下

http://eagle.cs.kent.edu/MAXIMA/maxima_21.html

要么

http://www.delorie.com/gnu/docs/maxima/maxima_62.html

用于专用数字代码,例如来自Quadpack.

(仍然想知道为什么我甚至试图回答这个问题.在Stack Overflow上必须有Maxima的专业知识.)

Daniel Lichtblau Wolfram Research

  • @Timo我与Maxima没有争吵,无论是程序还是实现者.此外,我认为能够领导这项工作的人罗伯特·多迪尔有时会询问或回答在MathGroup上发布的问题.永远友好和尊重,所以我有动力不要惹恼他.只希望他回答你的问题.所有这一切,你是对的,我签署我公司的名字可能是愚蠢的.应该补充说我不是代言人...... (3认同)