
(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 14 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 (* (sin re) (cosh im)))
double code(double re, double im) {
return sin(re) * cosh(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = sin(re) * cosh(im)
end function
public static double code(double re, double im) {
return Math.sin(re) * Math.cosh(im);
}
def code(re, im): return math.sin(re) * math.cosh(im)
function code(re, im) return Float64(sin(re) * cosh(im)) end
function tmp = code(re, im) tmp = sin(re) * cosh(im); end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[Cosh[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin re \cdot \cosh im
\end{array}
Initial program 100.0%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/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
cosh-0N/A
*-commutativeN/A
lower-*.f64N/A
cosh-0N/A
exp-0N/A
lower-*.f64N/A
exp-0N/A
lower-cosh.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-*.f64N/A
*-lft-identityN/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 2.0 (cosh im)))
(t_1 (* 0.5 (sin re)))
(t_2 (* t_1 (+ (exp (- im)) (exp im)))))
(if (<= t_2 (- INFINITY))
(* t_0 (* (fma -0.08333333333333333 (* re re) 0.5) re))
(if (<= t_2 1.0) (* t_1 (fma im im 2.0)) (* t_0 (* re 0.5))))))
double code(double re, double im) {
double t_0 = 2.0 * cosh(im);
double t_1 = 0.5 * sin(re);
double t_2 = t_1 * (exp(-im) + exp(im));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_0 * (fma(-0.08333333333333333, (re * re), 0.5) * re);
} else if (t_2 <= 1.0) {
tmp = t_1 * fma(im, im, 2.0);
} else {
tmp = t_0 * (re * 0.5);
}
return tmp;
}
function code(re, im) t_0 = Float64(2.0 * cosh(im)) t_1 = Float64(0.5 * sin(re)) t_2 = Float64(t_1 * Float64(exp(Float64(-im)) + exp(im))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(t_0 * Float64(fma(-0.08333333333333333, Float64(re * re), 0.5) * re)); elseif (t_2 <= 1.0) tmp = Float64(t_1 * fma(im, im, 2.0)); else tmp = Float64(t_0 * Float64(re * 0.5)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(2.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(t$95$0 * N[(N[(-0.08333333333333333 * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1.0], N[(t$95$1 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \cosh im\\
t_1 := 0.5 \cdot \sin re\\
t_2 := t\_1 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_0 \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\
\mathbf{elif}\;t\_2 \leq 1:\\
\;\;\;\;t\_1 \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(re \cdot 0.5\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 re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6474.7
Applied rewrites74.7%
lift-*.f64N/A
lift-+.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
lift-cosh.f64N/A
lower-*.f6474.7
Applied rewrites74.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 99.9%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6499.6
Applied rewrites99.6%
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 100.0%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.4
Applied rewrites82.4%
lift-*.f64N/A
lift-+.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
lift-cosh.f64N/A
lower-*.f6482.4
Applied rewrites82.4%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f6474.5
Applied rewrites74.5%
Final simplification87.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))) (t_1 (* t_0 (+ (exp (- im)) (exp im)))))
(if (<= t_1 (- INFINITY))
(*
(*
2.0
(fma
(fma
(fma 0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
0.5)
(* im im)
1.0))
(* (fma -0.08333333333333333 (* re re) 0.5) re))
(if (<= t_1 1.0)
(* t_0 (fma im im 2.0))
(* (* 2.0 (cosh im)) (* re 0.5))))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double t_1 = t_0 * (exp(-im) + exp(im));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (2.0 * fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0)) * (fma(-0.08333333333333333, (re * re), 0.5) * re);
} else if (t_1 <= 1.0) {
tmp = t_0 * fma(im, im, 2.0);
} else {
tmp = (2.0 * cosh(im)) * (re * 0.5);
}
return tmp;
}
function code(re, im) t_0 = Float64(0.5 * sin(re)) t_1 = Float64(t_0 * Float64(exp(Float64(-im)) + exp(im))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(2.0 * fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0)) * Float64(fma(-0.08333333333333333, Float64(re * re), 0.5) * re)); elseif (t_1 <= 1.0) tmp = Float64(t_0 * fma(im, im, 2.0)); else tmp = Float64(Float64(2.0 * cosh(im)) * Float64(re * 0.5)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(2.0 * 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]), $MachinePrecision] * N[(N[(-0.08333333333333333 * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1.0], N[(t$95$0 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
t_1 := t\_0 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\left(2 \cdot \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)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\
\mathbf{elif}\;t\_1 \leq 1:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \cosh im\right) \cdot \left(re \cdot 0.5\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 re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6474.7
Applied rewrites74.7%
lift-*.f64N/A
lift-+.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
lift-cosh.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
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-*.f6467.0
Applied rewrites67.0%
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 99.9%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6499.6
Applied rewrites99.6%
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 100.0%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.4
Applied rewrites82.4%
lift-*.f64N/A
lift-+.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
lift-cosh.f64N/A
lower-*.f6482.4
Applied rewrites82.4%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f6474.5
Applied rewrites74.5%
Final simplification85.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (sin re)) (+ (exp (- im)) (exp im)))))
(if (<= t_0 (- INFINITY))
(*
(*
2.0
(fma
(fma
(fma 0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
0.5)
(* im im)
1.0))
(* (fma -0.08333333333333333 (* re re) 0.5) re))
(if (<= t_0 1.0) (sin re) (* (* 2.0 (cosh im)) (* re 0.5))))))
double code(double re, double im) {
double t_0 = (0.5 * sin(re)) * (exp(-im) + exp(im));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (2.0 * fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0)) * (fma(-0.08333333333333333, (re * re), 0.5) * re);
} else if (t_0 <= 1.0) {
tmp = sin(re);
} else {
tmp = (2.0 * cosh(im)) * (re * 0.5);
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) + exp(im))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(2.0 * fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0)) * Float64(fma(-0.08333333333333333, Float64(re * re), 0.5) * re)); elseif (t_0 <= 1.0) tmp = sin(re); else tmp = Float64(Float64(2.0 * cosh(im)) * Float64(re * 0.5)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(2.0 * 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]), $MachinePrecision] * N[(N[(-0.08333333333333333 * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[Sin[re], $MachinePrecision], N[(N[(2.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\left(2 \cdot \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)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \cosh im\right) \cdot \left(re \cdot 0.5\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 re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6474.7
Applied rewrites74.7%
lift-*.f64N/A
lift-+.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
lift-cosh.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
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-*.f6467.0
Applied rewrites67.0%
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 99.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6461.6
Applied rewrites61.6%
lift-*.f64N/A
lift-+.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
lift-cosh.f64N/A
lower-*.f6461.7
Applied rewrites61.7%
Taylor expanded in im around 0
lower-sin.f6498.4
Applied rewrites98.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 100.0%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.4
Applied rewrites82.4%
lift-*.f64N/A
lift-+.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
lift-cosh.f64N/A
lower-*.f6482.4
Applied rewrites82.4%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f6474.5
Applied rewrites74.5%
Final simplification84.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (sin re)) (+ (exp (- im)) (exp im)))))
(if (<= t_0 (- INFINITY))
(*
(*
2.0
(fma
(fma
(fma 0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
0.5)
(* im im)
1.0))
(* (fma -0.08333333333333333 (* re re) 0.5) re))
(if (<= t_0 1.0)
(sin re)
(* (fma (fma 0.041666666666666664 (* im im) 0.5) (* im im) 1.0) re)))))
double code(double re, double im) {
double t_0 = (0.5 * sin(re)) * (exp(-im) + exp(im));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (2.0 * fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0)) * (fma(-0.08333333333333333, (re * re), 0.5) * re);
} else if (t_0 <= 1.0) {
tmp = sin(re);
} else {
tmp = fma(fma(0.041666666666666664, (im * im), 0.5), (im * im), 1.0) * re;
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) + exp(im))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(2.0 * fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0)) * Float64(fma(-0.08333333333333333, Float64(re * re), 0.5) * re)); elseif (t_0 <= 1.0) tmp = sin(re); else tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), 0.5), Float64(im * im), 1.0) * re); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(2.0 * 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]), $MachinePrecision] * N[(N[(-0.08333333333333333 * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[Sin[re], $MachinePrecision], N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * re), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\left(2 \cdot \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)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot re\\
\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 re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6474.7
Applied rewrites74.7%
lift-*.f64N/A
lift-+.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
lift-cosh.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
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-*.f6467.0
Applied rewrites67.0%
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 99.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6461.6
Applied rewrites61.6%
lift-*.f64N/A
lift-+.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
lift-cosh.f64N/A
lower-*.f6461.7
Applied rewrites61.7%
Taylor expanded in im around 0
lower-sin.f6498.4
Applied rewrites98.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 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f6479.6
Applied rewrites79.6%
Taylor expanded in re around 0
Applied rewrites68.8%
Final simplification83.3%
(FPCore (re im)
:precision binary64
(if (<= (sin re) 0.001)
(*
(*
2.0
(fma
(fma
(fma 0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
0.5)
(* im im)
1.0))
(* (fma -0.08333333333333333 (* re re) 0.5) re))
(*
(fma
(-
(fma
(* 0.008333333333333333 re)
re
(*
(*
(* (- (* 0.008333333333333333 (* re re)) 0.16666666666666666) 0.5)
im)
im))
0.16666666666666666)
(* re re)
(fma (fma 0.041666666666666664 (* im im) 0.5) (* im im) 1.0))
re)))
double code(double re, double im) {
double tmp;
if (sin(re) <= 0.001) {
tmp = (2.0 * fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0)) * (fma(-0.08333333333333333, (re * re), 0.5) * re);
} else {
tmp = fma((fma((0.008333333333333333 * re), re, (((((0.008333333333333333 * (re * re)) - 0.16666666666666666) * 0.5) * im) * im)) - 0.16666666666666666), (re * re), fma(fma(0.041666666666666664, (im * im), 0.5), (im * im), 1.0)) * re;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (sin(re) <= 0.001) tmp = Float64(Float64(2.0 * fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0)) * Float64(fma(-0.08333333333333333, Float64(re * re), 0.5) * re)); else tmp = Float64(fma(Float64(fma(Float64(0.008333333333333333 * re), re, Float64(Float64(Float64(Float64(Float64(0.008333333333333333 * Float64(re * re)) - 0.16666666666666666) * 0.5) * im) * im)) - 0.16666666666666666), Float64(re * re), fma(fma(0.041666666666666664, Float64(im * im), 0.5), Float64(im * im), 1.0)) * re); end return tmp end
code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], 0.001], N[(N[(2.0 * 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]), $MachinePrecision] * N[(N[(-0.08333333333333333 * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(0.008333333333333333 * re), $MachinePrecision] * re + N[(N[(N[(N[(N[(0.008333333333333333 * N[(re * re), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * 0.5), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(re * re), $MachinePrecision] + N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin re \leq 0.001:\\
\;\;\;\;\left(2 \cdot \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)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333 \cdot re, re, \left(\left(\left(0.008333333333333333 \cdot \left(re \cdot re\right) - 0.16666666666666666\right) \cdot 0.5\right) \cdot im\right) \cdot im\right) - 0.16666666666666666, re \cdot re, \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right)\right) \cdot re\\
\end{array}
\end{array}
if (sin.f64 re) < 1e-3Initial program 100.0%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6478.3
Applied rewrites78.3%
lift-*.f64N/A
lift-+.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
lift-cosh.f64N/A
lower-*.f6478.3
Applied rewrites78.3%
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-*.f6474.2
Applied rewrites74.2%
if 1e-3 < (sin.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f6489.7
Applied rewrites89.7%
Taylor expanded in re around 0
Applied rewrites20.1%
Taylor expanded in im around 0
Applied rewrites20.4%
(FPCore (re im)
:precision binary64
(if (<= (sin re) 5e-15)
(*
(*
2.0
(fma
(fma
(fma 0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
0.5)
(* im im)
1.0))
(* (fma -0.08333333333333333 (* re re) 0.5) re))
(*
(*
(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) <= 5e-15) {
tmp = (2.0 * fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0)) * (fma(-0.08333333333333333, (re * re), 0.5) * re);
} else {
tmp = (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) <= 5e-15) tmp = Float64(Float64(2.0 * fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0)) * Float64(fma(-0.08333333333333333, Float64(re * re), 0.5) * re)); else tmp = Float64(Float64(fma(Float64(Float64(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], 5e-15], N[(N[(2.0 * 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]), $MachinePrecision] * N[(N[(-0.08333333333333333 * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(0.004166666666666667 * N[(re * re), $MachinePrecision]), $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 5 \cdot 10^{-15}:\\
\;\;\;\;\left(2 \cdot \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)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(0.004166666666666667 \cdot \left(re \cdot re\right) - 0.08333333333333333, 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) < 4.99999999999999999e-15Initial program 100.0%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6478.0
Applied rewrites78.0%
lift-*.f64N/A
lift-+.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-undefN/A
lift-cosh.f64N/A
lower-*.f6478.0
Applied rewrites78.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-*.f6473.8
Applied rewrites73.8%
if 4.99999999999999999e-15 < (sin.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6480.6
Applied rewrites80.6%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6425.2
Applied rewrites25.2%
(FPCore (re im) :precision binary64 (if (<= (sin re) -0.0005) (* (* (fma (* re re) -0.08333333333333333 0.5) re) (fma im im 2.0)) (* (fma (fma 0.041666666666666664 (* im im) 0.5) (* im im) 1.0) re)))
double code(double re, double im) {
double tmp;
if (sin(re) <= -0.0005) {
tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * fma(im, im, 2.0);
} else {
tmp = fma(fma(0.041666666666666664, (im * im), 0.5), (im * im), 1.0) * re;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (sin(re) <= -0.0005) tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * fma(im, im, 2.0)); else tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), 0.5), Float64(im * im), 1.0) * re); end return tmp end
code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], -0.0005], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin re \leq -0.0005:\\
\;\;\;\;\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}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot re\\
\end{array}
\end{array}
if (sin.f64 re) < -5.0000000000000001e-4Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6472.7
Applied rewrites72.7%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6426.9
Applied rewrites26.9%
if -5.0000000000000001e-4 < (sin.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f6488.0
Applied rewrites88.0%
Taylor expanded in re around 0
Applied rewrites75.0%
(FPCore (re im) :precision binary64 (if (<= (sin re) -0.0005) (* (* (* (* re re) -0.08333333333333333) re) (fma im im 2.0)) (* (fma (fma 0.041666666666666664 (* im im) 0.5) (* im im) 1.0) re)))
double code(double re, double im) {
double tmp;
if (sin(re) <= -0.0005) {
tmp = (((re * re) * -0.08333333333333333) * re) * fma(im, im, 2.0);
} else {
tmp = fma(fma(0.041666666666666664, (im * im), 0.5), (im * im), 1.0) * re;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (sin(re) <= -0.0005) tmp = Float64(Float64(Float64(Float64(re * re) * -0.08333333333333333) * re) * fma(im, im, 2.0)); else tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), 0.5), Float64(im * im), 1.0) * re); end return tmp end
code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], -0.0005], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin re \leq -0.0005:\\
\;\;\;\;\left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot re\\
\end{array}
\end{array}
if (sin.f64 re) < -5.0000000000000001e-4Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6472.7
Applied rewrites72.7%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6426.9
Applied rewrites26.9%
Taylor expanded in re around inf
Applied rewrites25.2%
if -5.0000000000000001e-4 < (sin.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f6488.0
Applied rewrites88.0%
Taylor expanded in re around 0
Applied rewrites75.0%
(FPCore (re im) :precision binary64 (if (<= (sin re) -0.0005) (* (* (* (* 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 (sin(re) <= -0.0005) {
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 (sin(re) <= -0.0005) 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[Sin[re], $MachinePrecision], -0.0005], 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}\;\sin re \leq -0.0005:\\
\;\;\;\;\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 (sin.f64 re) < -5.0000000000000001e-4Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6472.7
Applied rewrites72.7%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6426.9
Applied rewrites26.9%
Taylor expanded in re around inf
Applied rewrites25.2%
if -5.0000000000000001e-4 < (sin.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6479.0
Applied rewrites79.0%
Taylor expanded in re around 0
lower-*.f6463.7
Applied rewrites63.7%
(FPCore (re im) :precision binary64 (if (<= (sin re) -0.0005) (* (* (fma (* -0.08333333333333333 re) re 0.5) re) 2.0) (* (* 0.5 re) (fma im im 2.0))))
double code(double re, double im) {
double tmp;
if (sin(re) <= -0.0005) {
tmp = (fma((-0.08333333333333333 * re), re, 0.5) * re) * 2.0;
} else {
tmp = (0.5 * re) * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (sin(re) <= -0.0005) tmp = Float64(Float64(fma(Float64(-0.08333333333333333 * re), re, 0.5) * re) * 2.0); else tmp = Float64(Float64(0.5 * re) * fma(im, im, 2.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], -0.0005], N[(N[(N[(N[(-0.08333333333333333 * re), $MachinePrecision] * re + 0.5), $MachinePrecision] * re), $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin re \leq -0.0005:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.08333333333333333 \cdot re, re, 0.5\right) \cdot re\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if (sin.f64 re) < -5.0000000000000001e-4Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites42.6%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6416.8
Applied rewrites16.8%
Applied rewrites16.8%
if -5.0000000000000001e-4 < (sin.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6479.0
Applied rewrites79.0%
Taylor expanded in re around 0
lower-*.f6463.7
Applied rewrites63.7%
(FPCore (re im) :precision binary64 (if (<= (sin re) -0.0005) (* (* (* (* -0.08333333333333333 re) re) re) 2.0) (* (* 0.5 re) (fma im im 2.0))))
double code(double re, double im) {
double tmp;
if (sin(re) <= -0.0005) {
tmp = (((-0.08333333333333333 * re) * re) * re) * 2.0;
} else {
tmp = (0.5 * re) * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (sin(re) <= -0.0005) tmp = Float64(Float64(Float64(Float64(-0.08333333333333333 * re) * re) * re) * 2.0); else tmp = Float64(Float64(0.5 * re) * fma(im, im, 2.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], -0.0005], N[(N[(N[(N[(-0.08333333333333333 * re), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin re \leq -0.0005:\\
\;\;\;\;\left(\left(\left(-0.08333333333333333 \cdot re\right) \cdot re\right) \cdot re\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if (sin.f64 re) < -5.0000000000000001e-4Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites42.6%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6416.8
Applied rewrites16.8%
Taylor expanded in re around inf
Applied rewrites16.8%
Taylor expanded in re around inf
Applied rewrites16.8%
if -5.0000000000000001e-4 < (sin.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6479.0
Applied rewrites79.0%
Taylor expanded in re around 0
lower-*.f6463.7
Applied rewrites63.7%
(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 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6477.4
Applied rewrites77.4%
Taylor expanded in re around 0
lower-*.f6452.6
Applied rewrites52.6%
(FPCore (re im) :precision binary64 (* (* 0.5 re) 2.0))
double code(double re, double im) {
return (0.5 * re) * 2.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * re) * 2.0d0
end function
public static double code(double re, double im) {
return (0.5 * re) * 2.0;
}
def code(re, im): return (0.5 * re) * 2.0
function code(re, im) return Float64(Float64(0.5 * re) * 2.0) end
function tmp = code(re, im) tmp = (0.5 * re) * 2.0; end
code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * 2.0), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot re\right) \cdot 2
\end{array}
Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.3%
Taylor expanded in re around 0
lower-*.f6431.8
Applied rewrites31.8%
herbie shell --seed 2024326
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))