
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))) (t_1 (* (exp im) -0.5)))
(if (<= t_0 (- INFINITY))
(* (+ 0.5 t_1) (cos re))
(if (<= t_0 0.001)
(- (* -0.16666666666666666 (* (cos re) (pow im 3.0))) (* im (cos re)))
(+ (* (cos re) (/ 0.5 (exp im))) (* t_1 (cos re)))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double t_1 = exp(im) * -0.5;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (0.5 + t_1) * cos(re);
} else if (t_0 <= 0.001) {
tmp = (-0.16666666666666666 * (cos(re) * pow(im, 3.0))) - (im * cos(re));
} else {
tmp = (cos(re) * (0.5 / exp(im))) + (t_1 * cos(re));
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double t_1 = Math.exp(im) * -0.5;
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (0.5 + t_1) * Math.cos(re);
} else if (t_0 <= 0.001) {
tmp = (-0.16666666666666666 * (Math.cos(re) * Math.pow(im, 3.0))) - (im * Math.cos(re));
} else {
tmp = (Math.cos(re) * (0.5 / Math.exp(im))) + (t_1 * Math.cos(re));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) t_1 = math.exp(im) * -0.5 tmp = 0 if t_0 <= -math.inf: tmp = (0.5 + t_1) * math.cos(re) elif t_0 <= 0.001: tmp = (-0.16666666666666666 * (math.cos(re) * math.pow(im, 3.0))) - (im * math.cos(re)) else: tmp = (math.cos(re) * (0.5 / math.exp(im))) + (t_1 * math.cos(re)) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) t_1 = Float64(exp(im) * -0.5) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(0.5 + t_1) * cos(re)); elseif (t_0 <= 0.001) tmp = Float64(Float64(-0.16666666666666666 * Float64(cos(re) * (im ^ 3.0))) - Float64(im * cos(re))); else tmp = Float64(Float64(cos(re) * Float64(0.5 / exp(im))) + Float64(t_1 * cos(re))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); t_1 = exp(im) * -0.5; tmp = 0.0; if (t_0 <= -Inf) tmp = (0.5 + t_1) * cos(re); elseif (t_0 <= 0.001) tmp = (-0.16666666666666666 * (cos(re) * (im ^ 3.0))) - (im * cos(re)); else tmp = (cos(re) * (0.5 / exp(im))) + (t_1 * cos(re)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[im], $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(0.5 + t$95$1), $MachinePrecision] * N[Cos[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.001], N[(N[(-0.16666666666666666 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[re], $MachinePrecision] * N[(0.5 / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := e^{im} \cdot -0.5\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\left(0.5 + t_1\right) \cdot \cos re\\
\mathbf{elif}\;t_0 \leq 0.001:\\
\;\;\;\;-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - im \cdot \cos re\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \frac{0.5}{e^{im}} + t_1 \cdot \cos re\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -inf.0Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
if -inf.0 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1e-3Initial program 8.7%
*-commutative8.7%
associate-*l*8.7%
sub-neg8.7%
+-commutative8.7%
distribute-lft-in8.7%
distribute-lft-in8.7%
distribute-rgt-in8.7%
distribute-lft-neg-out8.7%
distribute-rgt-neg-in8.7%
metadata-eval8.7%
metadata-eval8.7%
fma-def8.7%
metadata-eval8.7%
exp-diff8.7%
associate-*l/8.7%
exp-08.7%
metadata-eval8.7%
Simplified8.7%
Taylor expanded in im around 0 99.8%
mul-1-neg99.8%
unsub-neg99.8%
*-commutative99.8%
*-commutative99.8%
Simplified99.8%
if 1e-3 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 99.9%
*-commutative99.9%
associate-*l*99.9%
sub-neg99.9%
+-commutative99.9%
distribute-lft-in99.9%
distribute-lft-in99.9%
distribute-rgt-in99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-in99.9%
metadata-eval99.9%
metadata-eval99.9%
fma-def99.9%
metadata-eval99.9%
exp-diff99.9%
associate-*l/99.9%
exp-099.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in re around inf 99.9%
*-commutative99.9%
associate-*r/99.9%
metadata-eval99.9%
*-commutative99.9%
Simplified99.9%
*-commutative99.9%
distribute-rgt-in100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))) (t_1 (* (exp im) -0.5)))
(if (<= t_0 (- INFINITY))
(* (+ 0.5 t_1) (cos re))
(if (<= t_0 0.01)
(*
(cos re)
(+
(* -0.008333333333333333 (pow im 5.0))
(- (* -0.16666666666666666 (pow im 3.0)) im)))
(* (cos re) (+ t_1 (/ 0.5 (exp im))))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double t_1 = exp(im) * -0.5;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (0.5 + t_1) * cos(re);
} else if (t_0 <= 0.01) {
tmp = cos(re) * ((-0.008333333333333333 * pow(im, 5.0)) + ((-0.16666666666666666 * pow(im, 3.0)) - im));
} else {
tmp = cos(re) * (t_1 + (0.5 / exp(im)));
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double t_1 = Math.exp(im) * -0.5;
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (0.5 + t_1) * Math.cos(re);
} else if (t_0 <= 0.01) {
tmp = Math.cos(re) * ((-0.008333333333333333 * Math.pow(im, 5.0)) + ((-0.16666666666666666 * Math.pow(im, 3.0)) - im));
} else {
tmp = Math.cos(re) * (t_1 + (0.5 / Math.exp(im)));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) t_1 = math.exp(im) * -0.5 tmp = 0 if t_0 <= -math.inf: tmp = (0.5 + t_1) * math.cos(re) elif t_0 <= 0.01: tmp = math.cos(re) * ((-0.008333333333333333 * math.pow(im, 5.0)) + ((-0.16666666666666666 * math.pow(im, 3.0)) - im)) else: tmp = math.cos(re) * (t_1 + (0.5 / math.exp(im))) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) t_1 = Float64(exp(im) * -0.5) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(0.5 + t_1) * cos(re)); elseif (t_0 <= 0.01) tmp = Float64(cos(re) * Float64(Float64(-0.008333333333333333 * (im ^ 5.0)) + Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im))); else tmp = Float64(cos(re) * Float64(t_1 + Float64(0.5 / exp(im)))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); t_1 = exp(im) * -0.5; tmp = 0.0; if (t_0 <= -Inf) tmp = (0.5 + t_1) * cos(re); elseif (t_0 <= 0.01) tmp = cos(re) * ((-0.008333333333333333 * (im ^ 5.0)) + ((-0.16666666666666666 * (im ^ 3.0)) - im)); else tmp = cos(re) * (t_1 + (0.5 / exp(im))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[im], $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(0.5 + t$95$1), $MachinePrecision] * N[Cos[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.01], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.008333333333333333 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(t$95$1 + N[(0.5 / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := e^{im} \cdot -0.5\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\left(0.5 + t_1\right) \cdot \cos re\\
\mathbf{elif}\;t_0 \leq 0.01:\\
\;\;\;\;\cos re \cdot \left(-0.008333333333333333 \cdot {im}^{5} + \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(t_1 + \frac{0.5}{e^{im}}\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -inf.0Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
if -inf.0 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 0.0100000000000000002Initial program 9.3%
*-commutative9.3%
associate-*l*9.3%
sub-neg9.3%
+-commutative9.3%
distribute-lft-in9.3%
distribute-lft-in9.3%
distribute-rgt-in9.3%
distribute-lft-neg-out9.3%
distribute-rgt-neg-in9.3%
metadata-eval9.3%
metadata-eval9.3%
fma-def9.3%
metadata-eval9.3%
exp-diff9.3%
associate-*l/9.3%
exp-09.3%
metadata-eval9.3%
Simplified9.3%
Taylor expanded in im around 0 99.8%
if 0.0100000000000000002 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))) (t_1 (* (exp im) -0.5)))
(if (<= t_0 (- INFINITY))
(* (+ 0.5 t_1) (cos re))
(if (<= t_0 0.001)
(- (* -0.16666666666666666 (* (cos re) (pow im 3.0))) (* im (cos re)))
(* (cos re) (+ t_1 (/ 0.5 (exp im))))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double t_1 = exp(im) * -0.5;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (0.5 + t_1) * cos(re);
} else if (t_0 <= 0.001) {
tmp = (-0.16666666666666666 * (cos(re) * pow(im, 3.0))) - (im * cos(re));
} else {
tmp = cos(re) * (t_1 + (0.5 / exp(im)));
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double t_1 = Math.exp(im) * -0.5;
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (0.5 + t_1) * Math.cos(re);
} else if (t_0 <= 0.001) {
tmp = (-0.16666666666666666 * (Math.cos(re) * Math.pow(im, 3.0))) - (im * Math.cos(re));
} else {
tmp = Math.cos(re) * (t_1 + (0.5 / Math.exp(im)));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) t_1 = math.exp(im) * -0.5 tmp = 0 if t_0 <= -math.inf: tmp = (0.5 + t_1) * math.cos(re) elif t_0 <= 0.001: tmp = (-0.16666666666666666 * (math.cos(re) * math.pow(im, 3.0))) - (im * math.cos(re)) else: tmp = math.cos(re) * (t_1 + (0.5 / math.exp(im))) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) t_1 = Float64(exp(im) * -0.5) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(0.5 + t_1) * cos(re)); elseif (t_0 <= 0.001) tmp = Float64(Float64(-0.16666666666666666 * Float64(cos(re) * (im ^ 3.0))) - Float64(im * cos(re))); else tmp = Float64(cos(re) * Float64(t_1 + Float64(0.5 / exp(im)))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); t_1 = exp(im) * -0.5; tmp = 0.0; if (t_0 <= -Inf) tmp = (0.5 + t_1) * cos(re); elseif (t_0 <= 0.001) tmp = (-0.16666666666666666 * (cos(re) * (im ^ 3.0))) - (im * cos(re)); else tmp = cos(re) * (t_1 + (0.5 / exp(im))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[im], $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(0.5 + t$95$1), $MachinePrecision] * N[Cos[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.001], N[(N[(-0.16666666666666666 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(t$95$1 + N[(0.5 / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := e^{im} \cdot -0.5\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\left(0.5 + t_1\right) \cdot \cos re\\
\mathbf{elif}\;t_0 \leq 0.001:\\
\;\;\;\;-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - im \cdot \cos re\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(t_1 + \frac{0.5}{e^{im}}\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -inf.0Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
if -inf.0 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1e-3Initial program 8.7%
*-commutative8.7%
associate-*l*8.7%
sub-neg8.7%
+-commutative8.7%
distribute-lft-in8.7%
distribute-lft-in8.7%
distribute-rgt-in8.7%
distribute-lft-neg-out8.7%
distribute-rgt-neg-in8.7%
metadata-eval8.7%
metadata-eval8.7%
fma-def8.7%
metadata-eval8.7%
exp-diff8.7%
associate-*l/8.7%
exp-08.7%
metadata-eval8.7%
Simplified8.7%
Taylor expanded in im around 0 99.8%
mul-1-neg99.8%
unsub-neg99.8%
*-commutative99.8%
*-commutative99.8%
Simplified99.8%
if 1e-3 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 99.9%
*-commutative99.9%
associate-*l*99.9%
sub-neg99.9%
+-commutative99.9%
distribute-lft-in99.9%
distribute-lft-in99.9%
distribute-rgt-in99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-in99.9%
metadata-eval99.9%
metadata-eval99.9%
fma-def99.9%
metadata-eval99.9%
exp-diff99.9%
associate-*l/99.9%
exp-099.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in re around inf 99.9%
*-commutative99.9%
associate-*r/99.9%
metadata-eval99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))) (t_1 (* (exp im) -0.5)))
(if (<= t_0 (- INFINITY))
(* (+ 0.5 t_1) (cos re))
(if (<= t_0 0.001)
(* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im))
(* (cos re) (+ t_1 (/ 0.5 (exp im))))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double t_1 = exp(im) * -0.5;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (0.5 + t_1) * cos(re);
} else if (t_0 <= 0.001) {
tmp = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
} else {
tmp = cos(re) * (t_1 + (0.5 / exp(im)));
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double t_1 = Math.exp(im) * -0.5;
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (0.5 + t_1) * Math.cos(re);
} else if (t_0 <= 0.001) {
tmp = Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
} else {
tmp = Math.cos(re) * (t_1 + (0.5 / Math.exp(im)));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) t_1 = math.exp(im) * -0.5 tmp = 0 if t_0 <= -math.inf: tmp = (0.5 + t_1) * math.cos(re) elif t_0 <= 0.001: tmp = math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im) else: tmp = math.cos(re) * (t_1 + (0.5 / math.exp(im))) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) t_1 = Float64(exp(im) * -0.5) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(0.5 + t_1) * cos(re)); elseif (t_0 <= 0.001) tmp = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im)); else tmp = Float64(cos(re) * Float64(t_1 + Float64(0.5 / exp(im)))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); t_1 = exp(im) * -0.5; tmp = 0.0; if (t_0 <= -Inf) tmp = (0.5 + t_1) * cos(re); elseif (t_0 <= 0.001) tmp = cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im); else tmp = cos(re) * (t_1 + (0.5 / exp(im))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[im], $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(0.5 + t$95$1), $MachinePrecision] * N[Cos[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.001], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(t$95$1 + N[(0.5 / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := e^{im} \cdot -0.5\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\left(0.5 + t_1\right) \cdot \cos re\\
\mathbf{elif}\;t_0 \leq 0.001:\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(t_1 + \frac{0.5}{e^{im}}\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -inf.0Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
if -inf.0 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1e-3Initial program 8.7%
*-commutative8.7%
associate-*l*8.7%
sub-neg8.7%
+-commutative8.7%
distribute-lft-in8.7%
distribute-lft-in8.7%
distribute-rgt-in8.7%
distribute-lft-neg-out8.7%
distribute-rgt-neg-in8.7%
metadata-eval8.7%
metadata-eval8.7%
fma-def8.7%
metadata-eval8.7%
exp-diff8.7%
associate-*l/8.7%
exp-08.7%
metadata-eval8.7%
Simplified8.7%
Taylor expanded in im around 0 99.8%
neg-mul-199.8%
unsub-neg99.8%
Simplified99.8%
if 1e-3 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 99.9%
*-commutative99.9%
associate-*l*99.9%
sub-neg99.9%
+-commutative99.9%
distribute-lft-in99.9%
distribute-lft-in99.9%
distribute-rgt-in99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-in99.9%
metadata-eval99.9%
metadata-eval99.9%
fma-def99.9%
metadata-eval99.9%
exp-diff99.9%
associate-*l/99.9%
exp-099.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in re around inf 99.9%
*-commutative99.9%
associate-*r/99.9%
metadata-eval99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (<= t_0 (- INFINITY))
(* (+ 0.5 (* (exp im) -0.5)) (cos re))
(if (<= t_0 0.001)
(* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im))
(* (* 0.5 (cos re)) t_0)))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (0.5 + (exp(im) * -0.5)) * cos(re);
} else if (t_0 <= 0.001) {
tmp = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
} else {
tmp = (0.5 * cos(re)) * t_0;
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (0.5 + (Math.exp(im) * -0.5)) * Math.cos(re);
} else if (t_0 <= 0.001) {
tmp = Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
} else {
tmp = (0.5 * Math.cos(re)) * t_0;
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if t_0 <= -math.inf: tmp = (0.5 + (math.exp(im) * -0.5)) * math.cos(re) elif t_0 <= 0.001: tmp = math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im) else: tmp = (0.5 * math.cos(re)) * t_0 return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(0.5 + Float64(exp(im) * -0.5)) * cos(re)); elseif (t_0 <= 0.001) tmp = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im)); else tmp = Float64(Float64(0.5 * cos(re)) * t_0); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if (t_0 <= -Inf) tmp = (0.5 + (exp(im) * -0.5)) * cos(re); elseif (t_0 <= 0.001) tmp = cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im); else tmp = (0.5 * cos(re)) * t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(0.5 + N[(N[Exp[im], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] * N[Cos[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.001], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\left(0.5 + e^{im} \cdot -0.5\right) \cdot \cos re\\
\mathbf{elif}\;t_0 \leq 0.001:\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -inf.0Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
if -inf.0 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1e-3Initial program 8.7%
*-commutative8.7%
associate-*l*8.7%
sub-neg8.7%
+-commutative8.7%
distribute-lft-in8.7%
distribute-lft-in8.7%
distribute-rgt-in8.7%
distribute-lft-neg-out8.7%
distribute-rgt-neg-in8.7%
metadata-eval8.7%
metadata-eval8.7%
fma-def8.7%
metadata-eval8.7%
exp-diff8.7%
associate-*l/8.7%
exp-08.7%
metadata-eval8.7%
Simplified8.7%
Taylor expanded in im around 0 99.8%
neg-mul-199.8%
unsub-neg99.8%
Simplified99.8%
if 1e-3 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 99.9%
sub0-neg99.9%
Simplified99.9%
Final simplification99.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
(t_1 (* (cos re) (* -0.008333333333333333 (pow im 5.0)))))
(if (<= im -3.4e+53)
t_1
(if (<= im -0.0038)
t_0
(if (<= im 165000.0)
(* im (- (cos re)))
(if (<= im 4.5e+61) t_0 t_1))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(-im) - exp(im));
double t_1 = cos(re) * (-0.008333333333333333 * pow(im, 5.0));
double tmp;
if (im <= -3.4e+53) {
tmp = t_1;
} else if (im <= -0.0038) {
tmp = t_0;
} else if (im <= 165000.0) {
tmp = im * -cos(re);
} else if (im <= 4.5e+61) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * (exp(-im) - exp(im))
t_1 = cos(re) * ((-0.008333333333333333d0) * (im ** 5.0d0))
if (im <= (-3.4d+53)) then
tmp = t_1
else if (im <= (-0.0038d0)) then
tmp = t_0
else if (im <= 165000.0d0) then
tmp = im * -cos(re)
else if (im <= 4.5d+61) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
double t_1 = Math.cos(re) * (-0.008333333333333333 * Math.pow(im, 5.0));
double tmp;
if (im <= -3.4e+53) {
tmp = t_1;
} else if (im <= -0.0038) {
tmp = t_0;
} else if (im <= 165000.0) {
tmp = im * -Math.cos(re);
} else if (im <= 4.5e+61) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.exp(-im) - math.exp(im)) t_1 = math.cos(re) * (-0.008333333333333333 * math.pow(im, 5.0)) tmp = 0 if im <= -3.4e+53: tmp = t_1 elif im <= -0.0038: tmp = t_0 elif im <= 165000.0: tmp = im * -math.cos(re) elif im <= 4.5e+61: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))) t_1 = Float64(cos(re) * Float64(-0.008333333333333333 * (im ^ 5.0))) tmp = 0.0 if (im <= -3.4e+53) tmp = t_1; elseif (im <= -0.0038) tmp = t_0; elseif (im <= 165000.0) tmp = Float64(im * Float64(-cos(re))); elseif (im <= 4.5e+61) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (exp(-im) - exp(im)); t_1 = cos(re) * (-0.008333333333333333 * (im ^ 5.0)); tmp = 0.0; if (im <= -3.4e+53) tmp = t_1; elseif (im <= -0.0038) tmp = t_0; elseif (im <= 165000.0) tmp = im * -cos(re); elseif (im <= 4.5e+61) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[re], $MachinePrecision] * N[(-0.008333333333333333 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -3.4e+53], t$95$1, If[LessEqual[im, -0.0038], t$95$0, If[LessEqual[im, 165000.0], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 4.5e+61], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := \cos re \cdot \left(-0.008333333333333333 \cdot {im}^{5}\right)\\
\mathbf{if}\;im \leq -3.4 \cdot 10^{+53}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.0038:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 165000:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\mathbf{elif}\;im \leq 4.5 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -3.39999999999999998e53 or 4.5e61 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around 0 99.1%
Taylor expanded in im around inf 99.1%
if -3.39999999999999998e53 < im < -0.00379999999999999999 or 165000 < im < 4.5e61Initial program 99.9%
sub0-neg99.9%
Simplified99.9%
Taylor expanded in re around 0 75.8%
if -0.00379999999999999999 < im < 165000Initial program 10.7%
*-commutative10.7%
associate-*l*10.7%
sub-neg10.7%
+-commutative10.7%
distribute-lft-in10.7%
distribute-lft-in10.7%
distribute-rgt-in10.7%
distribute-lft-neg-out10.7%
distribute-rgt-neg-in10.7%
metadata-eval10.7%
metadata-eval10.7%
fma-def10.7%
metadata-eval10.7%
exp-diff10.7%
associate-*l/10.7%
exp-010.7%
metadata-eval10.7%
Simplified10.7%
Taylor expanded in im around 0 97.5%
neg-mul-197.5%
Simplified97.5%
Final simplification96.5%
(FPCore (re im)
:precision binary64
(if (<= im -3.4e+53)
(* (cos re) (* -0.008333333333333333 (pow im 5.0)))
(if (<= im -0.0225)
(* 0.5 (- (exp (- im)) (exp im)))
(if (<= im 2.1)
(* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im))
(* (+ 0.5 (* (exp im) -0.5)) (cos re))))))
double code(double re, double im) {
double tmp;
if (im <= -3.4e+53) {
tmp = cos(re) * (-0.008333333333333333 * pow(im, 5.0));
} else if (im <= -0.0225) {
tmp = 0.5 * (exp(-im) - exp(im));
} else if (im <= 2.1) {
tmp = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
} else {
tmp = (0.5 + (exp(im) * -0.5)) * cos(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-3.4d+53)) then
tmp = cos(re) * ((-0.008333333333333333d0) * (im ** 5.0d0))
else if (im <= (-0.0225d0)) then
tmp = 0.5d0 * (exp(-im) - exp(im))
else if (im <= 2.1d0) then
tmp = cos(re) * (((-0.16666666666666666d0) * (im ** 3.0d0)) - im)
else
tmp = (0.5d0 + (exp(im) * (-0.5d0))) * cos(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -3.4e+53) {
tmp = Math.cos(re) * (-0.008333333333333333 * Math.pow(im, 5.0));
} else if (im <= -0.0225) {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
} else if (im <= 2.1) {
tmp = Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
} else {
tmp = (0.5 + (Math.exp(im) * -0.5)) * Math.cos(re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -3.4e+53: tmp = math.cos(re) * (-0.008333333333333333 * math.pow(im, 5.0)) elif im <= -0.0225: tmp = 0.5 * (math.exp(-im) - math.exp(im)) elif im <= 2.1: tmp = math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im) else: tmp = (0.5 + (math.exp(im) * -0.5)) * math.cos(re) return tmp
function code(re, im) tmp = 0.0 if (im <= -3.4e+53) tmp = Float64(cos(re) * Float64(-0.008333333333333333 * (im ^ 5.0))); elseif (im <= -0.0225) tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); elseif (im <= 2.1) tmp = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im)); else tmp = Float64(Float64(0.5 + Float64(exp(im) * -0.5)) * cos(re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -3.4e+53) tmp = cos(re) * (-0.008333333333333333 * (im ^ 5.0)); elseif (im <= -0.0225) tmp = 0.5 * (exp(-im) - exp(im)); elseif (im <= 2.1) tmp = cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im); else tmp = (0.5 + (exp(im) * -0.5)) * cos(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -3.4e+53], N[(N[Cos[re], $MachinePrecision] * N[(-0.008333333333333333 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, -0.0225], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.1], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 + N[(N[Exp[im], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] * N[Cos[re], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.4 \cdot 10^{+53}:\\
\;\;\;\;\cos re \cdot \left(-0.008333333333333333 \cdot {im}^{5}\right)\\
\mathbf{elif}\;im \leq -0.0225:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{elif}\;im \leq 2.1:\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 + e^{im} \cdot -0.5\right) \cdot \cos re\\
\end{array}
\end{array}
if im < -3.39999999999999998e53Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around 0 98.5%
Taylor expanded in im around inf 98.5%
if -3.39999999999999998e53 < im < -0.022499999999999999Initial program 99.8%
sub0-neg99.8%
Simplified99.8%
Taylor expanded in re around 0 79.7%
if -0.022499999999999999 < im < 2.10000000000000009Initial program 9.3%
*-commutative9.3%
associate-*l*9.3%
sub-neg9.3%
+-commutative9.3%
distribute-lft-in9.3%
distribute-lft-in9.3%
distribute-rgt-in9.3%
distribute-lft-neg-out9.3%
distribute-rgt-neg-in9.3%
metadata-eval9.3%
metadata-eval9.3%
fma-def9.3%
metadata-eval9.3%
exp-diff9.3%
associate-*l/9.3%
exp-09.3%
metadata-eval9.3%
Simplified9.3%
Taylor expanded in im around 0 99.6%
neg-mul-199.6%
unsub-neg99.6%
Simplified99.6%
if 2.10000000000000009 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Final simplification98.7%
(FPCore (re im)
:precision binary64
(if (<= im -3.4e+53)
(* (cos re) (* -0.008333333333333333 (pow im 5.0)))
(if (<= im -0.0042)
(* 0.5 (- (exp (- im)) (exp im)))
(if (<= im 1.25)
(* im (- (cos re)))
(* (+ 0.5 (* (exp im) -0.5)) (cos re))))))
double code(double re, double im) {
double tmp;
if (im <= -3.4e+53) {
tmp = cos(re) * (-0.008333333333333333 * pow(im, 5.0));
} else if (im <= -0.0042) {
tmp = 0.5 * (exp(-im) - exp(im));
} else if (im <= 1.25) {
tmp = im * -cos(re);
} else {
tmp = (0.5 + (exp(im) * -0.5)) * cos(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-3.4d+53)) then
tmp = cos(re) * ((-0.008333333333333333d0) * (im ** 5.0d0))
else if (im <= (-0.0042d0)) then
tmp = 0.5d0 * (exp(-im) - exp(im))
else if (im <= 1.25d0) then
tmp = im * -cos(re)
else
tmp = (0.5d0 + (exp(im) * (-0.5d0))) * cos(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -3.4e+53) {
tmp = Math.cos(re) * (-0.008333333333333333 * Math.pow(im, 5.0));
} else if (im <= -0.0042) {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
} else if (im <= 1.25) {
tmp = im * -Math.cos(re);
} else {
tmp = (0.5 + (Math.exp(im) * -0.5)) * Math.cos(re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -3.4e+53: tmp = math.cos(re) * (-0.008333333333333333 * math.pow(im, 5.0)) elif im <= -0.0042: tmp = 0.5 * (math.exp(-im) - math.exp(im)) elif im <= 1.25: tmp = im * -math.cos(re) else: tmp = (0.5 + (math.exp(im) * -0.5)) * math.cos(re) return tmp
function code(re, im) tmp = 0.0 if (im <= -3.4e+53) tmp = Float64(cos(re) * Float64(-0.008333333333333333 * (im ^ 5.0))); elseif (im <= -0.0042) tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); elseif (im <= 1.25) tmp = Float64(im * Float64(-cos(re))); else tmp = Float64(Float64(0.5 + Float64(exp(im) * -0.5)) * cos(re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -3.4e+53) tmp = cos(re) * (-0.008333333333333333 * (im ^ 5.0)); elseif (im <= -0.0042) tmp = 0.5 * (exp(-im) - exp(im)); elseif (im <= 1.25) tmp = im * -cos(re); else tmp = (0.5 + (exp(im) * -0.5)) * cos(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -3.4e+53], N[(N[Cos[re], $MachinePrecision] * N[(-0.008333333333333333 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, -0.0042], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.25], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], N[(N[(0.5 + N[(N[Exp[im], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] * N[Cos[re], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.4 \cdot 10^{+53}:\\
\;\;\;\;\cos re \cdot \left(-0.008333333333333333 \cdot {im}^{5}\right)\\
\mathbf{elif}\;im \leq -0.0042:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{elif}\;im \leq 1.25:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 + e^{im} \cdot -0.5\right) \cdot \cos re\\
\end{array}
\end{array}
if im < -3.39999999999999998e53Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around 0 98.5%
Taylor expanded in im around inf 98.5%
if -3.39999999999999998e53 < im < -0.00419999999999999974Initial program 99.8%
sub0-neg99.8%
Simplified99.8%
Taylor expanded in re around 0 79.7%
if -0.00419999999999999974 < im < 1.25Initial program 9.3%
*-commutative9.3%
associate-*l*9.3%
sub-neg9.3%
+-commutative9.3%
distribute-lft-in9.3%
distribute-lft-in9.3%
distribute-rgt-in9.3%
distribute-lft-neg-out9.3%
distribute-rgt-neg-in9.3%
metadata-eval9.3%
metadata-eval9.3%
fma-def9.3%
metadata-eval9.3%
exp-diff9.3%
associate-*l/9.3%
exp-09.3%
metadata-eval9.3%
Simplified9.3%
Taylor expanded in im around 0 98.9%
neg-mul-198.9%
Simplified98.9%
if 1.25 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Final simplification98.4%
(FPCore (re im) :precision binary64 (if (or (<= im -0.007) (not (<= im 165000.0))) (* 0.5 (- (exp (- im)) (exp im))) (* im (- (cos re)))))
double code(double re, double im) {
double tmp;
if ((im <= -0.007) || !(im <= 165000.0)) {
tmp = 0.5 * (exp(-im) - exp(im));
} else {
tmp = im * -cos(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-0.007d0)) .or. (.not. (im <= 165000.0d0))) then
tmp = 0.5d0 * (exp(-im) - exp(im))
else
tmp = im * -cos(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -0.007) || !(im <= 165000.0)) {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
} else {
tmp = im * -Math.cos(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -0.007) or not (im <= 165000.0): tmp = 0.5 * (math.exp(-im) - math.exp(im)) else: tmp = im * -math.cos(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -0.007) || !(im <= 165000.0)) tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); else tmp = Float64(im * Float64(-cos(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -0.007) || ~((im <= 165000.0))) tmp = 0.5 * (exp(-im) - exp(im)); else tmp = im * -cos(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -0.007], N[Not[LessEqual[im, 165000.0]], $MachinePrecision]], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.007 \lor \neg \left(im \leq 165000\right):\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\end{array}
\end{array}
if im < -0.00700000000000000015 or 165000 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 68.1%
if -0.00700000000000000015 < im < 165000Initial program 10.7%
*-commutative10.7%
associate-*l*10.7%
sub-neg10.7%
+-commutative10.7%
distribute-lft-in10.7%
distribute-lft-in10.7%
distribute-rgt-in10.7%
distribute-lft-neg-out10.7%
distribute-rgt-neg-in10.7%
metadata-eval10.7%
metadata-eval10.7%
fma-def10.7%
metadata-eval10.7%
exp-diff10.7%
associate-*l/10.7%
exp-010.7%
metadata-eval10.7%
Simplified10.7%
Taylor expanded in im around 0 97.5%
neg-mul-197.5%
Simplified97.5%
Final simplification83.1%
(FPCore (re im) :precision binary64 (if (<= (cos re) -0.01) (- (* im (* 0.5 (* re re))) im) (- im)))
double code(double re, double im) {
double tmp;
if (cos(re) <= -0.01) {
tmp = (im * (0.5 * (re * re))) - im;
} else {
tmp = -im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (cos(re) <= (-0.01d0)) then
tmp = (im * (0.5d0 * (re * re))) - im
else
tmp = -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.cos(re) <= -0.01) {
tmp = (im * (0.5 * (re * re))) - im;
} else {
tmp = -im;
}
return tmp;
}
def code(re, im): tmp = 0 if math.cos(re) <= -0.01: tmp = (im * (0.5 * (re * re))) - im else: tmp = -im return tmp
function code(re, im) tmp = 0.0 if (cos(re) <= -0.01) tmp = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im); else tmp = Float64(-im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (cos(re) <= -0.01) tmp = (im * (0.5 * (re * re))) - im; else tmp = -im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Cos[re], $MachinePrecision], -0.01], N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], (-im)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos re \leq -0.01:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\
\mathbf{else}:\\
\;\;\;\;-im\\
\end{array}
\end{array}
if (cos.f64 re) < -0.0100000000000000002Initial program 57.3%
*-commutative57.3%
associate-*l*57.3%
sub-neg57.3%
+-commutative57.3%
distribute-lft-in57.3%
distribute-lft-in57.3%
distribute-rgt-in57.3%
distribute-lft-neg-out57.3%
distribute-rgt-neg-in57.3%
metadata-eval57.3%
metadata-eval57.3%
fma-def57.3%
metadata-eval57.3%
exp-diff57.2%
associate-*l/57.2%
exp-057.2%
metadata-eval57.2%
Simplified57.2%
Taylor expanded in re around inf 57.2%
*-commutative57.2%
associate-*r/57.2%
metadata-eval57.2%
*-commutative57.2%
Simplified57.2%
Taylor expanded in im around 0 50.2%
neg-mul-150.2%
Simplified50.2%
Taylor expanded in re around 0 36.1%
+-commutative36.1%
mul-1-neg36.1%
unsub-neg36.1%
*-commutative36.1%
*-commutative36.1%
associate-*l*36.1%
unpow236.1%
Simplified36.1%
if -0.0100000000000000002 < (cos.f64 re) Initial program 53.0%
*-commutative53.0%
associate-*l*53.0%
sub-neg53.0%
+-commutative53.0%
distribute-lft-in53.0%
distribute-lft-in53.0%
distribute-rgt-in53.0%
distribute-lft-neg-out53.0%
distribute-rgt-neg-in53.0%
metadata-eval53.0%
metadata-eval53.0%
fma-def53.0%
metadata-eval53.0%
exp-diff53.0%
associate-*l/53.0%
exp-053.0%
metadata-eval53.0%
Simplified53.0%
Taylor expanded in re around inf 53.0%
*-commutative53.0%
associate-*r/53.0%
metadata-eval53.0%
*-commutative53.0%
Simplified53.0%
Taylor expanded in im around 0 53.7%
neg-mul-153.7%
Simplified53.7%
Taylor expanded in re around 0 38.4%
+-commutative38.4%
mul-1-neg38.4%
unsub-neg38.4%
*-commutative38.4%
*-commutative38.4%
associate-*l*38.4%
unpow238.4%
Simplified38.4%
Taylor expanded in re around 0 42.1%
neg-mul-142.1%
Simplified42.1%
Final simplification40.2%
(FPCore (re im) :precision binary64 (if (or (<= im -4.3e+64) (not (<= im 8e+54))) (- (* -0.16666666666666666 (pow im 3.0)) im) (* im (- (cos re)))))
double code(double re, double im) {
double tmp;
if ((im <= -4.3e+64) || !(im <= 8e+54)) {
tmp = (-0.16666666666666666 * pow(im, 3.0)) - im;
} else {
tmp = im * -cos(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-4.3d+64)) .or. (.not. (im <= 8d+54))) then
tmp = ((-0.16666666666666666d0) * (im ** 3.0d0)) - im
else
tmp = im * -cos(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -4.3e+64) || !(im <= 8e+54)) {
tmp = (-0.16666666666666666 * Math.pow(im, 3.0)) - im;
} else {
tmp = im * -Math.cos(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -4.3e+64) or not (im <= 8e+54): tmp = (-0.16666666666666666 * math.pow(im, 3.0)) - im else: tmp = im * -math.cos(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -4.3e+64) || !(im <= 8e+54)) tmp = Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im); else tmp = Float64(im * Float64(-cos(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -4.3e+64) || ~((im <= 8e+54))) tmp = (-0.16666666666666666 * (im ^ 3.0)) - im; else tmp = im * -cos(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -4.3e+64], N[Not[LessEqual[im, 8e+54]], $MachinePrecision]], N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.3 \cdot 10^{+64} \lor \neg \left(im \leq 8 \cdot 10^{+54}\right):\\
\;\;\;\;-0.16666666666666666 \cdot {im}^{3} - im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\end{array}
\end{array}
if im < -4.2999999999999998e64 or 8.0000000000000006e54 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around 0 87.3%
neg-mul-187.3%
unsub-neg87.3%
Simplified87.3%
Taylor expanded in re around 0 57.7%
if -4.2999999999999998e64 < im < 8.0000000000000006e54Initial program 24.1%
*-commutative24.1%
associate-*l*24.1%
sub-neg24.1%
+-commutative24.1%
distribute-lft-in24.1%
distribute-lft-in24.1%
distribute-rgt-in24.1%
distribute-lft-neg-out24.1%
distribute-rgt-neg-in24.1%
metadata-eval24.1%
metadata-eval24.1%
fma-def24.1%
metadata-eval24.1%
exp-diff24.0%
associate-*l/24.0%
exp-024.0%
metadata-eval24.0%
Simplified24.0%
Taylor expanded in im around 0 83.4%
neg-mul-183.4%
Simplified83.4%
Final simplification73.2%
(FPCore (re im) :precision binary64 (if (or (<= im -4.4e+39) (not (<= im 600.0))) (- (* im (* 0.5 (* re re))) im) (* im (- (cos re)))))
double code(double re, double im) {
double tmp;
if ((im <= -4.4e+39) || !(im <= 600.0)) {
tmp = (im * (0.5 * (re * re))) - im;
} else {
tmp = im * -cos(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-4.4d+39)) .or. (.not. (im <= 600.0d0))) then
tmp = (im * (0.5d0 * (re * re))) - im
else
tmp = im * -cos(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -4.4e+39) || !(im <= 600.0)) {
tmp = (im * (0.5 * (re * re))) - im;
} else {
tmp = im * -Math.cos(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -4.4e+39) or not (im <= 600.0): tmp = (im * (0.5 * (re * re))) - im else: tmp = im * -math.cos(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -4.4e+39) || !(im <= 600.0)) tmp = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im); else tmp = Float64(im * Float64(-cos(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -4.4e+39) || ~((im <= 600.0))) tmp = (im * (0.5 * (re * re))) - im; else tmp = im * -cos(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -4.4e+39], N[Not[LessEqual[im, 600.0]], $MachinePrecision]], N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.4 \cdot 10^{+39} \lor \neg \left(im \leq 600\right):\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\end{array}
\end{array}
if im < -4.4000000000000003e39 or 600 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around 0 5.6%
neg-mul-15.6%
Simplified5.6%
Taylor expanded in re around 0 24.7%
+-commutative24.7%
mul-1-neg24.7%
unsub-neg24.7%
*-commutative24.7%
*-commutative24.7%
associate-*l*24.7%
unpow224.7%
Simplified24.7%
if -4.4000000000000003e39 < im < 600Initial program 12.7%
*-commutative12.7%
associate-*l*12.7%
sub-neg12.7%
+-commutative12.7%
distribute-lft-in12.7%
distribute-lft-in12.7%
distribute-rgt-in12.7%
distribute-lft-neg-out12.7%
distribute-rgt-neg-in12.7%
metadata-eval12.7%
metadata-eval12.7%
fma-def12.7%
metadata-eval12.7%
exp-diff12.7%
associate-*l/12.7%
exp-012.7%
metadata-eval12.7%
Simplified12.7%
Taylor expanded in im around 0 95.4%
neg-mul-195.4%
Simplified95.4%
Final simplification61.7%
(FPCore (re im) :precision binary64 (if (or (<= im -680.0) (not (<= im 520.0))) (* re (* re 1.5)) (- im)))
double code(double re, double im) {
double tmp;
if ((im <= -680.0) || !(im <= 520.0)) {
tmp = re * (re * 1.5);
} else {
tmp = -im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-680.0d0)) .or. (.not. (im <= 520.0d0))) then
tmp = re * (re * 1.5d0)
else
tmp = -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -680.0) || !(im <= 520.0)) {
tmp = re * (re * 1.5);
} else {
tmp = -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -680.0) or not (im <= 520.0): tmp = re * (re * 1.5) else: tmp = -im return tmp
function code(re, im) tmp = 0.0 if ((im <= -680.0) || !(im <= 520.0)) tmp = Float64(re * Float64(re * 1.5)); else tmp = Float64(-im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -680.0) || ~((im <= 520.0))) tmp = re * (re * 1.5); else tmp = -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -680.0], N[Not[LessEqual[im, 520.0]], $MachinePrecision]], N[(re * N[(re * 1.5), $MachinePrecision]), $MachinePrecision], (-im)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -680 \lor \neg \left(im \leq 520\right):\\
\;\;\;\;re \cdot \left(re \cdot 1.5\right)\\
\mathbf{else}:\\
\;\;\;\;-im\\
\end{array}
\end{array}
if im < -680 or 520 < im Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-lft-in100.0%
distribute-lft-in100.0%
distribute-rgt-in100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Applied egg-rr1.8%
Taylor expanded in re around 0 15.8%
*-commutative15.8%
unpow215.8%
associate-*l*15.8%
fma-neg15.8%
metadata-eval15.8%
Simplified15.8%
Taylor expanded in re around inf 15.9%
*-commutative15.9%
unpow215.9%
associate-*r*15.9%
Simplified15.9%
if -680 < im < 520Initial program 10.0%
*-commutative10.0%
associate-*l*10.0%
sub-neg10.0%
+-commutative10.0%
distribute-lft-in10.0%
distribute-lft-in10.0%
distribute-rgt-in10.0%
distribute-lft-neg-out10.0%
distribute-rgt-neg-in10.0%
metadata-eval10.0%
metadata-eval10.0%
fma-def10.0%
metadata-eval10.0%
exp-diff10.0%
associate-*l/10.0%
exp-010.0%
metadata-eval10.0%
Simplified10.0%
Taylor expanded in re around inf 10.0%
*-commutative10.0%
associate-*r/10.0%
metadata-eval10.0%
*-commutative10.0%
Simplified10.0%
Taylor expanded in im around 0 98.2%
neg-mul-198.2%
Simplified98.2%
Taylor expanded in re around 0 51.0%
+-commutative51.0%
mul-1-neg51.0%
unsub-neg51.0%
*-commutative51.0%
*-commutative51.0%
associate-*l*51.0%
unpow251.0%
Simplified51.0%
Taylor expanded in re around 0 55.0%
neg-mul-155.0%
Simplified55.0%
Final simplification35.8%
(FPCore (re im) :precision binary64 (- im))
double code(double re, double im) {
return -im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -im
end function
public static double code(double re, double im) {
return -im;
}
def code(re, im): return -im
function code(re, im) return Float64(-im) end
function tmp = code(re, im) tmp = -im; end
code[re_, im_] := (-im)
\begin{array}{l}
\\
-im
\end{array}
Initial program 54.3%
*-commutative54.3%
associate-*l*54.3%
sub-neg54.3%
+-commutative54.3%
distribute-lft-in54.3%
distribute-lft-in54.3%
distribute-rgt-in54.3%
distribute-lft-neg-out54.3%
distribute-rgt-neg-in54.3%
metadata-eval54.3%
metadata-eval54.3%
fma-def54.3%
metadata-eval54.3%
exp-diff54.3%
associate-*l/54.3%
exp-054.3%
metadata-eval54.3%
Simplified54.3%
Taylor expanded in re around inf 54.3%
*-commutative54.3%
associate-*r/54.3%
metadata-eval54.3%
*-commutative54.3%
Simplified54.3%
Taylor expanded in im around 0 52.6%
neg-mul-152.6%
Simplified52.6%
Taylor expanded in re around 0 37.7%
+-commutative37.7%
mul-1-neg37.7%
unsub-neg37.7%
*-commutative37.7%
*-commutative37.7%
associate-*l*37.7%
unpow237.7%
Simplified37.7%
Taylor expanded in re around 0 29.8%
neg-mul-129.8%
Simplified29.8%
Final simplification29.8%
(FPCore (re im) :precision binary64 -3.0)
double code(double re, double im) {
return -3.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -3.0d0
end function
public static double code(double re, double im) {
return -3.0;
}
def code(re, im): return -3.0
function code(re, im) return -3.0 end
function tmp = code(re, im) tmp = -3.0; end
code[re_, im_] := -3.0
\begin{array}{l}
\\
-3
\end{array}
Initial program 54.3%
*-commutative54.3%
associate-*l*54.3%
sub-neg54.3%
+-commutative54.3%
distribute-lft-in54.3%
distribute-lft-in54.3%
distribute-rgt-in54.3%
distribute-lft-neg-out54.3%
distribute-rgt-neg-in54.3%
metadata-eval54.3%
metadata-eval54.3%
fma-def54.3%
metadata-eval54.3%
exp-diff54.3%
associate-*l/54.3%
exp-054.3%
metadata-eval54.3%
Simplified54.3%
Applied egg-rr2.8%
Taylor expanded in re around 0 2.8%
Final simplification2.8%
(FPCore (re im) :precision binary64 0.0)
double code(double re, double im) {
return 0.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.0d0
end function
public static double code(double re, double im) {
return 0.0;
}
def code(re, im): return 0.0
function code(re, im) return 0.0 end
function tmp = code(re, im) tmp = 0.0; end
code[re_, im_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 54.3%
*-commutative54.3%
associate-*l*54.3%
sub-neg54.3%
+-commutative54.3%
distribute-lft-in54.3%
distribute-lft-in54.3%
distribute-rgt-in54.3%
distribute-lft-neg-out54.3%
distribute-rgt-neg-in54.3%
metadata-eval54.3%
metadata-eval54.3%
fma-def54.3%
metadata-eval54.3%
exp-diff54.3%
associate-*l/54.3%
exp-054.3%
metadata-eval54.3%
Simplified54.3%
Taylor expanded in re around inf 54.3%
*-commutative54.3%
associate-*r/54.3%
metadata-eval54.3%
*-commutative54.3%
Simplified54.3%
*-commutative54.3%
distribute-rgt-in54.3%
Applied egg-rr54.3%
Taylor expanded in im around 0 3.6%
distribute-rgt-out3.6%
metadata-eval3.6%
mul0-rgt3.6%
Simplified3.6%
Final simplification3.6%
(FPCore (re im)
:precision binary64
(if (< (fabs im) 1.0)
(-
(*
(cos re)
(+
(+ im (* (* (* 0.16666666666666666 im) im) im))
(* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
double code(double re, double im) {
double tmp;
if (fabs(im) < 1.0) {
tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (abs(im) < 1.0d0) then
tmp = -(cos(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
else
tmp = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.abs(im) < 1.0) {
tmp = -(Math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if math.fabs(im) < 1.0: tmp = -(math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))) else: tmp = (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (abs(im) < 1.0) tmp = Float64(-Float64(cos(re) * Float64(Float64(im + Float64(Float64(Float64(0.16666666666666666 * im) * im) * im)) + Float64(Float64(Float64(Float64(Float64(0.008333333333333333 * im) * im) * im) * im) * im)))); else tmp = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (abs(im) < 1.0) tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))); else tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Cos[re], $MachinePrecision] * N[(N[(im + N[(N[(N[(0.16666666666666666 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[(0.008333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\
\end{array}
\end{array}
herbie shell --seed 2023173
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
:herbie-target
(if (< (fabs im) 1.0) (- (* (cos re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))