15
\$\begingroup\$

Objective

Compute \$\pi\$ using nothing but \$i\$ (\$\sqrt{-1}\$).

Guidelines

  • ONLY exponentiation and multiplication may be used (i.e. \$i^i\$ or \$ii\$)
  • No additional symbols may be used (so no addition, subtraction, parentheses)
  • The result must be real and cannot be complex.
  • Expressions should use the principal branch for result computation.
  • If the solution is exceptionally large and repeats certain sequences of \$i\$ combinations, shorthands can be used (i.e. \$iiiiii\$ can become \$i^6\$), but the total number of \$i\$'s used for the purpose of scoring must reflect the fully expanded version without any numbers. Same goes for using variables to express large sequences of \$i\$'s to avoid numbers going off the page.

Scoring

  • Answers will scored using the formula \$10\left(1-\log_{10}\left(\left|x-\pi\right|\right)\right) - \sqrt[3]{N}\$, where \$x\$ is the result of your expression and \$N\$ is the number of \$i\$'s used.
  • Highest score wins.

Sample submission

52 bytes, 3 digits, 35.52 points

\$i^{i^{i}iii}i^{i^{i}iii}i^{i^{i}iii}i^{ii^{ii^{iii^{i}i}}ii}i^{i^{i}i^{ii}i^{i}i^{i}ii}i^{iiii^{ii^{iii}}} \approx 3.1404\$

\$\endgroup\$
10
  • 1
    \$\begingroup\$ Is it obvious what the branch cut behavior should be for complex powers? \$\endgroup\$
    – xnor
    Commented 2 days ago
  • \$\begingroup\$ @xnor It should be the principal branch for all expressions. \$\endgroup\$
    – WarpPrime
    Commented 2 days ago
  • 1
    \$\begingroup\$ Looks like the log in the scoring is a base 10 log. You should clarify as log can sometimes refer to base e. Effectively it's 10*(1+digits of accuracy)-(cuberoot N) \$\endgroup\$ Commented 2 days ago
  • \$\begingroup\$ @LevelRiverSt Fixed. \$\endgroup\$
    – WarpPrime
    Commented 2 days ago
  • 3
    \$\begingroup\$ @Seggan This would be the definitive solution if other operations were allowed, defeating the purpose of the challenge: \$\left(\left(-\frac{i}{i+i}\right)!\right)^{-ii-ii} = \pi \$ Simply uses the fact that \$(-0.5)! = \sqrt{\pi}\$ and the rest is straightforward. \$\endgroup\$
    – WarpPrime
    Commented yesterday

3 Answers 3

7
\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i)*i^(i))*i^(i^(i)*i*i*i)*i^(i*i^(i*i^(i^(i)*i)))*i^(i*i^(i*i^(i*i*i^(i)*i))*i*i)*i^(i^(i)*i*i*i)*i^(i*i^(i*i^(i^(i)*i)))*i^(i*i^(i*i^(i*i*i^(i)*i))*i*i)*i^(i^(i)*i*i*i)*i^(i*i^(i*i^(i^(i)*i)))*i^(i*i^(i*i^(i*i*i^(i)*i))*i*i)*i^(i^(i)*i*i*i)*i^(i*i^(i*i^(i^(i)*i)))*i^(i*i^(i*i^(i*i*i^(i)*i))*i*i)*i^(i^(i)*i*i*i)*i^(i*i^(i*i^(i^(i)*i)))*i^(i*i^(i*i^(i*i*i^(i)*i))*i*i)))

Try it online!
Desmos alternate link

Explanation

Abuses the fact that there are many combinations of \$i\$ that result in numbers that are very close to 1. This allows us to repeatedly multiply these values together for arbitrary precision.
\$i^{iiii^{ii^{iii}}} \approx 1.00082158\\i^{i^{i}iii}i^{ii^{ii^{i^{i}i}}}i^{ii^{ii^{iii^{i}i}}ii} \approx 0.99877162\$

I first started with creating a reasonable approximation for \$\pi\$ that uses "larger" (further from 1) values, then ran \$\log_b\left(\frac{\pi}{N}\right)\$, with \$b\$ being a suitable base like the two mentioned above, and \$N\$ being my rough approximation: $$N = \left(i^{i^{i}iii}\right)^{3}i^{ii^{ii^{iii^{i}i}}ii}i^{i^{i}i^{ii}i^{i}i^{i}ii}i^{iiii^{ii^{iii}}} \approx 3.1404$$I then approximated the fractional part of the logarithm with a suitable value:$$\log_{i^{iiii^{ii^{iii}}}}\left(\frac{\pi}{\left(i^{i^{i}iii}\right)^{3}i^{ii^{ii^{iii^{i}i}}ii}i^{i^{i}i^{ii}i^{i}i^{i}ii}i^{iiii^{ii^{iii}}}}\right) \approx 0.46012811\\\left(i^{i^{i^{i}i}i^{i}i^{ii}ii}\right)^{3}\left(i^{i^{i}i^{ii}i^{i}i^{i}ii}\right)^{5}i^{iiii^{ii^{iii}}} \approx 0.46004025$$Repeated second-order approximation of residual:$$ \log_{i^{iiii^{ii^{iii}}}}\left(\frac{0.46012811}{0.46004025}\right) \approx 0.23253312\\i^{i}i^{i^{i}i^{i^{i}i}i^{i^{i^{i}i}i}i^{ii}}\left(i^{i^{i}i^{ii}i^{i}i^{i}}\right)^{3}\left(i^{i^{i}iii}i^{ii^{ii^{i^{i}i}}}i^{ii^{ii^{iii^{i}i}}ii}\right)^{5} \approx 0.23252542$$ This method seems to work quite well, although I've been having a hard time finding a concise solution that gives more digits. Kudos to anyone who goes beyond 12 digits!

\$\endgroup\$
7
\$\begingroup\$

8 \$i\$'s, 2 digits, 22.44 points

$$ i^{{i^{ii^i}}iii} \approx 3.10558 $$

\$\log_i{\pi} \approx -0.72875i\$, and \$i^{ii^i} \approx 0.72142\$, so all that was needed was a quick \$iii=-i\$ to flip the number around and get a real result.

\$\endgroup\$
0
6
\$\begingroup\$

32 \$i\$'s, 55.7

$$ i^{ii^i}i^{iiii^{ii^{ii^{iii}}}}i^{ii^ii^{ii^{ii^i}}i^{ii^ii^i}} \approx 3.14158 $$

i^(i*i^i)*i^(i*i*i*i^(i*i^(i*i^(i*i*i))))*i^(i*i^i*i^(i*i^(i*i^i))*i^(i*i^i*i^i))

Try it online!


import math
i = 1j; g = [set(), {(i, "i")}]; best = -float('inf')
score = lambda n, N: -float('inf') if abs(n.imag) > 1e-8 else 10 * (1 - math.log(abs(abs(n) - math.pi), 10)) - N ** (1/3)

complexs = {}

for n in range(2, 20):
  print(n)
  s = set()
  g = g[:n] + [s]
  for x in range(1, n):
    for a in g[x]:
      for b in g[n - x]:
        try:
          t, e = (a[0] * b[0], "".join(['',a[1], '*', b[1], '']))
          if t in complexs: continue
          complexs[t] = e
          r = score(t, n)
          if r > best and a[1] < b[1]:
            best = r
            print(t, e, r)
          s.add((t, e))
        except: pass
    for b in g[n - 1]:
      a = (i, "i")
      try:
        t, e = (a[0] ** b[0], "".join(['',a[1], '^(', b[1], ')']))
        if t in complexs: continue
        complexs[t] = e
        r = score(t, n)
        if r > best and a[1] < b[1]:
          best = r
          print(t, e, r)
        s.add((t, e))
      except: pass


values = set()
reals = []

for s in g:
  ns = set()
  reals.append(ns)
  for x in s:
    if abs(x[0].imag) > 1e-8: continue
    if x[0].real in values: continue
    ns.add((x[0].real, x[1]))
    values.add(x[0].real)

for n in range(len(reals), 30):
  print(n)
  s = set()
  reals.append(s)
  for x in range(n):
    for a, ea in reals[x]:
      for b, eb in reals[n - x]:
        if ea < eb:
          try:
            t, e = (a * b, "".join(['',ea, '*', eb, '']))
            if t in values: continue
            values.add(t)
            r = score(t, n)
            if r > best:
              best = r
              print(t, e, r)
            s.add((t, e))
          except: pass

Found by some simple brute force.

\$\endgroup\$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.