【发布时间】:2011-02-08 03:02:38
【问题描述】:
我正在尝试最大化我的 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));
使用某些值评估 upandin 崩溃:
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.
没有 upandin 中的 float(),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
编辑:是否有任何类似 Mathematica 的开源程序可以 数值近似这个函数?我真的很想公开 源代码到开源平台。
【问题讨论】:
-
在我的机器上,当我评估它说“太大而无法表示为 DOUBLE-FLOAT:”,然后给出一个 9774 位整数。我实际上并不熟悉 Maxima,但也许您可以在早期将所有内容都转换为浮点数?
-
奇怪的是“rat:”消息暗示浮点数正在被转换回有理数,这可能会使事情变得更糟。而且千里马没有任意精度数?!
-
也许你可以把问题发到ask.sagemath.org,因为sage 中的很多微积分仍然使用Maxima。
标签: wolfram-mathematica maxima