MATLAB: Plotting a nonlinear curve in matlab

plotting 3dsymbolic

I would like MATLAB to draw the plot for the curve described by the following equation, where for instance (a,b,d) = (-10,-10,-10) is a point in 3D cartesian space and c = 2. x and y are the variables. Are there any thoughts?
x^2(1+1/c.^2) -2ax + y^2(1+1/c.^2) – 2by+(a^2+b^2+d^2-r^2)-2d/c(sqrt(x^2+y^2)) = 0
ps. the equation is actually the intersection of a sphere and cone and can be seen in http://mathworld.wolfram.com/Cone-SphereIntersection.html

Best Answer

If you have the Symbolic Toolbox, you can use solve(). But the solution involves a quartic so the solution will probably be in terms of RootOf(). You need two of the roots. Be careful, two of the roots might be spurious (and might be real-valued) so back-substitute and test before you accept a root at any given location.
For any given x you can use roots() to find the 4 y numerically:
roots([c^4+2*c^2+1, (-4*c^4-4*c^2)*b, (2*c^4+2*c^2)*a^2+(-4*c^4*x-4*c^2*x)*a+(6*c^4+2*c^2)*b^2+(2*d^2-2*r^2+2*x^2)*c^4+(-2*d^2-2*r^2+4*x^2)*c^2+2*x^2, -4*a^2*b*c^4+8*a*b*c^4*x-4*b^3*c^4+((-4*d^2+4*r^2-4*x^2)*c^4-4*c^2*x^2)*b, a^4*c^4-4*a^3*c^4*x+(2*b^2*c^4+(2*d^2-2*r^2+6*x^2)*c^4+2*c^2*x^2)*a^2+(-4*x*c^4*b^2+(-4*d^2*x+4*r^2*x-4*x^3)*c^4-4*x^3*c^2)*a+b^4*c^4+((2*d^2-2*r^2+2*x^2)*c^4+2*c^2*x^2)*b^2+(d^4+(-2*r^2+2*x^2)*d^2+r^4-2*x^2*r^2+x^4)*c^4+(-2*d^2*x^2-2*r^2*x^2+2*x^4)*c^2+x^4])
Be sure to cross-check the values.
For the a, b, c, d that you provide, the smallest positive r for which there are real-valued x and y that are solutions is r = 4*sqrt(5)+2*sqrt(5)*sqrt(2)
Related Question