
(FPCore (re im) :precision binary64 (* (exp re) (cos im)))
double code(double re, double im) {
return exp(re) * cos(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * cos(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.cos(im);
}
def code(re, im): return math.exp(re) * math.cos(im)
function code(re, im) return Float64(exp(re) * cos(im)) end
function tmp = code(re, im) tmp = exp(re) * cos(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \cos im
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (exp re) (cos im)))
double code(double re, double im) {
return exp(re) * cos(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * cos(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.cos(im);
}
def code(re, im): return math.exp(re) * math.cos(im)
function code(re, im) return Float64(exp(re) * cos(im)) end
function tmp = code(re, im) tmp = exp(re) * cos(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \cos im
\end{array}
(FPCore (re im) :precision binary64 (* (exp re) (cos im)))
double code(double re, double im) {
return exp(re) * cos(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * cos(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.cos(im);
}
def code(re, im): return math.exp(re) * math.cos(im)
function code(re, im) return Float64(exp(re) * cos(im)) end
function tmp = code(re, im) tmp = exp(re) * cos(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \cos im
\end{array}
Initial program 100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (cos im))) (t_1 (fma (fma 0.5 re 1.0) re 1.0)))
(if (<= t_0 -0.8)
(* t_1 (fma (* im im) -0.5 1.0))
(if (<= t_0 0.0)
(* 1.0 (* (* im im) -0.5))
(*
t_1
(fma (fma 0.041666666666666664 (* im im) -0.5) (* im im) 1.0))))))
double code(double re, double im) {
double t_0 = exp(re) * cos(im);
double t_1 = fma(fma(0.5, re, 1.0), re, 1.0);
double tmp;
if (t_0 <= -0.8) {
tmp = t_1 * fma((im * im), -0.5, 1.0);
} else if (t_0 <= 0.0) {
tmp = 1.0 * ((im * im) * -0.5);
} else {
tmp = t_1 * fma(fma(0.041666666666666664, (im * im), -0.5), (im * im), 1.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(exp(re) * cos(im)) t_1 = fma(fma(0.5, re, 1.0), re, 1.0) tmp = 0.0 if (t_0 <= -0.8) tmp = Float64(t_1 * fma(Float64(im * im), -0.5, 1.0)); elseif (t_0 <= 0.0) tmp = Float64(1.0 * Float64(Float64(im * im) * -0.5)); else tmp = Float64(t_1 * fma(fma(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[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]}, If[LessEqual[t$95$0, -0.8], N[(t$95$1 * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(1.0 * N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \cos im\\
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(0.5, re, 1\right), re, 1\right)\\
\mathbf{if}\;t\_0 \leq -0.8:\\
\;\;\;\;t\_1 \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;1 \cdot \left(\left(im \cdot im\right) \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, -0.5\right), im \cdot im, 1\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -0.80000000000000004Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6469.1
Applied rewrites69.1%
Taylor expanded in re around 0
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
associate-*r*N/A
unpow2N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
rgt-mult-inverseN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
distribute-lft-inN/A
*-commutativeN/A
Applied rewrites69.1%
if -0.80000000000000004 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6465.9
Applied rewrites65.9%
Taylor expanded in re around 0
Applied rewrites2.8%
Taylor expanded in im around inf
Applied rewrites26.4%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in re around 0
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
associate-*r*N/A
unpow2N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
rgt-mult-inverseN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
distribute-lft-inN/A
*-commutativeN/A
Applied rewrites59.5%
Taylor expanded in im 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-*.f6468.3
Applied rewrites68.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (cos im))))
(if (<= t_0 -0.8)
(* (+ 1.0 re) (fma (* im im) -0.5 1.0))
(if (<= t_0 0.0)
(* 1.0 (* (* im im) -0.5))
(* 1.0 (fma (* 0.041666666666666664 (* im im)) (* im im) 1.0))))))
double code(double re, double im) {
double t_0 = exp(re) * cos(im);
double tmp;
if (t_0 <= -0.8) {
tmp = (1.0 + re) * fma((im * im), -0.5, 1.0);
} else if (t_0 <= 0.0) {
tmp = 1.0 * ((im * im) * -0.5);
} else {
tmp = 1.0 * fma((0.041666666666666664 * (im * im)), (im * im), 1.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(exp(re) * cos(im)) tmp = 0.0 if (t_0 <= -0.8) tmp = Float64(Float64(1.0 + re) * fma(Float64(im * im), -0.5, 1.0)); elseif (t_0 <= 0.0) tmp = Float64(1.0 * Float64(Float64(im * im) * -0.5)); else tmp = Float64(1.0 * fma(Float64(0.041666666666666664 * Float64(im * im)), Float64(im * im), 1.0)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.8], N[(N[(1.0 + re), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(1.0 * N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(1.0 * N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \cos im\\
\mathbf{if}\;t\_0 \leq -0.8:\\
\;\;\;\;\left(1 + re\right) \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;1 \cdot \left(\left(im \cdot im\right) \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \mathsf{fma}\left(0.041666666666666664 \cdot \left(im \cdot im\right), im \cdot im, 1\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -0.80000000000000004Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6469.1
Applied rewrites69.1%
Taylor expanded in re around 0
lower-+.f6465.6
Applied rewrites65.6%
if -0.80000000000000004 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6465.9
Applied rewrites65.9%
Taylor expanded in re around 0
Applied rewrites2.8%
Taylor expanded in im around inf
Applied rewrites26.4%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in re around 0
Applied rewrites51.1%
Taylor expanded in im 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-*.f6457.2
Applied rewrites57.2%
Taylor expanded in im around inf
Applied rewrites56.9%
(FPCore (re im)
:precision binary64
(if (<= (exp re) 0.0)
(* 1.0 (* (* im im) -0.5))
(if (<= (exp re) 1.02)
(* (+ 1.0 re) (cos im))
(*
(fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0)
(fma (* im im) -0.5 1.0)))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.0) {
tmp = 1.0 * ((im * im) * -0.5);
} else if (exp(re) <= 1.02) {
tmp = (1.0 + re) * cos(im);
} else {
tmp = fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0) * fma((im * im), -0.5, 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (exp(re) <= 0.0) tmp = Float64(1.0 * Float64(Float64(im * im) * -0.5)); elseif (exp(re) <= 1.02) tmp = Float64(Float64(1.0 + re) * cos(im)); else tmp = Float64(fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0) * fma(Float64(im * im), -0.5, 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[(1.0 * N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 1.02], N[(N[(1.0 + re), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0:\\
\;\;\;\;1 \cdot \left(\left(im \cdot im\right) \cdot -0.5\right)\\
\mathbf{elif}\;e^{re} \leq 1.02:\\
\;\;\;\;\left(1 + re\right) \cdot \cos im\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right) \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in re around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites30.1%
if 0.0 < (exp.f64 re) < 1.02Initial program 100.0%
Taylor expanded in re around 0
lower-+.f6499.3
Applied rewrites99.3%
if 1.02 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.0
Applied rewrites80.0%
Taylor expanded in re around 0
+-commutativeN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
rgt-mult-inverseN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.1%
(FPCore (re im)
:precision binary64
(if (<= (exp re) 0.0)
(* 1.0 (* (* im im) -0.5))
(if (<= (exp re) 1.02)
(cos im)
(*
(fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0)
(fma (* im im) -0.5 1.0)))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.0) {
tmp = 1.0 * ((im * im) * -0.5);
} else if (exp(re) <= 1.02) {
tmp = cos(im);
} else {
tmp = fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0) * fma((im * im), -0.5, 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (exp(re) <= 0.0) tmp = Float64(1.0 * Float64(Float64(im * im) * -0.5)); elseif (exp(re) <= 1.02) tmp = cos(im); else tmp = Float64(fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0) * fma(Float64(im * im), -0.5, 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[(1.0 * N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 1.02], N[Cos[im], $MachinePrecision], N[(N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0:\\
\;\;\;\;1 \cdot \left(\left(im \cdot im\right) \cdot -0.5\right)\\
\mathbf{elif}\;e^{re} \leq 1.02:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right) \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in re around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites30.1%
if 0.0 < (exp.f64 re) < 1.02Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f6499.0
Applied rewrites99.0%
if 1.02 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.0
Applied rewrites80.0%
Taylor expanded in re around 0
+-commutativeN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
rgt-mult-inverseN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (fma (* im im) -0.5 1.0)))
(if (<= (exp re) 0.0)
(* 1.0 (* (* im im) -0.5))
(if (<= (exp re) 2.0)
(* (fma (fma 0.5 re 1.0) re 1.0) t_0)
(* (* (fma 0.16666666666666666 re 0.5) (* re re)) t_0)))))
double code(double re, double im) {
double t_0 = fma((im * im), -0.5, 1.0);
double tmp;
if (exp(re) <= 0.0) {
tmp = 1.0 * ((im * im) * -0.5);
} else if (exp(re) <= 2.0) {
tmp = fma(fma(0.5, re, 1.0), re, 1.0) * t_0;
} else {
tmp = (fma(0.16666666666666666, re, 0.5) * (re * re)) * t_0;
}
return tmp;
}
function code(re, im) t_0 = fma(Float64(im * im), -0.5, 1.0) tmp = 0.0 if (exp(re) <= 0.0) tmp = Float64(1.0 * Float64(Float64(im * im) * -0.5)); elseif (exp(re) <= 2.0) tmp = Float64(fma(fma(0.5, re, 1.0), re, 1.0) * t_0); else tmp = Float64(Float64(fma(0.16666666666666666, re, 0.5) * Float64(re * re)) * t_0); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, If[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[(1.0 * N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 2.0], N[(N[(N[(0.5 * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\mathbf{if}\;e^{re} \leq 0:\\
\;\;\;\;1 \cdot \left(\left(im \cdot im\right) \cdot -0.5\right)\\
\mathbf{elif}\;e^{re} \leq 2:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, re, 1\right), re, 1\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right) \cdot \left(re \cdot re\right)\right) \cdot t\_0\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in re around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites30.1%
if 0.0 < (exp.f64 re) < 2Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6458.7
Applied rewrites58.7%
Taylor expanded in re around 0
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
associate-*r*N/A
unpow2N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
rgt-mult-inverseN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
distribute-lft-inN/A
*-commutativeN/A
Applied rewrites57.2%
if 2 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6479.2
Applied rewrites79.2%
Taylor expanded in re around 0
+-commutativeN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
rgt-mult-inverseN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.7%
Taylor expanded in re around inf
Applied rewrites68.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (fma (* im im) -0.5 1.0)))
(if (<= (exp re) 0.0)
(* 1.0 (* (* im im) -0.5))
(if (<= (exp re) 2.0) (* (+ 1.0 re) t_0) (* (* (* re re) 0.5) t_0)))))
double code(double re, double im) {
double t_0 = fma((im * im), -0.5, 1.0);
double tmp;
if (exp(re) <= 0.0) {
tmp = 1.0 * ((im * im) * -0.5);
} else if (exp(re) <= 2.0) {
tmp = (1.0 + re) * t_0;
} else {
tmp = ((re * re) * 0.5) * t_0;
}
return tmp;
}
function code(re, im) t_0 = fma(Float64(im * im), -0.5, 1.0) tmp = 0.0 if (exp(re) <= 0.0) tmp = Float64(1.0 * Float64(Float64(im * im) * -0.5)); elseif (exp(re) <= 2.0) tmp = Float64(Float64(1.0 + re) * t_0); else tmp = Float64(Float64(Float64(re * re) * 0.5) * t_0); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, If[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[(1.0 * N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 2.0], N[(N[(1.0 + re), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\mathbf{if}\;e^{re} \leq 0:\\
\;\;\;\;1 \cdot \left(\left(im \cdot im\right) \cdot -0.5\right)\\
\mathbf{elif}\;e^{re} \leq 2:\\
\;\;\;\;\left(1 + re\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(re \cdot re\right) \cdot 0.5\right) \cdot t\_0\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in re around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites30.1%
if 0.0 < (exp.f64 re) < 2Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6458.7
Applied rewrites58.7%
Taylor expanded in re around 0
lower-+.f6457.0
Applied rewrites57.0%
if 2 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6479.2
Applied rewrites79.2%
Taylor expanded in re around 0
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
associate-*r*N/A
unpow2N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
rgt-mult-inverseN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
distribute-lft-inN/A
*-commutativeN/A
Applied rewrites56.3%
Applied rewrites56.3%
Taylor expanded in re around inf
Applied rewrites56.3%
(FPCore (re im)
:precision binary64
(if (<= (exp re) 0.0)
(* 1.0 (* (* im im) -0.5))
(*
(fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0)
(fma (* im im) -0.5 1.0))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.0) {
tmp = 1.0 * ((im * im) * -0.5);
} else {
tmp = fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0) * fma((im * im), -0.5, 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (exp(re) <= 0.0) tmp = Float64(1.0 * Float64(Float64(im * im) * -0.5)); else tmp = Float64(fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0) * fma(Float64(im * im), -0.5, 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[(1.0 * N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0:\\
\;\;\;\;1 \cdot \left(\left(im \cdot im\right) \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right) \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in re around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites30.1%
if 0.0 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6464.9
Applied rewrites64.9%
Taylor expanded in re around 0
+-commutativeN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
rgt-mult-inverseN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites60.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (fma (* im im) -0.5 1.0))))
(if (<= re -0.00068)
t_0
(if (<= re 0.00037)
(* (+ 1.0 re) (cos im))
(if (<= re 3.1e+98)
t_0
(* (fma (* (* re re) 0.16666666666666666) re 1.0) (cos im)))))))
double code(double re, double im) {
double t_0 = exp(re) * fma((im * im), -0.5, 1.0);
double tmp;
if (re <= -0.00068) {
tmp = t_0;
} else if (re <= 0.00037) {
tmp = (1.0 + re) * cos(im);
} else if (re <= 3.1e+98) {
tmp = t_0;
} else {
tmp = fma(((re * re) * 0.16666666666666666), re, 1.0) * cos(im);
}
return tmp;
}
function code(re, im) t_0 = Float64(exp(re) * fma(Float64(im * im), -0.5, 1.0)) tmp = 0.0 if (re <= -0.00068) tmp = t_0; elseif (re <= 0.00037) tmp = Float64(Float64(1.0 + re) * cos(im)); elseif (re <= 3.1e+98) tmp = t_0; else tmp = Float64(fma(Float64(Float64(re * re) * 0.16666666666666666), re, 1.0) * cos(im)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -0.00068], t$95$0, If[LessEqual[re, 0.00037], N[(N[(1.0 + re), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 3.1e+98], t$95$0, N[(N[(N[(N[(re * re), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * re + 1.0), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\mathbf{if}\;re \leq -0.00068:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;re \leq 0.00037:\\
\;\;\;\;\left(1 + re\right) \cdot \cos im\\
\mathbf{elif}\;re \leq 3.1 \cdot 10^{+98}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(re \cdot re\right) \cdot 0.16666666666666666, re, 1\right) \cdot \cos im\\
\end{array}
\end{array}
if re < -6.8e-4 or 3.6999999999999999e-4 < re < 3.10000000000000019e98Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6478.4
Applied rewrites78.4%
if -6.8e-4 < re < 3.6999999999999999e-4Initial program 100.0%
Taylor expanded in re around 0
lower-+.f64100.0
Applied rewrites100.0%
if 3.10000000000000019e98 < re Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6497.6
Applied rewrites97.6%
Taylor expanded in re around inf
Applied rewrites97.6%
(FPCore (re im)
:precision binary64
(if (<= (exp re) 0.0)
(* 1.0 (* (* im im) -0.5))
(*
(fma (* (* re re) 0.16666666666666666) re 1.0)
(fma (* im im) -0.5 1.0))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.0) {
tmp = 1.0 * ((im * im) * -0.5);
} else {
tmp = fma(((re * re) * 0.16666666666666666), re, 1.0) * fma((im * im), -0.5, 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (exp(re) <= 0.0) tmp = Float64(1.0 * Float64(Float64(im * im) * -0.5)); else tmp = Float64(fma(Float64(Float64(re * re) * 0.16666666666666666), re, 1.0) * fma(Float64(im * im), -0.5, 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[(1.0 * N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(re * re), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * re + 1.0), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0:\\
\;\;\;\;1 \cdot \left(\left(im \cdot im\right) \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(re \cdot re\right) \cdot 0.16666666666666666, re, 1\right) \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in re around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites30.1%
if 0.0 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6464.9
Applied rewrites64.9%
Taylor expanded in re around 0
+-commutativeN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
rgt-mult-inverseN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites60.8%
Taylor expanded in re around inf
Applied rewrites60.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (fma (* im im) -0.5 1.0))))
(if (<= re -0.00068)
t_0
(if (<= re 0.00037)
(* (+ 1.0 re) (cos im))
(if (<= re 1.35e+154) t_0 (* (* (* re re) 0.5) (cos im)))))))
double code(double re, double im) {
double t_0 = exp(re) * fma((im * im), -0.5, 1.0);
double tmp;
if (re <= -0.00068) {
tmp = t_0;
} else if (re <= 0.00037) {
tmp = (1.0 + re) * cos(im);
} else if (re <= 1.35e+154) {
tmp = t_0;
} else {
tmp = ((re * re) * 0.5) * cos(im);
}
return tmp;
}
function code(re, im) t_0 = Float64(exp(re) * fma(Float64(im * im), -0.5, 1.0)) tmp = 0.0 if (re <= -0.00068) tmp = t_0; elseif (re <= 0.00037) tmp = Float64(Float64(1.0 + re) * cos(im)); elseif (re <= 1.35e+154) tmp = t_0; else tmp = Float64(Float64(Float64(re * re) * 0.5) * cos(im)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -0.00068], t$95$0, If[LessEqual[re, 0.00037], N[(N[(1.0 + re), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.35e+154], t$95$0, N[(N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\mathbf{if}\;re \leq -0.00068:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;re \leq 0.00037:\\
\;\;\;\;\left(1 + re\right) \cdot \cos im\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(re \cdot re\right) \cdot 0.5\right) \cdot \cos im\\
\end{array}
\end{array}
if re < -6.8e-4 or 3.6999999999999999e-4 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6479.6
Applied rewrites79.6%
if -6.8e-4 < re < 3.6999999999999999e-4Initial program 100.0%
Taylor expanded in re around 0
lower-+.f64100.0
Applied rewrites100.0%
if 1.35000000000000003e154 < re Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in re around inf
Applied rewrites100.0%
(FPCore (re im) :precision binary64 (if (<= (exp re) 0.0) (* 1.0 (* (* im im) -0.5)) (* (fma (fma 0.5 re 1.0) re 1.0) (fma (* im im) -0.5 1.0))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.0) {
tmp = 1.0 * ((im * im) * -0.5);
} else {
tmp = fma(fma(0.5, re, 1.0), re, 1.0) * fma((im * im), -0.5, 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (exp(re) <= 0.0) tmp = Float64(1.0 * Float64(Float64(im * im) * -0.5)); else tmp = Float64(fma(fma(0.5, re, 1.0), re, 1.0) * fma(Float64(im * im), -0.5, 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[(1.0 * N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0:\\
\;\;\;\;1 \cdot \left(\left(im \cdot im\right) \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, re, 1\right), re, 1\right) \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in re around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites30.1%
if 0.0 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6464.9
Applied rewrites64.9%
Taylor expanded in re around 0
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
associate-*r*N/A
unpow2N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
rgt-mult-inverseN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
distribute-lft-inN/A
*-commutativeN/A
Applied rewrites56.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 re) re)))
(if (<= re -1.0)
(* (exp re) (* (* im im) -0.5))
(if (<= re 0.0275)
(* (+ 1.0 re) (cos im))
(if (<= re 1.35e+154)
(*
(+ (/ (- (* t_0 t_0) (* re re)) (- t_0 re)) 1.0)
(fma (* im im) -0.5 1.0))
(* (* (* re re) 0.5) (cos im)))))))
double code(double re, double im) {
double t_0 = (0.5 * re) * re;
double tmp;
if (re <= -1.0) {
tmp = exp(re) * ((im * im) * -0.5);
} else if (re <= 0.0275) {
tmp = (1.0 + re) * cos(im);
} else if (re <= 1.35e+154) {
tmp = ((((t_0 * t_0) - (re * re)) / (t_0 - re)) + 1.0) * fma((im * im), -0.5, 1.0);
} else {
tmp = ((re * re) * 0.5) * cos(im);
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(0.5 * re) * re) tmp = 0.0 if (re <= -1.0) tmp = Float64(exp(re) * Float64(Float64(im * im) * -0.5)); elseif (re <= 0.0275) tmp = Float64(Float64(1.0 + re) * cos(im)); elseif (re <= 1.35e+154) tmp = Float64(Float64(Float64(Float64(Float64(t_0 * t_0) - Float64(re * re)) / Float64(t_0 - re)) + 1.0) * fma(Float64(im * im), -0.5, 1.0)); else tmp = Float64(Float64(Float64(re * re) * 0.5) * cos(im)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * re), $MachinePrecision] * re), $MachinePrecision]}, If[LessEqual[re, -1.0], N[(N[Exp[re], $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 0.0275], N[(N[(1.0 + re), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.35e+154], N[(N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot re\right) \cdot re\\
\mathbf{if}\;re \leq -1:\\
\;\;\;\;e^{re} \cdot \left(\left(im \cdot im\right) \cdot -0.5\right)\\
\mathbf{elif}\;re \leq 0.0275:\\
\;\;\;\;\left(1 + re\right) \cdot \cos im\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(\frac{t\_0 \cdot t\_0 - re \cdot re}{t\_0 - re} + 1\right) \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(re \cdot re\right) \cdot 0.5\right) \cdot \cos im\\
\end{array}
\end{array}
if re < -1Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in im around inf
Applied rewrites75.9%
if -1 < re < 0.0275000000000000001Initial program 100.0%
Taylor expanded in re around 0
lower-+.f6499.3
Applied rewrites99.3%
if 0.0275000000000000001 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6489.3
Applied rewrites89.3%
Taylor expanded in re around 0
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
associate-*r*N/A
unpow2N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
rgt-mult-inverseN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
distribute-lft-inN/A
*-commutativeN/A
Applied rewrites41.8%
Applied rewrites41.8%
Applied rewrites74.8%
if 1.35000000000000003e154 < re Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in re around inf
Applied rewrites100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 re) re)))
(if (<= re -1.0)
(* 1.0 (* (pow im 6.0) -0.001388888888888889))
(if (<= re 0.0275)
(* (+ 1.0 re) (cos im))
(if (<= re 1.35e+154)
(*
(+ (/ (- (* t_0 t_0) (* re re)) (- t_0 re)) 1.0)
(fma (* im im) -0.5 1.0))
(* (* (* re re) 0.5) (cos im)))))))
double code(double re, double im) {
double t_0 = (0.5 * re) * re;
double tmp;
if (re <= -1.0) {
tmp = 1.0 * (pow(im, 6.0) * -0.001388888888888889);
} else if (re <= 0.0275) {
tmp = (1.0 + re) * cos(im);
} else if (re <= 1.35e+154) {
tmp = ((((t_0 * t_0) - (re * re)) / (t_0 - re)) + 1.0) * fma((im * im), -0.5, 1.0);
} else {
tmp = ((re * re) * 0.5) * cos(im);
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(0.5 * re) * re) tmp = 0.0 if (re <= -1.0) tmp = Float64(1.0 * Float64((im ^ 6.0) * -0.001388888888888889)); elseif (re <= 0.0275) tmp = Float64(Float64(1.0 + re) * cos(im)); elseif (re <= 1.35e+154) tmp = Float64(Float64(Float64(Float64(Float64(t_0 * t_0) - Float64(re * re)) / Float64(t_0 - re)) + 1.0) * fma(Float64(im * im), -0.5, 1.0)); else tmp = Float64(Float64(Float64(re * re) * 0.5) * cos(im)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * re), $MachinePrecision] * re), $MachinePrecision]}, If[LessEqual[re, -1.0], N[(1.0 * N[(N[Power[im, 6.0], $MachinePrecision] * -0.001388888888888889), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 0.0275], N[(N[(1.0 + re), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.35e+154], N[(N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot re\right) \cdot re\\
\mathbf{if}\;re \leq -1:\\
\;\;\;\;1 \cdot \left({im}^{6} \cdot -0.001388888888888889\right)\\
\mathbf{elif}\;re \leq 0.0275:\\
\;\;\;\;\left(1 + re\right) \cdot \cos im\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(\frac{t\_0 \cdot t\_0 - re \cdot re}{t\_0 - re} + 1\right) \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(re \cdot re\right) \cdot 0.5\right) \cdot \cos im\\
\end{array}
\end{array}
if re < -1Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in re around 0
Applied rewrites2.5%
Taylor expanded in im 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-*.f642.4
Applied rewrites2.4%
Taylor expanded in im around inf
Applied rewrites43.0%
if -1 < re < 0.0275000000000000001Initial program 100.0%
Taylor expanded in re around 0
lower-+.f6499.3
Applied rewrites99.3%
if 0.0275000000000000001 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6489.3
Applied rewrites89.3%
Taylor expanded in re around 0
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
associate-*r*N/A
unpow2N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
rgt-mult-inverseN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
distribute-lft-inN/A
*-commutativeN/A
Applied rewrites41.8%
Applied rewrites41.8%
Applied rewrites74.8%
if 1.35000000000000003e154 < re Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in re around inf
Applied rewrites100.0%
(FPCore (re im) :precision binary64 (if (<= (exp re) 0.0) (* 1.0 (* (* im im) -0.5)) (* (+ 1.0 re) (fma (* im im) -0.5 1.0))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.0) {
tmp = 1.0 * ((im * im) * -0.5);
} else {
tmp = (1.0 + re) * fma((im * im), -0.5, 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (exp(re) <= 0.0) tmp = Float64(1.0 * Float64(Float64(im * im) * -0.5)); else tmp = Float64(Float64(1.0 + re) * fma(Float64(im * im), -0.5, 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[(1.0 * N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + re), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0:\\
\;\;\;\;1 \cdot \left(\left(im \cdot im\right) \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + re\right) \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in re around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites30.1%
if 0.0 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6464.9
Applied rewrites64.9%
Taylor expanded in re around 0
lower-+.f6450.3
Applied rewrites50.3%
(FPCore (re im) :precision binary64 (if (<= (exp re) 1.5e-176) (* 1.0 (* (* im im) -0.5)) (* 1.0 (fma (* im im) -0.5 1.0))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 1.5e-176) {
tmp = 1.0 * ((im * im) * -0.5);
} else {
tmp = 1.0 * fma((im * im), -0.5, 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (exp(re) <= 1.5e-176) tmp = Float64(1.0 * Float64(Float64(im * im) * -0.5)); else tmp = Float64(1.0 * fma(Float64(im * im), -0.5, 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 1.5e-176], N[(1.0 * N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(1.0 * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 1.5 \cdot 10^{-176}:\\
\;\;\;\;1 \cdot \left(\left(im \cdot im\right) \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 1.5e-176Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in re around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites30.1%
if 1.5e-176 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6464.9
Applied rewrites64.9%
Taylor expanded in re around 0
Applied rewrites46.7%
(FPCore (re im)
:precision binary64
(if (<= re -1.0)
(* 1.0 (* (pow im 6.0) -0.001388888888888889))
(if (<= re 0.0155)
(* (+ 1.0 re) (cos im))
(*
(fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0)
(fma (* im im) -0.5 1.0)))))
double code(double re, double im) {
double tmp;
if (re <= -1.0) {
tmp = 1.0 * (pow(im, 6.0) * -0.001388888888888889);
} else if (re <= 0.0155) {
tmp = (1.0 + re) * cos(im);
} else {
tmp = fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0) * fma((im * im), -0.5, 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (re <= -1.0) tmp = Float64(1.0 * Float64((im ^ 6.0) * -0.001388888888888889)); elseif (re <= 0.0155) tmp = Float64(Float64(1.0 + re) * cos(im)); else tmp = Float64(fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0) * fma(Float64(im * im), -0.5, 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[re, -1.0], N[(1.0 * N[(N[Power[im, 6.0], $MachinePrecision] * -0.001388888888888889), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 0.0155], N[(N[(1.0 + re), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1:\\
\;\;\;\;1 \cdot \left({im}^{6} \cdot -0.001388888888888889\right)\\
\mathbf{elif}\;re \leq 0.0155:\\
\;\;\;\;\left(1 + re\right) \cdot \cos im\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right) \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\end{array}
\end{array}
if re < -1Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in re around 0
Applied rewrites2.5%
Taylor expanded in im 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-*.f642.4
Applied rewrites2.4%
Taylor expanded in im around inf
Applied rewrites43.0%
if -1 < re < 0.0155Initial program 100.0%
Taylor expanded in re around 0
lower-+.f6499.3
Applied rewrites99.3%
if 0.0155 < re Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.0
Applied rewrites80.0%
Taylor expanded in re around 0
+-commutativeN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
rgt-mult-inverseN/A
distribute-lft-inN/A
associate-+r+N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.1%
(FPCore (re im) :precision binary64 (* 1.0 (* (* im im) -0.5)))
double code(double re, double im) {
return 1.0 * ((im * im) * -0.5);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0 * ((im * im) * (-0.5d0))
end function
public static double code(double re, double im) {
return 1.0 * ((im * im) * -0.5);
}
def code(re, im): return 1.0 * ((im * im) * -0.5)
function code(re, im) return Float64(1.0 * Float64(Float64(im * im) * -0.5)) end
function tmp = code(re, im) tmp = 1.0 * ((im * im) * -0.5); end
code[re_, im_] := N[(1.0 * N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot \left(\left(im \cdot im\right) \cdot -0.5\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6468.3
Applied rewrites68.3%
Taylor expanded in re around 0
Applied rewrites33.1%
Taylor expanded in im around inf
Applied rewrites15.2%
herbie shell --seed 2024319
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))