math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 8.3s
Alternatives: 14
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
	return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im):
	return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\end{array}

Sampling outcomes in binary64 precision:

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 14 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.

Initial Program: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
	return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im):
	return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (sin re)) (+ (exp im) (exp (- im)))))
double code(double re, double im) {
	return (0.5 * sin(re)) * (exp(im) + exp(-im));
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * sin(re)) * (exp(im) + exp(-im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.sin(re)) * (Math.exp(im) + Math.exp(-im));
}
def code(re, im):
	return (0.5 * math.sin(re)) * (math.exp(im) + math.exp(-im))
function code(re, im)
	return Float64(Float64(0.5 * sin(re)) * Float64(exp(im) + exp(Float64(-im))))
end
function tmp = code(re, im)
	tmp = (0.5 * sin(re)) * (exp(im) + exp(-im));
end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)
\end{array}
Derivation
  1. Initial program 100.0%

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
    2. neg-sub0100.0%

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

    \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
  4. Add Preprocessing
  5. Final simplification100.0%

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right) \]
  6. Add Preprocessing

Alternative 2: 68.1% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 3.1 \cdot 10^{+19}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \sqrt{{im}^{4} \cdot 0.25}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 3.1e+19)
   (sin re)
   (if (<= im 1.15e+77)
     (+ re (* (pow re 3.0) -0.16666666666666666))
     (if (<= im 1.35e+154)
       (* re (sqrt (* (pow im 4.0) 0.25)))
       (* 0.5 (* (sin re) (pow im 2.0)))))))
double code(double re, double im) {
	double tmp;
	if (im <= 3.1e+19) {
		tmp = sin(re);
	} else if (im <= 1.15e+77) {
		tmp = re + (pow(re, 3.0) * -0.16666666666666666);
	} else if (im <= 1.35e+154) {
		tmp = re * sqrt((pow(im, 4.0) * 0.25));
	} else {
		tmp = 0.5 * (sin(re) * pow(im, 2.0));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 3.1d+19) then
        tmp = sin(re)
    else if (im <= 1.15d+77) then
        tmp = re + ((re ** 3.0d0) * (-0.16666666666666666d0))
    else if (im <= 1.35d+154) then
        tmp = re * sqrt(((im ** 4.0d0) * 0.25d0))
    else
        tmp = 0.5d0 * (sin(re) * (im ** 2.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 3.1e+19) {
		tmp = Math.sin(re);
	} else if (im <= 1.15e+77) {
		tmp = re + (Math.pow(re, 3.0) * -0.16666666666666666);
	} else if (im <= 1.35e+154) {
		tmp = re * Math.sqrt((Math.pow(im, 4.0) * 0.25));
	} else {
		tmp = 0.5 * (Math.sin(re) * Math.pow(im, 2.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 3.1e+19:
		tmp = math.sin(re)
	elif im <= 1.15e+77:
		tmp = re + (math.pow(re, 3.0) * -0.16666666666666666)
	elif im <= 1.35e+154:
		tmp = re * math.sqrt((math.pow(im, 4.0) * 0.25))
	else:
		tmp = 0.5 * (math.sin(re) * math.pow(im, 2.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 3.1e+19)
		tmp = sin(re);
	elseif (im <= 1.15e+77)
		tmp = Float64(re + Float64((re ^ 3.0) * -0.16666666666666666));
	elseif (im <= 1.35e+154)
		tmp = Float64(re * sqrt(Float64((im ^ 4.0) * 0.25)));
	else
		tmp = Float64(0.5 * Float64(sin(re) * (im ^ 2.0)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 3.1e+19)
		tmp = sin(re);
	elseif (im <= 1.15e+77)
		tmp = re + ((re ^ 3.0) * -0.16666666666666666);
	elseif (im <= 1.35e+154)
		tmp = re * sqrt(((im ^ 4.0) * 0.25));
	else
		tmp = 0.5 * (sin(re) * (im ^ 2.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 3.1e+19], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.15e+77], N[(re + N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(re * N[Sqrt[N[(N[Power[im, 4.0], $MachinePrecision] * 0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.1 \cdot 10^{+19}:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\

\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;re \cdot \sqrt{{im}^{4} \cdot 0.25}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < 3.1e19

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 69.3%

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

    if 3.1e19 < im < 1.14999999999999997e77

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 3.3%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left({im}^{2} + 2\right)} \]
      2. unpow23.3%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-define3.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(-0.08333333333333333 \cdot {re}^{3} + \color{blue}{0.5 \cdot re}\right) \]
    10. Simplified25.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(-0.08333333333333333 \cdot {re}^{3} + 0.5 \cdot re\right)} \]
    11. Taylor expanded in im around 0 24.9%

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

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

        \[\leadsto 2 \cdot \left(\color{blue}{re \cdot 0.5} + -0.08333333333333333 \cdot {re}^{3}\right) \]
      3. distribute-rgt-in24.9%

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

        \[\leadsto \color{blue}{re \cdot \left(0.5 \cdot 2\right)} + \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
      5. metadata-eval24.9%

        \[\leadsto re \cdot \color{blue}{1} + \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
      6. *-rgt-identity24.9%

        \[\leadsto \color{blue}{re} + \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
      7. *-commutative24.9%

        \[\leadsto re + \color{blue}{\left({re}^{3} \cdot -0.08333333333333333\right)} \cdot 2 \]
      8. associate-*l*24.9%

        \[\leadsto re + \color{blue}{{re}^{3} \cdot \left(-0.08333333333333333 \cdot 2\right)} \]
      9. metadata-eval24.9%

        \[\leadsto re + {re}^{3} \cdot \color{blue}{-0.16666666666666666} \]
    13. Simplified24.9%

      \[\leadsto \color{blue}{re + {re}^{3} \cdot -0.16666666666666666} \]

    if 1.14999999999999997e77 < im < 1.35000000000000003e154

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in re around 0 73.7%

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    8. Taylor expanded in im around 0 13.0%

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

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

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

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

      \[\leadsto \color{blue}{re \cdot \left(0.5 \cdot {im}^{2}\right)} \]
    12. Step-by-step derivation
      1. add-sqr-sqrt13.0%

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

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

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

        \[\leadsto re \cdot \sqrt{\left({im}^{2} \cdot 0.5\right) \cdot \color{blue}{\left({im}^{2} \cdot 0.5\right)}} \]
      5. swap-sqr73.7%

        \[\leadsto re \cdot \sqrt{\color{blue}{\left({im}^{2} \cdot {im}^{2}\right) \cdot \left(0.5 \cdot 0.5\right)}} \]
      6. pow-prod-up73.7%

        \[\leadsto re \cdot \sqrt{\color{blue}{{im}^{\left(2 + 2\right)}} \cdot \left(0.5 \cdot 0.5\right)} \]
      7. metadata-eval73.7%

        \[\leadsto re \cdot \sqrt{{im}^{\color{blue}{4}} \cdot \left(0.5 \cdot 0.5\right)} \]
      8. metadata-eval73.7%

        \[\leadsto re \cdot \sqrt{{im}^{4} \cdot \color{blue}{0.25}} \]
    13. Applied egg-rr73.7%

      \[\leadsto re \cdot \color{blue}{\sqrt{{im}^{4} \cdot 0.25}} \]

    if 1.35000000000000003e154 < im

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 100.0%

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-define100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    7. Simplified100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    8. Taylor expanded in im around inf 100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.1 \cdot 10^{+19}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \sqrt{{im}^{4} \cdot 0.25}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 79.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 5.2 \cdot 10^{+19}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{elif}\;im \leq 1.16 \cdot 10^{+77}:\\ \;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+152}:\\ \;\;\;\;re \cdot \sqrt{{im}^{4} \cdot 0.25}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 5.2e+19)
   (* (* 0.5 (sin re)) (fma im im 2.0))
   (if (<= im 1.16e+77)
     (+ re (* (pow re 3.0) -0.16666666666666666))
     (if (<= im 5e+152)
       (* re (sqrt (* (pow im 4.0) 0.25)))
       (* 0.5 (* (sin re) (pow im 2.0)))))))
double code(double re, double im) {
	double tmp;
	if (im <= 5.2e+19) {
		tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
	} else if (im <= 1.16e+77) {
		tmp = re + (pow(re, 3.0) * -0.16666666666666666);
	} else if (im <= 5e+152) {
		tmp = re * sqrt((pow(im, 4.0) * 0.25));
	} else {
		tmp = 0.5 * (sin(re) * pow(im, 2.0));
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= 5.2e+19)
		tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0));
	elseif (im <= 1.16e+77)
		tmp = Float64(re + Float64((re ^ 3.0) * -0.16666666666666666));
	elseif (im <= 5e+152)
		tmp = Float64(re * sqrt(Float64((im ^ 4.0) * 0.25)));
	else
		tmp = Float64(0.5 * Float64(sin(re) * (im ^ 2.0)));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 5.2e+19], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.16e+77], N[(re + N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5e+152], N[(re * N[Sqrt[N[(N[Power[im, 4.0], $MachinePrecision] * 0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.2 \cdot 10^{+19}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\

\mathbf{elif}\;im \leq 1.16 \cdot 10^{+77}:\\
\;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\

\mathbf{elif}\;im \leq 5 \cdot 10^{+152}:\\
\;\;\;\;re \cdot \sqrt{{im}^{4} \cdot 0.25}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < 5.2e19

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 81.7%

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    7. Simplified81.7%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]

    if 5.2e19 < im < 1.1600000000000001e77

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 3.3%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left({im}^{2} + 2\right)} \]
      2. unpow23.3%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-define3.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(im, im, 2\right) \cdot \left(-0.08333333333333333 \cdot {re}^{3} + \color{blue}{0.5 \cdot re}\right) \]
    10. Simplified25.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(-0.08333333333333333 \cdot {re}^{3} + 0.5 \cdot re\right)} \]
    11. Taylor expanded in im around 0 24.9%

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

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

        \[\leadsto 2 \cdot \left(\color{blue}{re \cdot 0.5} + -0.08333333333333333 \cdot {re}^{3}\right) \]
      3. distribute-rgt-in24.9%

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

        \[\leadsto \color{blue}{re \cdot \left(0.5 \cdot 2\right)} + \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
      5. metadata-eval24.9%

        \[\leadsto re \cdot \color{blue}{1} + \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
      6. *-rgt-identity24.9%

        \[\leadsto \color{blue}{re} + \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
      7. *-commutative24.9%

        \[\leadsto re + \color{blue}{\left({re}^{3} \cdot -0.08333333333333333\right)} \cdot 2 \]
      8. associate-*l*24.9%

        \[\leadsto re + \color{blue}{{re}^{3} \cdot \left(-0.08333333333333333 \cdot 2\right)} \]
      9. metadata-eval24.9%

        \[\leadsto re + {re}^{3} \cdot \color{blue}{-0.16666666666666666} \]
    13. Simplified24.9%

      \[\leadsto \color{blue}{re + {re}^{3} \cdot -0.16666666666666666} \]

    if 1.1600000000000001e77 < im < 5e152

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in re around 0 73.7%

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    8. Taylor expanded in im around 0 13.0%

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

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

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

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

      \[\leadsto \color{blue}{re \cdot \left(0.5 \cdot {im}^{2}\right)} \]
    12. Step-by-step derivation
      1. add-sqr-sqrt13.0%

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

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

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

        \[\leadsto re \cdot \sqrt{\left({im}^{2} \cdot 0.5\right) \cdot \color{blue}{\left({im}^{2} \cdot 0.5\right)}} \]
      5. swap-sqr73.7%

        \[\leadsto re \cdot \sqrt{\color{blue}{\left({im}^{2} \cdot {im}^{2}\right) \cdot \left(0.5 \cdot 0.5\right)}} \]
      6. pow-prod-up73.7%

        \[\leadsto re \cdot \sqrt{\color{blue}{{im}^{\left(2 + 2\right)}} \cdot \left(0.5 \cdot 0.5\right)} \]
      7. metadata-eval73.7%

        \[\leadsto re \cdot \sqrt{{im}^{\color{blue}{4}} \cdot \left(0.5 \cdot 0.5\right)} \]
      8. metadata-eval73.7%

        \[\leadsto re \cdot \sqrt{{im}^{4} \cdot \color{blue}{0.25}} \]
    13. Applied egg-rr73.7%

      \[\leadsto re \cdot \color{blue}{\sqrt{{im}^{4} \cdot 0.25}} \]

    if 5e152 < im

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 100.0%

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-define100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    7. Simplified100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    8. Taylor expanded in im around inf 100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 5.2 \cdot 10^{+19}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{elif}\;im \leq 1.16 \cdot 10^{+77}:\\ \;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+152}:\\ \;\;\;\;re \cdot \sqrt{{im}^{4} \cdot 0.25}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 74.3% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 5.6 \cdot 10^{-8}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+51}:\\ \;\;\;\;\left(e^{im} + e^{-im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;12 + \sin re \cdot \left(0.001388888888888889 \cdot {im}^{6} + 1\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 5.6e-8)
   (sin re)
   (if (<= im 2e+51)
     (* (+ (exp im) (exp (- im))) (* 0.5 re))
     (+ 12.0 (* (sin re) (+ (* 0.001388888888888889 (pow im 6.0)) 1.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= 5.6e-8) {
		tmp = sin(re);
	} else if (im <= 2e+51) {
		tmp = (exp(im) + exp(-im)) * (0.5 * re);
	} else {
		tmp = 12.0 + (sin(re) * ((0.001388888888888889 * pow(im, 6.0)) + 1.0));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 5.6d-8) then
        tmp = sin(re)
    else if (im <= 2d+51) then
        tmp = (exp(im) + exp(-im)) * (0.5d0 * re)
    else
        tmp = 12.0d0 + (sin(re) * ((0.001388888888888889d0 * (im ** 6.0d0)) + 1.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 5.6e-8) {
		tmp = Math.sin(re);
	} else if (im <= 2e+51) {
		tmp = (Math.exp(im) + Math.exp(-im)) * (0.5 * re);
	} else {
		tmp = 12.0 + (Math.sin(re) * ((0.001388888888888889 * Math.pow(im, 6.0)) + 1.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 5.6e-8:
		tmp = math.sin(re)
	elif im <= 2e+51:
		tmp = (math.exp(im) + math.exp(-im)) * (0.5 * re)
	else:
		tmp = 12.0 + (math.sin(re) * ((0.001388888888888889 * math.pow(im, 6.0)) + 1.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 5.6e-8)
		tmp = sin(re);
	elseif (im <= 2e+51)
		tmp = Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(0.5 * re));
	else
		tmp = Float64(12.0 + Float64(sin(re) * Float64(Float64(0.001388888888888889 * (im ^ 6.0)) + 1.0)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 5.6e-8)
		tmp = sin(re);
	elseif (im <= 2e+51)
		tmp = (exp(im) + exp(-im)) * (0.5 * re);
	else
		tmp = 12.0 + (sin(re) * ((0.001388888888888889 * (im ^ 6.0)) + 1.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 5.6e-8], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2e+51], N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(12.0 + N[(N[Sin[re], $MachinePrecision] * N[(N[(0.001388888888888889 * N[Power[im, 6.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.6 \cdot 10^{-8}:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 2 \cdot 10^{+51}:\\
\;\;\;\;\left(e^{im} + e^{-im}\right) \cdot \left(0.5 \cdot re\right)\\

\mathbf{else}:\\
\;\;\;\;12 + \sin re \cdot \left(0.001388888888888889 \cdot {im}^{6} + 1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 5.5999999999999999e-8

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 70.7%

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

    if 5.5999999999999999e-8 < im < 2e51

    1. Initial program 99.7%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub099.7%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{\color{blue}{-im}}\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in re around 0 78.2%

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

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

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

    if 2e51 < im

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 100.0%

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

        \[\leadsto \color{blue}{\left(\sin re + 0.001388888888888889 \cdot \left({im}^{6} \cdot \sin re\right)\right) + \left(0.041666666666666664 \cdot \left({im}^{4} \cdot \sin re\right) + 0.5 \cdot \left({im}^{2} \cdot \sin re\right)\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{\left(0.041666666666666664 \cdot \left({im}^{4} \cdot \sin re\right) + 0.5 \cdot \left({im}^{2} \cdot \sin re\right)\right) + \left(\sin re + 0.001388888888888889 \cdot \left({im}^{6} \cdot \sin re\right)\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \left(\color{blue}{\left(0.041666666666666664 \cdot {im}^{4}\right) \cdot \sin re} + 0.5 \cdot \left({im}^{2} \cdot \sin re\right)\right) + \left(\sin re + 0.001388888888888889 \cdot \left({im}^{6} \cdot \sin re\right)\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(\left(0.041666666666666664 \cdot {im}^{4}\right) \cdot \sin re + \color{blue}{\left(0.5 \cdot {im}^{2}\right) \cdot \sin re}\right) + \left(\sin re + 0.001388888888888889 \cdot \left({im}^{6} \cdot \sin re\right)\right) \]
      5. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(0.041666666666666664 \cdot {im}^{4} + 0.5 \cdot {im}^{2}\right)} + \left(\sin re + 0.001388888888888889 \cdot \left({im}^{6} \cdot \sin re\right)\right) \]
      6. associate-*r*100.0%

        \[\leadsto \sin re \cdot \left(0.041666666666666664 \cdot {im}^{4} + 0.5 \cdot {im}^{2}\right) + \left(\sin re + \color{blue}{\left(0.001388888888888889 \cdot {im}^{6}\right) \cdot \sin re}\right) \]
      7. distribute-rgt1-in100.0%

        \[\leadsto \sin re \cdot \left(0.041666666666666664 \cdot {im}^{4} + 0.5 \cdot {im}^{2}\right) + \color{blue}{\left(0.001388888888888889 \cdot {im}^{6} + 1\right) \cdot \sin re} \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.041666666666666664 \cdot {im}^{4} + 0.5 \cdot {im}^{2}\right) + \left(0.001388888888888889 \cdot {im}^{6} + 1\right) \cdot \sin re} \]
    8. Applied egg-rr100.0%

      \[\leadsto \color{blue}{12} + \left(0.001388888888888889 \cdot {im}^{6} + 1\right) \cdot \sin re \]
  3. Recombined 3 regimes into one program.
  4. Final simplification77.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 5.6 \cdot 10^{-8}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+51}:\\ \;\;\;\;\left(e^{im} + e^{-im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;12 + \sin re \cdot \left(0.001388888888888889 \cdot {im}^{6} + 1\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 72.1% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 5.6 \cdot 10^{-8}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(e^{im} + e^{-im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 5.6e-8)
   (sin re)
   (if (<= im 1.35e+154)
     (* (+ (exp im) (exp (- im))) (* 0.5 re))
     (* 0.5 (* (sin re) (pow im 2.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= 5.6e-8) {
		tmp = sin(re);
	} else if (im <= 1.35e+154) {
		tmp = (exp(im) + exp(-im)) * (0.5 * re);
	} else {
		tmp = 0.5 * (sin(re) * pow(im, 2.0));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 5.6d-8) then
        tmp = sin(re)
    else if (im <= 1.35d+154) then
        tmp = (exp(im) + exp(-im)) * (0.5d0 * re)
    else
        tmp = 0.5d0 * (sin(re) * (im ** 2.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 5.6e-8) {
		tmp = Math.sin(re);
	} else if (im <= 1.35e+154) {
		tmp = (Math.exp(im) + Math.exp(-im)) * (0.5 * re);
	} else {
		tmp = 0.5 * (Math.sin(re) * Math.pow(im, 2.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 5.6e-8:
		tmp = math.sin(re)
	elif im <= 1.35e+154:
		tmp = (math.exp(im) + math.exp(-im)) * (0.5 * re)
	else:
		tmp = 0.5 * (math.sin(re) * math.pow(im, 2.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 5.6e-8)
		tmp = sin(re);
	elseif (im <= 1.35e+154)
		tmp = Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(0.5 * re));
	else
		tmp = Float64(0.5 * Float64(sin(re) * (im ^ 2.0)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 5.6e-8)
		tmp = sin(re);
	elseif (im <= 1.35e+154)
		tmp = (exp(im) + exp(-im)) * (0.5 * re);
	else
		tmp = 0.5 * (sin(re) * (im ^ 2.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 5.6e-8], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.6 \cdot 10^{-8}:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(e^{im} + e^{-im}\right) \cdot \left(0.5 \cdot re\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 5.5999999999999999e-8

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 70.7%

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

    if 5.5999999999999999e-8 < im < 1.35000000000000003e154

    1. Initial program 99.9%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub099.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{\color{blue}{-im}}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in re around 0 77.4%

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

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

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

    if 1.35000000000000003e154 < im

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 100.0%

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-define100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    7. Simplified100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    8. Taylor expanded in im around inf 100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 5.6 \cdot 10^{-8}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(e^{im} + e^{-im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 64.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 2.7 \cdot 10^{+19}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.15 \cdot 10^{+149}:\\ \;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 2.7e+19)
   (sin re)
   (if (<= im 3.15e+149)
     (+ re (* (pow re 3.0) -0.16666666666666666))
     (* 0.5 (* (sin re) (pow im 2.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= 2.7e+19) {
		tmp = sin(re);
	} else if (im <= 3.15e+149) {
		tmp = re + (pow(re, 3.0) * -0.16666666666666666);
	} else {
		tmp = 0.5 * (sin(re) * pow(im, 2.0));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 2.7d+19) then
        tmp = sin(re)
    else if (im <= 3.15d+149) then
        tmp = re + ((re ** 3.0d0) * (-0.16666666666666666d0))
    else
        tmp = 0.5d0 * (sin(re) * (im ** 2.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 2.7e+19) {
		tmp = Math.sin(re);
	} else if (im <= 3.15e+149) {
		tmp = re + (Math.pow(re, 3.0) * -0.16666666666666666);
	} else {
		tmp = 0.5 * (Math.sin(re) * Math.pow(im, 2.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 2.7e+19:
		tmp = math.sin(re)
	elif im <= 3.15e+149:
		tmp = re + (math.pow(re, 3.0) * -0.16666666666666666)
	else:
		tmp = 0.5 * (math.sin(re) * math.pow(im, 2.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 2.7e+19)
		tmp = sin(re);
	elseif (im <= 3.15e+149)
		tmp = Float64(re + Float64((re ^ 3.0) * -0.16666666666666666));
	else
		tmp = Float64(0.5 * Float64(sin(re) * (im ^ 2.0)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 2.7e+19)
		tmp = sin(re);
	elseif (im <= 3.15e+149)
		tmp = re + ((re ^ 3.0) * -0.16666666666666666);
	else
		tmp = 0.5 * (sin(re) * (im ^ 2.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 2.7e+19], N[Sin[re], $MachinePrecision], If[LessEqual[im, 3.15e+149], N[(re + N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.7 \cdot 10^{+19}:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 3.15 \cdot 10^{+149}:\\
\;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 2.7e19

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 69.3%

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

    if 2.7e19 < im < 3.15e149

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 4.4%

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-define4.4%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    7. Simplified4.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(-0.08333333333333333 \cdot {re}^{3} + 0.5 \cdot re\right)} \]
    11. Taylor expanded in im around 0 21.2%

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

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

        \[\leadsto 2 \cdot \left(\color{blue}{re \cdot 0.5} + -0.08333333333333333 \cdot {re}^{3}\right) \]
      3. distribute-rgt-in21.2%

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

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

        \[\leadsto re \cdot \color{blue}{1} + \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
      6. *-rgt-identity21.2%

        \[\leadsto \color{blue}{re} + \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
      7. *-commutative21.2%

        \[\leadsto re + \color{blue}{\left({re}^{3} \cdot -0.08333333333333333\right)} \cdot 2 \]
      8. associate-*l*21.2%

        \[\leadsto re + \color{blue}{{re}^{3} \cdot \left(-0.08333333333333333 \cdot 2\right)} \]
      9. metadata-eval21.2%

        \[\leadsto re + {re}^{3} \cdot \color{blue}{-0.16666666666666666} \]
    13. Simplified21.2%

      \[\leadsto \color{blue}{re + {re}^{3} \cdot -0.16666666666666666} \]

    if 3.15e149 < im

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 97.2%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left({im}^{2} + 2\right)} \]
      2. unpow297.2%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-define97.2%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    7. Simplified97.2%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    8. Taylor expanded in im around inf 97.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.7 \cdot 10^{+19}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.15 \cdot 10^{+149}:\\ \;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 61.9% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 2.7 \cdot 10^{+19}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 2.5 \cdot 10^{+117}:\\ \;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 2.7e+19)
   (sin re)
   (if (<= im 2.5e+117)
     (+ re (* (pow re 3.0) -0.16666666666666666))
     (* (* 0.5 re) (fma im im 2.0)))))
double code(double re, double im) {
	double tmp;
	if (im <= 2.7e+19) {
		tmp = sin(re);
	} else if (im <= 2.5e+117) {
		tmp = re + (pow(re, 3.0) * -0.16666666666666666);
	} else {
		tmp = (0.5 * re) * fma(im, im, 2.0);
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= 2.7e+19)
		tmp = sin(re);
	elseif (im <= 2.5e+117)
		tmp = Float64(re + Float64((re ^ 3.0) * -0.16666666666666666));
	else
		tmp = Float64(Float64(0.5 * re) * fma(im, im, 2.0));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 2.7e+19], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.5e+117], N[(re + N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.7 \cdot 10^{+19}:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 2.5 \cdot 10^{+117}:\\
\;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\

\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 2.7e19

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 69.3%

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

    if 2.7e19 < im < 2.49999999999999992e117

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 3.7%

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    7. Simplified3.7%

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

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

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

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

        \[\leadsto \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot \left(2 + {im}^{2}\right) + \color{blue}{\left(re \cdot 0.5\right)} \cdot \left(2 + {im}^{2}\right) \]
      4. distribute-rgt-out23.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(-0.08333333333333333 \cdot {re}^{3} + 0.5 \cdot re\right)} \]
    11. Taylor expanded in im around 0 22.7%

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

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

        \[\leadsto 2 \cdot \left(\color{blue}{re \cdot 0.5} + -0.08333333333333333 \cdot {re}^{3}\right) \]
      3. distribute-rgt-in22.7%

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

        \[\leadsto \color{blue}{re \cdot \left(0.5 \cdot 2\right)} + \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
      5. metadata-eval22.7%

        \[\leadsto re \cdot \color{blue}{1} + \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
      6. *-rgt-identity22.7%

        \[\leadsto \color{blue}{re} + \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
      7. *-commutative22.7%

        \[\leadsto re + \color{blue}{\left({re}^{3} \cdot -0.08333333333333333\right)} \cdot 2 \]
      8. associate-*l*22.7%

        \[\leadsto re + \color{blue}{{re}^{3} \cdot \left(-0.08333333333333333 \cdot 2\right)} \]
      9. metadata-eval22.7%

        \[\leadsto re + {re}^{3} \cdot \color{blue}{-0.16666666666666666} \]
    13. Simplified22.7%

      \[\leadsto \color{blue}{re + {re}^{3} \cdot -0.16666666666666666} \]

    if 2.49999999999999992e117 < im

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in re around 0 75.6%

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    8. Taylor expanded in im around 0 66.3%

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    10. Simplified66.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.7 \cdot 10^{+19}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 2.5 \cdot 10^{+117}:\\ \;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 61.9% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 2.7 \cdot 10^{+19}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.8 \cdot 10^{+118}:\\ \;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 2.7e+19)
   (sin re)
   (if (<= im 3.8e+118)
     (+ re (* (pow re 3.0) -0.16666666666666666))
     (* re (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= 2.7e+19) {
		tmp = sin(re);
	} else if (im <= 3.8e+118) {
		tmp = re + (pow(re, 3.0) * -0.16666666666666666);
	} else {
		tmp = re * (0.5 * pow(im, 2.0));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 2.7d+19) then
        tmp = sin(re)
    else if (im <= 3.8d+118) then
        tmp = re + ((re ** 3.0d0) * (-0.16666666666666666d0))
    else
        tmp = re * (0.5d0 * (im ** 2.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 2.7e+19) {
		tmp = Math.sin(re);
	} else if (im <= 3.8e+118) {
		tmp = re + (Math.pow(re, 3.0) * -0.16666666666666666);
	} else {
		tmp = re * (0.5 * Math.pow(im, 2.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 2.7e+19:
		tmp = math.sin(re)
	elif im <= 3.8e+118:
		tmp = re + (math.pow(re, 3.0) * -0.16666666666666666)
	else:
		tmp = re * (0.5 * math.pow(im, 2.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 2.7e+19)
		tmp = sin(re);
	elseif (im <= 3.8e+118)
		tmp = Float64(re + Float64((re ^ 3.0) * -0.16666666666666666));
	else
		tmp = Float64(re * Float64(0.5 * (im ^ 2.0)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 2.7e+19)
		tmp = sin(re);
	elseif (im <= 3.8e+118)
		tmp = re + ((re ^ 3.0) * -0.16666666666666666);
	else
		tmp = re * (0.5 * (im ^ 2.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 2.7e+19], N[Sin[re], $MachinePrecision], If[LessEqual[im, 3.8e+118], N[(re + N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.7 \cdot 10^{+19}:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 3.8 \cdot 10^{+118}:\\
\;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\

\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 2.7e19

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 69.3%

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

    if 2.7e19 < im < 3.80000000000000016e118

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 3.7%

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    7. Simplified3.7%

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

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

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

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

        \[\leadsto \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot \left(2 + {im}^{2}\right) + \color{blue}{\left(re \cdot 0.5\right)} \cdot \left(2 + {im}^{2}\right) \]
      4. distribute-rgt-out23.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(im, im, 2\right) \cdot \left(-0.08333333333333333 \cdot {re}^{3} + 0.5 \cdot re\right)} \]
    11. Taylor expanded in im around 0 22.7%

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

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

        \[\leadsto 2 \cdot \left(\color{blue}{re \cdot 0.5} + -0.08333333333333333 \cdot {re}^{3}\right) \]
      3. distribute-rgt-in22.7%

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

        \[\leadsto \color{blue}{re \cdot \left(0.5 \cdot 2\right)} + \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
      5. metadata-eval22.7%

        \[\leadsto re \cdot \color{blue}{1} + \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
      6. *-rgt-identity22.7%

        \[\leadsto \color{blue}{re} + \left(-0.08333333333333333 \cdot {re}^{3}\right) \cdot 2 \]
      7. *-commutative22.7%

        \[\leadsto re + \color{blue}{\left({re}^{3} \cdot -0.08333333333333333\right)} \cdot 2 \]
      8. associate-*l*22.7%

        \[\leadsto re + \color{blue}{{re}^{3} \cdot \left(-0.08333333333333333 \cdot 2\right)} \]
      9. metadata-eval22.7%

        \[\leadsto re + {re}^{3} \cdot \color{blue}{-0.16666666666666666} \]
    13. Simplified22.7%

      \[\leadsto \color{blue}{re + {re}^{3} \cdot -0.16666666666666666} \]

    if 3.80000000000000016e118 < im

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in re around 0 75.6%

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    8. Taylor expanded in im around 0 66.3%

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot {im}^{2}\right) \cdot re} \]
      2. *-commutative66.3%

        \[\leadsto \color{blue}{re \cdot \left(0.5 \cdot {im}^{2}\right)} \]
    11. Simplified66.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.7 \cdot 10^{+19}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.8 \cdot 10^{+118}:\\ \;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 61.3% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 6.4 \cdot 10^{+36}:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 6.4e+36) (sin re) (* re (* 0.5 (pow im 2.0)))))
double code(double re, double im) {
	double tmp;
	if (im <= 6.4e+36) {
		tmp = sin(re);
	} else {
		tmp = re * (0.5 * pow(im, 2.0));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 6.4d+36) then
        tmp = sin(re)
    else
        tmp = re * (0.5d0 * (im ** 2.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 6.4e+36) {
		tmp = Math.sin(re);
	} else {
		tmp = re * (0.5 * Math.pow(im, 2.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 6.4e+36:
		tmp = math.sin(re)
	else:
		tmp = re * (0.5 * math.pow(im, 2.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 6.4e+36)
		tmp = sin(re);
	else
		tmp = Float64(re * Float64(0.5 * (im ^ 2.0)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 6.4e+36)
		tmp = sin(re);
	else
		tmp = re * (0.5 * (im ^ 2.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 6.4e+36], N[Sin[re], $MachinePrecision], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 6.4 \cdot 10^{+36}:\\
\;\;\;\;\sin re\\

\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 6.3999999999999998e36

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 67.6%

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

    if 6.3999999999999998e36 < im

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in re around 0 76.7%

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    8. Taylor expanded in im around 0 47.8%

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot {im}^{2}\right) \cdot re} \]
      2. *-commutative47.8%

        \[\leadsto \color{blue}{re \cdot \left(0.5 \cdot {im}^{2}\right)} \]
    11. Simplified47.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 6.4 \cdot 10^{+36}:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 50.8% accurate, 3.1× speedup?

\[\begin{array}{l} \\ \sin re \end{array} \]
(FPCore (re im) :precision binary64 (sin re))
double code(double re, double im) {
	return sin(re);
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = sin(re)
end function
public static double code(double re, double im) {
	return Math.sin(re);
}
def code(re, im):
	return math.sin(re)
function code(re, im)
	return sin(re)
end
function tmp = code(re, im)
	tmp = sin(re);
end
code[re_, im_] := N[Sin[re], $MachinePrecision]
\begin{array}{l}

\\
\sin re
\end{array}
Derivation
  1. Initial program 100.0%

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
    2. neg-sub0100.0%

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

    \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in im around 0 52.4%

    \[\leadsto \color{blue}{\sin re} \]
  6. Final simplification52.4%

    \[\leadsto \sin re \]
  7. Add Preprocessing

Alternative 11: 27.0% accurate, 51.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 0.5:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \end{array} \]
(FPCore (re im) :precision binary64 (if (<= re 0.5) re 0.5))
double code(double re, double im) {
	double tmp;
	if (re <= 0.5) {
		tmp = re;
	} else {
		tmp = 0.5;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 0.5d0) then
        tmp = re
    else
        tmp = 0.5d0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 0.5) {
		tmp = re;
	} else {
		tmp = 0.5;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 0.5:
		tmp = re
	else:
		tmp = 0.5
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 0.5)
		tmp = re;
	else
		tmp = 0.5;
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 0.5)
		tmp = re;
	else
		tmp = 0.5;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 0.5], re, 0.5]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.5:\\
\;\;\;\;re\\

\mathbf{else}:\\
\;\;\;\;0.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 0.5

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in re around 0 76.6%

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    8. Taylor expanded in im around 0 32.3%

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

    if 0.5 < re

    1. Initial program 100.0%

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
      2. neg-sub0100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
    4. Add Preprocessing
    5. Applied egg-rr7.2%

      \[\leadsto \color{blue}{0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification25.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 0.5:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 2.9% accurate, 309.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (re im) :precision binary64 0.0)
double code(double re, double im) {
	return 0.0;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = 0.0d0
end function
public static double code(double re, double im) {
	return 0.0;
}
def code(re, im):
	return 0.0
function code(re, im)
	return 0.0
end
function tmp = code(re, im)
	tmp = 0.0;
end
code[re_, im_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 100.0%

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
    2. neg-sub0100.0%

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

    \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
  4. Add Preprocessing
  5. Applied egg-rr2.7%

    \[\leadsto \color{blue}{0} \]
  6. Final simplification2.7%

    \[\leadsto 0 \]
  7. Add Preprocessing

Alternative 13: 4.4% accurate, 309.0× speedup?

\[\begin{array}{l} \\ 0.25 \end{array} \]
(FPCore (re im) :precision binary64 0.25)
double code(double re, double im) {
	return 0.25;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = 0.25d0
end function
public static double code(double re, double im) {
	return 0.25;
}
def code(re, im):
	return 0.25
function code(re, im)
	return 0.25
end
function tmp = code(re, im)
	tmp = 0.25;
end
code[re_, im_] := 0.25
\begin{array}{l}

\\
0.25
\end{array}
Derivation
  1. Initial program 100.0%

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
    2. neg-sub0100.0%

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

    \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
  4. Add Preprocessing
  5. Applied egg-rr4.6%

    \[\leadsto \color{blue}{0.25} \]
  6. Final simplification4.6%

    \[\leadsto 0.25 \]
  7. Add Preprocessing

Alternative 14: 4.6% accurate, 309.0× speedup?

\[\begin{array}{l} \\ 0.5 \end{array} \]
(FPCore (re im) :precision binary64 0.5)
double code(double re, double im) {
	return 0.5;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = 0.5d0
end function
public static double code(double re, double im) {
	return 0.5;
}
def code(re, im):
	return 0.5
function code(re, im)
	return 0.5
end
function tmp = code(re, im)
	tmp = 0.5;
end
code[re_, im_] := 0.5
\begin{array}{l}

\\
0.5
\end{array}
Derivation
  1. Initial program 100.0%

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{im} + e^{0 - im}\right)} \]
    2. neg-sub0100.0%

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

    \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)} \]
  4. Add Preprocessing
  5. Applied egg-rr4.7%

    \[\leadsto \color{blue}{0.5} \]
  6. Final simplification4.7%

    \[\leadsto 0.5 \]
  7. Add Preprocessing

Reproduce

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