Hacker News new | ask | show | jobs
by westurner 987 days ago
ENH: desmos [3d]: Support complex exponents; with i and/or a complex() function

Test equations for geogebra:

    equation -- what I think it looks like
    xi^2 -- Integer coordinate grid
    e^xπi -- Unit circle with another little circle also about the origin (0,0)
    e^(πi^x) -- crash / not responding: a(x)=e^(πi^(x))
                though it seems to work with x in Z+
    e**(x*pi*I)

    e^(x π i^π) -- somewhat scale-invariant interposed spirals around a single point attractor. (Zoom in/out)
Only SageMath preprocesses Python to replace XOR (^) with exp() or **, so:

  f(x) = x^2
  g(x) = x**2  # Python
  h(x) = exp(x, 2)
  x**2         # SymPy Gamma, Beta

  x**math.pi   # Python: 3.141592653589793
  x**pi        # SymPy: π

  x**1j        # Python
  x**I         # SymPy

  x**(1+I)    # BUG/ENH: Plot complex expressions with SymPy

  import sympy as sy
  display(sy.E, sy.I, sy.pi)
  from sympy import E, pi, I
  x,y = sy.symbols('x,y', real=True); display(x,y)
  eq01 = sy.Eq(y, E**(x*pi*I)); display(eq01)
  eq02 = sy.Rel(y, E**(x*pi*I), '=='); display(eq02)
  func01 = sy.Function('f')(E**(x*pi*I)); display(func01)
  func02 = sy.Function('f')(eq02.rhs); display(func02)
  assert eq01 == eq01
  assert func01 == func02

  import unittest
  test = unittest.TestCase()
  test.assertEqual(eq01, eq02)
  test.assertEqual(func01, func02)
Sympy Gamma: https://gamma.sympy.org/

Sympy Beta is SymPy Gamma compiled to WASM: https://github.com/eagleoflqj/sympy_beta

What methods for visualizing complex coordinate(s) are helpful? You can map the complex coordinate into e.g. the z-axis; or is complex phase - as is necessary to model [qubit] wave functions psi - just another high-dimensional dimension to also visualize?