在数学5调试工作计划用Mathematica 7 [英] Debugging a working program on Mathematica 5 with Mathematica 7

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

问题描述

我目前正在读的Mathematica使用说明书中编程和我试图找出这本书的第一个节目之一。基本上,当我运行下面的程序:

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 ^ \无穷大的错误,或者如果我降低 PlotPoints 选项,比如,60,溢出错误。我有一个工作的输出,虽然,但它不是什么它应该是。色调似乎被扩散掉左角而应当漫射原点的(如可看到的原始<一href="http://books.google.com/books?id=iZTxaxT_YeMC&lpg=PP1&dq=guidebook%20programming&pg=PA166#v=onepage&q&f=false"相对=nofollow>输出)

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(特洛特,数学指南为编程)原计划:

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 用这样的方式(先 PLO​​T3D 参数)不工作,所以我试图简单地适应新的使用它的方式。

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.

嗯,谢谢,我猜!

推荐答案

我终于找到了两种可供选择的方式来解决我的问题。第一种是简单地使用&LT;&LT; Version5`Graphics` 命令使用 PLO​​T3D 函数用数学V5的工作方式。从书中所采取的code工作就像它曾经。

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.

不过,如果希望以正确显示色调(即,不扩散掉左上角)的最新版本中,重缩放函数必须使用,就像这样:

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.

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

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