
(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:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (re im) :precision binary64 (* (cosh im) (sin re)))
double code(double re, double im) {
return cosh(im) * sin(re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = cosh(im) * sin(re)
end function
public static double code(double re, double im) {
return Math.cosh(im) * Math.sin(re);
}
def code(re, im): return math.cosh(im) * math.sin(re)
function code(re, im) return Float64(cosh(im) * sin(re)) end
function tmp = code(re, im) tmp = cosh(im) * sin(re); end
code[re_, im_] := N[(N[Cosh[im], $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cosh im \cdot \sin re
\end{array}
Initial program 99.6%
/-rgt-identityN/A
exp-0N/A
clear-numN/A
exp-0N/A
lift-exp.f64N/A
exp-diffN/A
lift--.f64N/A
lift-exp.f64N/A
lower-/.f64N/A
exp-099.6
lift--.f64N/A
sub0-negN/A
lower-neg.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
lift-/.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
remove-double-divN/A
distribute-rgt-inN/A
lift-exp.f64N/A
lift--.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites99.6%
Final simplification99.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))) (t_1 (* (+ (exp im) (exp (- im))) t_0)))
(if (<= t_1 (- INFINITY))
(* (* (* (* re re) -0.08333333333333333) re) (fma im im 2.0))
(if (<= t_1 1.0)
(* t_0 (fma im im 2.0))
(*
(fma (pow im 4.0) 0.08333333333333333 (fma im im 2.0))
(* 0.5 re))))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double t_1 = (exp(im) + exp(-im)) * t_0;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (((re * re) * -0.08333333333333333) * re) * fma(im, im, 2.0);
} else if (t_1 <= 1.0) {
tmp = t_0 * fma(im, im, 2.0);
} else {
tmp = fma(pow(im, 4.0), 0.08333333333333333, fma(im, im, 2.0)) * (0.5 * re);
}
return tmp;
}
function code(re, im) t_0 = Float64(0.5 * sin(re)) t_1 = Float64(Float64(exp(im) + exp(Float64(-im))) * t_0) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(Float64(Float64(re * re) * -0.08333333333333333) * re) * fma(im, im, 2.0)); elseif (t_1 <= 1.0) tmp = Float64(t_0 * fma(im, im, 2.0)); else tmp = Float64(fma((im ^ 4.0), 0.08333333333333333, fma(im, im, 2.0)) * Float64(0.5 * re)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1.0], N[(t$95$0 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[im, 4.0], $MachinePrecision] * 0.08333333333333333 + N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
t_1 := \left(e^{im} + e^{-im}\right) \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{elif}\;t\_1 \leq 1:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({im}^{4}, 0.08333333333333333, \mathsf{fma}\left(im, im, 2\right)\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -inf.0Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6448.5
Applied rewrites48.5%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6447.1
Applied rewrites47.1%
Taylor expanded in re around inf
Applied rewrites19.7%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 1Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6499.4
Applied rewrites99.4%
if 1 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 98.6%
Taylor expanded in im around 0
Applied rewrites2.7%
Taylor expanded in re around 0
lower-*.f642.5
Applied rewrites2.5%
Taylor expanded in im around 0
distribute-lft-inN/A
*-rgt-identityN/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
pow-sqrN/A
metadata-evalN/A
lower-pow.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f6457.2
Applied rewrites57.2%
Final simplification67.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (+ (exp im) (exp (- im))) (* 0.5 (sin re)))))
(if (<= t_0 (- INFINITY))
(* (* (* (* re re) -0.08333333333333333) re) (fma im im 2.0))
(if (<= t_0 1.0)
(* 1.0 (sin re))
(*
(*
(fma
(fma 0.004166666666666667 (* re re) -0.08333333333333333)
(* re re)
0.5)
re)
(fma im im 2.0))))))
double code(double re, double im) {
double t_0 = (exp(im) + exp(-im)) * (0.5 * sin(re));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (((re * re) * -0.08333333333333333) * re) * fma(im, im, 2.0);
} else if (t_0 <= 1.0) {
tmp = 1.0 * sin(re);
} else {
tmp = (fma(fma(0.004166666666666667, (re * re), -0.08333333333333333), (re * re), 0.5) * re) * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(0.5 * sin(re))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(Float64(Float64(re * re) * -0.08333333333333333) * re) * fma(im, im, 2.0)); elseif (t_0 <= 1.0) tmp = Float64(1.0 * sin(re)); else tmp = Float64(Float64(fma(fma(0.004166666666666667, Float64(re * re), -0.08333333333333333), Float64(re * re), 0.5) * re) * fma(im, im, 2.0)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(1.0 * N[Sin[re], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.004166666666666667 * N[(re * re), $MachinePrecision] + -0.08333333333333333), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{im} + e^{-im}\right) \cdot \left(0.5 \cdot \sin re\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;1 \cdot \sin re\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(0.004166666666666667, re \cdot re, -0.08333333333333333\right), re \cdot re, 0.5\right) \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -inf.0Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6448.5
Applied rewrites48.5%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6447.1
Applied rewrites47.1%
Taylor expanded in re around inf
Applied rewrites19.7%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 1Initial program 100.0%
/-rgt-identityN/A
exp-0N/A
clear-numN/A
exp-0N/A
lift-exp.f64N/A
exp-diffN/A
lift--.f64N/A
lift-exp.f64N/A
lower-/.f64N/A
exp-0100.0
lift--.f64N/A
sub0-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
lift-/.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
remove-double-divN/A
distribute-rgt-inN/A
lift-exp.f64N/A
lift--.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites100.0%
Taylor expanded in im around 0
Applied rewrites99.3%
if 1 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 98.6%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6454.5
Applied rewrites54.5%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6445.8
Applied rewrites45.8%
Final simplification64.5%
(FPCore (re im)
:precision binary64
(if (<= (* (+ (exp im) (exp (- im))) (* 0.5 (sin re))) 1e-9)
(* (* (fma (* re re) -0.08333333333333333 0.5) re) (fma im im 2.0))
(*
(*
(fma
(fma 0.004166666666666667 (* re re) -0.08333333333333333)
(* re re)
0.5)
re)
(fma im im 2.0))))
double code(double re, double im) {
double tmp;
if (((exp(im) + exp(-im)) * (0.5 * sin(re))) <= 1e-9) {
tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * fma(im, im, 2.0);
} else {
tmp = (fma(fma(0.004166666666666667, (re * re), -0.08333333333333333), (re * re), 0.5) * re) * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(0.5 * sin(re))) <= 1e-9) tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * fma(im, im, 2.0)); else tmp = Float64(Float64(fma(fma(0.004166666666666667, Float64(re * re), -0.08333333333333333), Float64(re * re), 0.5) * re) * fma(im, im, 2.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-9], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.004166666666666667 * N[(re * re), $MachinePrecision] + -0.08333333333333333), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(e^{im} + e^{-im}\right) \cdot \left(0.5 \cdot \sin re\right) \leq 10^{-9}:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(0.004166666666666667, re \cdot re, -0.08333333333333333\right), re \cdot re, 0.5\right) \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 1.00000000000000006e-9Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6477.3
Applied rewrites77.3%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6459.1
Applied rewrites59.1%
if 1.00000000000000006e-9 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 99.1%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6469.8
Applied rewrites69.8%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6433.0
Applied rewrites33.0%
Final simplification48.8%
(FPCore (re im) :precision binary64 (if (<= (* (+ (exp im) (exp (- im))) (* 0.5 (sin re))) 0.0002) (* (* (fma (* re re) -0.08333333333333333 0.5) re) (fma im im 2.0)) (* (* 0.5 re) (fma im im 2.0))))
double code(double re, double im) {
double tmp;
if (((exp(im) + exp(-im)) * (0.5 * sin(re))) <= 0.0002) {
tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * fma(im, im, 2.0);
} else {
tmp = (0.5 * re) * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(0.5 * sin(re))) <= 0.0002) tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * fma(im, im, 2.0)); else tmp = Float64(Float64(0.5 * re) * fma(im, im, 2.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0002], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(e^{im} + e^{-im}\right) \cdot \left(0.5 \cdot \sin re\right) \leq 0.0002:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 2.0000000000000001e-4Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6477.6
Applied rewrites77.6%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6459.6
Applied rewrites59.6%
if 2.0000000000000001e-4 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 99.1%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6469.2
Applied rewrites69.2%
Taylor expanded in re around 0
lower-*.f6431.0
Applied rewrites31.0%
Final simplification48.6%
(FPCore (re im) :precision binary64 (if (<= (* (+ (exp im) (exp (- im))) (* 0.5 (sin re))) -0.04) (* (* (* (* re re) -0.08333333333333333) re) (fma im im 2.0)) (* (* 0.5 re) (fma im im 2.0))))
double code(double re, double im) {
double tmp;
if (((exp(im) + exp(-im)) * (0.5 * sin(re))) <= -0.04) {
tmp = (((re * re) * -0.08333333333333333) * re) * fma(im, im, 2.0);
} else {
tmp = (0.5 * re) * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(0.5 * sin(re))) <= -0.04) tmp = Float64(Float64(Float64(Float64(re * re) * -0.08333333333333333) * re) * fma(im, im, 2.0)); else tmp = Float64(Float64(0.5 * re) * fma(im, im, 2.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.04], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(e^{im} + e^{-im}\right) \cdot \left(0.5 \cdot \sin re\right) \leq -0.04:\\
\;\;\;\;\left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -0.0400000000000000008Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6463.7
Applied rewrites63.7%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6434.0
Applied rewrites34.0%
Taylor expanded in re around inf
Applied rewrites14.7%
if -0.0400000000000000008 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 99.4%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6480.6
Applied rewrites80.6%
Taylor expanded in re around 0
lower-*.f6456.7
Applied rewrites56.7%
Final simplification41.1%
(FPCore (re im) :precision binary64 (if (<= (* (+ (exp im) (exp (- im))) (* 0.5 (sin re))) 0.0002) (* 2.0 (* (fma (* -0.08333333333333333 re) re 0.5) re)) (* (* 0.5 re) (fma im im 2.0))))
double code(double re, double im) {
double tmp;
if (((exp(im) + exp(-im)) * (0.5 * sin(re))) <= 0.0002) {
tmp = 2.0 * (fma((-0.08333333333333333 * re), re, 0.5) * re);
} else {
tmp = (0.5 * re) * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(0.5 * sin(re))) <= 0.0002) tmp = Float64(2.0 * Float64(fma(Float64(-0.08333333333333333 * re), re, 0.5) * re)); else tmp = Float64(Float64(0.5 * re) * fma(im, im, 2.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0002], N[(2.0 * N[(N[(N[(-0.08333333333333333 * re), $MachinePrecision] * re + 0.5), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(e^{im} + e^{-im}\right) \cdot \left(0.5 \cdot \sin re\right) \leq 0.0002:\\
\;\;\;\;2 \cdot \left(\mathsf{fma}\left(-0.08333333333333333 \cdot re, re, 0.5\right) \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 2.0000000000000001e-4Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites57.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6447.7
Applied rewrites47.7%
Applied rewrites47.7%
if 2.0000000000000001e-4 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 99.1%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6469.2
Applied rewrites69.2%
Taylor expanded in re around 0
lower-*.f6431.0
Applied rewrites31.0%
Final simplification41.2%
(FPCore (re im) :precision binary64 (if (<= (* (+ (exp im) (exp (- im))) (* 0.5 (sin re))) -0.04) (* 2.0 (* (* (* re re) -0.08333333333333333) re)) (* (* 0.5 re) (fma im im 2.0))))
double code(double re, double im) {
double tmp;
if (((exp(im) + exp(-im)) * (0.5 * sin(re))) <= -0.04) {
tmp = 2.0 * (((re * re) * -0.08333333333333333) * re);
} else {
tmp = (0.5 * re) * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(0.5 * sin(re))) <= -0.04) tmp = Float64(2.0 * Float64(Float64(Float64(re * re) * -0.08333333333333333) * re)); else tmp = Float64(Float64(0.5 * re) * fma(im, im, 2.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.04], N[(2.0 * N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(e^{im} + e^{-im}\right) \cdot \left(0.5 \cdot \sin re\right) \leq -0.04:\\
\;\;\;\;2 \cdot \left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -0.0400000000000000008Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites31.3%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6414.4
Applied rewrites14.4%
Taylor expanded in re around inf
Applied rewrites14.1%
if -0.0400000000000000008 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 99.4%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6480.6
Applied rewrites80.6%
Taylor expanded in re around 0
lower-*.f6456.7
Applied rewrites56.7%
Final simplification40.9%
(FPCore (re im)
:precision binary64
(let* ((t_0
(*
(fma (fma 0.041666666666666664 (* im im) 0.5) (* im im) 1.0)
(sin re))))
(if (<= im 600.0)
t_0
(if (<= im 1.72e+56)
(*
(fma im im 2.0)
(* (* (* (- (/ 0.5 (* re re)) 0.08333333333333333) re) re) re))
(if (<= im 2.5e+77)
(*
(fma
(pow im 4.0)
(fma 0.002777777777777778 (* im im) 0.08333333333333333)
(fma im im 2.0))
(* 0.5 re))
t_0)))))
double code(double re, double im) {
double t_0 = fma(fma(0.041666666666666664, (im * im), 0.5), (im * im), 1.0) * sin(re);
double tmp;
if (im <= 600.0) {
tmp = t_0;
} else if (im <= 1.72e+56) {
tmp = fma(im, im, 2.0) * (((((0.5 / (re * re)) - 0.08333333333333333) * re) * re) * re);
} else if (im <= 2.5e+77) {
tmp = fma(pow(im, 4.0), fma(0.002777777777777778, (im * im), 0.08333333333333333), fma(im, im, 2.0)) * (0.5 * re);
} else {
tmp = t_0;
}
return tmp;
}
function code(re, im) t_0 = Float64(fma(fma(0.041666666666666664, Float64(im * im), 0.5), Float64(im * im), 1.0) * sin(re)) tmp = 0.0 if (im <= 600.0) tmp = t_0; elseif (im <= 1.72e+56) tmp = Float64(fma(im, im, 2.0) * Float64(Float64(Float64(Float64(Float64(0.5 / Float64(re * re)) - 0.08333333333333333) * re) * re) * re)); elseif (im <= 2.5e+77) tmp = Float64(fma((im ^ 4.0), fma(0.002777777777777778, Float64(im * im), 0.08333333333333333), fma(im, im, 2.0)) * Float64(0.5 * re)); else tmp = t_0; end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 600.0], t$95$0, If[LessEqual[im, 1.72e+56], N[(N[(im * im + 2.0), $MachinePrecision] * N[(N[(N[(N[(N[(0.5 / N[(re * re), $MachinePrecision]), $MachinePrecision] - 0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.5e+77], N[(N[(N[Power[im, 4.0], $MachinePrecision] * N[(0.002777777777777778 * N[(im * im), $MachinePrecision] + 0.08333333333333333), $MachinePrecision] + N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot \sin re\\
\mathbf{if}\;im \leq 600:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq 1.72 \cdot 10^{+56}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(\left(\left(\left(\frac{0.5}{re \cdot re} - 0.08333333333333333\right) \cdot re\right) \cdot re\right) \cdot re\right)\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left({im}^{4}, \mathsf{fma}\left(0.002777777777777778, im \cdot im, 0.08333333333333333\right), \mathsf{fma}\left(im, im, 2\right)\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if im < 600 or 2.50000000000000002e77 < im Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
exp-0N/A
lower-*.f64N/A
exp-0N/A
lower-cosh.f64100.0
Applied rewrites100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6493.7
Applied rewrites93.7%
if 600 < im < 1.72e56Initial program 92.2%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f642.7
Applied rewrites2.7%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6410.9
Applied rewrites10.9%
Taylor expanded in re around inf
Applied rewrites60.2%
if 1.72e56 < im < 2.50000000000000002e77Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites2.9%
Taylor expanded in re around 0
lower-*.f644.4
Applied rewrites4.4%
Taylor expanded in im around 0
distribute-lft-inN/A
*-rgt-identityN/A
associate-+r+N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
pow-sqrN/A
metadata-evalN/A
lower-pow.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64100.0
Applied rewrites100.0%
Final simplification92.3%
(FPCore (re im)
:precision binary64
(if (<= (sin re) 1e-273)
(*
(fma im im 2.0)
(* (* (* (- (/ 0.5 (* re re)) 0.08333333333333333) re) re) re))
(*
(*
(fma
(fma 0.004166666666666667 (* re re) -0.08333333333333333)
(* re re)
0.5)
re)
(fma im im 2.0))))
double code(double re, double im) {
double tmp;
if (sin(re) <= 1e-273) {
tmp = fma(im, im, 2.0) * (((((0.5 / (re * re)) - 0.08333333333333333) * re) * re) * re);
} else {
tmp = (fma(fma(0.004166666666666667, (re * re), -0.08333333333333333), (re * re), 0.5) * re) * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (sin(re) <= 1e-273) tmp = Float64(fma(im, im, 2.0) * Float64(Float64(Float64(Float64(Float64(0.5 / Float64(re * re)) - 0.08333333333333333) * re) * re) * re)); else tmp = Float64(Float64(fma(fma(0.004166666666666667, Float64(re * re), -0.08333333333333333), Float64(re * re), 0.5) * re) * fma(im, im, 2.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], 1e-273], N[(N[(im * im + 2.0), $MachinePrecision] * N[(N[(N[(N[(N[(0.5 / N[(re * re), $MachinePrecision]), $MachinePrecision] - 0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.004166666666666667 * N[(re * re), $MachinePrecision] + -0.08333333333333333), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin re \leq 10^{-273}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(\left(\left(\left(\frac{0.5}{re \cdot re} - 0.08333333333333333\right) \cdot re\right) \cdot re\right) \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(0.004166666666666667, re \cdot re, -0.08333333333333333\right), re \cdot re, 0.5\right) \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if (sin.f64 re) < 1e-273Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6470.7
Applied rewrites70.7%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6449.0
Applied rewrites49.0%
Taylor expanded in re around inf
Applied rewrites47.4%
if 1e-273 < (sin.f64 re) Initial program 99.3%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6478.1
Applied rewrites78.1%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6448.6
Applied rewrites48.6%
Final simplification48.0%
(FPCore (re im)
:precision binary64
(if (<= im 600.0)
(*
(fma
(fma
(fma 0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
0.5)
(* im im)
1.0)
(sin re))
(if (<= im 7.2e+51)
(*
(fma im im 2.0)
(* (* (* (- (/ 0.5 (* re re)) 0.08333333333333333) re) re) re))
(*
(fma
(fma (* (* im im) 0.001388888888888889) (* im im) 0.5)
(* im im)
1.0)
(sin re)))))
double code(double re, double im) {
double tmp;
if (im <= 600.0) {
tmp = fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0) * sin(re);
} else if (im <= 7.2e+51) {
tmp = fma(im, im, 2.0) * (((((0.5 / (re * re)) - 0.08333333333333333) * re) * re) * re);
} else {
tmp = fma(fma(((im * im) * 0.001388888888888889), (im * im), 0.5), (im * im), 1.0) * sin(re);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 600.0) tmp = Float64(fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0) * sin(re)); elseif (im <= 7.2e+51) tmp = Float64(fma(im, im, 2.0) * Float64(Float64(Float64(Float64(Float64(0.5 / Float64(re * re)) - 0.08333333333333333) * re) * re) * re)); else tmp = Float64(fma(fma(Float64(Float64(im * im) * 0.001388888888888889), Float64(im * im), 0.5), Float64(im * im), 1.0) * sin(re)); end return tmp end
code[re_, im_] := If[LessEqual[im, 600.0], N[(N[(N[(N[(0.001388888888888889 * N[(im * im), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 7.2e+51], N[(N[(im * im + 2.0), $MachinePrecision] * N[(N[(N[(N[(N[(0.5 / N[(re * re), $MachinePrecision]), $MachinePrecision] - 0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision] * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 600:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot \sin re\\
\mathbf{elif}\;im \leq 7.2 \cdot 10^{+51}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(\left(\left(\left(\frac{0.5}{re \cdot re} - 0.08333333333333333\right) \cdot re\right) \cdot re\right) \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\left(im \cdot im\right) \cdot 0.001388888888888889, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot \sin re\\
\end{array}
\end{array}
if im < 600Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
exp-0N/A
lower-*.f64N/A
exp-0N/A
lower-cosh.f64100.0
Applied rewrites100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6494.2
Applied rewrites94.2%
if 600 < im < 7.20000000000000022e51Initial program 91.5%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f642.6
Applied rewrites2.6%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6411.0
Applied rewrites11.0%
Taylor expanded in re around inf
Applied rewrites64.8%
if 7.20000000000000022e51 < im Initial program 100.0%
/-rgt-identityN/A
exp-0N/A
clear-numN/A
exp-0N/A
lift-exp.f64N/A
exp-diffN/A
lift--.f64N/A
lift-exp.f64N/A
lower-/.f64N/A
exp-0100.0
lift--.f64N/A
sub0-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
lift-/.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
remove-double-divN/A
distribute-rgt-inN/A
lift-exp.f64N/A
lift--.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in im around inf
Applied rewrites100.0%
Final simplification94.2%
(FPCore (re im)
:precision binary64
(if (<= im 600.0)
(* (fma (fma 0.041666666666666664 (* im im) 0.5) (* im im) 1.0) (sin re))
(if (<= im 7.2e+51)
(*
(fma im im 2.0)
(* (* (* (- (/ 0.5 (* re re)) 0.08333333333333333) re) re) re))
(*
(fma
(fma (* (* im im) 0.001388888888888889) (* im im) 0.5)
(* im im)
1.0)
(sin re)))))
double code(double re, double im) {
double tmp;
if (im <= 600.0) {
tmp = fma(fma(0.041666666666666664, (im * im), 0.5), (im * im), 1.0) * sin(re);
} else if (im <= 7.2e+51) {
tmp = fma(im, im, 2.0) * (((((0.5 / (re * re)) - 0.08333333333333333) * re) * re) * re);
} else {
tmp = fma(fma(((im * im) * 0.001388888888888889), (im * im), 0.5), (im * im), 1.0) * sin(re);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 600.0) tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), 0.5), Float64(im * im), 1.0) * sin(re)); elseif (im <= 7.2e+51) tmp = Float64(fma(im, im, 2.0) * Float64(Float64(Float64(Float64(Float64(0.5 / Float64(re * re)) - 0.08333333333333333) * re) * re) * re)); else tmp = Float64(fma(fma(Float64(Float64(im * im) * 0.001388888888888889), Float64(im * im), 0.5), Float64(im * im), 1.0) * sin(re)); end return tmp end
code[re_, im_] := If[LessEqual[im, 600.0], N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 7.2e+51], N[(N[(im * im + 2.0), $MachinePrecision] * N[(N[(N[(N[(N[(0.5 / N[(re * re), $MachinePrecision]), $MachinePrecision] - 0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision] * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 600:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot \sin re\\
\mathbf{elif}\;im \leq 7.2 \cdot 10^{+51}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(\left(\left(\left(\frac{0.5}{re \cdot re} - 0.08333333333333333\right) \cdot re\right) \cdot re\right) \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\left(im \cdot im\right) \cdot 0.001388888888888889, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot \sin re\\
\end{array}
\end{array}
if im < 600Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
exp-0N/A
lower-*.f64N/A
exp-0N/A
lower-cosh.f64100.0
Applied rewrites100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6492.1
Applied rewrites92.1%
if 600 < im < 7.20000000000000022e51Initial program 91.5%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f642.6
Applied rewrites2.6%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6411.0
Applied rewrites11.0%
Taylor expanded in re around inf
Applied rewrites64.8%
if 7.20000000000000022e51 < im Initial program 100.0%
/-rgt-identityN/A
exp-0N/A
clear-numN/A
exp-0N/A
lift-exp.f64N/A
exp-diffN/A
lift--.f64N/A
lift-exp.f64N/A
lower-/.f64N/A
exp-0100.0
lift--.f64N/A
sub0-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
lift-/.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
remove-double-divN/A
distribute-rgt-inN/A
lift-exp.f64N/A
lift--.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in im around inf
Applied rewrites100.0%
Final simplification92.7%
(FPCore (re im)
:precision binary64
(let* ((t_0
(*
(fma (fma 0.041666666666666664 (* im im) 0.5) (* im im) 1.0)
(sin re))))
(if (<= im 600.0)
t_0
(if (<= im 1.85e+68)
(*
(fma im im 2.0)
(* (* (* (- (/ 0.5 (* re re)) 0.08333333333333333) re) re) re))
t_0))))
double code(double re, double im) {
double t_0 = fma(fma(0.041666666666666664, (im * im), 0.5), (im * im), 1.0) * sin(re);
double tmp;
if (im <= 600.0) {
tmp = t_0;
} else if (im <= 1.85e+68) {
tmp = fma(im, im, 2.0) * (((((0.5 / (re * re)) - 0.08333333333333333) * re) * re) * re);
} else {
tmp = t_0;
}
return tmp;
}
function code(re, im) t_0 = Float64(fma(fma(0.041666666666666664, Float64(im * im), 0.5), Float64(im * im), 1.0) * sin(re)) tmp = 0.0 if (im <= 600.0) tmp = t_0; elseif (im <= 1.85e+68) tmp = Float64(fma(im, im, 2.0) * Float64(Float64(Float64(Float64(Float64(0.5 / Float64(re * re)) - 0.08333333333333333) * re) * re) * re)); else tmp = t_0; end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 600.0], t$95$0, If[LessEqual[im, 1.85e+68], N[(N[(im * im + 2.0), $MachinePrecision] * N[(N[(N[(N[(N[(0.5 / N[(re * re), $MachinePrecision]), $MachinePrecision] - 0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot \sin re\\
\mathbf{if}\;im \leq 600:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq 1.85 \cdot 10^{+68}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(\left(\left(\left(\frac{0.5}{re \cdot re} - 0.08333333333333333\right) \cdot re\right) \cdot re\right) \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if im < 600 or 1.84999999999999999e68 < im Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
exp-0N/A
lower-*.f64N/A
exp-0N/A
lower-cosh.f64100.0
Applied rewrites100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6492.7
Applied rewrites92.7%
if 600 < im < 1.84999999999999999e68Initial program 93.7%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f643.0
Applied rewrites3.0%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f648.8
Applied rewrites8.8%
Taylor expanded in re around inf
Applied rewrites48.2%
Final simplification90.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (sin re)) (fma im im 2.0))))
(if (<= im 600.0)
t_0
(if (<= im 1.35e+154)
(*
(fma im im 2.0)
(* (* (* (- (/ 0.5 (* re re)) 0.08333333333333333) re) re) re))
t_0))))
double code(double re, double im) {
double t_0 = (0.5 * sin(re)) * fma(im, im, 2.0);
double tmp;
if (im <= 600.0) {
tmp = t_0;
} else if (im <= 1.35e+154) {
tmp = fma(im, im, 2.0) * (((((0.5 / (re * re)) - 0.08333333333333333) * re) * re) * re);
} else {
tmp = t_0;
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0)) tmp = 0.0 if (im <= 600.0) tmp = t_0; elseif (im <= 1.35e+154) tmp = Float64(fma(im, im, 2.0) * Float64(Float64(Float64(Float64(Float64(0.5 / Float64(re * re)) - 0.08333333333333333) * re) * re) * re)); else tmp = t_0; end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 600.0], t$95$0, If[LessEqual[im, 1.35e+154], N[(N[(im * im + 2.0), $MachinePrecision] * N[(N[(N[(N[(N[(0.5 / N[(re * re), $MachinePrecision]), $MachinePrecision] - 0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{if}\;im \leq 600:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(\left(\left(\left(\frac{0.5}{re \cdot re} - 0.08333333333333333\right) \cdot re\right) \cdot re\right) \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if im < 600 or 1.35000000000000003e154 < im Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6486.5
Applied rewrites86.5%
if 600 < im < 1.35000000000000003e154Initial program 97.5%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f644.5
Applied rewrites4.5%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6420.4
Applied rewrites20.4%
Taylor expanded in re around inf
Applied rewrites43.6%
Final simplification80.1%
(FPCore (re im) :precision binary64 (* (* 0.5 re) (fma im im 2.0)))
double code(double re, double im) {
return (0.5 * re) * fma(im, im, 2.0);
}
function code(re, im) return Float64(Float64(0.5 * re) * fma(im, im, 2.0)) end
code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)
\end{array}
Initial program 99.6%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6474.3
Applied rewrites74.3%
Taylor expanded in re around 0
lower-*.f6448.0
Applied rewrites48.0%
(FPCore (re im) :precision binary64 (* 2.0 (* 0.5 re)))
double code(double re, double im) {
return 2.0 * (0.5 * re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 2.0d0 * (0.5d0 * re)
end function
public static double code(double re, double im) {
return 2.0 * (0.5 * re);
}
def code(re, im): return 2.0 * (0.5 * re)
function code(re, im) return Float64(2.0 * Float64(0.5 * re)) end
function tmp = code(re, im) tmp = 2.0 * (0.5 * re); end
code[re_, im_] := N[(2.0 * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(0.5 \cdot re\right)
\end{array}
Initial program 99.6%
Taylor expanded in im around 0
Applied rewrites48.7%
Taylor expanded in re around 0
lower-*.f6425.6
Applied rewrites25.6%
Final simplification25.6%
herbie shell --seed 2024325
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))