math.cos on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 9.2s
Alternatives: 16
Speedup: TODO×

Specification

?
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]

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 16 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?

\[\cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right) \]
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
  2. Step-by-step derivation
    1. *-commutative100.0%

      \[\leadsto \color{blue}{\left(\cos re \cdot 0.5\right)} \cdot \left(e^{-im} + e^{im}\right) \]
    2. associate-*l*100.0%

      \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot \left(e^{-im} + e^{im}\right)\right)} \]
    3. +-commutative100.0%

      \[\leadsto \cos re \cdot \left(0.5 \cdot \color{blue}{\left(e^{im} + e^{-im}\right)}\right) \]
    4. distribute-lft-in100.0%

      \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{-im}\right)} \]
    5. distribute-lft-in100.0%

      \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{-im}\right)\right)} \]
    6. distribute-rgt-in100.0%

      \[\leadsto \cos re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
    7. *-commutative100.0%

      \[\leadsto \cos re \cdot \left(\color{blue}{0.5 \cdot e^{im}} + e^{-im} \cdot 0.5\right) \]
    8. fma-def100.0%

      \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{-im} \cdot 0.5\right)} \]
    9. exp-neg100.0%

      \[\leadsto \cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
    10. associate-*l/100.0%

      \[\leadsto \cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
    11. metadata-eval100.0%

      \[\leadsto \cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
  4. Final simplification100.0%

    \[\leadsto \cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right) \]

Alternative 2?

\[\begin{array}{l} \mathbf{if}\;im \leq -2.35 \cdot 10^{+79}:\\ \;\;\;\;{im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)\\ \mathbf{elif}\;im \leq -12.5:\\ \;\;\;\;0.5 \cdot \left(e^{im} + e^{-im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \mathsf{fma}\left(0.5, e^{im}, 0.5\right)\\ \end{array} \]
Derivation
  1. Split input into 3 regimes
  2. if im < -2.35000000000000011e79

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 100.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left({im}^{2} + 0.08333333333333333 \cdot {im}^{4}\right)\right)} \]
    3. Step-by-step derivation
      1. unpow2100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(\color{blue}{im \cdot im} + 0.08333333333333333 \cdot {im}^{4}\right)\right) \]
      2. *-commutative100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im + \color{blue}{{im}^{4} \cdot 0.08333333333333333}\right)\right) \]
    4. Simplified100.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im + {im}^{4} \cdot 0.08333333333333333\right)\right)} \]
    5. Taylor expanded in im around inf 100.0%

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left(\cos re \cdot {im}^{4}\right)} \]
    6. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{4}\right) \cdot 0.041666666666666664} \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left({im}^{4} \cdot \cos re\right)} \cdot 0.041666666666666664 \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{{im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)} \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{{im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)} \]

    if -2.35000000000000011e79 < im < -12.5

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in re around 0 73.3%

      \[\leadsto \color{blue}{0.5 \cdot \left(e^{im} + e^{-im}\right)} \]

    if -12.5 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos re \cdot 0.5\right)} \cdot \left(e^{-im} + e^{im}\right) \]
      2. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot \left(e^{-im} + e^{im}\right)\right)} \]
      3. +-commutative100.0%

        \[\leadsto \cos re \cdot \left(0.5 \cdot \color{blue}{\left(e^{im} + e^{-im}\right)}\right) \]
      4. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{-im}\right)} \]
      5. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{-im}\right)\right)} \]
      6. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      7. *-commutative100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{0.5 \cdot e^{im}} + e^{-im} \cdot 0.5\right) \]
      8. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{-im} \cdot 0.5\right)} \]
      9. exp-neg100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      10. associate-*l/100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      11. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 97.6%

      \[\leadsto \cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification96.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.35 \cdot 10^{+79}:\\ \;\;\;\;{im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)\\ \mathbf{elif}\;im \leq -12.5:\\ \;\;\;\;0.5 \cdot \left(e^{im} + e^{-im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \mathsf{fma}\left(0.5, e^{im}, 0.5\right)\\ \end{array} \]

Alternative 3?

\[\left(\cos re \cdot 0.5\right) \cdot \left(e^{im} + e^{-im}\right) \]
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
  2. Final simplification100.0%

    \[\leadsto \left(\cos re \cdot 0.5\right) \cdot \left(e^{im} + e^{-im}\right) \]

Alternative 4?

\[\begin{array}{l} \mathbf{if}\;im \leq -2.35 \cdot 10^{+79}:\\ \;\;\;\;{im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)\\ \mathbf{elif}\;im \leq -12.5 \lor \neg \left(im \leq 0.165\right) \land im \leq 4 \cdot 10^{+76}:\\ \;\;\;\;0.5 \cdot \left(e^{im} + e^{-im}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(2 + \left(im \cdot im + {im}^{4} \cdot 0.08333333333333333\right)\right)\\ \end{array} \]
Derivation
  1. Split input into 3 regimes
  2. if im < -2.35000000000000011e79

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 100.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left({im}^{2} + 0.08333333333333333 \cdot {im}^{4}\right)\right)} \]
    3. Step-by-step derivation
      1. unpow2100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(\color{blue}{im \cdot im} + 0.08333333333333333 \cdot {im}^{4}\right)\right) \]
      2. *-commutative100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im + \color{blue}{{im}^{4} \cdot 0.08333333333333333}\right)\right) \]
    4. Simplified100.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im + {im}^{4} \cdot 0.08333333333333333\right)\right)} \]
    5. Taylor expanded in im around inf 100.0%

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left(\cos re \cdot {im}^{4}\right)} \]
    6. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{4}\right) \cdot 0.041666666666666664} \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left({im}^{4} \cdot \cos re\right)} \cdot 0.041666666666666664 \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{{im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)} \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{{im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)} \]

    if -2.35000000000000011e79 < im < -12.5 or 0.165000000000000008 < im < 4.0000000000000002e76

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in re around 0 78.3%

      \[\leadsto \color{blue}{0.5 \cdot \left(e^{im} + e^{-im}\right)} \]

    if -12.5 < im < 0.165000000000000008 or 4.0000000000000002e76 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 99.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left({im}^{2} + 0.08333333333333333 \cdot {im}^{4}\right)\right)} \]
    3. Step-by-step derivation
      1. unpow299.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(\color{blue}{im \cdot im} + 0.08333333333333333 \cdot {im}^{4}\right)\right) \]
      2. *-commutative99.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im + \color{blue}{{im}^{4} \cdot 0.08333333333333333}\right)\right) \]
    4. Simplified99.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im + {im}^{4} \cdot 0.08333333333333333\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification96.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.35 \cdot 10^{+79}:\\ \;\;\;\;{im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)\\ \mathbf{elif}\;im \leq -12.5 \lor \neg \left(im \leq 0.165\right) \land im \leq 4 \cdot 10^{+76}:\\ \;\;\;\;0.5 \cdot \left(e^{im} + e^{-im}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(2 + \left(im \cdot im + {im}^{4} \cdot 0.08333333333333333\right)\right)\\ \end{array} \]

Alternative 5?

\[\begin{array}{l} t_0 := \left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ t_1 := 0.5 \cdot \left(e^{im} + e^{-im}\right)\\ \mathbf{if}\;im \leq -2.5 \cdot 10^{+154}:\\ \;\;\;\;im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\ \mathbf{elif}\;im \leq -12.5:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 1.26 \cdot 10^{-9}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 7.9 \cdot 10^{+62}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+101}:\\ \;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+136}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Derivation
  1. Split input into 4 regimes
  2. if im < -2.50000000000000002e154

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 100.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow2100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
    4. Simplified100.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
    5. Taylor expanded in im around inf 100.0%

      \[\leadsto \color{blue}{0.5 \cdot \left(\cos re \cdot {im}^{2}\right)} \]
    6. Step-by-step derivation
      1. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot {im}^{2}} \]
      2. unpow2100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot im\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(\left(0.5 \cdot \cos re\right) \cdot im\right) \cdot im} \]
      4. *-commutative100.0%

        \[\leadsto \color{blue}{im \cdot \left(\left(0.5 \cdot \cos re\right) \cdot im\right)} \]
      5. *-commutative100.0%

        \[\leadsto im \cdot \left(\color{blue}{\left(\cos re \cdot 0.5\right)} \cdot im\right) \]
      6. associate-*l*100.0%

        \[\leadsto im \cdot \color{blue}{\left(\cos re \cdot \left(0.5 \cdot im\right)\right)} \]
      7. *-commutative100.0%

        \[\leadsto im \cdot \left(\cos re \cdot \color{blue}{\left(im \cdot 0.5\right)}\right) \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{im \cdot \left(\cos re \cdot \left(im \cdot 0.5\right)\right)} \]

    if -2.50000000000000002e154 < im < -12.5 or 1.25999999999999999e-9 < im < 7.8999999999999997e62 or 1.39999999999999991e101 < im < 1.1e136

    1. Initial program 99.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in re around 0 83.1%

      \[\leadsto \color{blue}{0.5 \cdot \left(e^{im} + e^{-im}\right)} \]

    if -12.5 < im < 1.25999999999999999e-9 or 1.1e136 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 98.9%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow298.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
    4. Simplified98.9%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]

    if 7.8999999999999997e62 < im < 1.39999999999999991e101

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 4.9%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow24.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
    4. Simplified4.9%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
    5. Taylor expanded in re around 0 75.7%

      \[\leadsto \color{blue}{0.5 \cdot \left(2 + {im}^{2}\right) + -0.25 \cdot \left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right)} \]
    6. Step-by-step derivation
      1. *-commutative75.7%

        \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot 0.5} + -0.25 \cdot \left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right) \]
      2. *-commutative75.7%

        \[\leadsto \left(2 + {im}^{2}\right) \cdot 0.5 + \color{blue}{\left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right) \cdot -0.25} \]
      3. associate-*l*75.7%

        \[\leadsto \left(2 + {im}^{2}\right) \cdot 0.5 + \color{blue}{\left(2 + {im}^{2}\right) \cdot \left({re}^{2} \cdot -0.25\right)} \]
      4. distribute-lft-out75.7%

        \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot \left(0.5 + {re}^{2} \cdot -0.25\right)} \]
      5. +-commutative75.7%

        \[\leadsto \color{blue}{\left({im}^{2} + 2\right)} \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      6. unpow275.7%

        \[\leadsto \left(\color{blue}{im \cdot im} + 2\right) \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      7. fma-def75.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      8. *-commutative75.7%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + \color{blue}{-0.25 \cdot {re}^{2}}\right) \]
      9. unpow275.7%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    7. Simplified75.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification94.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.5 \cdot 10^{+154}:\\ \;\;\;\;im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\ \mathbf{elif}\;im \leq -12.5:\\ \;\;\;\;0.5 \cdot \left(e^{im} + e^{-im}\right)\\ \mathbf{elif}\;im \leq 1.26 \cdot 10^{-9}:\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 7.9 \cdot 10^{+62}:\\ \;\;\;\;0.5 \cdot \left(e^{im} + e^{-im}\right)\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+101}:\\ \;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+136}:\\ \;\;\;\;0.5 \cdot \left(e^{im} + e^{-im}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \end{array} \]

Alternative 6?

\[\begin{array}{l} t_0 := 0.5 \cdot \left(e^{im} + e^{-im}\right)\\ t_1 := {im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)\\ \mathbf{if}\;im \leq -2.35 \cdot 10^{+79}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -12.5:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 1.26 \cdot 10^{-9}:\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 4 \cdot 10^{+76}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Derivation
  1. Split input into 3 regimes
  2. if im < -2.35000000000000011e79 or 4.0000000000000002e76 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 99.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left({im}^{2} + 0.08333333333333333 \cdot {im}^{4}\right)\right)} \]
    3. Step-by-step derivation
      1. unpow299.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(\color{blue}{im \cdot im} + 0.08333333333333333 \cdot {im}^{4}\right)\right) \]
      2. *-commutative99.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im + \color{blue}{{im}^{4} \cdot 0.08333333333333333}\right)\right) \]
    4. Simplified99.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im + {im}^{4} \cdot 0.08333333333333333\right)\right)} \]
    5. Taylor expanded in im around inf 99.0%

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left(\cos re \cdot {im}^{4}\right)} \]
    6. Step-by-step derivation
      1. *-commutative99.0%

        \[\leadsto \color{blue}{\left(\cos re \cdot {im}^{4}\right) \cdot 0.041666666666666664} \]
      2. *-commutative99.0%

        \[\leadsto \color{blue}{\left({im}^{4} \cdot \cos re\right)} \cdot 0.041666666666666664 \]
      3. associate-*l*99.0%

        \[\leadsto \color{blue}{{im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)} \]
    7. Simplified99.0%

      \[\leadsto \color{blue}{{im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)} \]

    if -2.35000000000000011e79 < im < -12.5 or 1.25999999999999999e-9 < im < 4.0000000000000002e76

    1. Initial program 99.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in re around 0 79.7%

      \[\leadsto \color{blue}{0.5 \cdot \left(e^{im} + e^{-im}\right)} \]

    if -12.5 < im < 1.25999999999999999e-9

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 99.3%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow299.3%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
    4. Simplified99.3%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification96.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.35 \cdot 10^{+79}:\\ \;\;\;\;{im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)\\ \mathbf{elif}\;im \leq -12.5:\\ \;\;\;\;0.5 \cdot \left(e^{im} + e^{-im}\right)\\ \mathbf{elif}\;im \leq 1.26 \cdot 10^{-9}:\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 4 \cdot 10^{+76}:\\ \;\;\;\;0.5 \cdot \left(e^{im} + e^{-im}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{4} \cdot \left(\cos re \cdot 0.041666666666666664\right)\\ \end{array} \]

Alternative 7?

\[\begin{array}{l} t_0 := \left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ t_1 := 0.5 \cdot \frac{9.506944444444445 - {im}^{4}}{3.0833333333333335 - im \cdot im}\\ \mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\ \mathbf{elif}\;im \leq -1.35 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 18000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+101}:\\ \;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+136}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Derivation
  1. Split input into 4 regimes
  2. if im < -1.35000000000000003e154

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 100.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow2100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
    4. Simplified100.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
    5. Taylor expanded in im around inf 100.0%

      \[\leadsto \color{blue}{0.5 \cdot \left(\cos re \cdot {im}^{2}\right)} \]
    6. Step-by-step derivation
      1. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot {im}^{2}} \]
      2. unpow2100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot im\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(\left(0.5 \cdot \cos re\right) \cdot im\right) \cdot im} \]
      4. *-commutative100.0%

        \[\leadsto \color{blue}{im \cdot \left(\left(0.5 \cdot \cos re\right) \cdot im\right)} \]
      5. *-commutative100.0%

        \[\leadsto im \cdot \left(\color{blue}{\left(\cos re \cdot 0.5\right)} \cdot im\right) \]
      6. associate-*l*100.0%

        \[\leadsto im \cdot \color{blue}{\left(\cos re \cdot \left(0.5 \cdot im\right)\right)} \]
      7. *-commutative100.0%

        \[\leadsto im \cdot \left(\cos re \cdot \color{blue}{\left(im \cdot 0.5\right)}\right) \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{im \cdot \left(\cos re \cdot \left(im \cdot 0.5\right)\right)} \]

    if -1.35000000000000003e154 < im < -1.3499999999999999e69 or 1.39999999999999991e101 < im < 1.1e136

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 96.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(\color{blue}{im \cdot im} + 0.08333333333333333 \cdot {im}^{4}\right)\right) \]
      2. *-commutative96.3%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im + \color{blue}{{im}^{4} \cdot 0.08333333333333333}\right)\right) \]
    4. Simplified96.3%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im + {im}^{4} \cdot 0.08333333333333333\right)\right)} \]
    5. Applied egg-rr6.9%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im + \color{blue}{1.0833333333333333}\right)\right) \]
    6. Taylor expanded in re around 0 5.6%

      \[\leadsto \color{blue}{0.5 \cdot \left(3.0833333333333335 + {im}^{2}\right)} \]
    7. Step-by-step derivation
      1. flip-+80.2%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{3.0833333333333335 \cdot 3.0833333333333335 - {im}^{2} \cdot {im}^{2}}{3.0833333333333335 - {im}^{2}}} \]
      2. div-sub80.2%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{3.0833333333333335 \cdot 3.0833333333333335}{3.0833333333333335 - {im}^{2}} - \frac{{im}^{2} \cdot {im}^{2}}{3.0833333333333335 - {im}^{2}}\right)} \]
      3. metadata-eval80.2%

        \[\leadsto 0.5 \cdot \left(\frac{\color{blue}{9.506944444444445}}{3.0833333333333335 - {im}^{2}} - \frac{{im}^{2} \cdot {im}^{2}}{3.0833333333333335 - {im}^{2}}\right) \]
      4. unpow280.2%

        \[\leadsto 0.5 \cdot \left(\frac{9.506944444444445}{3.0833333333333335 - \color{blue}{im \cdot im}} - \frac{{im}^{2} \cdot {im}^{2}}{3.0833333333333335 - {im}^{2}}\right) \]
      5. pow-prod-up80.2%

        \[\leadsto 0.5 \cdot \left(\frac{9.506944444444445}{3.0833333333333335 - im \cdot im} - \frac{\color{blue}{{im}^{\left(2 + 2\right)}}}{3.0833333333333335 - {im}^{2}}\right) \]
      6. metadata-eval80.2%

        \[\leadsto 0.5 \cdot \left(\frac{9.506944444444445}{3.0833333333333335 - im \cdot im} - \frac{{im}^{\color{blue}{4}}}{3.0833333333333335 - {im}^{2}}\right) \]
      7. unpow280.2%

        \[\leadsto 0.5 \cdot \left(\frac{9.506944444444445}{3.0833333333333335 - im \cdot im} - \frac{{im}^{4}}{3.0833333333333335 - \color{blue}{im \cdot im}}\right) \]
    8. Applied egg-rr80.2%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{9.506944444444445}{3.0833333333333335 - im \cdot im} - \frac{{im}^{4}}{3.0833333333333335 - im \cdot im}\right)} \]
    9. Step-by-step derivation
      1. div-sub80.2%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{9.506944444444445 - {im}^{4}}{3.0833333333333335 - im \cdot im}} \]
    10. Simplified80.2%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{9.506944444444445 - {im}^{4}}{3.0833333333333335 - im \cdot im}} \]

    if -1.3499999999999999e69 < im < 1.8e10 or 1.1e136 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 89.8%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow289.8%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
    4. Simplified89.8%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]

    if 1.8e10 < im < 1.39999999999999991e101

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 4.2%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow24.2%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
    4. Simplified4.2%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
    5. Taylor expanded in re around 0 36.5%

      \[\leadsto \color{blue}{0.5 \cdot \left(2 + {im}^{2}\right) + -0.25 \cdot \left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right)} \]
    6. Step-by-step derivation
      1. *-commutative36.5%

        \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot 0.5} + -0.25 \cdot \left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right) \]
      2. *-commutative36.5%

        \[\leadsto \left(2 + {im}^{2}\right) \cdot 0.5 + \color{blue}{\left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right) \cdot -0.25} \]
      3. associate-*l*36.5%

        \[\leadsto \left(2 + {im}^{2}\right) \cdot 0.5 + \color{blue}{\left(2 + {im}^{2}\right) \cdot \left({re}^{2} \cdot -0.25\right)} \]
      4. distribute-lft-out36.5%

        \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot \left(0.5 + {re}^{2} \cdot -0.25\right)} \]
      5. +-commutative36.5%

        \[\leadsto \color{blue}{\left({im}^{2} + 2\right)} \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      6. unpow236.5%

        \[\leadsto \left(\color{blue}{im \cdot im} + 2\right) \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      7. fma-def36.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      8. *-commutative36.5%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + \color{blue}{-0.25 \cdot {re}^{2}}\right) \]
      9. unpow236.5%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    7. Simplified36.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification85.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\ \mathbf{elif}\;im \leq -1.35 \cdot 10^{+69}:\\ \;\;\;\;0.5 \cdot \frac{9.506944444444445 - {im}^{4}}{3.0833333333333335 - im \cdot im}\\ \mathbf{elif}\;im \leq 18000000000:\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+101}:\\ \;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+136}:\\ \;\;\;\;0.5 \cdot \frac{9.506944444444445 - {im}^{4}}{3.0833333333333335 - im \cdot im}\\ \mathbf{else}:\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \end{array} \]

Alternative 8?

\[\begin{array}{l} t_0 := im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\ \mathbf{if}\;im \leq -1.45:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 175000000000:\\ \;\;\;\;\cos re\\ \mathbf{elif}\;im \leq 4.1 \cdot 10^{+153}:\\ \;\;\;\;re \cdot \left(re \cdot -0.5\right) + 1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Derivation
  1. Split input into 3 regimes
  2. if im < -1.44999999999999996 or 4.10000000000000017e153 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 68.7%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow268.7%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
    4. Simplified68.7%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
    5. Taylor expanded in im around inf 68.7%

      \[\leadsto \color{blue}{0.5 \cdot \left(\cos re \cdot {im}^{2}\right)} \]
    6. Step-by-step derivation
      1. associate-*r*68.7%

        \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot {im}^{2}} \]
      2. unpow268.7%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot im\right)} \]
      3. associate-*r*68.7%

        \[\leadsto \color{blue}{\left(\left(0.5 \cdot \cos re\right) \cdot im\right) \cdot im} \]
      4. *-commutative68.7%

        \[\leadsto \color{blue}{im \cdot \left(\left(0.5 \cdot \cos re\right) \cdot im\right)} \]
      5. *-commutative68.7%

        \[\leadsto im \cdot \left(\color{blue}{\left(\cos re \cdot 0.5\right)} \cdot im\right) \]
      6. associate-*l*68.7%

        \[\leadsto im \cdot \color{blue}{\left(\cos re \cdot \left(0.5 \cdot im\right)\right)} \]
      7. *-commutative68.7%

        \[\leadsto im \cdot \left(\cos re \cdot \color{blue}{\left(im \cdot 0.5\right)}\right) \]
    7. Simplified68.7%

      \[\leadsto \color{blue}{im \cdot \left(\cos re \cdot \left(im \cdot 0.5\right)\right)} \]

    if -1.44999999999999996 < im < 1.75e11

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos re \cdot 0.5\right)} \cdot \left(e^{-im} + e^{im}\right) \]
      2. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot \left(e^{-im} + e^{im}\right)\right)} \]
      3. +-commutative100.0%

        \[\leadsto \cos re \cdot \left(0.5 \cdot \color{blue}{\left(e^{im} + e^{-im}\right)}\right) \]
      4. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{-im}\right)} \]
      5. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{-im}\right)\right)} \]
      6. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      7. *-commutative100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{0.5 \cdot e^{im}} + e^{-im} \cdot 0.5\right) \]
      8. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{-im} \cdot 0.5\right)} \]
      9. exp-neg100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      10. associate-*l/100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      11. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 96.5%

      \[\leadsto \color{blue}{\cos re} \]

    if 1.75e11 < im < 4.10000000000000017e153

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 4.8%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow24.8%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
    4. Simplified4.8%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
    5. Taylor expanded in re around 0 33.5%

      \[\leadsto \color{blue}{0.5 \cdot \left(2 + {im}^{2}\right) + -0.25 \cdot \left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right)} \]
    6. Step-by-step derivation
      1. *-commutative33.5%

        \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot 0.5} + -0.25 \cdot \left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right) \]
      2. *-commutative33.5%

        \[\leadsto \left(2 + {im}^{2}\right) \cdot 0.5 + \color{blue}{\left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right) \cdot -0.25} \]
      3. associate-*l*33.5%

        \[\leadsto \left(2 + {im}^{2}\right) \cdot 0.5 + \color{blue}{\left(2 + {im}^{2}\right) \cdot \left({re}^{2} \cdot -0.25\right)} \]
      4. distribute-lft-out33.5%

        \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot \left(0.5 + {re}^{2} \cdot -0.25\right)} \]
      5. +-commutative33.5%

        \[\leadsto \color{blue}{\left({im}^{2} + 2\right)} \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      6. unpow233.5%

        \[\leadsto \left(\color{blue}{im \cdot im} + 2\right) \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      7. fma-def33.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      8. *-commutative33.5%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + \color{blue}{-0.25 \cdot {re}^{2}}\right) \]
      9. unpow233.5%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    7. Simplified33.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    8. Taylor expanded in im around 0 29.8%

      \[\leadsto \color{blue}{2 \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
    9. Step-by-step derivation
      1. distribute-lft-in29.8%

        \[\leadsto \color{blue}{2 \cdot 0.5 + 2 \cdot \left(-0.25 \cdot {re}^{2}\right)} \]
      2. metadata-eval29.8%

        \[\leadsto \color{blue}{1} + 2 \cdot \left(-0.25 \cdot {re}^{2}\right) \]
      3. associate-*r*29.8%

        \[\leadsto 1 + \color{blue}{\left(2 \cdot -0.25\right) \cdot {re}^{2}} \]
      4. metadata-eval29.8%

        \[\leadsto 1 + \color{blue}{-0.5} \cdot {re}^{2} \]
      5. +-commutative29.8%

        \[\leadsto \color{blue}{-0.5 \cdot {re}^{2} + 1} \]
      6. *-commutative29.8%

        \[\leadsto \color{blue}{{re}^{2} \cdot -0.5} + 1 \]
      7. unpow229.8%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot -0.5 + 1 \]
      8. associate-*l*29.8%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot -0.5\right)} + 1 \]
    10. Simplified29.8%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot -0.5\right) + 1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification78.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.45:\\ \;\;\;\;im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\ \mathbf{elif}\;im \leq 175000000000:\\ \;\;\;\;\cos re\\ \mathbf{elif}\;im \leq 4.1 \cdot 10^{+153}:\\ \;\;\;\;re \cdot \left(re \cdot -0.5\right) + 1\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(\cos re \cdot \left(0.5 \cdot im\right)\right)\\ \end{array} \]

Alternative 9?

\[\left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right) \]
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
  2. Taylor expanded in im around 0 75.3%

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
  3. Step-by-step derivation
    1. unpow275.3%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
  4. Simplified75.3%

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
  5. Final simplification75.3%

    \[\leadsto \left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right) \]

Alternative 10?

\[\begin{array}{l} t_0 := 0.5 \cdot \left(im \cdot im\right)\\ \mathbf{if}\;im \leq -2.7 \cdot 10^{+50}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 960000000000:\\ \;\;\;\;\cos re\\ \mathbf{elif}\;im \leq 1.12 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(re \cdot -0.5\right) + 1\\ \mathbf{else}:\\ \;\;\;\;1 + t_0\\ \end{array} \]
Derivation
  1. Split input into 4 regimes
  2. if im < -2.7e50

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 89.5%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left({im}^{2} + 0.08333333333333333 \cdot {im}^{4}\right)\right)} \]
    3. Step-by-step derivation
      1. unpow289.5%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(\color{blue}{im \cdot im} + 0.08333333333333333 \cdot {im}^{4}\right)\right) \]
      2. *-commutative89.5%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im + \color{blue}{{im}^{4} \cdot 0.08333333333333333}\right)\right) \]
    4. Simplified89.5%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im + {im}^{4} \cdot 0.08333333333333333\right)\right)} \]
    5. Applied egg-rr61.2%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im + \color{blue}{1.0833333333333333}\right)\right) \]
    6. Taylor expanded in re around 0 47.4%

      \[\leadsto \color{blue}{0.5 \cdot \left(3.0833333333333335 + {im}^{2}\right)} \]
    7. Taylor expanded in im around inf 47.4%

      \[\leadsto 0.5 \cdot \color{blue}{{im}^{2}} \]
    8. Step-by-step derivation
      1. unpow247.4%

        \[\leadsto 0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
    9. Simplified47.4%

      \[\leadsto 0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]

    if -2.7e50 < im < 9.6e11

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos re \cdot 0.5\right)} \cdot \left(e^{-im} + e^{im}\right) \]
      2. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot \left(e^{-im} + e^{im}\right)\right)} \]
      3. +-commutative100.0%

        \[\leadsto \cos re \cdot \left(0.5 \cdot \color{blue}{\left(e^{im} + e^{-im}\right)}\right) \]
      4. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{-im}\right)} \]
      5. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{-im}\right)\right)} \]
      6. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      7. *-commutative100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{0.5 \cdot e^{im}} + e^{-im} \cdot 0.5\right) \]
      8. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{-im} \cdot 0.5\right)} \]
      9. exp-neg100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{1}{e^{im}}} \cdot 0.5\right) \]
      10. associate-*l/100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{1 \cdot 0.5}{e^{im}}}\right) \]
      11. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 90.6%

      \[\leadsto \color{blue}{\cos re} \]

    if 9.6e11 < im < 1.11999999999999994e154

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 4.8%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow24.8%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
    4. Simplified4.8%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
    5. Taylor expanded in re around 0 33.5%

      \[\leadsto \color{blue}{0.5 \cdot \left(2 + {im}^{2}\right) + -0.25 \cdot \left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right)} \]
    6. Step-by-step derivation
      1. *-commutative33.5%

        \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot 0.5} + -0.25 \cdot \left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right) \]
      2. *-commutative33.5%

        \[\leadsto \left(2 + {im}^{2}\right) \cdot 0.5 + \color{blue}{\left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right) \cdot -0.25} \]
      3. associate-*l*33.5%

        \[\leadsto \left(2 + {im}^{2}\right) \cdot 0.5 + \color{blue}{\left(2 + {im}^{2}\right) \cdot \left({re}^{2} \cdot -0.25\right)} \]
      4. distribute-lft-out33.5%

        \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot \left(0.5 + {re}^{2} \cdot -0.25\right)} \]
      5. +-commutative33.5%

        \[\leadsto \color{blue}{\left({im}^{2} + 2\right)} \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      6. unpow233.5%

        \[\leadsto \left(\color{blue}{im \cdot im} + 2\right) \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      7. fma-def33.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      8. *-commutative33.5%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + \color{blue}{-0.25 \cdot {re}^{2}}\right) \]
      9. unpow233.5%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    7. Simplified33.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    8. Taylor expanded in im around 0 29.8%

      \[\leadsto \color{blue}{2 \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
    9. Step-by-step derivation
      1. distribute-lft-in29.8%

        \[\leadsto \color{blue}{2 \cdot 0.5 + 2 \cdot \left(-0.25 \cdot {re}^{2}\right)} \]
      2. metadata-eval29.8%

        \[\leadsto \color{blue}{1} + 2 \cdot \left(-0.25 \cdot {re}^{2}\right) \]
      3. associate-*r*29.8%

        \[\leadsto 1 + \color{blue}{\left(2 \cdot -0.25\right) \cdot {re}^{2}} \]
      4. metadata-eval29.8%

        \[\leadsto 1 + \color{blue}{-0.5} \cdot {re}^{2} \]
      5. +-commutative29.8%

        \[\leadsto \color{blue}{-0.5 \cdot {re}^{2} + 1} \]
      6. *-commutative29.8%

        \[\leadsto \color{blue}{{re}^{2} \cdot -0.5} + 1 \]
      7. unpow229.8%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot -0.5 + 1 \]
      8. associate-*l*29.8%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot -0.5\right)} + 1 \]
    10. Simplified29.8%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot -0.5\right) + 1} \]

    if 1.11999999999999994e154 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 100.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow2100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
    4. Simplified100.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
    5. Taylor expanded in re around 0 77.4%

      \[\leadsto \color{blue}{0.5 \cdot \left(2 + {im}^{2}\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-in77.4%

        \[\leadsto \color{blue}{0.5 \cdot 2 + 0.5 \cdot {im}^{2}} \]
      2. metadata-eval77.4%

        \[\leadsto \color{blue}{1} + 0.5 \cdot {im}^{2} \]
      3. unpow277.4%

        \[\leadsto 1 + 0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
    7. Simplified77.4%

      \[\leadsto \color{blue}{1 + 0.5 \cdot \left(im \cdot im\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification72.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.7 \cdot 10^{+50}:\\ \;\;\;\;0.5 \cdot \left(im \cdot im\right)\\ \mathbf{elif}\;im \leq 960000000000:\\ \;\;\;\;\cos re\\ \mathbf{elif}\;im \leq 1.12 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(re \cdot -0.5\right) + 1\\ \mathbf{else}:\\ \;\;\;\;1 + 0.5 \cdot \left(im \cdot im\right)\\ \end{array} \]

Alternative 11?

\[\begin{array}{l} t_0 := re \cdot \left(re \cdot -0.5\right) + 1\\ \mathbf{if}\;re \leq -5 \cdot 10^{+166}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;re \leq 1.1 \cdot 10^{+164}:\\ \;\;\;\;1 + 0.5 \cdot \left(im \cdot im\right)\\ \mathbf{elif}\;re \leq 7.2 \cdot 10^{+220}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;26623333280885244000 + \left(re \cdot re\right) \cdot 26623333280885244000\\ \end{array} \]
Derivation
  1. Split input into 3 regimes
  2. if re < -5.0000000000000002e166 or 1.10000000000000003e164 < re < 7.20000000000000038e220

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 66.1%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow266.1%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
    4. Simplified66.1%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
    5. Taylor expanded in re around 0 26.5%

      \[\leadsto \color{blue}{0.5 \cdot \left(2 + {im}^{2}\right) + -0.25 \cdot \left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right)} \]
    6. Step-by-step derivation
      1. *-commutative26.5%

        \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot 0.5} + -0.25 \cdot \left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right) \]
      2. *-commutative26.5%

        \[\leadsto \left(2 + {im}^{2}\right) \cdot 0.5 + \color{blue}{\left(\left(2 + {im}^{2}\right) \cdot {re}^{2}\right) \cdot -0.25} \]
      3. associate-*l*26.5%

        \[\leadsto \left(2 + {im}^{2}\right) \cdot 0.5 + \color{blue}{\left(2 + {im}^{2}\right) \cdot \left({re}^{2} \cdot -0.25\right)} \]
      4. distribute-lft-out39.3%

        \[\leadsto \color{blue}{\left(2 + {im}^{2}\right) \cdot \left(0.5 + {re}^{2} \cdot -0.25\right)} \]
      5. +-commutative39.3%

        \[\leadsto \color{blue}{\left({im}^{2} + 2\right)} \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      6. unpow239.3%

        \[\leadsto \left(\color{blue}{im \cdot im} + 2\right) \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      7. fma-def39.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \cdot \left(0.5 + {re}^{2} \cdot -0.25\right) \]
      8. *-commutative39.3%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + \color{blue}{-0.25 \cdot {re}^{2}}\right) \]
      9. unpow239.3%

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    7. Simplified39.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    8. Taylor expanded in im around 0 39.3%

      \[\leadsto \color{blue}{2 \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
    9. Step-by-step derivation
      1. distribute-lft-in39.3%

        \[\leadsto \color{blue}{2 \cdot 0.5 + 2 \cdot \left(-0.25 \cdot {re}^{2}\right)} \]
      2. metadata-eval39.3%

        \[\leadsto \color{blue}{1} + 2 \cdot \left(-0.25 \cdot {re}^{2}\right) \]
      3. associate-*r*39.3%

        \[\leadsto 1 + \color{blue}{\left(2 \cdot -0.25\right) \cdot {re}^{2}} \]
      4. metadata-eval39.3%

        \[\leadsto 1 + \color{blue}{-0.5} \cdot {re}^{2} \]
      5. +-commutative39.3%

        \[\leadsto \color{blue}{-0.5 \cdot {re}^{2} + 1} \]
      6. *-commutative39.3%

        \[\leadsto \color{blue}{{re}^{2} \cdot -0.5} + 1 \]
      7. unpow239.3%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot -0.5 + 1 \]
      8. associate-*l*39.3%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot -0.5\right)} + 1 \]
    10. Simplified39.3%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot -0.5\right) + 1} \]

    if -5.0000000000000002e166 < re < 1.10000000000000003e164

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 77.6%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow277.6%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
    4. Simplified77.6%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
    5. Taylor expanded in re around 0 58.4%

      \[\leadsto \color{blue}{0.5 \cdot \left(2 + {im}^{2}\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-in58.4%

        \[\leadsto \color{blue}{0.5 \cdot 2 + 0.5 \cdot {im}^{2}} \]
      2. metadata-eval58.4%

        \[\leadsto \color{blue}{1} + 0.5 \cdot {im}^{2} \]
      3. unpow258.4%

        \[\leadsto 1 + 0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
    7. Simplified58.4%

      \[\leadsto \color{blue}{1 + 0.5 \cdot \left(im \cdot im\right)} \]

    if 7.20000000000000038e220 < re

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 79.3%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left({im}^{2} + 0.08333333333333333 \cdot {im}^{4}\right)\right)} \]
    3. Step-by-step derivation
      1. unpow279.3%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(\color{blue}{im \cdot im} + 0.08333333333333333 \cdot {im}^{4}\right)\right) \]
      2. *-commutative79.3%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im + \color{blue}{{im}^{4} \cdot 0.08333333333333333}\right)\right) \]
    4. Simplified79.3%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im + {im}^{4} \cdot 0.08333333333333333\right)\right)} \]
    5. Applied egg-rr4.3%

      \[\leadsto \color{blue}{{\left(1.9380669946781485 \cdot 10^{-10} \cdot \cos re\right)}^{-2}} \]
    6. Step-by-step derivation
      1. *-commutative4.3%

        \[\leadsto {\color{blue}{\left(\cos re \cdot 1.9380669946781485 \cdot 10^{-10}\right)}}^{-2} \]
    7. Simplified4.3%

      \[\leadsto \color{blue}{{\left(\cos re \cdot 1.9380669946781485 \cdot 10^{-10}\right)}^{-2}} \]
    8. Taylor expanded in re around 0 35.8%

      \[\leadsto \color{blue}{26623333280885244000 + 26623333280885244000 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. unpow235.8%

        \[\leadsto 26623333280885244000 + 26623333280885244000 \cdot \color{blue}{\left(re \cdot re\right)} \]
    10. Simplified35.8%

      \[\leadsto \color{blue}{26623333280885244000 + 26623333280885244000 \cdot \left(re \cdot re\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification53.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -5 \cdot 10^{+166}:\\ \;\;\;\;re \cdot \left(re \cdot -0.5\right) + 1\\ \mathbf{elif}\;re \leq 1.1 \cdot 10^{+164}:\\ \;\;\;\;1 + 0.5 \cdot \left(im \cdot im\right)\\ \mathbf{elif}\;re \leq 7.2 \cdot 10^{+220}:\\ \;\;\;\;re \cdot \left(re \cdot -0.5\right) + 1\\ \mathbf{else}:\\ \;\;\;\;26623333280885244000 + \left(re \cdot re\right) \cdot 26623333280885244000\\ \end{array} \]

Alternative 12?

\[\begin{array}{l} \mathbf{if}\;im \leq -12.5 \lor \neg \left(im \leq 1.4\right):\\ \;\;\;\;0.5 \cdot \left(im \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if im < -12.5 or 1.3999999999999999 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 73.3%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left({im}^{2} + 0.08333333333333333 \cdot {im}^{4}\right)\right)} \]
    3. Step-by-step derivation
      1. unpow273.3%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(\color{blue}{im \cdot im} + 0.08333333333333333 \cdot {im}^{4}\right)\right) \]
      2. *-commutative73.3%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im + \color{blue}{{im}^{4} \cdot 0.08333333333333333}\right)\right) \]
    4. Simplified73.3%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im + {im}^{4} \cdot 0.08333333333333333\right)\right)} \]
    5. Applied egg-rr51.5%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im + \color{blue}{1.0833333333333333}\right)\right) \]
    6. Taylor expanded in re around 0 39.8%

      \[\leadsto \color{blue}{0.5 \cdot \left(3.0833333333333335 + {im}^{2}\right)} \]
    7. Taylor expanded in im around inf 39.8%

      \[\leadsto 0.5 \cdot \color{blue}{{im}^{2}} \]
    8. Step-by-step derivation
      1. unpow239.8%

        \[\leadsto 0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
    9. Simplified39.8%

      \[\leadsto 0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]

    if -12.5 < im < 1.3999999999999999

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 98.9%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left({im}^{2} + 0.08333333333333333 \cdot {im}^{4}\right)\right)} \]
    3. Step-by-step derivation
      1. unpow298.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(\color{blue}{im \cdot im} + 0.08333333333333333 \cdot {im}^{4}\right)\right) \]
      2. *-commutative98.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im + \color{blue}{{im}^{4} \cdot 0.08333333333333333}\right)\right) \]
    4. Simplified98.9%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im + {im}^{4} \cdot 0.08333333333333333\right)\right)} \]
    5. Applied egg-rr55.2%

      \[\leadsto \color{blue}{\frac{\cos re - 1.9380669946781485 \cdot 10^{-10} \cdot \cos re}{\cos re - 1.9380669946781485 \cdot 10^{-10} \cdot \cos re}} \]
    6. Step-by-step derivation
      1. *-inverses55.2%

        \[\leadsto \color{blue}{1} \]
    7. Simplified55.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -12.5 \lor \neg \left(im \leq 1.4\right):\\ \;\;\;\;0.5 \cdot \left(im \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 13?

\[\begin{array}{l} \mathbf{if}\;re \leq 1.7 \cdot 10^{+178}:\\ \;\;\;\;1 + 0.5 \cdot \left(im \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;26623333280885244000 + \left(re \cdot re\right) \cdot 26623333280885244000\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if re < 1.7000000000000001e178

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 76.4%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow276.4%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
    4. Simplified76.4%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
    5. Taylor expanded in re around 0 52.4%

      \[\leadsto \color{blue}{0.5 \cdot \left(2 + {im}^{2}\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-in52.4%

        \[\leadsto \color{blue}{0.5 \cdot 2 + 0.5 \cdot {im}^{2}} \]
      2. metadata-eval52.4%

        \[\leadsto \color{blue}{1} + 0.5 \cdot {im}^{2} \]
      3. unpow252.4%

        \[\leadsto 1 + 0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
    7. Simplified52.4%

      \[\leadsto \color{blue}{1 + 0.5 \cdot \left(im \cdot im\right)} \]

    if 1.7000000000000001e178 < re

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Taylor expanded in im around 0 79.4%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left({im}^{2} + 0.08333333333333333 \cdot {im}^{4}\right)\right)} \]
    3. Step-by-step derivation
      1. unpow279.4%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(\color{blue}{im \cdot im} + 0.08333333333333333 \cdot {im}^{4}\right)\right) \]
      2. *-commutative79.4%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im + \color{blue}{{im}^{4} \cdot 0.08333333333333333}\right)\right) \]
    4. Simplified79.4%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im + {im}^{4} \cdot 0.08333333333333333\right)\right)} \]
    5. Applied egg-rr3.7%

      \[\leadsto \color{blue}{{\left(1.9380669946781485 \cdot 10^{-10} \cdot \cos re\right)}^{-2}} \]
    6. Step-by-step derivation
      1. *-commutative3.7%

        \[\leadsto {\color{blue}{\left(\cos re \cdot 1.9380669946781485 \cdot 10^{-10}\right)}}^{-2} \]
    7. Simplified3.7%

      \[\leadsto \color{blue}{{\left(\cos re \cdot 1.9380669946781485 \cdot 10^{-10}\right)}^{-2}} \]
    8. Taylor expanded in re around 0 29.0%

      \[\leadsto \color{blue}{26623333280885244000 + 26623333280885244000 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. unpow229.0%

        \[\leadsto 26623333280885244000 + 26623333280885244000 \cdot \color{blue}{\left(re \cdot re\right)} \]
    10. Simplified29.0%

      \[\leadsto \color{blue}{26623333280885244000 + 26623333280885244000 \cdot \left(re \cdot re\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification49.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1.7 \cdot 10^{+178}:\\ \;\;\;\;1 + 0.5 \cdot \left(im \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;26623333280885244000 + \left(re \cdot re\right) \cdot 26623333280885244000\\ \end{array} \]

Alternative 14?

\[1 + 0.5 \cdot \left(im \cdot im\right) \]
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
  2. Taylor expanded in im around 0 75.3%

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
  3. Step-by-step derivation
    1. unpow275.3%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
  4. Simplified75.3%

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
  5. Taylor expanded in re around 0 47.9%

    \[\leadsto \color{blue}{0.5 \cdot \left(2 + {im}^{2}\right)} \]
  6. Step-by-step derivation
    1. distribute-lft-in47.9%

      \[\leadsto \color{blue}{0.5 \cdot 2 + 0.5 \cdot {im}^{2}} \]
    2. metadata-eval47.9%

      \[\leadsto \color{blue}{1} + 0.5 \cdot {im}^{2} \]
    3. unpow247.9%

      \[\leadsto 1 + 0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
  7. Simplified47.9%

    \[\leadsto \color{blue}{1 + 0.5 \cdot \left(im \cdot im\right)} \]
  8. Final simplification47.9%

    \[\leadsto 1 + 0.5 \cdot \left(im \cdot im\right) \]

Alternative 15?

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

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
  2. Taylor expanded in im around 0 75.3%

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
  3. Step-by-step derivation
    1. unpow275.3%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right) \]
  4. Simplified75.3%

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
  5. Applied egg-rr3.3%

    \[\leadsto \color{blue}{-2 + \cos re} \]
  6. Step-by-step derivation
    1. +-commutative3.3%

      \[\leadsto \color{blue}{\cos re + -2} \]
  7. Simplified3.3%

    \[\leadsto \color{blue}{\cos re + -2} \]
  8. Taylor expanded in re around 0 3.7%

    \[\leadsto \color{blue}{-1} \]
  9. Final simplification3.7%

    \[\leadsto -1 \]

Alternative 16?

\[1 \]
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
  2. Taylor expanded in im around 0 86.2%

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left({im}^{2} + 0.08333333333333333 \cdot {im}^{4}\right)\right)} \]
  3. Step-by-step derivation
    1. unpow286.2%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(\color{blue}{im \cdot im} + 0.08333333333333333 \cdot {im}^{4}\right)\right) \]
    2. *-commutative86.2%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im + \color{blue}{{im}^{4} \cdot 0.08333333333333333}\right)\right) \]
  4. Simplified86.2%

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im + {im}^{4} \cdot 0.08333333333333333\right)\right)} \]
  5. Applied egg-rr29.1%

    \[\leadsto \color{blue}{\frac{\cos re - 1.9380669946781485 \cdot 10^{-10} \cdot \cos re}{\cos re - 1.9380669946781485 \cdot 10^{-10} \cdot \cos re}} \]
  6. Step-by-step derivation
    1. *-inverses29.1%

      \[\leadsto \color{blue}{1} \]
  7. Simplified29.1%

    \[\leadsto \color{blue}{1} \]
  8. Final simplification29.1%

    \[\leadsto 1 \]

Reproduce

?
herbie shell --seed 2023166 
(FPCore (re im)
  :name "math.cos on complex, real part"
  :precision binary64
  (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))