
(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 12 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 (if (or (<= (exp re) 1.0) (not (<= (exp re) 1.000002))) (exp re) (cos im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 1.0) || !(exp(re) <= 1.000002)) {
tmp = exp(re);
} else {
tmp = cos(im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((exp(re) <= 1.0d0) .or. (.not. (exp(re) <= 1.000002d0))) then
tmp = exp(re)
else
tmp = cos(im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) <= 1.0) || !(Math.exp(re) <= 1.000002)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 1.0) or not (math.exp(re) <= 1.000002): tmp = math.exp(re) else: tmp = math.cos(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 1.0) || !(exp(re) <= 1.000002)) tmp = exp(re); else tmp = cos(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 1.0) || ~((exp(re) <= 1.000002))) tmp = exp(re); else tmp = cos(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 1.0], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.000002]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[Cos[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 1 \lor \neg \left(e^{re} \leq 1.000002\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im\\
\end{array}
\end{array}
if (exp.f64 re) < 1 or 1.00000200000000006 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 73.5%
if 1 < (exp.f64 re) < 1.00000200000000006Initial program 99.0%
Taylor expanded in re around 0 83.5%
Final simplification73.6%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.045) (and (not (<= re 0.0145)) (<= re 1e+103)))
(exp re)
(*
(cos im)
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.045) || (!(re <= 0.0145) && (re <= 1e+103))) {
tmp = exp(re);
} else {
tmp = cos(im) * (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 ((re <= (-0.045d0)) .or. (.not. (re <= 0.0145d0)) .and. (re <= 1d+103)) then
tmp = exp(re)
else
tmp = cos(im) * (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 ((re <= -0.045) || (!(re <= 0.0145) && (re <= 1e+103))) {
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): tmp = 0 if (re <= -0.045) or (not (re <= 0.0145) and (re <= 1e+103)): 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) tmp = 0.0 if ((re <= -0.045) || (!(re <= 0.0145) && (re <= 1e+103))) 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) tmp = 0.0; if ((re <= -0.045) || (~((re <= 0.0145)) && (re <= 1e+103))) 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_] := If[Or[LessEqual[re, -0.045], And[N[Not[LessEqual[re, 0.0145]], $MachinePrecision], LessEqual[re, 1e+103]]], 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}
\mathbf{if}\;re \leq -0.045 \lor \neg \left(re \leq 0.0145\right) \land re \leq 10^{+103}:\\
\;\;\;\;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 re < -0.044999999999999998 or 0.0145000000000000007 < re < 1e103Initial program 100.0%
Taylor expanded in im around 0 93.1%
if -0.044999999999999998 < re < 0.0145000000000000007 or 1e103 < re Initial program 100.0%
Taylor expanded in re around 0 99.9%
*-commutative99.9%
Simplified99.9%
Final simplification97.6%
(FPCore (re im) :precision binary64 (if (or (<= re -0.0027) (and (not (<= re 0.0058)) (<= re 1.9e+154))) (exp re) (* (cos im) (+ 1.0 (* re (+ 1.0 (* re 0.5)))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.0027) || (!(re <= 0.0058) && (re <= 1.9e+154))) {
tmp = exp(re);
} else {
tmp = cos(im) * (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 ((re <= (-0.0027d0)) .or. (.not. (re <= 0.0058d0)) .and. (re <= 1.9d+154)) then
tmp = exp(re)
else
tmp = cos(im) * (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 ((re <= -0.0027) || (!(re <= 0.0058) && (re <= 1.9e+154))) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (1.0 + (re * (1.0 + (re * 0.5))));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.0027) or (not (re <= 0.0058) and (re <= 1.9e+154)): tmp = math.exp(re) else: tmp = math.cos(im) * (1.0 + (re * (1.0 + (re * 0.5)))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.0027) || (!(re <= 0.0058) && (re <= 1.9e+154))) 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) tmp = 0.0; if ((re <= -0.0027) || (~((re <= 0.0058)) && (re <= 1.9e+154))) tmp = exp(re); else tmp = cos(im) * (1.0 + (re * (1.0 + (re * 0.5)))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.0027], And[N[Not[LessEqual[re, 0.0058]], $MachinePrecision], LessEqual[re, 1.9e+154]]], 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}
\mathbf{if}\;re \leq -0.0027 \lor \neg \left(re \leq 0.0058\right) \land re \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.0027000000000000001 or 0.0058 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 92.9%
if -0.0027000000000000001 < re < 0.0058 or 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 99.7%
*-commutative99.7%
Simplified99.7%
Final simplification97.1%
(FPCore (re im) :precision binary64 (if (or (<= re -0.00088) (not (<= re 0.055))) (exp re) (* (cos im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((re <= -0.00088) || !(re <= 0.055)) {
tmp = exp(re);
} else {
tmp = cos(im) * (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 ((re <= (-0.00088d0)) .or. (.not. (re <= 0.055d0))) then
tmp = exp(re)
else
tmp = cos(im) * (re + 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.00088) || !(re <= 0.055)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.00088) or not (re <= 0.055): tmp = math.exp(re) else: tmp = math.cos(im) * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.00088) || !(re <= 0.055)) tmp = exp(re); else tmp = Float64(cos(im) * Float64(re + 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.00088) || ~((re <= 0.055))) tmp = exp(re); else tmp = cos(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.00088], N[Not[LessEqual[re, 0.055]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.00088 \lor \neg \left(re \leq 0.055\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -8.80000000000000031e-4 or 0.0550000000000000003 < re Initial program 100.0%
Taylor expanded in im around 0 86.8%
if -8.80000000000000031e-4 < re < 0.0550000000000000003Initial program 99.9%
Taylor expanded in re around 0 98.8%
distribute-rgt1-in98.8%
Simplified98.8%
Final simplification92.4%
(FPCore (re im)
:precision binary64
(if (<= re 1.65e+24)
(cos im)
(*
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666))))))
(+ 1.0 (* -0.5 (* im im))))))
double code(double re, double im) {
double tmp;
if (re <= 1.65e+24) {
tmp = cos(im);
} else {
tmp = (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) * (1.0 + (-0.5 * (im * im)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 1.65d+24) then
tmp = cos(im)
else
tmp = (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0)))))) * (1.0d0 + ((-0.5d0) * (im * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 1.65e+24) {
tmp = Math.cos(im);
} else {
tmp = (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) * (1.0 + (-0.5 * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.65e+24: tmp = math.cos(im) else: tmp = (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) * (1.0 + (-0.5 * (im * im))) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.65e+24) tmp = cos(im); else tmp = Float64(Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666)))))) * Float64(1.0 + Float64(-0.5 * Float64(im * im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.65e+24) tmp = cos(im); else tmp = (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) * (1.0 + (-0.5 * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.65e+24], N[Cos[im], $MachinePrecision], N[(N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.65 \cdot 10^{+24}:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;\left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right) \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if re < 1.6499999999999999e24Initial program 100.0%
Taylor expanded in re around 0 65.5%
if 1.6499999999999999e24 < re Initial program 100.0%
Taylor expanded in re around 0 67.7%
*-commutative67.7%
Simplified67.7%
Taylor expanded in im around 0 57.7%
unpow257.7%
Applied egg-rr57.7%
(FPCore (re im) :precision binary64 (let* ((t_0 (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))) (if (<= re 2.7e+54) t_0 (* t_0 (+ 1.0 (* -0.5 (* im im)))))))
double code(double re, double im) {
double t_0 = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
double tmp;
if (re <= 2.7e+54) {
tmp = t_0;
} else {
tmp = t_0 * (1.0 + (-0.5 * (im * im)));
}
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 = 1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0)))))
if (re <= 2.7d+54) then
tmp = t_0
else
tmp = t_0 * (1.0d0 + ((-0.5d0) * (im * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
double tmp;
if (re <= 2.7e+54) {
tmp = t_0;
} else {
tmp = t_0 * (1.0 + (-0.5 * (im * im)));
}
return tmp;
}
def code(re, im): t_0 = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))) tmp = 0 if re <= 2.7e+54: tmp = t_0 else: tmp = t_0 * (1.0 + (-0.5 * (im * im))) return tmp
function code(re, im) t_0 = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666)))))) tmp = 0.0 if (re <= 2.7e+54) tmp = t_0; else tmp = Float64(t_0 * Float64(1.0 + Float64(-0.5 * Float64(im * im)))); end return tmp end
function tmp_2 = code(re, im) t_0 = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))); tmp = 0.0; if (re <= 2.7e+54) tmp = t_0; else tmp = t_0 * (1.0 + (-0.5 * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, 2.7e+54], t$95$0, N[(t$95$0 * N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\\
\mathbf{if}\;re \leq 2.7 \cdot 10^{+54}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if re < 2.70000000000000011e54Initial program 100.0%
Taylor expanded in re around 0 65.0%
*-commutative65.0%
Simplified65.0%
Taylor expanded in im around 0 37.6%
if 2.70000000000000011e54 < re Initial program 100.0%
Taylor expanded in re around 0 73.2%
*-commutative73.2%
Simplified73.2%
Taylor expanded in im around 0 62.4%
unpow262.4%
Applied egg-rr62.4%
Final simplification44.3%
(FPCore (re im) :precision binary64 (if (<= im 2.8e+254) (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))) (* (+ 1.0 (* re (+ 1.0 (* re 0.5)))) (+ 1.0 (* -0.5 (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 2.8e+254) {
tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
} else {
tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (1.0 + (-0.5 * (im * im)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.8d+254) then
tmp = 1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0)))))
else
tmp = (1.0d0 + (re * (1.0d0 + (re * 0.5d0)))) * (1.0d0 + ((-0.5d0) * (im * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.8e+254) {
tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
} else {
tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (1.0 + (-0.5 * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.8e+254: tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))) else: tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (1.0 + (-0.5 * (im * im))) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.8e+254) tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666)))))); else tmp = Float64(Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))) * Float64(1.0 + Float64(-0.5 * Float64(im * im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.8e+254) tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))); else tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (1.0 + (-0.5 * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.8e+254], N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.8 \cdot 10^{+254}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right) \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 2.79999999999999982e254Initial program 100.0%
Taylor expanded in re around 0 66.4%
*-commutative66.4%
Simplified66.4%
Taylor expanded in im around 0 43.3%
if 2.79999999999999982e254 < im Initial program 100.0%
Taylor expanded in re around 0 89.1%
*-commutative89.1%
Simplified89.1%
Taylor expanded in im around 0 34.3%
unpow234.3%
Applied egg-rr34.3%
Taylor expanded in re around 0 34.3%
*-commutative34.3%
Simplified34.3%
Final simplification43.0%
(FPCore (re im) :precision binary64 (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))
double code(double re, double im) {
return 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0)))))
end function
public static double code(double re, double im) {
return 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
}
def code(re, im): return 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))
function code(re, im) return Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666)))))) end
function tmp = code(re, im) tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))); end
code[re_, im_] := 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}
\\
1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 67.2%
*-commutative67.2%
Simplified67.2%
Taylor expanded in im around 0 42.4%
Final simplification42.4%
(FPCore (re im) :precision binary64 (+ 1.0 (* re (+ 1.0 (* re 0.5)))))
double code(double re, double im) {
return 1.0 + (re * (1.0 + (re * 0.5)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0 + (re * (1.0d0 + (re * 0.5d0)))
end function
public static double code(double re, double im) {
return 1.0 + (re * (1.0 + (re * 0.5)));
}
def code(re, im): return 1.0 + (re * (1.0 + (re * 0.5)))
function code(re, im) return Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))) end
function tmp = code(re, im) tmp = 1.0 + (re * (1.0 + (re * 0.5))); end
code[re_, im_] := N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + re \cdot \left(1 + re \cdot 0.5\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 72.9%
Taylor expanded in re around 0 38.6%
*-commutative62.9%
Simplified38.6%
(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 im around 0 72.9%
Taylor expanded in re around 0 28.6%
+-commutative28.6%
Simplified28.6%
(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 re around 0 47.2%
Taylor expanded in im around 0 27.9%
herbie shell --seed 2024123
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))