
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (let* ((t_0 (/ 0.5 (cosh im))) (t_1 (pow t_0 0.25))) (* (cos re) (/ (/ (/ 0.5 (pow t_0 0.5)) t_1) t_1))))
double code(double re, double im) {
double t_0 = 0.5 / cosh(im);
double t_1 = pow(t_0, 0.25);
return cos(re) * (((0.5 / pow(t_0, 0.5)) / t_1) / t_1);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
t_0 = 0.5d0 / cosh(im)
t_1 = t_0 ** 0.25d0
code = cos(re) * (((0.5d0 / (t_0 ** 0.5d0)) / t_1) / t_1)
end function
public static double code(double re, double im) {
double t_0 = 0.5 / Math.cosh(im);
double t_1 = Math.pow(t_0, 0.25);
return Math.cos(re) * (((0.5 / Math.pow(t_0, 0.5)) / t_1) / t_1);
}
def code(re, im): t_0 = 0.5 / math.cosh(im) t_1 = math.pow(t_0, 0.25) return math.cos(re) * (((0.5 / math.pow(t_0, 0.5)) / t_1) / t_1)
function code(re, im) t_0 = Float64(0.5 / cosh(im)) t_1 = t_0 ^ 0.25 return Float64(cos(re) * Float64(Float64(Float64(0.5 / (t_0 ^ 0.5)) / t_1) / t_1)) end
function tmp = code(re, im) t_0 = 0.5 / cosh(im); t_1 = t_0 ^ 0.25; tmp = cos(re) * (((0.5 / (t_0 ^ 0.5)) / t_1) / t_1); end
code[re_, im_] := Block[{t$95$0 = N[(0.5 / N[Cosh[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 0.25], $MachinePrecision]}, N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(0.5 / N[Power[t$95$0, 0.5], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0.5}{\cosh im}\\
t_1 := {t\_0}^{0.25}\\
\cos re \cdot \frac{\frac{\frac{0.5}{{t\_0}^{0.5}}}{t\_1}}{t\_1}
\end{array}
\end{array}
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-neg.f64N/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
lower-*.f64N/A
lower-cosh.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (+ (exp im) (exp (- im))) (* (cos re) 0.5))))
(if (<= t_0 -1e+183)
(*
(* im im)
(fma
(fma
(fma -0.0006944444444444445 (* re re) 0.020833333333333332)
(* re re)
-0.25)
(* re re)
0.5))
(if (<= t_0 0.9999999999997766)
(*
(fma
(fma
(fma 0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
0.5)
(* im im)
1.0)
(cos re))
(* 1.0 (cosh im))))))
double code(double re, double im) {
double t_0 = (exp(im) + exp(-im)) * (cos(re) * 0.5);
double tmp;
if (t_0 <= -1e+183) {
tmp = (im * im) * fma(fma(fma(-0.0006944444444444445, (re * re), 0.020833333333333332), (re * re), -0.25), (re * re), 0.5);
} else if (t_0 <= 0.9999999999997766) {
tmp = fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0) * cos(re);
} else {
tmp = 1.0 * cosh(im);
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(cos(re) * 0.5)) tmp = 0.0 if (t_0 <= -1e+183) tmp = Float64(Float64(im * im) * fma(fma(fma(-0.0006944444444444445, Float64(re * re), 0.020833333333333332), Float64(re * re), -0.25), Float64(re * re), 0.5)); elseif (t_0 <= 0.9999999999997766) tmp = Float64(fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0) * cos(re)); else tmp = Float64(1.0 * cosh(im)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+183], N[(N[(im * im), $MachinePrecision] * N[(N[(N[(-0.0006944444444444445 * N[(re * re), $MachinePrecision] + 0.020833333333333332), $MachinePrecision] * N[(re * re), $MachinePrecision] + -0.25), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.9999999999997766], 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[Cos[re], $MachinePrecision]), $MachinePrecision], N[(1.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{im} + e^{-im}\right) \cdot \left(\cos re \cdot 0.5\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+183}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0006944444444444445, re \cdot re, 0.020833333333333332\right), re \cdot re, -0.25\right), re \cdot re, 0.5\right)\\
\mathbf{elif}\;t\_0 \leq 0.9999999999997766:\\
\;\;\;\;\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 \cos re\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \cosh im\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -9.99999999999999947e182Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6446.5
Applied rewrites46.5%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6497.2
Applied rewrites97.2%
Taylor expanded in im around inf
Applied rewrites97.2%
if -9.99999999999999947e182 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 0.99999999999977662Initial 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-neg.f64N/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
lower-*.f64N/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-*.f6497.2
Applied rewrites97.2%
if 0.99999999999977662 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 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-neg.f64N/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
lower-*.f64N/A
lower-cosh.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
*-lft-identity100.0
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites100.0%
Final simplification98.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (+ (exp im) (exp (- im))) (* (cos re) 0.5))))
(if (<= t_0 -1e+183)
(*
(* im im)
(fma
(fma
(fma -0.0006944444444444445 (* re re) 0.020833333333333332)
(* re re)
-0.25)
(* re re)
0.5))
(if (<= t_0 0.9999999999997766)
(*
(fma (fma (* im im) 0.041666666666666664 0.5) (* im im) 1.0)
(cos re))
(* 1.0 (cosh im))))))
double code(double re, double im) {
double t_0 = (exp(im) + exp(-im)) * (cos(re) * 0.5);
double tmp;
if (t_0 <= -1e+183) {
tmp = (im * im) * fma(fma(fma(-0.0006944444444444445, (re * re), 0.020833333333333332), (re * re), -0.25), (re * re), 0.5);
} else if (t_0 <= 0.9999999999997766) {
tmp = fma(fma((im * im), 0.041666666666666664, 0.5), (im * im), 1.0) * cos(re);
} else {
tmp = 1.0 * cosh(im);
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(cos(re) * 0.5)) tmp = 0.0 if (t_0 <= -1e+183) tmp = Float64(Float64(im * im) * fma(fma(fma(-0.0006944444444444445, Float64(re * re), 0.020833333333333332), Float64(re * re), -0.25), Float64(re * re), 0.5)); elseif (t_0 <= 0.9999999999997766) tmp = Float64(fma(fma(Float64(im * im), 0.041666666666666664, 0.5), Float64(im * im), 1.0) * cos(re)); else tmp = Float64(1.0 * cosh(im)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+183], N[(N[(im * im), $MachinePrecision] * N[(N[(N[(-0.0006944444444444445 * N[(re * re), $MachinePrecision] + 0.020833333333333332), $MachinePrecision] * N[(re * re), $MachinePrecision] + -0.25), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.9999999999997766], N[(N[(N[(N[(im * im), $MachinePrecision] * 0.041666666666666664 + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[re], $MachinePrecision]), $MachinePrecision], N[(1.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{im} + e^{-im}\right) \cdot \left(\cos re \cdot 0.5\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+183}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0006944444444444445, re \cdot re, 0.020833333333333332\right), re \cdot re, -0.25\right), re \cdot re, 0.5\right)\\
\mathbf{elif}\;t\_0 \leq 0.9999999999997766:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(im \cdot im, 0.041666666666666664, 0.5\right), im \cdot im, 1\right) \cdot \cos re\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \cosh im\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -9.99999999999999947e182Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6446.5
Applied rewrites46.5%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6497.2
Applied rewrites97.2%
Taylor expanded in im around inf
Applied rewrites97.2%
if -9.99999999999999947e182 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 0.99999999999977662Initial 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-neg.f64N/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
lower-*.f64N/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
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6497.0
Applied rewrites97.0%
if 0.99999999999977662 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 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-neg.f64N/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
lower-*.f64N/A
lower-cosh.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
*-lft-identity100.0
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites100.0%
Final simplification98.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (cos re) 0.5)) (t_1 (* (+ (exp im) (exp (- im))) t_0)))
(if (<= t_1 -1e+158)
(*
(* im im)
(fma
(fma
(fma -0.0006944444444444445 (* re re) 0.020833333333333332)
(* re re)
-0.25)
(* re re)
0.5))
(if (<= t_1 0.9999999999997766)
(* (fma im im 2.0) t_0)
(* 1.0 (cosh im))))))
double code(double re, double im) {
double t_0 = cos(re) * 0.5;
double t_1 = (exp(im) + exp(-im)) * t_0;
double tmp;
if (t_1 <= -1e+158) {
tmp = (im * im) * fma(fma(fma(-0.0006944444444444445, (re * re), 0.020833333333333332), (re * re), -0.25), (re * re), 0.5);
} else if (t_1 <= 0.9999999999997766) {
tmp = fma(im, im, 2.0) * t_0;
} else {
tmp = 1.0 * cosh(im);
}
return tmp;
}
function code(re, im) t_0 = Float64(cos(re) * 0.5) t_1 = Float64(Float64(exp(im) + exp(Float64(-im))) * t_0) tmp = 0.0 if (t_1 <= -1e+158) tmp = Float64(Float64(im * im) * fma(fma(fma(-0.0006944444444444445, Float64(re * re), 0.020833333333333332), Float64(re * re), -0.25), Float64(re * re), 0.5)); elseif (t_1 <= 0.9999999999997766) tmp = Float64(fma(im, im, 2.0) * t_0); else tmp = Float64(1.0 * cosh(im)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[Cos[re], $MachinePrecision] * 0.5), $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, -1e+158], N[(N[(im * im), $MachinePrecision] * N[(N[(N[(-0.0006944444444444445 * N[(re * re), $MachinePrecision] + 0.020833333333333332), $MachinePrecision] * N[(re * re), $MachinePrecision] + -0.25), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.9999999999997766], N[(N[(im * im + 2.0), $MachinePrecision] * t$95$0), $MachinePrecision], N[(1.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos re \cdot 0.5\\
t_1 := \left(e^{im} + e^{-im}\right) \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+158}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0006944444444444445, re \cdot re, 0.020833333333333332\right), re \cdot re, -0.25\right), re \cdot re, 0.5\right)\\
\mathbf{elif}\;t\_1 \leq 0.9999999999997766:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \cosh im\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -9.99999999999999953e157Initial program 99.9%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6445.3
Applied rewrites45.3%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/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.6
Applied rewrites94.6%
Taylor expanded in im around inf
Applied rewrites94.6%
if -9.99999999999999953e157 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 0.99999999999977662Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6498.0
Applied rewrites98.0%
if 0.99999999999977662 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 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-neg.f64N/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
lower-*.f64N/A
lower-cosh.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
*-lft-identity100.0
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites100.0%
Final simplification98.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (+ (exp im) (exp (- im))) (* (cos re) 0.5))))
(if (<= t_0 -1e+158)
(*
(* im im)
(fma
(fma
(fma -0.0006944444444444445 (* re re) 0.020833333333333332)
(* re re)
-0.25)
(* re re)
0.5))
(if (<= t_0 0.9999999999997766) (cos re) (* 1.0 (cosh im))))))
double code(double re, double im) {
double t_0 = (exp(im) + exp(-im)) * (cos(re) * 0.5);
double tmp;
if (t_0 <= -1e+158) {
tmp = (im * im) * fma(fma(fma(-0.0006944444444444445, (re * re), 0.020833333333333332), (re * re), -0.25), (re * re), 0.5);
} else if (t_0 <= 0.9999999999997766) {
tmp = cos(re);
} else {
tmp = 1.0 * cosh(im);
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(cos(re) * 0.5)) tmp = 0.0 if (t_0 <= -1e+158) tmp = Float64(Float64(im * im) * fma(fma(fma(-0.0006944444444444445, Float64(re * re), 0.020833333333333332), Float64(re * re), -0.25), Float64(re * re), 0.5)); elseif (t_0 <= 0.9999999999997766) tmp = cos(re); else tmp = Float64(1.0 * cosh(im)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+158], N[(N[(im * im), $MachinePrecision] * N[(N[(N[(-0.0006944444444444445 * N[(re * re), $MachinePrecision] + 0.020833333333333332), $MachinePrecision] * N[(re * re), $MachinePrecision] + -0.25), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.9999999999997766], N[Cos[re], $MachinePrecision], N[(1.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{im} + e^{-im}\right) \cdot \left(\cos re \cdot 0.5\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+158}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0006944444444444445, re \cdot re, 0.020833333333333332\right), re \cdot re, -0.25\right), re \cdot re, 0.5\right)\\
\mathbf{elif}\;t\_0 \leq 0.9999999999997766:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \cosh im\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -9.99999999999999953e157Initial program 99.9%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6445.3
Applied rewrites45.3%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/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.6
Applied rewrites94.6%
Taylor expanded in im around inf
Applied rewrites94.6%
if -9.99999999999999953e157 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 0.99999999999977662Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites97.9%
Taylor expanded in re around 0
Applied rewrites16.9%
Taylor expanded in im around 0
lower-cos.f6497.9
Applied rewrites97.9%
if 0.99999999999977662 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 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-neg.f64N/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
lower-*.f64N/A
lower-cosh.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
*-lft-identity100.0
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites100.0%
Final simplification98.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (+ (exp im) (exp (- im))) (* (cos re) 0.5))))
(if (<= t_0 -1e+158)
(*
(* im im)
(fma
(fma
(fma -0.0006944444444444445 (* re re) 0.020833333333333332)
(* re re)
-0.25)
(* re re)
0.5))
(if (<= t_0 0.9999999999997766)
(cos re)
(*
1.0
(fma
(fma
(fma 0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
0.5)
(* im im)
1.0))))))
double code(double re, double im) {
double t_0 = (exp(im) + exp(-im)) * (cos(re) * 0.5);
double tmp;
if (t_0 <= -1e+158) {
tmp = (im * im) * fma(fma(fma(-0.0006944444444444445, (re * re), 0.020833333333333332), (re * re), -0.25), (re * re), 0.5);
} else if (t_0 <= 0.9999999999997766) {
tmp = cos(re);
} else {
tmp = 1.0 * fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(cos(re) * 0.5)) tmp = 0.0 if (t_0 <= -1e+158) tmp = Float64(Float64(im * im) * fma(fma(fma(-0.0006944444444444445, Float64(re * re), 0.020833333333333332), Float64(re * re), -0.25), Float64(re * re), 0.5)); elseif (t_0 <= 0.9999999999997766) tmp = cos(re); else tmp = Float64(1.0 * fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+158], N[(N[(im * im), $MachinePrecision] * N[(N[(N[(-0.0006944444444444445 * N[(re * re), $MachinePrecision] + 0.020833333333333332), $MachinePrecision] * N[(re * re), $MachinePrecision] + -0.25), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.9999999999997766], N[Cos[re], $MachinePrecision], N[(1.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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{im} + e^{-im}\right) \cdot \left(\cos re \cdot 0.5\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+158}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0006944444444444445, re \cdot re, 0.020833333333333332\right), re \cdot re, -0.25\right), re \cdot re, 0.5\right)\\
\mathbf{elif}\;t\_0 \leq 0.9999999999997766:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;1 \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)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -9.99999999999999953e157Initial program 99.9%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6445.3
Applied rewrites45.3%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/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.6
Applied rewrites94.6%
Taylor expanded in im around inf
Applied rewrites94.6%
if -9.99999999999999953e157 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 0.99999999999977662Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites97.9%
Taylor expanded in re around 0
Applied rewrites16.9%
Taylor expanded in im around 0
lower-cos.f6497.9
Applied rewrites97.9%
if 0.99999999999977662 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 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-neg.f64N/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
lower-*.f64N/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-*.f6493.5
Applied rewrites93.5%
Taylor expanded in re around 0
Applied rewrites93.5%
Final simplification95.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (+ (exp im) (exp (- im))) (* (cos re) 0.5))))
(if (<= t_0 -0.05)
(*
2.0
(fma
(fma (* (* re re) -0.0006944444444444445) (* re re) -0.25)
(* re re)
0.5))
(if (<= t_0 0.99995)
(* 0.5 2.0)
(*
(fma (fma 0.020833333333333332 (* re re) -0.25) (* re re) 0.5)
(fma im im 2.0))))))
double code(double re, double im) {
double t_0 = (exp(im) + exp(-im)) * (cos(re) * 0.5);
double tmp;
if (t_0 <= -0.05) {
tmp = 2.0 * fma(fma(((re * re) * -0.0006944444444444445), (re * re), -0.25), (re * re), 0.5);
} else if (t_0 <= 0.99995) {
tmp = 0.5 * 2.0;
} else {
tmp = fma(fma(0.020833333333333332, (re * re), -0.25), (re * re), 0.5) * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(cos(re) * 0.5)) tmp = 0.0 if (t_0 <= -0.05) tmp = Float64(2.0 * fma(fma(Float64(Float64(re * re) * -0.0006944444444444445), Float64(re * re), -0.25), Float64(re * re), 0.5)); elseif (t_0 <= 0.99995) tmp = Float64(0.5 * 2.0); else tmp = Float64(fma(fma(0.020833333333333332, Float64(re * re), -0.25), Float64(re * re), 0.5) * 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[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.05], N[(2.0 * N[(N[(N[(N[(re * re), $MachinePrecision] * -0.0006944444444444445), $MachinePrecision] * N[(re * re), $MachinePrecision] + -0.25), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.99995], N[(0.5 * 2.0), $MachinePrecision], N[(N[(N[(0.020833333333333332 * N[(re * re), $MachinePrecision] + -0.25), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{im} + e^{-im}\right) \cdot \left(\cos re \cdot 0.5\right)\\
\mathbf{if}\;t\_0 \leq -0.05:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\left(re \cdot re\right) \cdot -0.0006944444444444445, re \cdot re, -0.25\right), re \cdot re, 0.5\right)\\
\mathbf{elif}\;t\_0 \leq 0.99995:\\
\;\;\;\;0.5 \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.020833333333333332, re \cdot re, -0.25\right), re \cdot re, 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -0.050000000000000003Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites48.1%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6446.8
Applied rewrites46.8%
Taylor expanded in re around inf
Applied rewrites46.8%
if -0.050000000000000003 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 0.999950000000000006Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites98.2%
Taylor expanded in re around 0
Applied rewrites22.9%
if 0.999950000000000006 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6477.0
Applied rewrites77.0%
Taylor expanded in re around 0
+-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-*.f6480.2
Applied rewrites80.2%
Final simplification62.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (+ (exp im) (exp (- im))) (* (cos re) 0.5))))
(if (<= t_0 -0.05)
(* (* -0.25 (* re re)) (fma im im 2.0))
(if (<= t_0 0.99995)
(* 0.5 2.0)
(*
(fma (fma 0.020833333333333332 (* re re) -0.25) (* re re) 0.5)
(fma im im 2.0))))))
double code(double re, double im) {
double t_0 = (exp(im) + exp(-im)) * (cos(re) * 0.5);
double tmp;
if (t_0 <= -0.05) {
tmp = (-0.25 * (re * re)) * fma(im, im, 2.0);
} else if (t_0 <= 0.99995) {
tmp = 0.5 * 2.0;
} else {
tmp = fma(fma(0.020833333333333332, (re * re), -0.25), (re * re), 0.5) * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(cos(re) * 0.5)) tmp = 0.0 if (t_0 <= -0.05) tmp = Float64(Float64(-0.25 * Float64(re * re)) * fma(im, im, 2.0)); elseif (t_0 <= 0.99995) tmp = Float64(0.5 * 2.0); else tmp = Float64(fma(fma(0.020833333333333332, Float64(re * re), -0.25), Float64(re * re), 0.5) * 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[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.05], N[(N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.99995], N[(0.5 * 2.0), $MachinePrecision], N[(N[(N[(0.020833333333333332 * N[(re * re), $MachinePrecision] + -0.25), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{im} + e^{-im}\right) \cdot \left(\cos re \cdot 0.5\right)\\
\mathbf{if}\;t\_0 \leq -0.05:\\
\;\;\;\;\left(-0.25 \cdot \left(re \cdot re\right)\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{elif}\;t\_0 \leq 0.99995:\\
\;\;\;\;0.5 \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.020833333333333332, re \cdot re, -0.25\right), re \cdot re, 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -0.050000000000000003Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6470.1
Applied rewrites70.1%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6440.3
Applied rewrites40.3%
Taylor expanded in re around inf
Applied rewrites40.3%
if -0.050000000000000003 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 0.999950000000000006Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites98.2%
Taylor expanded in re around 0
Applied rewrites22.9%
if 0.999950000000000006 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6477.0
Applied rewrites77.0%
Taylor expanded in re around 0
+-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-*.f6480.2
Applied rewrites80.2%
Final simplification60.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (+ (exp im) (exp (- im))) (* (cos re) 0.5))))
(if (<= t_0 -0.05)
(* (* -0.25 (* re re)) (fma im im 2.0))
(if (<= t_0 0.99995)
(* 0.5 2.0)
(*
(fma (* 0.020833333333333332 (* re re)) (* re re) 0.5)
(fma im im 2.0))))))
double code(double re, double im) {
double t_0 = (exp(im) + exp(-im)) * (cos(re) * 0.5);
double tmp;
if (t_0 <= -0.05) {
tmp = (-0.25 * (re * re)) * fma(im, im, 2.0);
} else if (t_0 <= 0.99995) {
tmp = 0.5 * 2.0;
} else {
tmp = fma((0.020833333333333332 * (re * re)), (re * re), 0.5) * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(cos(re) * 0.5)) tmp = 0.0 if (t_0 <= -0.05) tmp = Float64(Float64(-0.25 * Float64(re * re)) * fma(im, im, 2.0)); elseif (t_0 <= 0.99995) tmp = Float64(0.5 * 2.0); else tmp = Float64(fma(Float64(0.020833333333333332 * Float64(re * re)), Float64(re * re), 0.5) * 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[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.05], N[(N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.99995], N[(0.5 * 2.0), $MachinePrecision], N[(N[(N[(0.020833333333333332 * N[(re * re), $MachinePrecision]), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{im} + e^{-im}\right) \cdot \left(\cos re \cdot 0.5\right)\\
\mathbf{if}\;t\_0 \leq -0.05:\\
\;\;\;\;\left(-0.25 \cdot \left(re \cdot re\right)\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{elif}\;t\_0 \leq 0.99995:\\
\;\;\;\;0.5 \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.020833333333333332 \cdot \left(re \cdot re\right), re \cdot re, 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -0.050000000000000003Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6470.1
Applied rewrites70.1%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6440.3
Applied rewrites40.3%
Taylor expanded in re around inf
Applied rewrites40.3%
if -0.050000000000000003 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 0.999950000000000006Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites98.2%
Taylor expanded in re around 0
Applied rewrites22.9%
if 0.999950000000000006 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6477.0
Applied rewrites77.0%
Taylor expanded in re around 0
+-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-*.f6480.2
Applied rewrites80.2%
Taylor expanded in re around inf
Applied rewrites79.6%
Final simplification60.2%
(FPCore (re im)
:precision binary64
(if (<= (* (+ (exp im) (exp (- im))) (* (cos re) 0.5)) -0.05)
(*
(fma im im 2.0)
(fma
(fma
(fma -0.0006944444444444445 (* re re) 0.020833333333333332)
(* re re)
-0.25)
(* re re)
0.5))
(*
1.0
(fma
(fma
(fma 0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
0.5)
(* im im)
1.0))))
double code(double re, double im) {
double tmp;
if (((exp(im) + exp(-im)) * (cos(re) * 0.5)) <= -0.05) {
tmp = fma(im, im, 2.0) * fma(fma(fma(-0.0006944444444444445, (re * re), 0.020833333333333332), (re * re), -0.25), (re * re), 0.5);
} else {
tmp = 1.0 * fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(cos(re) * 0.5)) <= -0.05) tmp = Float64(fma(im, im, 2.0) * fma(fma(fma(-0.0006944444444444445, Float64(re * re), 0.020833333333333332), Float64(re * re), -0.25), Float64(re * re), 0.5)); else tmp = Float64(1.0 * fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], -0.05], N[(N[(im * im + 2.0), $MachinePrecision] * N[(N[(N[(-0.0006944444444444445 * N[(re * re), $MachinePrecision] + 0.020833333333333332), $MachinePrecision] * N[(re * re), $MachinePrecision] + -0.25), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], N[(1.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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(e^{im} + e^{-im}\right) \cdot \left(\cos re \cdot 0.5\right) \leq -0.05:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0006944444444444445, re \cdot re, 0.020833333333333332\right), re \cdot re, -0.25\right), re \cdot re, 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1 \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)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -0.050000000000000003Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6470.1
Applied rewrites70.1%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6451.0
Applied rewrites51.0%
if -0.050000000000000003 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 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-neg.f64N/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
lower-*.f64N/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.9
Applied rewrites94.9%
Taylor expanded in re around 0
Applied rewrites77.8%
Final simplification70.8%
(FPCore (re im)
:precision binary64
(if (<= (* (+ (exp im) (exp (- im))) (* (cos re) 0.5)) -0.0517)
(*
(* im im)
(fma
(fma
(fma -0.0006944444444444445 (* re re) 0.020833333333333332)
(* re re)
-0.25)
(* re re)
0.5))
(*
1.0
(fma
(fma
(fma 0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
0.5)
(* im im)
1.0))))
double code(double re, double im) {
double tmp;
if (((exp(im) + exp(-im)) * (cos(re) * 0.5)) <= -0.0517) {
tmp = (im * im) * fma(fma(fma(-0.0006944444444444445, (re * re), 0.020833333333333332), (re * re), -0.25), (re * re), 0.5);
} else {
tmp = 1.0 * fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(cos(re) * 0.5)) <= -0.0517) tmp = Float64(Float64(im * im) * fma(fma(fma(-0.0006944444444444445, Float64(re * re), 0.020833333333333332), Float64(re * re), -0.25), Float64(re * re), 0.5)); else tmp = Float64(1.0 * fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], -0.0517], N[(N[(im * im), $MachinePrecision] * N[(N[(N[(-0.0006944444444444445 * N[(re * re), $MachinePrecision] + 0.020833333333333332), $MachinePrecision] * N[(re * re), $MachinePrecision] + -0.25), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], N[(1.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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(e^{im} + e^{-im}\right) \cdot \left(\cos re \cdot 0.5\right) \leq -0.0517:\\
\;\;\;\;\left(im \cdot im\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0006944444444444445, re \cdot re, 0.020833333333333332\right), re \cdot re, -0.25\right), re \cdot re, 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1 \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)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -0.0517000000000000029Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6469.2
Applied rewrites69.2%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6452.5
Applied rewrites52.5%
Taylor expanded in im around inf
Applied rewrites52.2%
if -0.0517000000000000029 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 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-neg.f64N/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
lower-*.f64N/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.9
Applied rewrites94.9%
Taylor expanded in re around 0
Applied rewrites77.0%
Final simplification70.7%
(FPCore (re im)
:precision binary64
(if (<= (* (+ (exp im) (exp (- im))) (* (cos re) 0.5)) -0.05)
(*
2.0
(fma
(fma (* (* re re) -0.0006944444444444445) (* re re) -0.25)
(* re re)
0.5))
(*
1.0
(fma
(fma
(fma 0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
0.5)
(* im im)
1.0))))
double code(double re, double im) {
double tmp;
if (((exp(im) + exp(-im)) * (cos(re) * 0.5)) <= -0.05) {
tmp = 2.0 * fma(fma(((re * re) * -0.0006944444444444445), (re * re), -0.25), (re * re), 0.5);
} else {
tmp = 1.0 * fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(cos(re) * 0.5)) <= -0.05) tmp = Float64(2.0 * fma(fma(Float64(Float64(re * re) * -0.0006944444444444445), Float64(re * re), -0.25), Float64(re * re), 0.5)); else tmp = Float64(1.0 * fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], -0.05], N[(2.0 * N[(N[(N[(N[(re * re), $MachinePrecision] * -0.0006944444444444445), $MachinePrecision] * N[(re * re), $MachinePrecision] + -0.25), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], N[(1.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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(e^{im} + e^{-im}\right) \cdot \left(\cos re \cdot 0.5\right) \leq -0.05:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\left(re \cdot re\right) \cdot -0.0006944444444444445, re \cdot re, -0.25\right), re \cdot re, 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1 \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)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -0.050000000000000003Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites48.1%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6446.8
Applied rewrites46.8%
Taylor expanded in re around inf
Applied rewrites46.8%
if -0.050000000000000003 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 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-neg.f64N/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
lower-*.f64N/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.9
Applied rewrites94.9%
Taylor expanded in re around 0
Applied rewrites77.8%
Final simplification69.7%
(FPCore (re im) :precision binary64 (if (<= (* (+ (exp im) (exp (- im))) (* (cos re) 0.5)) 2.0) (* 0.5 2.0) (* 0.5 (* im im))))
double code(double re, double im) {
double tmp;
if (((exp(im) + exp(-im)) * (cos(re) * 0.5)) <= 2.0) {
tmp = 0.5 * 2.0;
} else {
tmp = 0.5 * (im * im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (((exp(im) + exp(-im)) * (cos(re) * 0.5d0)) <= 2.0d0) then
tmp = 0.5d0 * 2.0d0
else
tmp = 0.5d0 * (im * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (((Math.exp(im) + Math.exp(-im)) * (Math.cos(re) * 0.5)) <= 2.0) {
tmp = 0.5 * 2.0;
} else {
tmp = 0.5 * (im * im);
}
return tmp;
}
def code(re, im): tmp = 0 if ((math.exp(im) + math.exp(-im)) * (math.cos(re) * 0.5)) <= 2.0: tmp = 0.5 * 2.0 else: tmp = 0.5 * (im * im) return tmp
function code(re, im) tmp = 0.0 if (Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(cos(re) * 0.5)) <= 2.0) tmp = Float64(0.5 * 2.0); else tmp = Float64(0.5 * Float64(im * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (((exp(im) + exp(-im)) * (cos(re) * 0.5)) <= 2.0) tmp = 0.5 * 2.0; else tmp = 0.5 * (im * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], N[(0.5 * 2.0), $MachinePrecision], N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(e^{im} + e^{-im}\right) \cdot \left(\cos re \cdot 0.5\right) \leq 2:\\
\;\;\;\;0.5 \cdot 2\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 2Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites79.1%
Taylor expanded in re around 0
Applied rewrites42.3%
if 2 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6459.5
Applied rewrites59.5%
Taylor expanded in re around 0
Applied rewrites59.5%
Taylor expanded in im around inf
Applied rewrites59.5%
Final simplification47.9%
(FPCore (re im) :precision binary64 (* (cos re) (cosh im)))
double code(double re, double im) {
return cos(re) * cosh(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = cos(re) * cosh(im)
end function
public static double code(double re, double im) {
return Math.cos(re) * Math.cosh(im);
}
def code(re, im): return math.cos(re) * math.cosh(im)
function code(re, im) return Float64(cos(re) * cosh(im)) end
function tmp = code(re, im) tmp = cos(re) * cosh(im); end
code[re_, im_] := N[(N[Cos[re], $MachinePrecision] * N[Cosh[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos re \cdot \cosh im
\end{array}
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-neg.f64N/A
cosh-undefN/A
associate-*r*N/A
metadata-evalN/A
lower-*.f64N/A
lower-cosh.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
*-lft-identity100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (re im) :precision binary64 (if (<= (cos re) -0.02) (* (* -0.25 (* re re)) (fma im im 2.0)) (* 0.5 (fma im im 2.0))))
double code(double re, double im) {
double tmp;
if (cos(re) <= -0.02) {
tmp = (-0.25 * (re * re)) * fma(im, im, 2.0);
} else {
tmp = 0.5 * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (cos(re) <= -0.02) tmp = Float64(Float64(-0.25 * Float64(re * re)) * fma(im, im, 2.0)); else tmp = Float64(0.5 * fma(im, im, 2.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Cos[re], $MachinePrecision], -0.02], N[(N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos re \leq -0.02:\\
\;\;\;\;\left(-0.25 \cdot \left(re \cdot re\right)\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if (cos.f64 re) < -0.0200000000000000004Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6470.1
Applied rewrites70.1%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6440.3
Applied rewrites40.3%
Taylor expanded in re around inf
Applied rewrites40.3%
if -0.0200000000000000004 < (cos.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6481.6
Applied rewrites81.6%
Taylor expanded in re around 0
Applied rewrites64.8%
(FPCore (re im) :precision binary64 (if (<= (cos re) -0.02) (* (fma (* re re) -0.25 0.5) 2.0) (* 0.5 (fma im im 2.0))))
double code(double re, double im) {
double tmp;
if (cos(re) <= -0.02) {
tmp = fma((re * re), -0.25, 0.5) * 2.0;
} else {
tmp = 0.5 * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (cos(re) <= -0.02) tmp = Float64(fma(Float64(re * re), -0.25, 0.5) * 2.0); else tmp = Float64(0.5 * fma(im, im, 2.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Cos[re], $MachinePrecision], -0.02], N[(N[(N[(re * re), $MachinePrecision] * -0.25 + 0.5), $MachinePrecision] * 2.0), $MachinePrecision], N[(0.5 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos re \leq -0.02:\\
\;\;\;\;\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if (cos.f64 re) < -0.0200000000000000004Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites48.1%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6423.3
Applied rewrites23.3%
if -0.0200000000000000004 < (cos.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6481.6
Applied rewrites81.6%
Taylor expanded in re around 0
Applied rewrites64.8%
(FPCore (re im) :precision binary64 (* 0.5 (fma im im 2.0)))
double code(double re, double im) {
return 0.5 * fma(im, im, 2.0);
}
function code(re, im) return Float64(0.5 * fma(im, im, 2.0)) end
code[re_, im_] := N[(0.5 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \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.f6478.6
Applied rewrites78.6%
Taylor expanded in re around 0
Applied rewrites48.0%
(FPCore (re im) :precision binary64 (* 0.5 2.0))
double code(double re, double im) {
return 0.5 * 2.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * 2.0d0
end function
public static double code(double re, double im) {
return 0.5 * 2.0;
}
def code(re, im): return 0.5 * 2.0
function code(re, im) return Float64(0.5 * 2.0) end
function tmp = code(re, im) tmp = 0.5 * 2.0; end
code[re_, im_] := N[(0.5 * 2.0), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot 2
\end{array}
Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites54.2%
Taylor expanded in re around 0
Applied rewrites29.5%
herbie shell --seed 2024331
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))