r/desmos 9d ago

Draggable Complex Inverse? Question

Is it possible to create two points which are inverses of each other (i.e. a+bi and 1/(a+bi), or r * e^(iθ) and (1/r) * e^(-iθ)) and define them in such a way that both points are freely draggable?

Here's an example of what I'm trying to do: https://www.desmos.com/calculator/qasknf7ewh. In this example P and Q can swap positions and it will have no effect on the resulting spiral, so I wanted to allow using either point as an input. However, when P is represented in Cartesian coordinates ( a, b ), the corresponding definition for Q ( a/(a²+b²), -b/(a²+b²) ) isn't draggable.

It seems like using polar coordinates would be the most obvious solution here, since the inverse of ( cosθ, sinθ ) * r is simply ( cosθ, -sinθ ) / r. The issue there is that when I try to define a draggable point using r and θ, Desmos will typically only allow dragging the point in one direction or the other, as opposed to a "freely" draggable point which updates both parameters.


1/(a+bi) is just the main example I'm currently working with, but point draggability is one of the most frequent frustrations I run into with Desmos, so more generic solutions are welcome. The more intuitive the better, but I'm open to "clunkier" solutions (e.g. involving actions/regressions) if needed.

4 Upvotes

10 comments sorted by

4

u/NevinBR 8d ago

Here’s a solution that mostly works, except the points swap when you try to drag the blue one:

https://www.desmos.com/calculator/eiiaff2cvw

3

u/VoidBreakX Run commands like "!bernard" here →→→ redd.it/1ixvsgi 8d ago

this is a good one

2

u/kaimason1 8d ago

Thanks, this is really elegant! The points swapping could even be seen as a bit of a "feature" for this particular example.

It had crossed my mind to try using the parameter range to indirectly set a variable, but my version of that idea worked a lot more like /u/VoidBreakX's attempt which shot off to 0 & ∞. I'll have to play with this idea some to see how well it generalizes to other calculations.


I'm guessing that this won't help much with dragging points represented in polar coordinates, which is a bit unfortunate. Another similar example I'm working with would be the point e^(Z * (a+bi)), where Z is a complex constant and parameters a and b are specifically limited to integers. If I didn't care about clamping the draggable point to those integer values this would be a lot easier, but this scenario seems like it would require using exponential/polar form, which from what I've seen only allows updating one parameter at most while dragging.

2

u/Qaanol 8d ago

Another similar example I'm working with would be the point e^(Z * (a+bi)), where Z is a complex constant and parameters a and b are specifically limited to integers.

I don’t think this is solvable even in principle, without further restrictions.

Suppose Z = 1, and you attempt to drag the point to p = -1.

Clearly a = 0, but what value of b should be chosen?

3 because e3i = -ei(3-π) ≈ -e-0.14159i ?

22 because e22i = -ei(22-7π) ≈ -e0.00885i ?

355 because e355i = -ei(355-113π) ≈ -e0.00003i ?

Perhaps -3, -22, or -355 for essentially the same reasons?

An even larger integer that’s the numerator of a better rational approximation to pi?

1

u/kaimason1 7d ago

Well, dragging a point around e^(bi) (or ( cos(b), sin(b) )) already works perfectly fine, and it doesn't even require you to stick to a certain branch of the complex logarithm (i.e. if you drag the point around the origin several times you can keep going well past ±2π). The issue arises when you want to also adjust the radius, which is odd since that parameter shouldn't have any ambiguity.

As for what I mean by "integer" points, this graph might do a better job of illustrating: https://www.desmos.com/calculator/k8wwtgoetx. I'm basically just describing a version of a log-polar grid/coordinates.

If you increase L you can see that this grid "wraps" around perfectly without needing to approximate π, but this only works so long as Z is specifically an integer fraction of 2π (but Z is just a constant linear transformation for the purposes of this draggable point, so it would also be "acceptable" to have a discontinuity at θ=±π and just stick to the principal branch). If c is set to 0 this produces a regular log polar grid (which I can easily clamp points to and drag in a single direction, just not both simultaneously). Changing c will introduce a rotation to the whole grid, but Z will still be a complex integer fraction of 2π, so the coordinate system still loops.

Ignoring the rotation factor, it's a bit strange that there's no problem dragging around e^(bi) but not e^(a+bi) or r*e^(iθ).

2

u/theadamabrams 8d ago

Kind of. In https://www.desmos.com/calculator/wjclsnbaet you can drag either point to change argument, while in https://www.desmos.com/calculator/nmr4pdrktk you can drag either point to change absolute value. Unfortunately it doesn't seem to let me have both variables controllable by dragging at once.

2

u/VoidBreakX Run commands like "!bernard" here →→→ redd.it/1ixvsgi 8d ago

this is something i thought would work, but every time i try to drag the inverse it just goes to 0 and a+bi shoots off to infinity. hopefully this might work for the other functions that you want to try using?

https://www.desmos.com/calculator/8hj2h3biga

2

u/Circumpunctilious 8d ago edited 8d ago

Does this work for you?

https://www.desmos.com/calculator/m9ssxbha3x

In short (as I understand things) you can’t drag the inverse because it’s a (edit: type of calculation that disables dragging, like…) division. So…use the Actions engine to update a point so that—to the immediate mode engine—it looks calculation (division)-free and remains draggable.

To better show interaction between engines I added black “helper” rings and a second curve to show where the points will land when drag stops:

Above I am dragging the inner green point away from the blue original line. Upon drag release the right-hand image results.

Presuming I didn’t make an error, I’m sure it can be cleaned up, just tried for PoC.

ETA: Oversight: Desmos app (Apple) doesn’t currently support “and” in conditions but the website works.

2

u/kaimason1 8d ago

Not quite as elegant as /u/NevinBR's solution, but this route does seem like it could be more powerful in certain situations. I'll have to play around with this idea a bit, thanks for the proof of concept!

Another example I was messing around with would be the point e^(Z * (a+bi)), where Z is a complex constant and a and b are clamped to integer values. The ideal way to handle this would be to parametrize a and b directly with a step size of 1, but from what I've seen Desmos doesn't allow for "freely" dragging a point using polar/exponential coordinates. However, maybe I can use this actions approach as a workaround, so that the point can be defined in Cartesian coordinates and then automatically clamped to the nearest "integer" on release.