在 Mathematica 中求隐函数的根
在 Mathematica 中查找隐式函数的根
我有一个隐式函数,例如:
f(x,y) = x^3 + x*y + y^2 - 36
我想找到根,即方程的解 f(x,y) = 0
绘制解很简单:
ContourPlot[x^3 + x*y + y^2 - 36 == 0, {x , -2 Pi, 2 Pi}, {y, -3 Pi, 3 Pi}]
但是我希望获得图中的数据,而不仅仅是视觉图中的数据。 那么如何找到绘图的数据呢?
Find root of implicit function in Mathematica
I have an implicit function, for example:
f(x,y) = x^3 + x*y + y^2 - 36
I want to find the root, ie solutions to the equation f(x,y) = 0
Drawing the solution is easy:
ContourPlot[x^3 + x*y + y^2 - 36 == 0, {x, -2 Pi, 2 Pi}, {y, -3 Pi, 3 Pi}]
however I would like to have the data that is in the plot and not only the visual plot.
So how do I find the data of the plot?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不确定我是否正确解释了您的第二个问题,但假设您需要生成的 ContourPlot 中的 (x,y) 点列表,执行此操作的一种方法可能如下:
要获取点列表
“采取看看“ListPlot
给出
编辑
Nasser 正确指出了这个问题已经之前提到过。 这里是一个指向本质上相同问题的链接,Szabolcs 的这个答案是相关的。
关于上面给出的答案, 这种方法可能更direct:
最后,我应该承认“LunchTime Playground。Mathematica 的乐趣:如何从图中提取点”,请参阅这里,这两个都给出了 上面建议的方法(我现在经常使用)。
编辑 2
此方法是上述方法 1 的改进,因为点是作为 {x,y} 值列表(列表列表)获取的,没有任何无关的 { }。
Paul Abbott 发表在 Mathematica Journal 第 7 卷第 2 期,第 108-112 页,1998 年的文章,
在区间中求根,提供了很多有用的信息,并且可以使用 这里
他指出以下内容也有效
并且(!)
我在评论中引用了FreshApple 提出的问题,可能会发现以下方法的(轻微变体):
以下计算结果为
True
编辑 3
只是或有趣...
给出
I'm not sure if I am interpreting your second question properly, but assuming you require a list of (x,y) points from the generated ContourPlot, one way of doing this might be the following:
To obtain a list of points
'Take a look' with ListPlot
giving
Edit
Nasser has correctly pointed out that this question has been addressed before. Here is one link to essentially the same question and this answer by Szabolcs is relevant.
As regards the answer given above, this method is probably more direct:
Finally, I should acknowledge " LunchTime Playground. Fun with Mathematica: How to extract points from a plot", see here, which gives both methods suggested above (and which I now use routinely).
Edit 2
This method is an improvement on method 1 above, as the points are obtained as a list of {x,y} values (list-of-lists) without any extraneous { }.
An article by Paul Abbott in the Mathematica Journal Vol 7, No 2, pp 108-112, 1998,
Finding Roots in an Interval, gives a lot of useful information and is available here
He points out the the following also work
and(!)
I have made reference in the comments to the question by FreshApple where a (slight variant) of the following method may be found:
The following evaluates to
True
Edit 3
Just or fun ...
gives
我鼓励您探索有关方程求解的文档,特别是求解 和 NSolve 函数。
编辑
复制并粘贴您需要的部分。
或者,在我看来,这是解决您实际问题的更好方法。
您可能需要一些选项才能获得正确的解决方案。
I would encourage you to explore the documentation on equation solving and particularly the Solve and NSolve functions.
EDIT
Copy and paste the bit you need.
Alternatively, and in my view a better solution to your actual problem.
You might need some options to get the right solution.
Verbeia 答案的 0.02 美元贡献:
请记住检查 x(y) 和 y(x) 解决方案,因为其中一个可能比另一个更干净。
在您的示例中:
A $.02 contribution on Verbeia's answer:
Remember to check both x(y) and y(x) solutions as one of them could be cleaner than the other.
In your example: