
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
(FPCore (re im) :precision binary64 (* (/ (exp (+ 1.0 re)) E) (sin im)))
double code(double re, double im) {
return (exp((1.0 + re)) / ((double) M_E)) * sin(im);
}
public static double code(double re, double im) {
return (Math.exp((1.0 + re)) / Math.E) * Math.sin(im);
}
def code(re, im): return (math.exp((1.0 + re)) / math.e) * math.sin(im)
function code(re, im) return Float64(Float64(exp(Float64(1.0 + re)) / exp(1)) * sin(im)) end
function tmp = code(re, im) tmp = (exp((1.0 + re)) / 2.71828182845904523536) * sin(im); end
code[re_, im_] := N[(N[(N[Exp[N[(1.0 + re), $MachinePrecision]], $MachinePrecision] / E), $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{1 + re}}{e} \cdot \sin im
\end{array}
Initial program 100.0%
expm1-log1p-u80.4%
expm1-undefine80.4%
exp-diff80.4%
log1p-undefine80.4%
rem-exp-log100.0%
exp-1-e100.0%
Applied egg-rr100.0%
(FPCore (re im) :precision binary64 (if (<= (exp re) 0.99999995) (* im (+ 1.0 (expm1 re))) (if (<= (exp re) 1.000002) (* (+ 1.0 re) (sin im)) (* im (exp re)))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.99999995) {
tmp = im * (1.0 + expm1(re));
} else if (exp(re) <= 1.000002) {
tmp = (1.0 + re) * sin(im);
} else {
tmp = im * exp(re);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (Math.exp(re) <= 0.99999995) {
tmp = im * (1.0 + Math.expm1(re));
} else if (Math.exp(re) <= 1.000002) {
tmp = (1.0 + re) * Math.sin(im);
} else {
tmp = im * Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 0.99999995: tmp = im * (1.0 + math.expm1(re)) elif math.exp(re) <= 1.000002: tmp = (1.0 + re) * math.sin(im) else: tmp = im * math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 0.99999995) tmp = Float64(im * Float64(1.0 + expm1(re))); elseif (exp(re) <= 1.000002) tmp = Float64(Float64(1.0 + re) * sin(im)); else tmp = Float64(im * exp(re)); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.99999995], N[(im * N[(1.0 + N[(Exp[re] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 1.000002], N[(N[(1.0 + re), $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision], N[(im * N[Exp[re], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.99999995:\\
\;\;\;\;im \cdot \left(1 + \mathsf{expm1}\left(re\right)\right)\\
\mathbf{elif}\;e^{re} \leq 1.000002:\\
\;\;\;\;\left(1 + re\right) \cdot \sin im\\
\mathbf{else}:\\
\;\;\;\;im \cdot e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 0.999999949999999971Initial program 100.0%
Taylor expanded in im around 0 98.1%
log1p-expm1-u98.1%
log1p-undefine98.1%
add-exp-log98.1%
Applied egg-rr98.1%
if 0.999999949999999971 < (exp.f64 re) < 1.00000200000000006Initial program 100.0%
Taylor expanded in re around 0 100.0%
distribute-rgt1-in100.0%
Simplified100.0%
if 1.00000200000000006 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 76.8%
Final simplification93.4%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 0.99999995) (not (<= (exp re) 1.000002))) (* im (exp re)) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.99999995) || !(exp(re) <= 1.000002)) {
tmp = im * exp(re);
} else {
tmp = sin(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) <= 0.99999995d0) .or. (.not. (exp(re) <= 1.000002d0))) then
tmp = im * exp(re)
else
tmp = sin(im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) <= 0.99999995) || !(Math.exp(re) <= 1.000002)) {
tmp = im * Math.exp(re);
} else {
tmp = Math.sin(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.99999995) or not (math.exp(re) <= 1.000002): tmp = im * math.exp(re) else: tmp = math.sin(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.99999995) || !(exp(re) <= 1.000002)) tmp = Float64(im * exp(re)); else tmp = sin(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 0.99999995) || ~((exp(re) <= 1.000002))) tmp = im * exp(re); else tmp = sin(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.99999995], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.000002]], $MachinePrecision]], N[(im * N[Exp[re], $MachinePrecision]), $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.99999995 \lor \neg \left(e^{re} \leq 1.000002\right):\\
\;\;\;\;im \cdot e^{re}\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.999999949999999971 or 1.00000200000000006 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 85.9%
if 0.999999949999999971 < (exp.f64 re) < 1.00000200000000006Initial program 100.0%
Taylor expanded in re around 0 99.6%
Final simplification93.2%
(FPCore (re im) :precision binary64 (if (<= (exp re) 0.99999995) (* im (+ 1.0 (expm1 re))) (if (<= (exp re) 1.000002) (sin im) (* im (exp re)))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.99999995) {
tmp = im * (1.0 + expm1(re));
} else if (exp(re) <= 1.000002) {
tmp = sin(im);
} else {
tmp = im * exp(re);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (Math.exp(re) <= 0.99999995) {
tmp = im * (1.0 + Math.expm1(re));
} else if (Math.exp(re) <= 1.000002) {
tmp = Math.sin(im);
} else {
tmp = im * Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 0.99999995: tmp = im * (1.0 + math.expm1(re)) elif math.exp(re) <= 1.000002: tmp = math.sin(im) else: tmp = im * math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 0.99999995) tmp = Float64(im * Float64(1.0 + expm1(re))); elseif (exp(re) <= 1.000002) tmp = sin(im); else tmp = Float64(im * exp(re)); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.99999995], N[(im * N[(1.0 + N[(Exp[re] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 1.000002], N[Sin[im], $MachinePrecision], N[(im * N[Exp[re], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.99999995:\\
\;\;\;\;im \cdot \left(1 + \mathsf{expm1}\left(re\right)\right)\\
\mathbf{elif}\;e^{re} \leq 1.000002:\\
\;\;\;\;\sin im\\
\mathbf{else}:\\
\;\;\;\;im \cdot e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 0.999999949999999971Initial program 100.0%
Taylor expanded in im around 0 98.1%
log1p-expm1-u98.1%
log1p-undefine98.1%
add-exp-log98.1%
Applied egg-rr98.1%
if 0.999999949999999971 < (exp.f64 re) < 1.00000200000000006Initial program 100.0%
Taylor expanded in re around 0 99.6%
if 1.00000200000000006 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 76.8%
Final simplification93.2%
(FPCore (re im) :precision binary64 (* (sin im) (exp re)))
double code(double re, double im) {
return sin(im) * exp(re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = sin(im) * exp(re)
end function
public static double code(double re, double im) {
return Math.sin(im) * Math.exp(re);
}
def code(re, im): return math.sin(im) * math.exp(re)
function code(re, im) return Float64(sin(im) * exp(re)) end
function tmp = code(re, im) tmp = sin(im) * exp(re); end
code[re_, im_] := N[(N[Sin[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin im \cdot e^{re}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.0255) (and (not (<= re 1.7)) (<= re 1.05e+103)))
(* im (+ 1.0 (expm1 re)))
(*
(sin im)
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.0255) || (!(re <= 1.7) && (re <= 1.05e+103))) {
tmp = im * (1.0 + expm1(re));
} else {
tmp = sin(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if ((re <= -0.0255) || (!(re <= 1.7) && (re <= 1.05e+103))) {
tmp = im * (1.0 + Math.expm1(re));
} else {
tmp = Math.sin(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.0255) or (not (re <= 1.7) and (re <= 1.05e+103)): tmp = im * (1.0 + math.expm1(re)) else: tmp = math.sin(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.0255) || (!(re <= 1.7) && (re <= 1.05e+103))) tmp = Float64(im * Float64(1.0 + expm1(re))); else tmp = Float64(sin(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666))))))); end return tmp end
code[re_, im_] := If[Or[LessEqual[re, -0.0255], And[N[Not[LessEqual[re, 1.7]], $MachinePrecision], LessEqual[re, 1.05e+103]]], N[(im * N[(1.0 + N[(Exp[re] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[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.0255 \lor \neg \left(re \leq 1.7\right) \land re \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;im \cdot \left(1 + \mathsf{expm1}\left(re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sin 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.0254999999999999984 or 1.69999999999999996 < re < 1.0500000000000001e103Initial program 100.0%
Taylor expanded in im around 0 91.6%
log1p-expm1-u91.6%
log1p-undefine91.6%
add-exp-log91.6%
Applied egg-rr91.6%
if -0.0254999999999999984 < re < 1.69999999999999996 or 1.0500000000000001e103 < re Initial program 100.0%
Taylor expanded in re around 0 99.4%
*-commutative99.4%
Simplified99.4%
Final simplification97.2%
(FPCore (re im)
:precision binary64
(if (<= re -0.0154)
(* im (+ 1.0 (expm1 re)))
(if (or (<= re 0.23) (not (<= re 1.9e+154)))
(* (sin im) (+ 1.0 (* re (+ 1.0 (* re 0.5)))))
(* im (exp re)))))
double code(double re, double im) {
double tmp;
if (re <= -0.0154) {
tmp = im * (1.0 + expm1(re));
} else if ((re <= 0.23) || !(re <= 1.9e+154)) {
tmp = sin(im) * (1.0 + (re * (1.0 + (re * 0.5))));
} else {
tmp = im * exp(re);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (re <= -0.0154) {
tmp = im * (1.0 + Math.expm1(re));
} else if ((re <= 0.23) || !(re <= 1.9e+154)) {
tmp = Math.sin(im) * (1.0 + (re * (1.0 + (re * 0.5))));
} else {
tmp = im * Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.0154: tmp = im * (1.0 + math.expm1(re)) elif (re <= 0.23) or not (re <= 1.9e+154): tmp = math.sin(im) * (1.0 + (re * (1.0 + (re * 0.5)))) else: tmp = im * math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.0154) tmp = Float64(im * Float64(1.0 + expm1(re))); elseif ((re <= 0.23) || !(re <= 1.9e+154)) tmp = Float64(sin(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))); else tmp = Float64(im * exp(re)); end return tmp end
code[re_, im_] := If[LessEqual[re, -0.0154], N[(im * N[(1.0 + N[(Exp[re] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[re, 0.23], N[Not[LessEqual[re, 1.9e+154]], $MachinePrecision]], N[(N[Sin[im], $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[Exp[re], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.0154:\\
\;\;\;\;im \cdot \left(1 + \mathsf{expm1}\left(re\right)\right)\\
\mathbf{elif}\;re \leq 0.23 \lor \neg \left(re \leq 1.9 \cdot 10^{+154}\right):\\
\;\;\;\;\sin im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot e^{re}\\
\end{array}
\end{array}
if re < -0.0154Initial program 100.0%
Taylor expanded in im around 0 98.1%
log1p-expm1-u98.1%
log1p-undefine98.1%
add-exp-log98.1%
Applied egg-rr98.1%
if -0.0154 < re < 0.23000000000000001 or 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 99.2%
*-commutative99.2%
Simplified99.2%
if 0.23000000000000001 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 79.4%
Final simplification96.3%
(FPCore (re im) :precision binary64 (if (<= re -9.6e-8) (* im (+ 1.0 (expm1 re))) (if (<= re 2.4e-6) (* (sin im) (/ (* (+ 1.0 re) E) E)) (* im (exp re)))))
double code(double re, double im) {
double tmp;
if (re <= -9.6e-8) {
tmp = im * (1.0 + expm1(re));
} else if (re <= 2.4e-6) {
tmp = sin(im) * (((1.0 + re) * ((double) M_E)) / ((double) M_E));
} else {
tmp = im * exp(re);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (re <= -9.6e-8) {
tmp = im * (1.0 + Math.expm1(re));
} else if (re <= 2.4e-6) {
tmp = Math.sin(im) * (((1.0 + re) * Math.E) / Math.E);
} else {
tmp = im * Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -9.6e-8: tmp = im * (1.0 + math.expm1(re)) elif re <= 2.4e-6: tmp = math.sin(im) * (((1.0 + re) * math.e) / math.e) else: tmp = im * math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -9.6e-8) tmp = Float64(im * Float64(1.0 + expm1(re))); elseif (re <= 2.4e-6) tmp = Float64(sin(im) * Float64(Float64(Float64(1.0 + re) * exp(1)) / exp(1))); else tmp = Float64(im * exp(re)); end return tmp end
code[re_, im_] := If[LessEqual[re, -9.6e-8], N[(im * N[(1.0 + N[(Exp[re] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 2.4e-6], N[(N[Sin[im], $MachinePrecision] * N[(N[(N[(1.0 + re), $MachinePrecision] * E), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision], N[(im * N[Exp[re], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -9.6 \cdot 10^{-8}:\\
\;\;\;\;im \cdot \left(1 + \mathsf{expm1}\left(re\right)\right)\\
\mathbf{elif}\;re \leq 2.4 \cdot 10^{-6}:\\
\;\;\;\;\sin im \cdot \frac{\left(1 + re\right) \cdot e}{e}\\
\mathbf{else}:\\
\;\;\;\;im \cdot e^{re}\\
\end{array}
\end{array}
if re < -9.59999999999999994e-8Initial program 100.0%
Taylor expanded in im around 0 98.1%
log1p-expm1-u98.1%
log1p-undefine98.1%
add-exp-log98.1%
Applied egg-rr98.1%
if -9.59999999999999994e-8 < re < 2.3999999999999999e-6Initial program 100.0%
expm1-log1p-u100.0%
expm1-undefine100.0%
exp-diff100.0%
log1p-undefine100.0%
rem-exp-log100.0%
exp-1-e100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 100.0%
exp-1-e100.0%
exp-1-e100.0%
distribute-rgt1-in100.0%
+-commutative100.0%
Simplified100.0%
if 2.3999999999999999e-6 < re Initial program 100.0%
Taylor expanded in im around 0 76.8%
Final simplification93.4%
(FPCore (re im) :precision binary64 (if (<= re 8e-9) (sin im) (* im (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if (re <= 8e-9) {
tmp = sin(im);
} else {
tmp = 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 <= 8d-9) then
tmp = sin(im)
else
tmp = 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 <= 8e-9) {
tmp = Math.sin(im);
} else {
tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 8e-9: tmp = math.sin(im) else: tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if (re <= 8e-9) tmp = sin(im); else tmp = Float64(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 <= 8e-9) tmp = sin(im); else tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 8e-9], N[Sin[im], $MachinePrecision], N[(im * 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 8 \cdot 10^{-9}:\\
\;\;\;\;\sin im\\
\mathbf{else}:\\
\;\;\;\;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 < 8.0000000000000005e-9Initial program 100.0%
Taylor expanded in re around 0 73.8%
if 8.0000000000000005e-9 < re Initial program 100.0%
Taylor expanded in re around 0 69.6%
*-commutative69.6%
Simplified69.6%
Taylor expanded in im around 0 63.1%
Final simplification70.9%
(FPCore (re im) :precision binary64 (* im (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666))))))))
double code(double re, double im) {
return im * (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 = im * (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0))))))
end function
public static double code(double re, double im) {
return im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
def code(re, im): return im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))))
function code(re, im) return Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666))))))) end
function tmp = code(re, im) tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); end
code[re_, im_] := N[(im * 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}
\\
im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 72.6%
*-commutative72.6%
Simplified72.6%
Taylor expanded in im around 0 43.0%
Final simplification43.0%
(FPCore (re im) :precision binary64 (* im (+ 1.0 (* re (+ 1.0 (* re 0.5))))))
double code(double re, double im) {
return im * (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 = im * (1.0d0 + (re * (1.0d0 + (re * 0.5d0))))
end function
public static double code(double re, double im) {
return im * (1.0 + (re * (1.0 + (re * 0.5))));
}
def code(re, im): return im * (1.0 + (re * (1.0 + (re * 0.5))))
function code(re, im) return Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))) end
function tmp = code(re, im) tmp = im * (1.0 + (re * (1.0 + (re * 0.5)))); end
code[re_, im_] := N[(im * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 65.5%
Taylor expanded in re around 0 38.5%
*-commutative67.6%
Simplified38.5%
Final simplification38.5%
(FPCore (re im) :precision binary64 (if (<= im 1.36e+35) im (* re im)))
double code(double re, double im) {
double tmp;
if (im <= 1.36e+35) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.36d+35) then
tmp = im
else
tmp = re * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.36e+35) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.36e+35: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (im <= 1.36e+35) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.36e+35) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.36e+35], im, N[(re * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.36 \cdot 10^{+35}:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if im < 1.36e35Initial program 100.0%
Taylor expanded in re around 0 53.0%
Taylor expanded in im around 0 35.4%
if 1.36e35 < im Initial program 100.0%
Taylor expanded in re around 0 62.8%
distribute-rgt1-in62.8%
Simplified62.8%
Taylor expanded in im around 0 9.8%
Taylor expanded in re around inf 11.4%
*-commutative11.4%
Simplified11.4%
(FPCore (re im) :precision binary64 (* im (+ -1.0 (+ re 2.0))))
double code(double re, double im) {
return im * (-1.0 + (re + 2.0));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * ((-1.0d0) + (re + 2.0d0))
end function
public static double code(double re, double im) {
return im * (-1.0 + (re + 2.0));
}
def code(re, im): return im * (-1.0 + (re + 2.0))
function code(re, im) return Float64(im * Float64(-1.0 + Float64(re + 2.0))) end
function tmp = code(re, im) tmp = im * (-1.0 + (re + 2.0)); end
code[re_, im_] := N[(im * N[(-1.0 + N[(re + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(-1 + \left(re + 2\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 55.9%
distribute-rgt1-in55.9%
Simplified55.9%
Taylor expanded in im around 0 30.9%
expm1-log1p-u30.4%
expm1-undefine30.4%
Applied egg-rr30.4%
sub-neg30.4%
metadata-eval30.4%
+-commutative30.4%
log1p-undefine30.4%
rem-exp-log30.9%
+-commutative30.9%
associate-+r+30.9%
metadata-eval30.9%
Simplified30.9%
Final simplification30.9%
(FPCore (re im) :precision binary64 (* (+ 1.0 re) im))
double code(double re, double im) {
return (1.0 + re) * im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (1.0d0 + re) * im
end function
public static double code(double re, double im) {
return (1.0 + re) * im;
}
def code(re, im): return (1.0 + re) * im
function code(re, im) return Float64(Float64(1.0 + re) * im) end
function tmp = code(re, im) tmp = (1.0 + re) * im; end
code[re_, im_] := N[(N[(1.0 + re), $MachinePrecision] * im), $MachinePrecision]
\begin{array}{l}
\\
\left(1 + re\right) \cdot im
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 55.9%
distribute-rgt1-in55.9%
Simplified55.9%
Taylor expanded in im around 0 30.9%
Final simplification30.9%
(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 im end
function tmp = code(re, im) tmp = im; end
code[re_, im_] := im
\begin{array}{l}
\\
im
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 55.2%
Taylor expanded in im around 0 27.3%
herbie shell --seed 2024176
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))