Bouland and Aaronson, Equation (26)

Percentage Accurate: 99.9% → 100.0%
Time: 6.5s
Alternatives: 10
Speedup: TODO×

Specification

?
\[\begin{array}{l} t_0 := b \cdot b\\ \left({\left(a \cdot a + t_0\right)}^{2} + 4 \cdot t_0\right) - 1 \end{array} \]

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Alternative 1?

\[{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right) \]
Derivation
  1. Initial program 99.9%

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  2. Step-by-step derivation
    1. associate--l+99.9%

      \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(b \cdot b\right) - 1\right)} \]
    2. unpow299.9%

      \[\leadsto \color{blue}{\left(a \cdot a + b \cdot b\right) \cdot \left(a \cdot a + b \cdot b\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
    3. unpow199.9%

      \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{1}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
    4. sqr-pow99.9%

      \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
    5. associate-*r*99.9%

      \[\leadsto \color{blue}{\left(\left(a \cdot a + b \cdot b\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)} \]
  4. Final simplification100.0%

    \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right) \]

Alternative 2?

\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+20}:\\ \;\;\;\;{a}^{4} + -1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4} + \left(b \cdot b\right) \cdot \left(4 + \left(a \cdot a\right) \cdot 2\right)\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 2e20

    1. Initial program 99.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+99.8%

        \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(b \cdot b\right) - 1\right)} \]
      2. unpow299.8%

        \[\leadsto \color{blue}{\left(a \cdot a + b \cdot b\right) \cdot \left(a \cdot a + b \cdot b\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      3. unpow199.8%

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{1}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      4. sqr-pow99.8%

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      5. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(\left(a \cdot a + b \cdot b\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)} \]
    4. Taylor expanded in b around 0 97.9%

      \[\leadsto \color{blue}{{a}^{4} - 1} \]

    if 2e20 < (*.f64 b b)

    1. Initial program 99.9%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+99.9%

        \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(b \cdot b\right) - 1\right)} \]
      2. unpow299.9%

        \[\leadsto \color{blue}{\left(a \cdot a + b \cdot b\right) \cdot \left(a \cdot a + b \cdot b\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      3. unpow199.9%

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{1}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      4. sqr-pow99.9%

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      5. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(\left(a \cdot a + b \cdot b\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)} \]
    4. Taylor expanded in b around inf 99.0%

      \[\leadsto \color{blue}{{b}^{4} + \left(4 + 2 \cdot {a}^{2}\right) \cdot {b}^{2}} \]
    5. Step-by-step derivation
      1. unpow299.0%

        \[\leadsto {b}^{4} + \left(4 + 2 \cdot \color{blue}{\left(a \cdot a\right)}\right) \cdot {b}^{2} \]
      2. unpow299.0%

        \[\leadsto {b}^{4} + \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \color{blue}{\left(b \cdot b\right)} \]
    6. Simplified99.0%

      \[\leadsto \color{blue}{{b}^{4} + \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \left(b \cdot b\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+20}:\\ \;\;\;\;{a}^{4} + -1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4} + \left(b \cdot b\right) \cdot \left(4 + \left(a \cdot a\right) \cdot 2\right)\\ \end{array} \]

Alternative 3?

\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) + -1 \]
Derivation
  1. Initial program 99.9%

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  2. Final simplification99.9%

    \[\leadsto \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) + -1 \]

Alternative 4?

\[\begin{array}{l} \mathbf{if}\;a \leq -1.12 \cdot 10^{+30}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq 2050000000:\\ \;\;\;\;b \cdot \left(b \cdot 4\right) + \left({b}^{4} + -1\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if a < -1.12e30 or 2.05e9 < a

    1. Initial program 99.9%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+99.9%

        \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(b \cdot b\right) - 1\right)} \]
      2. unpow299.9%

        \[\leadsto \color{blue}{\left(a \cdot a + b \cdot b\right) \cdot \left(a \cdot a + b \cdot b\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      3. unpow199.9%

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{1}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      4. sqr-pow99.9%

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      5. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(\left(a \cdot a + b \cdot b\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)} \]
    4. Taylor expanded in a around inf 98.3%

      \[\leadsto \color{blue}{{a}^{4}} \]

    if -1.12e30 < a < 2.05e9

    1. Initial program 99.9%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    2. Taylor expanded in a around 0 96.7%

      \[\leadsto \left({\color{blue}{\left({b}^{2}\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    3. Step-by-step derivation
      1. unpow296.7%

        \[\leadsto \left({\color{blue}{\left(b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    4. Simplified96.7%

      \[\leadsto \left({\color{blue}{\left(b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    5. Step-by-step derivation
      1. unpow296.7%

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      2. unpow296.7%

        \[\leadsto \left(\color{blue}{{\left(b \cdot b\right)}^{2}} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      3. unpow-prod-down96.7%

        \[\leadsto \left(\color{blue}{{b}^{2} \cdot {b}^{2}} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      4. pow-sqr96.8%

        \[\leadsto \left(\color{blue}{{b}^{\left(2 \cdot 2\right)}} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      5. metadata-eval96.8%

        \[\leadsto \left({b}^{\color{blue}{4}} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      6. +-commutative96.8%

        \[\leadsto \color{blue}{\left(4 \cdot \left(b \cdot b\right) + {b}^{4}\right)} - 1 \]
      7. associate--l+96.8%

        \[\leadsto \color{blue}{4 \cdot \left(b \cdot b\right) + \left({b}^{4} - 1\right)} \]
      8. *-commutative96.8%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot 4} + \left({b}^{4} - 1\right) \]
      9. associate-*r*96.8%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot 4\right)} + \left({b}^{4} - 1\right) \]
    6. Applied egg-rr96.8%

      \[\leadsto \color{blue}{b \cdot \left(b \cdot 4\right) + \left({b}^{4} - 1\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.12 \cdot 10^{+30}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq 2050000000:\\ \;\;\;\;b \cdot \left(b \cdot 4\right) + \left({b}^{4} + -1\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]

Alternative 5?

\[\begin{array}{l} \mathbf{if}\;a \cdot a \leq 2 \cdot 10^{+44}:\\ \;\;\;\;{b}^{4} + \left(b \cdot \left(b \cdot 4\right) + -1\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a a) < 2.0000000000000002e44

    1. Initial program 99.9%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    2. Taylor expanded in a around 0 96.1%

      \[\leadsto \left({\color{blue}{\left({b}^{2}\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    3. Step-by-step derivation
      1. unpow296.1%

        \[\leadsto \left({\color{blue}{\left(b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    4. Simplified96.1%

      \[\leadsto \left({\color{blue}{\left(b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    5. Step-by-step derivation
      1. unpow296.1%

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      2. unpow296.1%

        \[\leadsto \left(\color{blue}{{\left(b \cdot b\right)}^{2}} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      3. unpow-prod-down96.1%

        \[\leadsto \left(\color{blue}{{b}^{2} \cdot {b}^{2}} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      4. pow-sqr96.2%

        \[\leadsto \left(\color{blue}{{b}^{\left(2 \cdot 2\right)}} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      5. metadata-eval96.2%

        \[\leadsto \left({b}^{\color{blue}{4}} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      6. +-commutative96.2%

        \[\leadsto \color{blue}{\left(4 \cdot \left(b \cdot b\right) + {b}^{4}\right)} - 1 \]
      7. associate--l+96.1%

        \[\leadsto \color{blue}{4 \cdot \left(b \cdot b\right) + \left({b}^{4} - 1\right)} \]
      8. *-commutative96.1%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot 4} + \left({b}^{4} - 1\right) \]
      9. associate-*r*96.1%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot 4\right)} + \left({b}^{4} - 1\right) \]
    6. Applied egg-rr96.1%

      \[\leadsto \color{blue}{b \cdot \left(b \cdot 4\right) + \left({b}^{4} - 1\right)} \]
    7. Step-by-step derivation
      1. +-commutative96.1%

        \[\leadsto \color{blue}{\left({b}^{4} - 1\right) + b \cdot \left(b \cdot 4\right)} \]
      2. metadata-eval96.1%

        \[\leadsto \left({b}^{\color{blue}{\left(2 + 2\right)}} - 1\right) + b \cdot \left(b \cdot 4\right) \]
      3. pow-prod-up96.1%

        \[\leadsto \left(\color{blue}{{b}^{2} \cdot {b}^{2}} - 1\right) + b \cdot \left(b \cdot 4\right) \]
      4. pow296.1%

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right)} \cdot {b}^{2} - 1\right) + b \cdot \left(b \cdot 4\right) \]
      5. pow296.1%

        \[\leadsto \left(\left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} - 1\right) + b \cdot \left(b \cdot 4\right) \]
      6. associate-+l-96.1%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right) - \left(1 - b \cdot \left(b \cdot 4\right)\right)} \]
      7. pow296.1%

        \[\leadsto \color{blue}{{b}^{2}} \cdot \left(b \cdot b\right) - \left(1 - b \cdot \left(b \cdot 4\right)\right) \]
      8. pow296.1%

        \[\leadsto {b}^{2} \cdot \color{blue}{{b}^{2}} - \left(1 - b \cdot \left(b \cdot 4\right)\right) \]
      9. pow-prod-up96.2%

        \[\leadsto \color{blue}{{b}^{\left(2 + 2\right)}} - \left(1 - b \cdot \left(b \cdot 4\right)\right) \]
      10. metadata-eval96.2%

        \[\leadsto {b}^{\color{blue}{4}} - \left(1 - b \cdot \left(b \cdot 4\right)\right) \]
    8. Applied egg-rr96.2%

      \[\leadsto \color{blue}{{b}^{4} - \left(1 - b \cdot \left(b \cdot 4\right)\right)} \]

    if 2.0000000000000002e44 < (*.f64 a a)

    1. Initial program 99.9%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+99.9%

        \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(b \cdot b\right) - 1\right)} \]
      2. unpow299.9%

        \[\leadsto \color{blue}{\left(a \cdot a + b \cdot b\right) \cdot \left(a \cdot a + b \cdot b\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      3. unpow199.9%

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{1}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      4. sqr-pow99.9%

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(\left(a \cdot a + b \cdot b\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)} \]
    4. Taylor expanded in a around inf 98.3%

      \[\leadsto \color{blue}{{a}^{4}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot a \leq 2 \cdot 10^{+44}:\\ \;\;\;\;{b}^{4} + \left(b \cdot \left(b \cdot 4\right) + -1\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]

Alternative 6?

\[\begin{array}{l} \mathbf{if}\;a \leq -1.4 \cdot 10^{+22} \lor \neg \left(a \leq 330000000\right):\\ \;\;\;\;{a}^{4}\\ \mathbf{else}:\\ \;\;\;\;\left(4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if a < -1.4e22 or 3.3e8 < a

    1. Initial program 99.9%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+99.9%

        \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(b \cdot b\right) - 1\right)} \]
      2. unpow299.9%

        \[\leadsto \color{blue}{\left(a \cdot a + b \cdot b\right) \cdot \left(a \cdot a + b \cdot b\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      3. unpow199.9%

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{1}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      4. sqr-pow99.9%

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      5. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(\left(a \cdot a + b \cdot b\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)} \]
    4. Taylor expanded in a around inf 98.3%

      \[\leadsto \color{blue}{{a}^{4}} \]

    if -1.4e22 < a < 3.3e8

    1. Initial program 99.9%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    2. Taylor expanded in a around 0 96.7%

      \[\leadsto \left({\color{blue}{\left({b}^{2}\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    3. Step-by-step derivation
      1. unpow296.7%

        \[\leadsto \left({\color{blue}{\left(b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    4. Simplified96.7%

      \[\leadsto \left({\color{blue}{\left(b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    5. Step-by-step derivation
      1. unpow296.7%

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    6. Applied egg-rr96.7%

      \[\leadsto \left(\color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.4 \cdot 10^{+22} \lor \neg \left(a \leq 330000000\right):\\ \;\;\;\;{a}^{4}\\ \mathbf{else}:\\ \;\;\;\;\left(4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1\\ \end{array} \]

Alternative 7?

\[\left(4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1 \]
Derivation
  1. Initial program 99.9%

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  2. Taylor expanded in a around 0 67.5%

    \[\leadsto \left({\color{blue}{\left({b}^{2}\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  3. Step-by-step derivation
    1. unpow267.5%

      \[\leadsto \left({\color{blue}{\left(b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  4. Simplified67.5%

    \[\leadsto \left({\color{blue}{\left(b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  5. Step-by-step derivation
    1. unpow267.5%

      \[\leadsto \left(\color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  6. Applied egg-rr67.5%

    \[\leadsto \left(\color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  7. Final simplification67.5%

    \[\leadsto \left(4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1 \]

Alternative 8?

\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 0.4:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 0.40000000000000002

    1. Initial program 99.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    2. Taylor expanded in a around 0 51.8%

      \[\leadsto \left({\color{blue}{\left({b}^{2}\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    3. Step-by-step derivation
      1. unpow251.8%

        \[\leadsto \left({\color{blue}{\left(b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    4. Simplified51.8%

      \[\leadsto \left({\color{blue}{\left(b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    5. Taylor expanded in b around 0 50.4%

      \[\leadsto \color{blue}{-1} \]

    if 0.40000000000000002 < (*.f64 b b)

    1. Initial program 99.9%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+99.9%

        \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(b \cdot b\right) - 1\right)} \]
      2. unpow299.9%

        \[\leadsto \color{blue}{\left(a \cdot a + b \cdot b\right) \cdot \left(a \cdot a + b \cdot b\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      3. unpow199.9%

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{1}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      4. sqr-pow99.9%

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      5. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(\left(a \cdot a + b \cdot b\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)} \]
    4. Taylor expanded in b around inf 95.1%

      \[\leadsto \color{blue}{{b}^{4} + \left(4 + 2 \cdot {a}^{2}\right) \cdot {b}^{2}} \]
    5. Step-by-step derivation
      1. unpow295.1%

        \[\leadsto {b}^{4} + \left(4 + 2 \cdot \color{blue}{\left(a \cdot a\right)}\right) \cdot {b}^{2} \]
      2. unpow295.1%

        \[\leadsto {b}^{4} + \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \color{blue}{\left(b \cdot b\right)} \]
    6. Simplified95.1%

      \[\leadsto \color{blue}{{b}^{4} + \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \left(b \cdot b\right)} \]
    7. Taylor expanded in a around 0 83.0%

      \[\leadsto {b}^{4} + \color{blue}{4 \cdot {b}^{2}} \]
    8. Step-by-step derivation
      1. unpow283.0%

        \[\leadsto {b}^{4} + 4 \cdot \color{blue}{\left(b \cdot b\right)} \]
      2. *-commutative83.0%

        \[\leadsto {b}^{4} + \color{blue}{\left(b \cdot b\right) \cdot 4} \]
      3. associate-*r*83.0%

        \[\leadsto {b}^{4} + \color{blue}{b \cdot \left(b \cdot 4\right)} \]
    9. Simplified83.0%

      \[\leadsto {b}^{4} + \color{blue}{b \cdot \left(b \cdot 4\right)} \]
    10. Step-by-step derivation
      1. metadata-eval83.0%

        \[\leadsto {b}^{\color{blue}{\left(2 \cdot 2\right)}} + b \cdot \left(b \cdot 4\right) \]
      2. pow-sqr82.9%

        \[\leadsto \color{blue}{{b}^{2} \cdot {b}^{2}} + b \cdot \left(b \cdot 4\right) \]
      3. pow282.9%

        \[\leadsto \color{blue}{\left(b \cdot b\right)} \cdot {b}^{2} + b \cdot \left(b \cdot 4\right) \]
      4. pow282.9%

        \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} + b \cdot \left(b \cdot 4\right) \]
      5. associate-*r*82.9%

        \[\leadsto \left(b \cdot b\right) \cdot \left(b \cdot b\right) + \color{blue}{\left(b \cdot b\right) \cdot 4} \]
      6. distribute-lft-out82.9%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)} \]
    11. Applied egg-rr82.9%

      \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 0.4:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \end{array} \]

Alternative 9?

\[\begin{array}{l} \mathbf{if}\;b \leq -2.15 \cdot 10^{-11} \lor \neg \left(b \leq 0.49\right):\\ \;\;\;\;b \cdot \left(b \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if b < -2.15000000000000001e-11 or 0.48999999999999999 < b

    1. Initial program 99.9%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+99.9%

        \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(b \cdot b\right) - 1\right)} \]
      2. unpow299.9%

        \[\leadsto \color{blue}{\left(a \cdot a + b \cdot b\right) \cdot \left(a \cdot a + b \cdot b\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      3. unpow199.9%

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{1}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      4. sqr-pow99.9%

        \[\leadsto \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
      5. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(\left(a \cdot a + b \cdot b\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)} \]
    4. Taylor expanded in b around inf 95.1%

      \[\leadsto \color{blue}{{b}^{4} + \left(4 + 2 \cdot {a}^{2}\right) \cdot {b}^{2}} \]
    5. Step-by-step derivation
      1. unpow295.1%

        \[\leadsto {b}^{4} + \left(4 + 2 \cdot \color{blue}{\left(a \cdot a\right)}\right) \cdot {b}^{2} \]
      2. unpow295.1%

        \[\leadsto {b}^{4} + \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \color{blue}{\left(b \cdot b\right)} \]
    6. Simplified95.1%

      \[\leadsto \color{blue}{{b}^{4} + \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \left(b \cdot b\right)} \]
    7. Taylor expanded in a around 0 81.8%

      \[\leadsto {b}^{4} + \color{blue}{4 \cdot {b}^{2}} \]
    8. Step-by-step derivation
      1. unpow281.8%

        \[\leadsto {b}^{4} + 4 \cdot \color{blue}{\left(b \cdot b\right)} \]
      2. *-commutative81.8%

        \[\leadsto {b}^{4} + \color{blue}{\left(b \cdot b\right) \cdot 4} \]
      3. associate-*r*81.8%

        \[\leadsto {b}^{4} + \color{blue}{b \cdot \left(b \cdot 4\right)} \]
    9. Simplified81.8%

      \[\leadsto {b}^{4} + \color{blue}{b \cdot \left(b \cdot 4\right)} \]
    10. Step-by-step derivation
      1. metadata-eval81.8%

        \[\leadsto {b}^{\color{blue}{\left(2 \cdot 2\right)}} + b \cdot \left(b \cdot 4\right) \]
      2. pow-sqr81.7%

        \[\leadsto \color{blue}{{b}^{2} \cdot {b}^{2}} + b \cdot \left(b \cdot 4\right) \]
      3. pow281.7%

        \[\leadsto \color{blue}{\left(b \cdot b\right)} \cdot {b}^{2} + b \cdot \left(b \cdot 4\right) \]
      4. pow281.7%

        \[\leadsto \left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} + b \cdot \left(b \cdot 4\right) \]
      5. associate-*r*81.7%

        \[\leadsto \left(b \cdot b\right) \cdot \left(b \cdot b\right) + \color{blue}{\left(b \cdot b\right) \cdot 4} \]
      6. distribute-lft-out81.7%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)} \]
    11. Applied egg-rr81.7%

      \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)} \]
    12. Taylor expanded in b around 0 52.0%

      \[\leadsto \color{blue}{4 \cdot {b}^{2}} \]
    13. Step-by-step derivation
      1. unpow252.0%

        \[\leadsto 4 \cdot \color{blue}{\left(b \cdot b\right)} \]
      2. *-commutative52.0%

        \[\leadsto \color{blue}{\left(b \cdot b\right) \cdot 4} \]
      3. associate-*r*52.0%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot 4\right)} \]
    14. Simplified52.0%

      \[\leadsto \color{blue}{b \cdot \left(b \cdot 4\right)} \]

    if -2.15000000000000001e-11 < b < 0.48999999999999999

    1. Initial program 99.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    2. Taylor expanded in a around 0 52.6%

      \[\leadsto \left({\color{blue}{\left({b}^{2}\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    3. Step-by-step derivation
      1. unpow252.6%

        \[\leadsto \left({\color{blue}{\left(b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    4. Simplified52.6%

      \[\leadsto \left({\color{blue}{\left(b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    5. Taylor expanded in b around 0 51.2%

      \[\leadsto \color{blue}{-1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification51.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2.15 \cdot 10^{-11} \lor \neg \left(b \leq 0.49\right):\\ \;\;\;\;b \cdot \left(b \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 10?

\[-1 \]
Derivation
  1. Initial program 99.9%

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  2. Taylor expanded in a around 0 67.5%

    \[\leadsto \left({\color{blue}{\left({b}^{2}\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  3. Step-by-step derivation
    1. unpow267.5%

      \[\leadsto \left({\color{blue}{\left(b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  4. Simplified67.5%

    \[\leadsto \left({\color{blue}{\left(b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  5. Taylor expanded in b around 0 25.5%

    \[\leadsto \color{blue}{-1} \]
  6. Final simplification25.5%

    \[\leadsto -1 \]

Reproduce

?
herbie shell --seed 2023166 
(FPCore (a b)
  :name "Bouland and Aaronson, Equation (26)"
  :precision binary64
  (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))