[R] plotting a bivariate quadratic curve

2011-11-12 Thread Yackov Lubarsky
Hi,

I would like to plot a x,y curve described by the equation :

Ax^2 + Bx + Cy^2 + Dy + E == 0

(A,B,C,D,E are constants)

This sounds like quite the common task but haven't been able to figure
out how to do this. Could you please help ? I am new to R so probably
missing something basic.

Thanks

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] plotting a bivariate quadratic curve

2011-11-12 Thread Duncan Murdoch

On 11-11-12 5:50 AM, Yackov Lubarsky wrote:

Hi,

I would like to plot a x,y curve described by the equation :

Ax^2 + Bx + Cy^2 + Dy + E == 0

(A,B,C,D,E are constants)

This sounds like quite the common task but haven't been able to figure
out how to do this. Could you please help ? I am new to R so probably
missing something basic.



R is not very good at that, but one way to do it is to draw a contour 
plot of the bivariate function, with a single contour at level 0.  For 
example,


A - B - C - D - 1
E - -1
x - y - seq(-3, 3, len=100)
z - outer(x, y, function(x, y) A*x^2 + B*x + C*y^2 + D*y + E)
contour(x, y, z, levels=0, drawLabels=FALSE)

Another would be to solve for y as a function of x, and draw both 
branches.


Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] plotting a bivariate quadratic curve

2011-11-12 Thread Barry Rowlingson
On Sat, Nov 12, 2011 at 10:50 AM, Yackov Lubarsky yluba...@gmail.com wrote:
 Hi,

 I would like to plot a x,y curve described by the equation :

 Ax^2 + Bx + Cy^2 + Dy + E == 0

 (A,B,C,D,E are constants)

 This sounds like quite the common task but haven't been able to figure
 out how to do this. Could you please help ? I am new to R so probably
 missing something basic.

 What you may be missing was all figured out by the ancient Greeks and
they didnt even have R in their alphabet!

 You've got this:

http://mathworld.wolfram.com/QuadraticCurve.html

 but with b=0. I'm not sure how many of the awkward cases (line pairs,
imaginary everything) disappear with b=0, but you can compute the
Delta, I, J, and K determinants to figure it out. Then set theta to
seq(0,2*pi,len=100) and compute r from the polar equation form. Plot
r*cos(theta), r*sin(theta)...

Confession: its been a long time since I did maths like this (forgive
me father, for I have not sin'd).

Barry

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.