
(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 15 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) 0.9999995) (not (<= (exp re) 1.6))) (exp re) (cos im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.9999995) || !(exp(re) <= 1.6)) {
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) <= 0.9999995d0) .or. (.not. (exp(re) <= 1.6d0))) 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) <= 0.9999995) || !(Math.exp(re) <= 1.6)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.9999995) or not (math.exp(re) <= 1.6): tmp = math.exp(re) else: tmp = math.cos(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.9999995) || !(exp(re) <= 1.6)) tmp = exp(re); else tmp = cos(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 0.9999995) || ~((exp(re) <= 1.6))) tmp = exp(re); else tmp = cos(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.9999995], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.6]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[Cos[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.9999995 \lor \neg \left(e^{re} \leq 1.6\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.999999500000000041 or 1.6000000000000001 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 85.5%
if 0.999999500000000041 < (exp.f64 re) < 1.6000000000000001Initial program 100.0%
Taylor expanded in re around 0 98.1%
Final simplification92.1%
(FPCore (re im) :precision binary64 (if (<= (exp re) 0.9999995) (+ 1.0 (expm1 re)) (if (<= (exp re) 1.6) (cos im) (exp re))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.9999995) {
tmp = 1.0 + expm1(re);
} else if (exp(re) <= 1.6) {
tmp = cos(im);
} else {
tmp = exp(re);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (Math.exp(re) <= 0.9999995) {
tmp = 1.0 + Math.expm1(re);
} else if (Math.exp(re) <= 1.6) {
tmp = Math.cos(im);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 0.9999995: tmp = 1.0 + math.expm1(re) elif math.exp(re) <= 1.6: tmp = math.cos(im) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 0.9999995) tmp = Float64(1.0 + expm1(re)); elseif (exp(re) <= 1.6) tmp = cos(im); else tmp = exp(re); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.9999995], N[(1.0 + N[(Exp[re] - 1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 1.6], N[Cos[im], $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.9999995:\\
\;\;\;\;1 + \mathsf{expm1}\left(re\right)\\
\mathbf{elif}\;e^{re} \leq 1.6:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 0.999999500000000041Initial program 100.0%
Taylor expanded in im around 0 97.2%
log1p-expm1-u97.2%
log1p-undefine97.2%
add-exp-log97.2%
Applied egg-rr97.2%
if 0.999999500000000041 < (exp.f64 re) < 1.6000000000000001Initial program 100.0%
Taylor expanded in re around 0 98.1%
if 1.6000000000000001 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 76.5%
(FPCore (re im)
:precision binary64
(if (<= re -0.041)
(+ 1.0 (expm1 re))
(if (or (<= re 0.42) (not (<= re 1.02e+103)))
(*
(cos im)
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))
(exp re))))
double code(double re, double im) {
double tmp;
if (re <= -0.041) {
tmp = 1.0 + expm1(re);
} else if ((re <= 0.42) || !(re <= 1.02e+103)) {
tmp = cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
} else {
tmp = exp(re);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (re <= -0.041) {
tmp = 1.0 + Math.expm1(re);
} else if ((re <= 0.42) || !(re <= 1.02e+103)) {
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): tmp = 0 if re <= -0.041: tmp = 1.0 + math.expm1(re) elif (re <= 0.42) or not (re <= 1.02e+103): 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) tmp = 0.0 if (re <= -0.041) tmp = Float64(1.0 + expm1(re)); elseif ((re <= 0.42) || !(re <= 1.02e+103)) 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
code[re_, im_] := If[LessEqual[re, -0.041], N[(1.0 + N[(Exp[re] - 1), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[re, 0.42], N[Not[LessEqual[re, 1.02e+103]], $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], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.041:\\
\;\;\;\;1 + \mathsf{expm1}\left(re\right)\\
\mathbf{elif}\;re \leq 0.42 \lor \neg \left(re \leq 1.02 \cdot 10^{+103}\right):\\
\;\;\;\;\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 re < -0.0410000000000000017Initial program 100.0%
Taylor expanded in im around 0 98.6%
log1p-expm1-u98.6%
log1p-undefine98.6%
add-exp-log98.6%
Applied egg-rr98.6%
if -0.0410000000000000017 < re < 0.419999999999999984 or 1.01999999999999991e103 < re Initial program 100.0%
Taylor expanded in re around 0 99.6%
*-commutative99.6%
Simplified99.6%
if 0.419999999999999984 < re < 1.01999999999999991e103Initial program 100.0%
Taylor expanded in im around 0 76.0%
Final simplification97.1%
(FPCore (re im)
:precision binary64
(if (<= re -0.024)
(+ 1.0 (expm1 re))
(if (or (<= re 0.42) (not (<= re 1.9e+154)))
(* (cos im) (+ 1.0 (* re (+ 1.0 (* re 0.5)))))
(exp re))))
double code(double re, double im) {
double tmp;
if (re <= -0.024) {
tmp = 1.0 + expm1(re);
} else if ((re <= 0.42) || !(re <= 1.9e+154)) {
tmp = cos(im) * (1.0 + (re * (1.0 + (re * 0.5))));
} else {
tmp = exp(re);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (re <= -0.024) {
tmp = 1.0 + Math.expm1(re);
} else if ((re <= 0.42) || !(re <= 1.9e+154)) {
tmp = Math.cos(im) * (1.0 + (re * (1.0 + (re * 0.5))));
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.024: tmp = 1.0 + math.expm1(re) elif (re <= 0.42) or not (re <= 1.9e+154): tmp = math.cos(im) * (1.0 + (re * (1.0 + (re * 0.5)))) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.024) tmp = Float64(1.0 + expm1(re)); elseif ((re <= 0.42) || !(re <= 1.9e+154)) tmp = Float64(cos(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))); else tmp = exp(re); end return tmp end
code[re_, im_] := If[LessEqual[re, -0.024], N[(1.0 + N[(Exp[re] - 1), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[re, 0.42], N[Not[LessEqual[re, 1.9e+154]], $MachinePrecision]], N[(N[Cos[im], $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.024:\\
\;\;\;\;1 + \mathsf{expm1}\left(re\right)\\
\mathbf{elif}\;re \leq 0.42 \lor \neg \left(re \leq 1.9 \cdot 10^{+154}\right):\\
\;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if re < -0.024Initial program 100.0%
Taylor expanded in im around 0 98.6%
log1p-expm1-u98.6%
log1p-undefine98.6%
add-exp-log98.6%
Applied egg-rr98.6%
if -0.024 < re < 0.419999999999999984 or 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 99.5%
*-commutative99.5%
Simplified99.5%
if 0.419999999999999984 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 78.9%
Final simplification96.3%
(FPCore (re im)
:precision binary64
(if (<= re -0.00094)
(+ 1.0 (expm1 re))
(if (<= re 0.42)
(/ (cos im) (+ 1.0 (* re (+ (* re 0.5) -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 <= -0.00094) {
tmp = 1.0 + expm1(re);
} else if (re <= 0.42) {
tmp = cos(im) / (1.0 + (re * ((re * 0.5) + -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;
}
public static double code(double re, double im) {
double tmp;
if (re <= -0.00094) {
tmp = 1.0 + Math.expm1(re);
} else if (re <= 0.42) {
tmp = Math.cos(im) / (1.0 + (re * ((re * 0.5) + -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 <= -0.00094: tmp = 1.0 + math.expm1(re) elif re <= 0.42: tmp = math.cos(im) / (1.0 + (re * ((re * 0.5) + -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 <= -0.00094) tmp = Float64(1.0 + expm1(re)); elseif (re <= 0.42) tmp = Float64(cos(im) / Float64(1.0 + Float64(re * Float64(Float64(re * 0.5) + -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
code[re_, im_] := If[LessEqual[re, -0.00094], N[(1.0 + N[(Exp[re] - 1), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 0.42], N[(N[Cos[im], $MachinePrecision] / N[(1.0 + N[(re * N[(N[(re * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $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 -0.00094:\\
\;\;\;\;1 + \mathsf{expm1}\left(re\right)\\
\mathbf{elif}\;re \leq 0.42:\\
\;\;\;\;\frac{\cos im}{1 + re \cdot \left(re \cdot 0.5 + -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 < -9.39999999999999972e-4Initial program 100.0%
Taylor expanded in im around 0 98.6%
log1p-expm1-u98.6%
log1p-undefine98.6%
add-exp-log98.6%
Applied egg-rr98.6%
if -9.39999999999999972e-4 < re < 0.419999999999999984Initial program 100.0%
*-un-lft-identity100.0%
exp-prod100.0%
expm1-log1p-u100.0%
expm1-undefine100.0%
pow-sub99.9%
exp-1-e99.9%
log1p-undefine99.9%
rem-exp-log99.9%
pow199.9%
exp-1-e99.9%
Applied egg-rr99.9%
*-commutative99.9%
clear-num99.9%
un-div-inv99.9%
clear-num99.9%
pow199.9%
pow-div100.0%
add-exp-log100.0%
expm1-undefine100.0%
log1p-define100.0%
expm1-log1p-u100.0%
pow-to-exp100.0%
log-E100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 99.4%
if 0.419999999999999984 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 78.9%
if 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification96.3%
(FPCore (re im) :precision binary64 (if (<= re -5.8e-5) (+ 1.0 (expm1 re)) (if (<= re 0.42) (* (cos im) (+ re 1.0)) (exp re))))
double code(double re, double im) {
double tmp;
if (re <= -5.8e-5) {
tmp = 1.0 + expm1(re);
} else if (re <= 0.42) {
tmp = cos(im) * (re + 1.0);
} else {
tmp = exp(re);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (re <= -5.8e-5) {
tmp = 1.0 + Math.expm1(re);
} else if (re <= 0.42) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -5.8e-5: tmp = 1.0 + math.expm1(re) elif re <= 0.42: tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -5.8e-5) tmp = Float64(1.0 + expm1(re)); elseif (re <= 0.42) tmp = Float64(cos(im) * Float64(re + 1.0)); else tmp = exp(re); end return tmp end
code[re_, im_] := If[LessEqual[re, -5.8e-5], N[(1.0 + N[(Exp[re] - 1), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 0.42], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -5.8 \cdot 10^{-5}:\\
\;\;\;\;1 + \mathsf{expm1}\left(re\right)\\
\mathbf{elif}\;re \leq 0.42:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if re < -5.8e-5Initial program 100.0%
Taylor expanded in im around 0 98.6%
log1p-expm1-u98.6%
log1p-undefine98.6%
add-exp-log98.6%
Applied egg-rr98.6%
if -5.8e-5 < re < 0.419999999999999984Initial program 100.0%
Taylor expanded in re around 0 98.9%
distribute-rgt1-in98.9%
Simplified98.9%
if 0.419999999999999984 < re Initial program 100.0%
Taylor expanded in im around 0 76.5%
Final simplification92.9%
(FPCore (re im)
:precision binary64
(if (<= re 0.64)
(cos im)
(if (<= re 1.02e+92)
(* (* re (+ 1.0 (/ 1.0 re))) (+ 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 (re <= 0.64) {
tmp = cos(im);
} else if (re <= 1.02e+92) {
tmp = (re * (1.0 + (1.0 / re))) * (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 (re <= 0.64d0) then
tmp = cos(im)
else if (re <= 1.02d+92) then
tmp = (re * (1.0d0 + (1.0d0 / re))) * (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 (re <= 0.64) {
tmp = Math.cos(im);
} else if (re <= 1.02e+92) {
tmp = (re * (1.0 + (1.0 / re))) * (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 re <= 0.64: tmp = math.cos(im) elif re <= 1.02e+92: tmp = (re * (1.0 + (1.0 / re))) * (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 (re <= 0.64) tmp = cos(im); elseif (re <= 1.02e+92) tmp = Float64(Float64(re * Float64(1.0 + Float64(1.0 / re))) * 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 (re <= 0.64) tmp = cos(im); elseif (re <= 1.02e+92) tmp = (re * (1.0 + (1.0 / re))) * (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[re, 0.64], N[Cos[im], $MachinePrecision], If[LessEqual[re, 1.02e+92], N[(N[(re * N[(1.0 + N[(1.0 / re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * 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 0.64:\\
\;\;\;\;\cos im\\
\mathbf{elif}\;re \leq 1.02 \cdot 10^{+92}:\\
\;\;\;\;\left(re \cdot \left(1 + \frac{1}{re}\right)\right) \cdot \left(1 + -0.5 \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 < 0.640000000000000013Initial program 100.0%
Taylor expanded in re around 0 71.8%
if 0.640000000000000013 < re < 1.02000000000000003e92Initial program 100.0%
Taylor expanded in re around 0 4.3%
distribute-rgt1-in4.3%
Simplified4.3%
Taylor expanded in im around 0 23.4%
unpow223.4%
Applied egg-rr23.4%
Taylor expanded in re around inf 23.4%
if 1.02000000000000003e92 < re Initial program 100.0%
Taylor expanded in re around 0 97.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in im around 0 75.2%
Final simplification67.8%
(FPCore (re im) :precision binary64 (if (<= re 1.3e-15) (/ 1.0 (- 1.0 re)) (* re (+ 1.0 (* -0.5 (* im im))))))
double code(double re, double im) {
double tmp;
if (re <= 1.3e-15) {
tmp = 1.0 / (1.0 - re);
} else {
tmp = re * (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.3d-15) then
tmp = 1.0d0 / (1.0d0 - re)
else
tmp = re * (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.3e-15) {
tmp = 1.0 / (1.0 - re);
} else {
tmp = re * (1.0 + (-0.5 * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.3e-15: tmp = 1.0 / (1.0 - re) else: tmp = re * (1.0 + (-0.5 * (im * im))) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.3e-15) tmp = Float64(1.0 / Float64(1.0 - re)); else tmp = Float64(re * 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.3e-15) tmp = 1.0 / (1.0 - re); else tmp = re * (1.0 + (-0.5 * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.3e-15], N[(1.0 / N[(1.0 - re), $MachinePrecision]), $MachinePrecision], N[(re * N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.3 \cdot 10^{-15}:\\
\;\;\;\;\frac{1}{1 - re}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if re < 1.30000000000000002e-15Initial program 100.0%
*-un-lft-identity100.0%
exp-prod100.0%
expm1-log1p-u72.6%
expm1-undefine72.6%
pow-sub72.5%
exp-1-e72.5%
log1p-undefine72.5%
rem-exp-log99.9%
pow199.9%
exp-1-e99.9%
Applied egg-rr99.9%
*-commutative99.9%
clear-num99.9%
un-div-inv99.9%
clear-num99.9%
pow199.9%
pow-div100.0%
add-exp-log72.6%
expm1-undefine72.6%
log1p-define72.6%
expm1-log1p-u99.9%
pow-to-exp100.0%
log-E100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 73.7%
neg-mul-173.7%
sub-neg73.7%
Simplified73.7%
Taylor expanded in im around 0 37.3%
if 1.30000000000000002e-15 < re Initial program 100.0%
Taylor expanded in re around 0 7.1%
distribute-rgt1-in7.1%
Simplified7.1%
Taylor expanded in im around 0 18.0%
unpow218.0%
Applied egg-rr18.0%
Taylor expanded in re around inf 18.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 71.0%
*-commutative71.0%
Simplified71.0%
Taylor expanded in im around 0 39.8%
Final simplification39.8%
(FPCore (re im) :precision binary64 (if (<= re 1.3e-15) (/ 1.0 (- 1.0 re)) (+ 1.0 (* -0.5 (* im im)))))
double code(double re, double im) {
double tmp;
if (re <= 1.3e-15) {
tmp = 1.0 / (1.0 - re);
} 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 <= 1.3d-15) then
tmp = 1.0d0 / (1.0d0 - re)
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 <= 1.3e-15) {
tmp = 1.0 / (1.0 - re);
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.3e-15: tmp = 1.0 / (1.0 - re) else: tmp = 1.0 + (-0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.3e-15) tmp = Float64(1.0 / Float64(1.0 - re)); 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 <= 1.3e-15) tmp = 1.0 / (1.0 - re); else tmp = 1.0 + (-0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.3e-15], N[(1.0 / N[(1.0 - re), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.3 \cdot 10^{-15}:\\
\;\;\;\;\frac{1}{1 - re}\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if re < 1.30000000000000002e-15Initial program 100.0%
*-un-lft-identity100.0%
exp-prod100.0%
expm1-log1p-u72.6%
expm1-undefine72.6%
pow-sub72.5%
exp-1-e72.5%
log1p-undefine72.5%
rem-exp-log99.9%
pow199.9%
exp-1-e99.9%
Applied egg-rr99.9%
*-commutative99.9%
clear-num99.9%
un-div-inv99.9%
clear-num99.9%
pow199.9%
pow-div100.0%
add-exp-log72.6%
expm1-undefine72.6%
log1p-define72.6%
expm1-log1p-u99.9%
pow-to-exp100.0%
log-E100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 73.7%
neg-mul-173.7%
sub-neg73.7%
Simplified73.7%
Taylor expanded in im around 0 37.3%
if 1.30000000000000002e-15 < re Initial program 100.0%
Taylor expanded in re around 0 4.9%
Taylor expanded in im around 0 14.0%
unpow218.0%
Applied egg-rr14.0%
(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 66.0%
Taylor expanded in re around 0 35.7%
*-commutative66.1%
Simplified35.7%
(FPCore (re im) :precision binary64 (+ -1.0 (+ re 2.0)))
double code(double re, double im) {
return -1.0 + (re + 2.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (-1.0d0) + (re + 2.0d0)
end function
public static double code(double re, double im) {
return -1.0 + (re + 2.0);
}
def code(re, im): return -1.0 + (re + 2.0)
function code(re, im) return Float64(-1.0 + Float64(re + 2.0)) end
function tmp = code(re, im) tmp = -1.0 + (re + 2.0); end
code[re_, im_] := N[(-1.0 + N[(re + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left(re + 2\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 54.8%
distribute-rgt1-in54.8%
Simplified54.8%
Taylor expanded in im around 0 27.6%
+-commutative27.6%
expm1-log1p-u27.1%
expm1-undefine27.1%
+-commutative27.1%
Applied egg-rr27.1%
sub-neg27.1%
metadata-eval27.1%
+-commutative27.1%
log1p-undefine27.1%
rem-exp-log27.6%
associate-+r+27.6%
metadata-eval27.6%
Simplified27.6%
Final simplification27.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 re around 0 54.8%
distribute-rgt1-in54.8%
Simplified54.8%
Taylor expanded in im around 0 27.6%
Final simplification27.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 im around 0 66.0%
Taylor expanded in re around 0 27.2%
herbie shell --seed 2024177
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))