Processing math: 100%
Ask Your Question
1

Select component of an `implicit_plot` curve

asked 3 years ago

c.p. gravatar image

updated 3 years ago

slelievre gravatar image

I'd like to plot one of the connected components of a plot. This is like

sage: x, y = SR.var('x, y', domain='real')
sage: F0 = x^2 - y^2 - 1
sage: B0 = 3.5
sage: G0 = implicit_plot(F0, (x, -B0, B0), (y, -B0, B0), gridlines=True)
sage: G0.show(figsize=5)
Launched png viewer for Graphics object consisting of 1 graphics primitive

Implicit plot of hyperbola

which one could solve and manually select the connected components. In my case, I deal with an equation that is inconvenient to plot directly from the solution. Is there a command or a feature to `implicit plot' which has the effect of "taking this connected component of the solution" (e.g. in the example, passing through (1,0)?) Also I wouldn't like to restrict to either positive or negative x (my curve is somehow more complicated and restricting to regions doesn't work).

I excluded the curve to make this a minimal example, but it's probably helpful to know that I don't know how to easily parametrize it. Is something like

   sage: F = -1/720*x^6*y*cos(sqrt(2)*pi) + 1/144*x^4*y^3*cos(sqrt(2)*pi) - 1/240*x^2*y^5*cos(sqrt(2)*pi)+ 1/5040*y^7*cos(sqrt(2)*pi) - 1/5040*x^7*sin(sqrt(2)*pi) + 1/240*x^5*y^2*sin(sqrt(2)*pi) -1/144*x^3*y^4*sin(sqrt(2)*pi) + 1/720*x*y^6*sin(sqrt(2)*pi) +1/114688*720^(2/5)*abs(-2*sqrt(5) + 10)^(7/2)*cos(2/5*sqrt(2)*pi)*cos(7/2*arctan2(0, -2*sqrt(5) + 10))   + 1/114688*720^(2/5)*abs(-2*sqrt(5) + 10)^(7/2)*sin(2/5*sqrt(2)*pi)*sin(7/2*arctan2(0, -2*sqrt(5) + 10))- 3/8192*720^(2/5)*sqrt(5)*abs(-2*sqrt(5) + 10)^(5/2)*cos(2/5*sqrt(2)*pi)*cos(5/2*arctan2(0,  -2*sqrt(5) + 10)) - 3/8192*720^(2/5)*sqrt(5)*abs(-2*sqrt(5) + 10)^(5/2)*sin(2/5*sqrt(2)*pi)   *sin(5/2*arctan2(0, -2*sqrt(5) + 10)) - 9/8192*720^(2/5)*abs(-2*sqrt(5) + 10)^(5/2)   *cos(2/5*sqrt(2)*pi)*cos(5/2*arctan2(0, -2*sqrt(5) + 10)) - 9/8192*720^(2/5)*abs(-2*sqrt(5)  + 10)^(5/2)*sin(2/5*sqrt(2)*pi)*sin(5/2*arctan2(0, -2*sqrt(5) + 10))+ 15/2048*720^(2/5)*sqrt(5)*abs(-2*sqrt(5) + 10)^(3/2)*cos(2/5*sqrt(2)*pi)*cos(3/2*arctan2(0,   -2*sqrt(5) + 10)) + 15/2048*720^(2/5)*sqrt(5)*abs(-2*sqrt(5)  + 10)^(3/2)*sin(2/5*sqrt(2)*pi)*sin(3/2*arctan2(0, -2*sqrt(5) + 10))  + 35/2048*720^(2/5)*abs(-2*sqrt(5) + 10)^(3/2)*cos(2/5*sqrt(2)*pi)*cos(3/2*arctan2(0, -2*sqrt(5) + 10)) + 35/2048*720^(2/5)*abs(-2*sqrt(5) + 10)^(3/2)*sin(2/5*sqrt(2)*pi)*sin(3/2*arctan2(0, -2*sqrt(5)  + 10)) - 5/64*720^(2/5)*sqrt(5)*sqrt(abs(-2*sqrt(5)  + 10))*cos(2/5*sqrt(2)*pi)*cos(1/2*arctan2(0, -2*sqrt(5) + 10))  - 5/64*720^(2/5)*sqrt(5)*sqrt(abs(-2*sqrt(5) + 10))*sin(2/5*sqrt(2)*pi)*sin(1/2*arctan2(0, -2*sqrt(5) + 10)) - 25/256*720^(2/5)*sqrt(abs(-2*sqrt(5) + 10))*cos(2/5*sqrt(2)*pi)*cos(1/2*arctan2(0, -2*sqrt(5)  + 10)) - 25/256*720^(2/5)*sqrt(abs(-2*sqrt(5) + 10))*sin(2/5*sqrt(2)*pi)*sin(1/2*arctan2(0, -2*sqrt(5)  + 10)) + x*y + 5/56*720^(2/5)*sqrt(5)*sin(2/5*sqrt(2)*pi) - 5/56*720^(2/5)*sin(2/5*sqrt(2)*pi)
sage: B = 7.5
sage: G = implicit_plot(F, (x, -B, B), (y, -B, B), gridlines=True)
sage: G.show(figsize=5)

Implicit plot of degree 7 function of x and y

This has many connected components (on the finite plane), the square root of two is just to match another conventions, you could ignore this and any number-theoretical stuff, just think about the sort of not low degree polynomial in two variables. Cannot upload the plot yet.

Preview: (hide)

Comments

To make it more answerable: what is your more complicated equation?

rburing gravatar imagerburing ( 3 years ago )

@rburing Hi, thanks, I added it.

c.p. gravatar imagec.p. ( 3 years ago )

After staring at the complicated equation for some time, here is a more concise rephrasing of it.

Putting z=x+iy, there are some real constants A, B, C such that the equation amounts to: Re(eiAz77!+eiBz22!)=C

The degree 7 explains the 7 components of the curve.

The approach in @FrédéricC's answer to Ask Sage question 54765 might give inspiration here.

slelievre gravatar imageslelievre ( 3 years ago )

@slelievre Hi, thanks for the insight and suggestions (and the edit!)

c.p. gravatar imagec.p. ( 3 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 3 years ago

slelievre gravatar image

Ideally, find a parametric description. Then use a parametric plot with the appropriate range for the parameter.

sage: x, y = SR.va('x, y')
sage: a = acosh(2.)
sage: opt = dict(xmin=-2, xmax=2, ymin=-2, ymax=2, axes=False, frame=True)
sage: Gi = implicit_plot(x^2 - y^2 - 1, (x, -2, 2), (y, -2, 2),
....:                    linewidth=5, color='steelblue', **opt)
sage: Gp = parametric_plot((cosh, sinh), (-a, a),
....:                      thickness=2, color='firebrick', **opt)
sage: Gip = Gi + Gp
sage: P = point2d([(-2, -2), (2, 2)], color='white', alpha=0)
sage: G = graphics_array([P + Gi, P + Gp, P + Gip], ncols=1)
sage: G.show(figsize=12)
Preview: (hide)
link

Comments

1

thank you for answering. I just don't find a parametrization of my curve (now added to the question's body).

c.p. gravatar imagec.p. ( 3 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 3 years ago

Seen: 375 times

Last updated: Feb 16 '22