绘制隐式函数 [英] Plotting implicit function

查看:150
本文介绍了绘制隐式函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



1 = x ^ 2 + 4 *(y ^ 2)+ x * y

我试图在R中绘制下面的隐式公式: p>

这应该是一个椭圆。我想随机抽样x值,然后根据这些值生成图。

这是一个相关的线程,但那里的解决方案似乎特定于3D案例。这个问题对我的预期更加抵制谷歌搜索,所以也许R语言会调用其他隐式公式。



预先感谢!

解决方案

您可能无法理解的两件事。当用这种技巧绘制隐式函数时,你需要将所有的项移到函数的右边,这样你的隐式函数就变成了:

  0 = -1 + x ^ 2 + 4 *(y ^ 2)+ x * y 

然后使用等值零值是有意义的:

$ p $ x <-seq(-1.1,1.1,length = 1000)$ (x,y)4 * y ^ 2 + x ^ 2 + x * y - (x,y) 1)
contour(x,y,z,levels = 0)

在第一个版本上签名错误。 @mnels'是正确的。




I'm trying to plot the following implicit formula in R:

1 = x^2 + 4*(y^2) + x*y

which should be an ellipse. I'd like to randomly sample the x values and then generate the graph based on those.

Here's a related thread, but the solutions there seem to be specific to the 3D case. This question has been more resistant to Googling that I would have expected, so maybe the R language calls implicit formulas something else.

Thanks in advance!

解决方案

Two things you may not understand. When plotting implicit functions with that technique, you need to move all terms to the RHS of the function so that your implicit function becomes:

0 = -1+ x^2 + 4*(y^2) + x*y

Then using the contour value of zero will make sense:

x<-seq(-1.1,1.1,length=1000)
y<-seq(-1,1,length=1000)
z<-outer(x,y,function(x,y) 4*y^2+x^2+x*y -1 )
contour(x,y,z,levels=0)

I got a sign wrong on the first version. @mnels' was correct.

这篇关于绘制隐式函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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