
(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) 2.0))) (exp re) (cos im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 1.0) || !(exp(re) <= 2.0)) {
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) <= 2.0d0))) 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) <= 2.0)) {
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) <= 2.0): 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) <= 2.0)) 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) <= 2.0))) 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], 2.0]], $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 2\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im\\
\end{array}
\end{array}
if (exp.f64 re) < 1 or 2 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 72.4%
if 1 < (exp.f64 re) < 2Initial program 100.0%
Taylor expanded in re around 0 71.7%
Final simplification72.4%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.001) (and (not (<= re 2.6)) (<= 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.001) || (!(re <= 2.6) && (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.001d0)) .or. (.not. (re <= 2.6d0)) .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.001) || (!(re <= 2.6) && (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.001) or (not (re <= 2.6) 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.001) || (!(re <= 2.6) && (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.001) || (~((re <= 2.6)) && (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.001], And[N[Not[LessEqual[re, 2.6]], $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.001 \lor \neg \left(re \leq 2.6\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 < -1e-3 or 2.60000000000000009 < re < 1e103Initial program 100.0%
Taylor expanded in im around 0 94.4%
if -1e-3 < re < 2.60000000000000009 or 1e103 < re Initial program 100.0%
Taylor expanded in re around 0 99.6%
*-commutative99.6%
Simplified99.6%
Final simplification98.1%
(FPCore (re im)
:precision binary64
(if (<= re -2.25e-6)
(exp re)
(if (<= re 0.00028)
(* (cos im) (+ re 1.0))
(if (<= 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 <= -2.25e-6) {
tmp = exp(re);
} else if (re <= 0.00028) {
tmp = cos(im) * (re + 1.0);
} else if (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 <= (-2.25d-6)) then
tmp = exp(re)
else if (re <= 0.00028d0) then
tmp = cos(im) * (re + 1.0d0)
else if (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 <= -2.25e-6) {
tmp = Math.exp(re);
} else if (re <= 0.00028) {
tmp = Math.cos(im) * (re + 1.0);
} else if (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 <= -2.25e-6: tmp = math.exp(re) elif re <= 0.00028: tmp = math.cos(im) * (re + 1.0) elif 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 <= -2.25e-6) tmp = exp(re); elseif (re <= 0.00028) tmp = Float64(cos(im) * Float64(re + 1.0)); elseif (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 <= -2.25e-6) tmp = exp(re); elseif (re <= 0.00028) tmp = cos(im) * (re + 1.0); elseif (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[LessEqual[re, -2.25e-6], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.00028], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[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 -2.25 \cdot 10^{-6}:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.00028:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{elif}\;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 < -2.25000000000000006e-6 or 2.7999999999999998e-4 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 90.0%
if -2.25000000000000006e-6 < re < 2.7999999999999998e-4Initial program 100.0%
Taylor expanded in re around 0 100.0%
distribute-rgt1-in100.0%
Simplified100.0%
if 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification96.6%
(FPCore (re im) :precision binary64 (if (or (<= re -0.00047) (not (<= re 0.00018))) (exp re) (* (cos im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((re <= -0.00047) || !(re <= 0.00018)) {
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.00047d0)) .or. (.not. (re <= 0.00018d0))) 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.00047) || !(re <= 0.00018)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.00047) or not (re <= 0.00018): tmp = math.exp(re) else: tmp = math.cos(im) * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.00047) || !(re <= 0.00018)) 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.00047) || ~((re <= 0.00018))) tmp = exp(re); else tmp = cos(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.00047], N[Not[LessEqual[re, 0.00018]], $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.00047 \lor \neg \left(re \leq 0.00018\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -4.69999999999999986e-4 or 1.80000000000000011e-4 < re Initial program 100.0%
Taylor expanded in im around 0 84.7%
if -4.69999999999999986e-4 < re < 1.80000000000000011e-4Initial program 100.0%
Taylor expanded in re around 0 100.0%
distribute-rgt1-in100.0%
Simplified100.0%
Final simplification92.7%
(FPCore (re im)
:precision binary64
(if (<= re 1.75e+19)
(cos im)
(if (<= re 1.5e+103)
(+ re (* -0.5 (* re (* im im))))
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if (re <= 1.75e+19) {
tmp = cos(im);
} else if (re <= 1.5e+103) {
tmp = re + (-0.5 * (re * (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 (re <= 1.75d+19) then
tmp = cos(im)
else if (re <= 1.5d+103) then
tmp = re + ((-0.5d0) * (re * (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 (re <= 1.75e+19) {
tmp = Math.cos(im);
} else if (re <= 1.5e+103) {
tmp = re + (-0.5 * (re * (im * im)));
} else {
tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.75e+19: tmp = math.cos(im) elif re <= 1.5e+103: tmp = re + (-0.5 * (re * (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 (re <= 1.75e+19) tmp = cos(im); elseif (re <= 1.5e+103) tmp = Float64(re + Float64(-0.5 * Float64(re * 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 (re <= 1.75e+19) tmp = cos(im); elseif (re <= 1.5e+103) tmp = re + (-0.5 * (re * (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[re, 1.75e+19], N[Cos[im], $MachinePrecision], If[LessEqual[re, 1.5e+103], N[(re + N[(-0.5 * N[(re * N[(im * im), $MachinePrecision]), $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}\;re \leq 1.75 \cdot 10^{+19}:\\
\;\;\;\;\cos im\\
\mathbf{elif}\;re \leq 1.5 \cdot 10^{+103}:\\
\;\;\;\;re + -0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\\
\end{array}
\end{array}
if re < 1.75e19Initial program 100.0%
Taylor expanded in re around 0 69.7%
if 1.75e19 < re < 1.5e103Initial program 100.0%
Taylor expanded in re around 0 3.6%
distribute-rgt1-in3.6%
Simplified3.6%
Taylor expanded in re around inf 3.6%
Taylor expanded in im around 0 39.8%
unpow239.8%
Applied egg-rr39.8%
if 1.5e103 < re Initial program 100.0%
Taylor expanded in im around 0 74.0%
Taylor expanded in re around 0 74.0%
*-commutative100.0%
Simplified74.0%
Final simplification69.0%
(FPCore (re im) :precision binary64 (if (<= im 7.2e+216) (+ 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 (im <= 7.2e+216) {
tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
} else {
tmp = 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 <= 7.2d+216) then
tmp = 1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0)))))
else
tmp = 1.0d0 + ((-0.5d0) * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 7.2e+216) {
tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 7.2e+216: tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))) else: tmp = 1.0 + (-0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 7.2e+216) tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666)))))); else tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 7.2e+216) tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))); else tmp = 1.0 + (-0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 7.2e+216], 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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 7.2 \cdot 10^{+216}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 7.2000000000000004e216Initial program 100.0%
Taylor expanded in im around 0 75.5%
Taylor expanded in re around 0 49.9%
*-commutative72.8%
Simplified49.9%
if 7.2000000000000004e216 < im Initial program 100.0%
Taylor expanded in re around 0 43.9%
Taylor expanded in im around 0 32.8%
unpow232.7%
Applied egg-rr32.8%
(FPCore (re im) :precision binary64 (if (<= im 2.6e+116) (+ 1.0 (* re (+ 1.0 (* re 0.5)))) (+ re (* -0.5 (* re (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 2.6e+116) {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
} else {
tmp = re + (-0.5 * (re * (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.6d+116) then
tmp = 1.0d0 + (re * (1.0d0 + (re * 0.5d0)))
else
tmp = re + ((-0.5d0) * (re * (im * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.6e+116) {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
} else {
tmp = re + (-0.5 * (re * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.6e+116: tmp = 1.0 + (re * (1.0 + (re * 0.5))) else: tmp = re + (-0.5 * (re * (im * im))) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.6e+116) tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))); else tmp = Float64(re + Float64(-0.5 * Float64(re * Float64(im * im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.6e+116) tmp = 1.0 + (re * (1.0 + (re * 0.5))); else tmp = re + (-0.5 * (re * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.6e+116], N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re + N[(-0.5 * N[(re * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.6 \cdot 10^{+116}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;re + -0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 2.59999999999999987e116Initial program 100.0%
Taylor expanded in im around 0 77.2%
Taylor expanded in re around 0 46.5%
*-commutative66.4%
Simplified46.5%
if 2.59999999999999987e116 < im Initial program 100.0%
Taylor expanded in re around 0 49.6%
distribute-rgt1-in49.6%
Simplified49.6%
Taylor expanded in re around inf 4.8%
Taylor expanded in im around 0 19.1%
unpow219.1%
Applied egg-rr19.1%
Final simplification42.9%
(FPCore (re im) :precision binary64 (if (<= im 2.6e+116) (+ 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.6e+116) {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
} else {
tmp = 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.6d+116) then
tmp = 1.0d0 + (re * (1.0d0 + (re * 0.5d0)))
else
tmp = 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.6e+116) {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.6e+116: tmp = 1.0 + (re * (1.0 + (re * 0.5))) else: tmp = 1.0 + (-0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.6e+116) tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))); else tmp = 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.6e+116) tmp = 1.0 + (re * (1.0 + (re * 0.5))); else tmp = 1.0 + (-0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.6e+116], 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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.6 \cdot 10^{+116}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 2.59999999999999987e116Initial program 100.0%
Taylor expanded in im around 0 77.2%
Taylor expanded in re around 0 46.5%
*-commutative66.4%
Simplified46.5%
if 2.59999999999999987e116 < im Initial program 100.0%
Taylor expanded in re around 0 48.7%
Taylor expanded in im around 0 19.0%
unpow219.1%
Applied egg-rr19.0%
(FPCore (re im) :precision binary64 (if (<= re 5.2e-55) (+ re 1.0) (+ 1.0 (* -0.5 (* im im)))))
double code(double re, double im) {
double tmp;
if (re <= 5.2e-55) {
tmp = re + 1.0;
} else {
tmp = 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 <= 5.2d-55) then
tmp = re + 1.0d0
else
tmp = 1.0d0 + ((-0.5d0) * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 5.2e-55) {
tmp = re + 1.0;
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 5.2e-55: tmp = re + 1.0 else: tmp = 1.0 + (-0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (re <= 5.2e-55) tmp = Float64(re + 1.0); else tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 5.2e-55) tmp = re + 1.0; else tmp = 1.0 + (-0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 5.2e-55], N[(re + 1.0), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 5.2 \cdot 10^{-55}:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if re < 5.1999999999999998e-55Initial program 100.0%
Taylor expanded in re around 0 69.6%
distribute-rgt1-in69.6%
Simplified69.6%
Taylor expanded in im around 0 41.9%
+-commutative41.9%
Simplified41.9%
if 5.1999999999999998e-55 < re Initial program 100.0%
Taylor expanded in re around 0 18.5%
Taylor expanded in im around 0 29.0%
unpow224.0%
Applied egg-rr29.0%
(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.1%
distribute-rgt1-in54.1%
Simplified54.1%
Taylor expanded in im around 0 33.1%
+-commutative33.1%
Simplified33.1%
(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 72.1%
Taylor expanded in re around 0 32.7%
herbie shell --seed 2024157
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))