用Mathematica调试Mathematica 5的工作程序7 [英] Debugging a working program on Mathematica 5 with Mathematica 7

查看:202
本文介绍了用Mathematica调试Mathematica 5的工作程序7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读数学教程指导手册,我正在努力研究本书的第一个程序之一。基本上,当我运行以下程序时:

I'm currently reading the Mathematica Guidebooks for Programming and I was trying to work out one of the very first program of the book. Basically, when I run the following program:

Plot3D[{Re[Exp[1/(x + I y)]]}, {x, -0.02, 0.022}, {y, -0.04, 0.042}, 
 PlotRange -> {-1, 8}, PlotPoints -> 120, Mesh -> False, 
 ColorFunction -> Function[{x1, x2, x3}, Hue[Arg[Exp[1/(x1 + I x2)]]]]]

我得到1/0错误和e ^ \infinity错误,或者如果我将 PlotPoints 选项降低到60,溢出错误。我有一个工作的输出,但它不是它应该是。色调似乎在左角扩散,而它应该是原始的扩散(从原来的输出

either I get a 1/0 error and e^\infinity error or, if I lower the PlotPoints options to, say, 60, an overflow error. I have a working output though, but it's not what it's supposed to be. The hue seems to be diffusing off the left corner whereas it should be diffusing of the origin (as can be seen on the original output)

是原来的程序,显然运行在Mathematica 5(Trott,Mathematica Guidebook编程):

Here is the original program which apparently runs on Mathematica 5 (Trott, Mathematica Guidebook for Programming):

Off[Plot3D::gval];

Plot3D[{Re[Exp[1/(x + I y)]], Hue[Arg[Exp[1/(x + I y)]]]},
       {x, -0.02, 0.022}, {y, -0.04, 0.042},
       PlotRange -> {-1, 8}, PlotPoints -> 120, Mesh -> False]

Off[Plot3D::gval];

但是,以这种方式使用 ColorFunction Plot3D 参数)不起作用,所以我试图简单地适应其使用它的新方式。

However, ColorFunction used this way (first Plot3D argument) doesn't work and so I tried to simply adapt to its new way of using it.

嗯,谢谢我猜!

推荐答案

替代方法来解决我的问题。第一个是简单地使用<< Version5`Graphics` 命令使用 Plot3D 的功能与Mathematica V5配合使用。从书中取得的代码就像以前一样工作。

I finally found two alternative ways to solve my problem. The first one is to simply use the << Version5`Graphics` command to use Plot3Dfunction the way it worked with Mathematica V5. The code taken from the book works just like it used to.

但是,如果希望正确显示色调(也就是说,没有扩散离开左角)使用最新版本,必须使用 Rescale 函数,就像这样:

However, if one wishes to display correctly the hue (that is, without diffusion off the left-hand corner) with the latest version, the Rescale function must be used, just like this:

Plot3D[Evaluate[Re[f[x, y]]], {x, -.02, .022}, {y, -0.04, 0.042},
PlotRange -> {-1, 2}, PlotPoints -> 120, Mesh -> False,
ColorFunction -> Function[{x, y, z}, Hue@Rescale[Arg[f[x, y]], {-π, π}]],
ColorFunctionScaling -> False,
ClippingStyle -> None]

我假设数学中的参数函数不会自动映射到[-Pi,Pi]范围,因此必须重新缩放到此域。结果是相当好看,虽然与原始情节有一些微小的差异。

I suppose the argument function in Mathematica does not map automatically to the [-Pi,Pi) range and so it must be rescaled to this domain. The result is quite good-looking, although there are some minor differences with the original plot.

这篇关于用Mathematica调试Mathematica 5的工作程序7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆