
(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 13 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))))
(if (<= t_0 (- INFINITY))
(* (+ 1.0 (* re (+ 1.0 (* re 0.5)))) (+ 1.0 (* -0.5 (pow im 2.0))))
(if (<= t_0 -0.05)
(* (cos im) (+ re 1.0))
(if (or (<= t_0 0.0) (not (<= t_0 0.9999999987557401)))
(exp re)
(*
(cos im)
(+
1.0
(* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666))))))))))))
double code(double re, double im) {
double t_0 = exp(re) * cos(im);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (1.0 + (-0.5 * pow(im, 2.0)));
} else if (t_0 <= -0.05) {
tmp = cos(im) * (re + 1.0);
} else if ((t_0 <= 0.0) || !(t_0 <= 0.9999999987557401)) {
tmp = exp(re);
} else {
tmp = cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(re) * Math.cos(im);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (1.0 + (-0.5 * Math.pow(im, 2.0)));
} else if (t_0 <= -0.05) {
tmp = Math.cos(im) * (re + 1.0);
} else if ((t_0 <= 0.0) || !(t_0 <= 0.9999999987557401)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * math.cos(im) tmp = 0 if t_0 <= -math.inf: tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (1.0 + (-0.5 * math.pow(im, 2.0))) elif t_0 <= -0.05: tmp = math.cos(im) * (re + 1.0) elif (t_0 <= 0.0) or not (t_0 <= 0.9999999987557401): tmp = math.exp(re) else: tmp = math.cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) return tmp
function code(re, im) t_0 = Float64(exp(re) * cos(im)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))) * Float64(1.0 + Float64(-0.5 * (im ^ 2.0)))); elseif (t_0 <= -0.05) tmp = Float64(cos(im) * Float64(re + 1.0)); elseif ((t_0 <= 0.0) || !(t_0 <= 0.9999999987557401)) tmp = exp(re); else tmp = Float64(cos(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * cos(im); tmp = 0.0; if (t_0 <= -Inf) tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (1.0 + (-0.5 * (im ^ 2.0))); elseif (t_0 <= -0.05) tmp = cos(im) * (re + 1.0); elseif ((t_0 <= 0.0) || ~((t_0 <= 0.9999999987557401))) tmp = exp(re); else tmp = cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.05], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$0, 0.0], N[Not[LessEqual[t$95$0, 0.9999999987557401]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \cos im\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right) \cdot \left(1 + -0.5 \cdot {im}^{2}\right)\\
\mathbf{elif}\;t\_0 \leq -0.05:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{elif}\;t\_0 \leq 0 \lor \neg \left(t\_0 \leq 0.9999999987557401\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -inf.0Initial program 100.0%
Taylor expanded in re around 0 46.5%
*-commutative46.5%
Simplified46.5%
Taylor expanded in im around 0 94.4%
if -inf.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < -0.050000000000000003Initial program 99.9%
Taylor expanded in re around 0 99.9%
distribute-rgt1-in99.9%
Simplified99.9%
if -0.050000000000000003 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0 or 0.999999998755740083 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in im around 0 100.0%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.999999998755740083Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification99.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (cos im))))
(if (<= t_0 (- INFINITY))
(+ re (* -0.5 (* re (pow im 2.0))))
(if (<= t_0 -0.05)
(* (cos im) (+ re 1.0))
(if (or (<= t_0 0.0) (not (<= t_0 0.9999999987557401)))
(exp re)
(* (cos im) (+ 1.0 (* re (+ 1.0 (* re 0.5))))))))))
double code(double re, double im) {
double t_0 = exp(re) * cos(im);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = re + (-0.5 * (re * pow(im, 2.0)));
} else if (t_0 <= -0.05) {
tmp = cos(im) * (re + 1.0);
} else if ((t_0 <= 0.0) || !(t_0 <= 0.9999999987557401)) {
tmp = exp(re);
} else {
tmp = cos(im) * (1.0 + (re * (1.0 + (re * 0.5))));
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(re) * Math.cos(im);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = re + (-0.5 * (re * Math.pow(im, 2.0)));
} else if (t_0 <= -0.05) {
tmp = Math.cos(im) * (re + 1.0);
} else if ((t_0 <= 0.0) || !(t_0 <= 0.9999999987557401)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (1.0 + (re * (1.0 + (re * 0.5))));
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * math.cos(im) tmp = 0 if t_0 <= -math.inf: tmp = re + (-0.5 * (re * math.pow(im, 2.0))) elif t_0 <= -0.05: tmp = math.cos(im) * (re + 1.0) elif (t_0 <= 0.0) or not (t_0 <= 0.9999999987557401): tmp = math.exp(re) else: tmp = math.cos(im) * (1.0 + (re * (1.0 + (re * 0.5)))) return tmp
function code(re, im) t_0 = Float64(exp(re) * cos(im)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(re + Float64(-0.5 * Float64(re * (im ^ 2.0)))); elseif (t_0 <= -0.05) tmp = Float64(cos(im) * Float64(re + 1.0)); elseif ((t_0 <= 0.0) || !(t_0 <= 0.9999999987557401)) tmp = exp(re); else tmp = Float64(cos(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * cos(im); tmp = 0.0; if (t_0 <= -Inf) tmp = re + (-0.5 * (re * (im ^ 2.0))); elseif (t_0 <= -0.05) tmp = cos(im) * (re + 1.0); elseif ((t_0 <= 0.0) || ~((t_0 <= 0.9999999987557401))) tmp = exp(re); else tmp = cos(im) * (1.0 + (re * (1.0 + (re * 0.5)))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(re + N[(-0.5 * N[(re * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.05], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$0, 0.0], N[Not[LessEqual[t$95$0, 0.9999999987557401]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \cos im\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;re + -0.5 \cdot \left(re \cdot {im}^{2}\right)\\
\mathbf{elif}\;t\_0 \leq -0.05:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{elif}\;t\_0 \leq 0 \lor \neg \left(t\_0 \leq 0.9999999987557401\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -inf.0Initial program 100.0%
Taylor expanded in re around 0 4.9%
distribute-rgt1-in4.9%
Simplified4.9%
Taylor expanded in re around inf 4.9%
*-commutative4.9%
Simplified4.9%
Taylor expanded in im around 0 76.9%
if -inf.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < -0.050000000000000003Initial program 99.9%
Taylor expanded in re around 0 99.9%
distribute-rgt1-in99.9%
Simplified99.9%
if -0.050000000000000003 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0 or 0.999999998755740083 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in im around 0 100.0%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.999999998755740083Initial program 100.0%
Taylor expanded in re around 0 99.3%
*-commutative99.3%
Simplified99.3%
Final simplification98.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (cos im))))
(if (<= t_0 (- INFINITY))
(+ re (* -0.5 (* re (pow im 2.0))))
(if (or (<= t_0 -0.05) (and (not (<= t_0 0.0)) (<= t_0 0.9995)))
(* (cos im) (+ re 1.0))
(exp re)))))
double code(double re, double im) {
double t_0 = exp(re) * cos(im);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = re + (-0.5 * (re * pow(im, 2.0)));
} else if ((t_0 <= -0.05) || (!(t_0 <= 0.0) && (t_0 <= 0.9995))) {
tmp = cos(im) * (re + 1.0);
} else {
tmp = exp(re);
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(re) * Math.cos(im);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = re + (-0.5 * (re * Math.pow(im, 2.0)));
} else if ((t_0 <= -0.05) || (!(t_0 <= 0.0) && (t_0 <= 0.9995))) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * math.cos(im) tmp = 0 if t_0 <= -math.inf: tmp = re + (-0.5 * (re * math.pow(im, 2.0))) elif (t_0 <= -0.05) or (not (t_0 <= 0.0) and (t_0 <= 0.9995)): tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) return tmp
function code(re, im) t_0 = Float64(exp(re) * cos(im)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(re + Float64(-0.5 * Float64(re * (im ^ 2.0)))); elseif ((t_0 <= -0.05) || (!(t_0 <= 0.0) && (t_0 <= 0.9995))) tmp = Float64(cos(im) * Float64(re + 1.0)); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * cos(im); tmp = 0.0; if (t_0 <= -Inf) tmp = re + (-0.5 * (re * (im ^ 2.0))); elseif ((t_0 <= -0.05) || (~((t_0 <= 0.0)) && (t_0 <= 0.9995))) tmp = cos(im) * (re + 1.0); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(re + N[(-0.5 * N[(re * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$0, -0.05], And[N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision], LessEqual[t$95$0, 0.9995]]], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[Exp[re], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \cos im\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;re + -0.5 \cdot \left(re \cdot {im}^{2}\right)\\
\mathbf{elif}\;t\_0 \leq -0.05 \lor \neg \left(t\_0 \leq 0\right) \land t\_0 \leq 0.9995:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -inf.0Initial program 100.0%
Taylor expanded in re around 0 4.9%
distribute-rgt1-in4.9%
Simplified4.9%
Taylor expanded in re around inf 4.9%
*-commutative4.9%
Simplified4.9%
Taylor expanded in im around 0 76.9%
if -inf.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < -0.050000000000000003 or 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.99950000000000006Initial program 100.0%
Taylor expanded in re around 0 99.9%
distribute-rgt1-in99.9%
Simplified99.9%
if -0.050000000000000003 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0 or 0.99950000000000006 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in im around 0 99.8%
Final simplification98.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (cos im))))
(if (<= t_0 (- INFINITY))
(+ 1.0 (* -0.5 (* im im)))
(if (or (<= t_0 -0.05) (and (not (<= t_0 0.0)) (<= t_0 0.9995)))
(* (cos im) (+ re 1.0))
(exp re)))))
double code(double re, double im) {
double t_0 = exp(re) * cos(im);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = 1.0 + (-0.5 * (im * im));
} else if ((t_0 <= -0.05) || (!(t_0 <= 0.0) && (t_0 <= 0.9995))) {
tmp = cos(im) * (re + 1.0);
} else {
tmp = exp(re);
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(re) * Math.cos(im);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = 1.0 + (-0.5 * (im * im));
} else if ((t_0 <= -0.05) || (!(t_0 <= 0.0) && (t_0 <= 0.9995))) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * math.cos(im) tmp = 0 if t_0 <= -math.inf: tmp = 1.0 + (-0.5 * (im * im)) elif (t_0 <= -0.05) or (not (t_0 <= 0.0) and (t_0 <= 0.9995)): tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) return tmp
function code(re, im) t_0 = Float64(exp(re) * cos(im)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im))); elseif ((t_0 <= -0.05) || (!(t_0 <= 0.0) && (t_0 <= 0.9995))) tmp = Float64(cos(im) * Float64(re + 1.0)); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * cos(im); tmp = 0.0; if (t_0 <= -Inf) tmp = 1.0 + (-0.5 * (im * im)); elseif ((t_0 <= -0.05) || (~((t_0 <= 0.0)) && (t_0 <= 0.9995))) tmp = cos(im) * (re + 1.0); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$0, -0.05], And[N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision], LessEqual[t$95$0, 0.9995]]], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[Exp[re], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \cos im\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;t\_0 \leq -0.05 \lor \neg \left(t\_0 \leq 0\right) \land t\_0 \leq 0.9995:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -inf.0Initial program 100.0%
Taylor expanded in re around 0 3.1%
Taylor expanded in im around 0 52.8%
unpow252.8%
Applied egg-rr52.8%
if -inf.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < -0.050000000000000003 or 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.99950000000000006Initial program 100.0%
Taylor expanded in re around 0 99.9%
distribute-rgt1-in99.9%
Simplified99.9%
if -0.050000000000000003 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0 or 0.99950000000000006 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in im around 0 99.8%
Final simplification96.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (cos im))))
(if (<= t_0 (- INFINITY))
(+ 1.0 (* -0.5 (* im im)))
(if (or (<= t_0 -0.05) (and (not (<= t_0 0.0)) (<= t_0 0.9995)))
(cos im)
(exp re)))))
double code(double re, double im) {
double t_0 = exp(re) * cos(im);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = 1.0 + (-0.5 * (im * im));
} else if ((t_0 <= -0.05) || (!(t_0 <= 0.0) && (t_0 <= 0.9995))) {
tmp = cos(im);
} else {
tmp = exp(re);
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(re) * Math.cos(im);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = 1.0 + (-0.5 * (im * im));
} else if ((t_0 <= -0.05) || (!(t_0 <= 0.0) && (t_0 <= 0.9995))) {
tmp = Math.cos(im);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * math.cos(im) tmp = 0 if t_0 <= -math.inf: tmp = 1.0 + (-0.5 * (im * im)) elif (t_0 <= -0.05) or (not (t_0 <= 0.0) and (t_0 <= 0.9995)): tmp = math.cos(im) else: tmp = math.exp(re) return tmp
function code(re, im) t_0 = Float64(exp(re) * cos(im)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im))); elseif ((t_0 <= -0.05) || (!(t_0 <= 0.0) && (t_0 <= 0.9995))) tmp = cos(im); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * cos(im); tmp = 0.0; if (t_0 <= -Inf) tmp = 1.0 + (-0.5 * (im * im)); elseif ((t_0 <= -0.05) || (~((t_0 <= 0.0)) && (t_0 <= 0.9995))) tmp = cos(im); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$0, -0.05], And[N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision], LessEqual[t$95$0, 0.9995]]], N[Cos[im], $MachinePrecision], N[Exp[re], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \cos im\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;t\_0 \leq -0.05 \lor \neg \left(t\_0 \leq 0\right) \land t\_0 \leq 0.9995:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -inf.0Initial program 100.0%
Taylor expanded in re around 0 3.1%
Taylor expanded in im around 0 52.8%
unpow252.8%
Applied egg-rr52.8%
if -inf.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < -0.050000000000000003 or 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.99950000000000006Initial program 100.0%
Taylor expanded in re around 0 99.0%
if -0.050000000000000003 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0 or 0.99950000000000006 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in im around 0 99.8%
Final simplification96.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (cos im))))
(if (or (<= t_0 -0.05) (and (not (<= t_0 0.0)) (<= t_0 0.9999999987557401)))
(*
(cos im)
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))
(exp re))))
double code(double re, double im) {
double t_0 = exp(re) * cos(im);
double tmp;
if ((t_0 <= -0.05) || (!(t_0 <= 0.0) && (t_0 <= 0.9999999987557401))) {
tmp = cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
} else {
tmp = exp(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = exp(re) * cos(im)
if ((t_0 <= (-0.05d0)) .or. (.not. (t_0 <= 0.0d0)) .and. (t_0 <= 0.9999999987557401d0)) then
tmp = cos(im) * (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0))))))
else
tmp = exp(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(re) * Math.cos(im);
double tmp;
if ((t_0 <= -0.05) || (!(t_0 <= 0.0) && (t_0 <= 0.9999999987557401))) {
tmp = Math.cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * math.cos(im) tmp = 0 if (t_0 <= -0.05) or (not (t_0 <= 0.0) and (t_0 <= 0.9999999987557401)): tmp = math.cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) else: tmp = math.exp(re) return tmp
function code(re, im) t_0 = Float64(exp(re) * cos(im)) tmp = 0.0 if ((t_0 <= -0.05) || (!(t_0 <= 0.0) && (t_0 <= 0.9999999987557401))) tmp = Float64(cos(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666))))))); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * cos(im); tmp = 0.0; if ((t_0 <= -0.05) || (~((t_0 <= 0.0)) && (t_0 <= 0.9999999987557401))) tmp = cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.05], And[N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision], LessEqual[t$95$0, 0.9999999987557401]]], N[(N[Cos[im], $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \cos im\\
\mathbf{if}\;t\_0 \leq -0.05 \lor \neg \left(t\_0 \leq 0\right) \land t\_0 \leq 0.9999999987557401:\\
\;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -0.050000000000000003 or 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.999999998755740083Initial program 100.0%
Taylor expanded in re around 0 89.5%
*-commutative89.5%
Simplified89.5%
if -0.050000000000000003 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0 or 0.999999998755740083 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in im around 0 100.0%
Final simplification97.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) (cos im))))
(if (<= t_0 (- INFINITY))
(+ 1.0 (* -0.5 (* im im)))
(if (<= t_0 0.9995)
(cos im)
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666))))))))))
double code(double re, double im) {
double t_0 = exp(re) * cos(im);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = 1.0 + (-0.5 * (im * im));
} else if (t_0 <= 0.9995) {
tmp = cos(im);
} else {
tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(re) * Math.cos(im);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = 1.0 + (-0.5 * (im * im));
} else if (t_0 <= 0.9995) {
tmp = Math.cos(im);
} else {
tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * math.cos(im) tmp = 0 if t_0 <= -math.inf: tmp = 1.0 + (-0.5 * (im * im)) elif t_0 <= 0.9995: tmp = math.cos(im) else: tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))) return tmp
function code(re, im) t_0 = Float64(exp(re) * cos(im)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im))); elseif (t_0 <= 0.9995) tmp = cos(im); else tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666)))))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * cos(im); tmp = 0.0; if (t_0 <= -Inf) tmp = 1.0 + (-0.5 * (im * im)); elseif (t_0 <= 0.9995) tmp = cos(im); else tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.9995], N[Cos[im], $MachinePrecision], N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot \cos im\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;t\_0 \leq 0.9995:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -inf.0Initial program 100.0%
Taylor expanded in re around 0 3.1%
Taylor expanded in im around 0 52.8%
unpow252.8%
Applied egg-rr52.8%
if -inf.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.99950000000000006Initial program 100.0%
Taylor expanded in re around 0 47.8%
if 0.99950000000000006 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in im around 0 99.7%
Taylor expanded in re around 0 92.0%
*-commutative92.3%
Simplified92.0%
(FPCore (re im) :precision binary64 (if (<= (* (exp re) (cos im)) 0.0) (+ 1.0 (* -0.5 (* im im))) (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666))))))))
double code(double re, double im) {
double tmp;
if ((exp(re) * cos(im)) <= 0.0) {
tmp = 1.0 + (-0.5 * (im * im));
} else {
tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((exp(re) * cos(im)) <= 0.0d0) then
tmp = 1.0d0 + ((-0.5d0) * (im * im))
else
tmp = 1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0)))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) * Math.cos(im)) <= 0.0) {
tmp = 1.0 + (-0.5 * (im * im));
} else {
tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) * math.cos(im)) <= 0.0: tmp = 1.0 + (-0.5 * (im * im)) else: tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))) return tmp
function code(re, im) tmp = 0.0 if (Float64(exp(re) * cos(im)) <= 0.0) tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im))); else tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666)))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) * cos(im)) <= 0.0) tmp = 1.0 + (-0.5 * (im * im)); else tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision], 0.0], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \cdot \cos im \leq 0:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0 29.9%
Taylor expanded in im around 0 10.3%
unpow210.3%
Applied egg-rr10.3%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in im around 0 87.0%
Taylor expanded in re around 0 80.5%
*-commutative93.6%
Simplified80.5%
(FPCore (re im) :precision binary64 (if (<= (* (exp re) (cos im)) 0.0) (+ 1.0 (* -0.5 (* im im))) (+ 1.0 (* re (+ 1.0 (* re 0.5))))))
double code(double re, double im) {
double tmp;
if ((exp(re) * cos(im)) <= 0.0) {
tmp = 1.0 + (-0.5 * (im * im));
} else {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((exp(re) * cos(im)) <= 0.0d0) then
tmp = 1.0d0 + ((-0.5d0) * (im * im))
else
tmp = 1.0d0 + (re * (1.0d0 + (re * 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) * Math.cos(im)) <= 0.0) {
tmp = 1.0 + (-0.5 * (im * im));
} else {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) * math.cos(im)) <= 0.0: tmp = 1.0 + (-0.5 * (im * im)) else: tmp = 1.0 + (re * (1.0 + (re * 0.5))) return tmp
function code(re, im) tmp = 0.0 if (Float64(exp(re) * cos(im)) <= 0.0) tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im))); else tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) * cos(im)) <= 0.0) tmp = 1.0 + (-0.5 * (im * im)); else tmp = 1.0 + (re * (1.0 + (re * 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision], 0.0], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \cdot \cos im \leq 0:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot 0.5\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0 29.9%
Taylor expanded in im around 0 10.3%
unpow210.3%
Applied egg-rr10.3%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in im around 0 87.0%
Taylor expanded in re around 0 75.8%
*-commutative88.8%
Simplified75.8%
(FPCore (re im) :precision binary64 (if (<= (* (exp re) (cos im)) 0.0) (+ 1.0 (* -0.5 (* im im))) (+ re 1.0)))
double code(double re, double im) {
double tmp;
if ((exp(re) * cos(im)) <= 0.0) {
tmp = 1.0 + (-0.5 * (im * im));
} else {
tmp = re + 1.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((exp(re) * cos(im)) <= 0.0d0) then
tmp = 1.0d0 + ((-0.5d0) * (im * im))
else
tmp = re + 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) * Math.cos(im)) <= 0.0) {
tmp = 1.0 + (-0.5 * (im * im));
} else {
tmp = re + 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) * math.cos(im)) <= 0.0: tmp = 1.0 + (-0.5 * (im * im)) else: tmp = re + 1.0 return tmp
function code(re, im) tmp = 0.0 if (Float64(exp(re) * cos(im)) <= 0.0) tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im))); else tmp = Float64(re + 1.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) * cos(im)) <= 0.0) tmp = 1.0 + (-0.5 * (im * im)); else tmp = re + 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision], 0.0], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \cdot \cos im \leq 0:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;re + 1\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0 29.9%
Taylor expanded in im around 0 10.3%
unpow210.3%
Applied egg-rr10.3%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in re around 0 73.2%
distribute-rgt1-in73.2%
Simplified73.2%
Taylor expanded in im around 0 60.2%
+-commutative60.2%
Simplified60.2%
(FPCore (re im) :precision binary64 (+ re 1.0))
double code(double re, double im) {
return re + 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re + 1.0d0
end function
public static double code(double re, double im) {
return re + 1.0;
}
def code(re, im): return re + 1.0
function code(re, im) return Float64(re + 1.0) end
function tmp = code(re, im) tmp = re + 1.0; end
code[re_, im_] := N[(re + 1.0), $MachinePrecision]
\begin{array}{l}
\\
re + 1
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 54.9%
distribute-rgt1-in54.9%
Simplified54.9%
Taylor expanded in im around 0 35.5%
+-commutative35.5%
Simplified35.5%
(FPCore (re im) :precision binary64 1.0)
double code(double re, double im) {
return 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0
end function
public static double code(double re, double im) {
return 1.0;
}
def code(re, im): return 1.0
function code(re, im) return 1.0 end
function tmp = code(re, im) tmp = 1.0; end
code[re_, im_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 74.7%
Taylor expanded in re around 0 35.2%
herbie shell --seed 2024191
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))