如何在Mathematica中获得准确的绘图曲线? [英] How to obtain accurate plot curves in Mathematica?
问题描述
在Mathematica中运行以下代码:
Run the following code In Mathematica:
r=6197/3122;
p[k_,w_]:=Sqrt[w^2/r^2-k^2];q[k_,w_]:=Sqrt[w^2-k^2];
a[k_,w_,p_,q_]:=(k^2-q^2)^2 Sin[p]Cos[q]+4k^2 p q Cos[p]Sin[q]
a[k_,w_]:=a[k,w,p[k,w],q[k,w]];
ContourPlot[a[k,w]==0,{w,0,6},{k,0,14}]
这给了我非常不准确的曲线:
This gives me very inaccurate curves:
我尝试将ContourPlot
的PlotPoints
和WorkingPrecision
选项分别设置为30和20,但无济于事.您还将注意到,唯一的数字参数r
是精确的有理数.我不知道还能尝试什么.谢谢.
I have tried setting the PlotPoints
and WorkingPrecision
options of ContourPlot
to 30 and 20 respectively, to no avail. You will also notice that the only numerical parameter, r
, is an exact rational number. I don't know what else to try. Thanks.
我期望得到的曲线是下图上的三个黑色曲线(分别标记为A1,A2和A3)
The curves I expect to get are the three black ones (marked A1, A2, and A3) on the following picture
推荐答案
您确定a
的图片和/或定义吗?根据a
的定义,可以得出k==w
上的a[k,w]==0
,但该曲线未出现在图片中.
Are you sure about the picture and/or the definition for a
? From the definition of a
it follows that a[k,w]==0
on k==w
but that curve doesn't appear in your picture.
无论如何,假设a
的定义是正确的,绘制轮廓的问题是在域w^2/r^2-k^2<0
中,p[k,w]
和Sin[p[k,w]]
都变成纯虚构的,这意味着a[k,w]
变成纯虚构的虚构的.由于ContourPlot
不喜欢复数值函数,因此仅绘制了域w^2/r^2>=k^2
中的轮廓部分.
Anyway, assuming that the definition of a
is right, the problem with plotting the contours is that in the domain w^2/r^2-k^2<0
, both p[k,w]
and Sin[p[k,w]]
become purely imaginary which means that a[k,w]
becomes purely imaginary as well. Since ContourPlot
doesn't like complex valued functions only the parts of the contours in the domain w^2/r^2>=k^2
are plotted.
并非Sin[p[k,w]]/p[k,w]
对于k
和w
的所有值都是真实的(并且在限制p[k,w]->0
中表现良好).因此,要解决a
变得复杂的问题,您可以绘制等高线a[k,w]/p[k,w]==0
:
Not that Sin[p[k,w]]/p[k,w]
is real for all values of k
and w
(and it's nicely behaved in the limit p[k,w]->0
). Therefore, to get around the problem of a
becoming complex you could plot the contours a[k,w]/p[k,w]==0
instead:
ContourPlot[a[k, w]/p[k, w] == 0, {w, 0, 6}, {k, 0, 14}]
结果
的轮廓图
这篇关于如何在Mathematica中获得准确的绘图曲线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!