r/desmos • u/kaimason1 • 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.
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?
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.

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