
(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 (<= (exp re) 1.0) (exp re) (if (<= (exp re) 2.0) (cos im) (pow E re))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 1.0) {
tmp = exp(re);
} else if (exp(re) <= 2.0) {
tmp = cos(im);
} else {
tmp = pow(((double) M_E), re);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (Math.exp(re) <= 1.0) {
tmp = Math.exp(re);
} else if (Math.exp(re) <= 2.0) {
tmp = Math.cos(im);
} else {
tmp = Math.pow(Math.E, re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 1.0: tmp = math.exp(re) elif math.exp(re) <= 2.0: tmp = math.cos(im) else: tmp = math.pow(math.e, re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 1.0) tmp = exp(re); elseif (exp(re) <= 2.0) tmp = cos(im); else tmp = exp(1) ^ re; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (exp(re) <= 1.0) tmp = exp(re); elseif (exp(re) <= 2.0) tmp = cos(im); else tmp = 2.71828182845904523536 ^ re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 1.0], N[Exp[re], $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 2.0], N[Cos[im], $MachinePrecision], N[Power[E, re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 1:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;e^{re} \leq 2:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;{e}^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 1Initial program 100.0%
Taylor expanded in im around 0 77.6%
if 1 < (exp.f64 re) < 2Initial program 100.0%
Taylor expanded in re around 0 56.5%
if 2 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 71.8%
*-un-lft-identity71.8%
exp-prod71.8%
exp-1-e71.8%
Applied egg-rr71.8%
(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 76.3%
if 1 < (exp.f64 re) < 2Initial program 100.0%
Taylor expanded in re around 0 56.5%
Final simplification76.0%
(FPCore (re im)
:precision binary64
(if (<= re -0.00145)
(exp re)
(if (or (<= re 0.116) (not (<= re 1.02e+103)))
(*
(cos im)
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))
(pow E re))))
double code(double re, double im) {
double tmp;
if (re <= -0.00145) {
tmp = exp(re);
} else if ((re <= 0.116) || !(re <= 1.02e+103)) {
tmp = cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
} else {
tmp = pow(((double) M_E), re);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (re <= -0.00145) {
tmp = Math.exp(re);
} else if ((re <= 0.116) || !(re <= 1.02e+103)) {
tmp = Math.cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
} else {
tmp = Math.pow(Math.E, re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.00145: tmp = math.exp(re) elif (re <= 0.116) or not (re <= 1.02e+103): tmp = math.cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) else: tmp = math.pow(math.e, re) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.00145) tmp = exp(re); elseif ((re <= 0.116) || !(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(1) ^ re; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -0.00145) tmp = exp(re); elseif ((re <= 0.116) || ~((re <= 1.02e+103))) tmp = cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); else tmp = 2.71828182845904523536 ^ re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.00145], N[Exp[re], $MachinePrecision], If[Or[LessEqual[re, 0.116], 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[Power[E, re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.00145:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.116 \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.00145Initial program 100.0%
Taylor expanded in im around 0 100.0%
if -0.00145 < re < 0.116000000000000006 or 1.01999999999999991e103 < re Initial program 100.0%
Taylor expanded in re around 0 99.4%
*-commutative99.4%
Simplified99.4%
if 0.116000000000000006 < re < 1.01999999999999991e103Initial program 100.0%
Taylor expanded in im around 0 55.8%
*-un-lft-identity55.8%
exp-prod55.8%
exp-1-e55.8%
Applied egg-rr55.8%
Final simplification95.5%
(FPCore (re im)
:precision binary64
(if (<= re -3.2e-5)
(exp re)
(if (or (<= re 0.116) (not (<= re 1.9e+154)))
(* (cos im) (+ 1.0 (* re (+ 1.0 (* re 0.5)))))
(pow E re))))
double code(double re, double im) {
double tmp;
if (re <= -3.2e-5) {
tmp = exp(re);
} else if ((re <= 0.116) || !(re <= 1.9e+154)) {
tmp = cos(im) * (1.0 + (re * (1.0 + (re * 0.5))));
} else {
tmp = pow(((double) M_E), re);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (re <= -3.2e-5) {
tmp = Math.exp(re);
} else if ((re <= 0.116) || !(re <= 1.9e+154)) {
tmp = Math.cos(im) * (1.0 + (re * (1.0 + (re * 0.5))));
} else {
tmp = Math.pow(Math.E, re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -3.2e-5: tmp = math.exp(re) elif (re <= 0.116) or not (re <= 1.9e+154): tmp = math.cos(im) * (1.0 + (re * (1.0 + (re * 0.5)))) else: tmp = math.pow(math.e, re) return tmp
function code(re, im) tmp = 0.0 if (re <= -3.2e-5) tmp = exp(re); elseif ((re <= 0.116) || !(re <= 1.9e+154)) tmp = Float64(cos(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))); else tmp = exp(1) ^ re; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -3.2e-5) tmp = exp(re); elseif ((re <= 0.116) || ~((re <= 1.9e+154))) tmp = cos(im) * (1.0 + (re * (1.0 + (re * 0.5)))); else tmp = 2.71828182845904523536 ^ re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -3.2e-5], N[Exp[re], $MachinePrecision], If[Or[LessEqual[re, 0.116], 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[Power[E, re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -3.2 \cdot 10^{-5}:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.116 \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 < -3.19999999999999986e-5Initial program 100.0%
Taylor expanded in im around 0 100.0%
if -3.19999999999999986e-5 < re < 0.116000000000000006 or 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 99.2%
*-commutative99.2%
Simplified99.2%
if 0.116000000000000006 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 61.3%
*-un-lft-identity61.3%
exp-prod61.3%
exp-1-e61.3%
Applied egg-rr61.3%
Final simplification95.0%
(FPCore (re im) :precision binary64 (if (<= re -2.65e-5) (exp re) (if (<= re 0.116) (* (cos im) (+ re 1.0)) (pow E re))))
double code(double re, double im) {
double tmp;
if (re <= -2.65e-5) {
tmp = exp(re);
} else if (re <= 0.116) {
tmp = cos(im) * (re + 1.0);
} else {
tmp = pow(((double) M_E), re);
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (re <= -2.65e-5) {
tmp = Math.exp(re);
} else if (re <= 0.116) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.pow(Math.E, re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -2.65e-5: tmp = math.exp(re) elif re <= 0.116: tmp = math.cos(im) * (re + 1.0) else: tmp = math.pow(math.e, re) return tmp
function code(re, im) tmp = 0.0 if (re <= -2.65e-5) tmp = exp(re); elseif (re <= 0.116) tmp = Float64(cos(im) * Float64(re + 1.0)); else tmp = exp(1) ^ re; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -2.65e-5) tmp = exp(re); elseif (re <= 0.116) tmp = cos(im) * (re + 1.0); else tmp = 2.71828182845904523536 ^ re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -2.65e-5], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.116], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[Power[E, re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -2.65 \cdot 10^{-5}:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.116:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;{e}^{re}\\
\end{array}
\end{array}
if re < -2.65e-5Initial program 100.0%
Taylor expanded in im around 0 100.0%
if -2.65e-5 < re < 0.116000000000000006Initial program 100.0%
Taylor expanded in re around 0 98.9%
distribute-rgt1-in98.9%
Simplified98.9%
if 0.116000000000000006 < re Initial program 100.0%
Taylor expanded in im around 0 71.8%
*-un-lft-identity71.8%
exp-prod71.8%
exp-1-e71.8%
Applied egg-rr71.8%
Final simplification93.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.5 (* im im))))
(if (<= re -9.6e+16)
(* (+ re 1.0) t_0)
(if (<= re 16000.0)
(cos im)
(if (<= re 6.4e+94)
(* (* re (+ 1.0 (/ 1.0 re))) (+ 1.0 t_0))
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))))))
double code(double re, double im) {
double t_0 = -0.5 * (im * im);
double tmp;
if (re <= -9.6e+16) {
tmp = (re + 1.0) * t_0;
} else if (re <= 16000.0) {
tmp = cos(im);
} else if (re <= 6.4e+94) {
tmp = (re * (1.0 + (1.0 / re))) * (1.0 + t_0);
} 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) :: t_0
real(8) :: tmp
t_0 = (-0.5d0) * (im * im)
if (re <= (-9.6d+16)) then
tmp = (re + 1.0d0) * t_0
else if (re <= 16000.0d0) then
tmp = cos(im)
else if (re <= 6.4d+94) then
tmp = (re * (1.0d0 + (1.0d0 / re))) * (1.0d0 + t_0)
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 t_0 = -0.5 * (im * im);
double tmp;
if (re <= -9.6e+16) {
tmp = (re + 1.0) * t_0;
} else if (re <= 16000.0) {
tmp = Math.cos(im);
} else if (re <= 6.4e+94) {
tmp = (re * (1.0 + (1.0 / re))) * (1.0 + t_0);
} else {
tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
}
return tmp;
}
def code(re, im): t_0 = -0.5 * (im * im) tmp = 0 if re <= -9.6e+16: tmp = (re + 1.0) * t_0 elif re <= 16000.0: tmp = math.cos(im) elif re <= 6.4e+94: tmp = (re * (1.0 + (1.0 / re))) * (1.0 + t_0) else: tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))) return tmp
function code(re, im) t_0 = Float64(-0.5 * Float64(im * im)) tmp = 0.0 if (re <= -9.6e+16) tmp = Float64(Float64(re + 1.0) * t_0); elseif (re <= 16000.0) tmp = cos(im); elseif (re <= 6.4e+94) tmp = Float64(Float64(re * Float64(1.0 + Float64(1.0 / re))) * Float64(1.0 + t_0)); else tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666)))))); end return tmp end
function tmp_2 = code(re, im) t_0 = -0.5 * (im * im); tmp = 0.0; if (re <= -9.6e+16) tmp = (re + 1.0) * t_0; elseif (re <= 16000.0) tmp = cos(im); elseif (re <= 6.4e+94) tmp = (re * (1.0 + (1.0 / re))) * (1.0 + t_0); else tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -9.6e+16], N[(N[(re + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[re, 16000.0], N[Cos[im], $MachinePrecision], If[LessEqual[re, 6.4e+94], N[(N[(re * N[(1.0 + N[(1.0 / re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + t$95$0), $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}
t_0 := -0.5 \cdot \left(im \cdot im\right)\\
\mathbf{if}\;re \leq -9.6 \cdot 10^{+16}:\\
\;\;\;\;\left(re + 1\right) \cdot t\_0\\
\mathbf{elif}\;re \leq 16000:\\
\;\;\;\;\cos im\\
\mathbf{elif}\;re \leq 6.4 \cdot 10^{+94}:\\
\;\;\;\;\left(re \cdot \left(1 + \frac{1}{re}\right)\right) \cdot \left(1 + t\_0\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 < -9.6e16Initial program 100.0%
Taylor expanded in re around 0 2.2%
distribute-rgt1-in2.2%
Simplified2.2%
Taylor expanded in im around 0 1.9%
associate-+r+1.9%
+-commutative1.9%
*-lft-identity1.9%
associate-*r*1.9%
+-commutative1.9%
distribute-rgt-out1.9%
Simplified1.9%
Taylor expanded in im around inf 25.4%
unpow225.4%
Applied egg-rr25.4%
if -9.6e16 < re < 16000Initial program 100.0%
Taylor expanded in re around 0 94.3%
if 16000 < re < 6.40000000000000028e94Initial program 100.0%
Taylor expanded in re around 0 3.5%
distribute-rgt1-in3.5%
Simplified3.5%
Taylor expanded in im around 0 26.7%
associate-+r+26.7%
+-commutative26.7%
*-lft-identity26.7%
associate-*r*26.7%
+-commutative26.7%
distribute-rgt-out26.7%
Simplified26.7%
unpow225.6%
Applied egg-rr26.7%
Taylor expanded in re around inf 26.7%
if 6.40000000000000028e94 < re Initial program 100.0%
Taylor expanded in im around 0 83.8%
Taylor expanded in re around 0 79.0%
*-commutative95.2%
Simplified79.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.5 (* im im))))
(if (<= re -1.0)
(* (+ re 1.0) t_0)
(if (<= re 3.6e+179)
(* (+ re 1.0) (+ 1.0 t_0))
(+ 1.0 (* re (+ 1.0 (* re 0.5))))))))
double code(double re, double im) {
double t_0 = -0.5 * (im * im);
double tmp;
if (re <= -1.0) {
tmp = (re + 1.0) * t_0;
} else if (re <= 3.6e+179) {
tmp = (re + 1.0) * (1.0 + t_0);
} else {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = (-0.5d0) * (im * im)
if (re <= (-1.0d0)) then
tmp = (re + 1.0d0) * t_0
else if (re <= 3.6d+179) then
tmp = (re + 1.0d0) * (1.0d0 + t_0)
else
tmp = 1.0d0 + (re * (1.0d0 + (re * 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = -0.5 * (im * im);
double tmp;
if (re <= -1.0) {
tmp = (re + 1.0) * t_0;
} else if (re <= 3.6e+179) {
tmp = (re + 1.0) * (1.0 + t_0);
} else {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
}
return tmp;
}
def code(re, im): t_0 = -0.5 * (im * im) tmp = 0 if re <= -1.0: tmp = (re + 1.0) * t_0 elif re <= 3.6e+179: tmp = (re + 1.0) * (1.0 + t_0) else: tmp = 1.0 + (re * (1.0 + (re * 0.5))) return tmp
function code(re, im) t_0 = Float64(-0.5 * Float64(im * im)) tmp = 0.0 if (re <= -1.0) tmp = Float64(Float64(re + 1.0) * t_0); elseif (re <= 3.6e+179) tmp = Float64(Float64(re + 1.0) * Float64(1.0 + t_0)); else tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))); end return tmp end
function tmp_2 = code(re, im) t_0 = -0.5 * (im * im); tmp = 0.0; if (re <= -1.0) tmp = (re + 1.0) * t_0; elseif (re <= 3.6e+179) tmp = (re + 1.0) * (1.0 + t_0); else tmp = 1.0 + (re * (1.0 + (re * 0.5))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -1.0], N[(N[(re + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[re, 3.6e+179], N[(N[(re + 1.0), $MachinePrecision] * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(im \cdot im\right)\\
\mathbf{if}\;re \leq -1:\\
\;\;\;\;\left(re + 1\right) \cdot t\_0\\
\mathbf{elif}\;re \leq 3.6 \cdot 10^{+179}:\\
\;\;\;\;\left(re + 1\right) \cdot \left(1 + t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -1Initial program 100.0%
Taylor expanded in re around 0 2.2%
distribute-rgt1-in2.2%
Simplified2.2%
Taylor expanded in im around 0 1.9%
associate-+r+1.9%
+-commutative1.9%
*-lft-identity1.9%
associate-*r*1.9%
+-commutative1.9%
distribute-rgt-out1.9%
Simplified1.9%
Taylor expanded in im around inf 24.5%
unpow224.5%
Applied egg-rr24.5%
if -1 < re < 3.5999999999999998e179Initial program 100.0%
Taylor expanded in re around 0 77.1%
distribute-rgt1-in77.1%
Simplified77.1%
Taylor expanded in im around 0 50.5%
associate-+r+50.5%
+-commutative50.5%
*-lft-identity50.5%
associate-*r*50.5%
+-commutative50.5%
distribute-rgt-out50.5%
Simplified50.5%
unpow28.5%
Applied egg-rr50.5%
if 3.5999999999999998e179 < re Initial program 100.0%
Taylor expanded in im around 0 92.0%
Taylor expanded in re around 0 92.0%
*-commutative100.0%
Simplified92.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.5 (* im im))))
(if (<= re -3.2)
(* (+ re 1.0) t_0)
(if (<= re 7.8e-38) (+ re 1.0) (* re (+ 1.0 t_0))))))
double code(double re, double im) {
double t_0 = -0.5 * (im * im);
double tmp;
if (re <= -3.2) {
tmp = (re + 1.0) * t_0;
} else if (re <= 7.8e-38) {
tmp = re + 1.0;
} else {
tmp = re * (1.0 + t_0);
}
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 = (-0.5d0) * (im * im)
if (re <= (-3.2d0)) then
tmp = (re + 1.0d0) * t_0
else if (re <= 7.8d-38) then
tmp = re + 1.0d0
else
tmp = re * (1.0d0 + t_0)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = -0.5 * (im * im);
double tmp;
if (re <= -3.2) {
tmp = (re + 1.0) * t_0;
} else if (re <= 7.8e-38) {
tmp = re + 1.0;
} else {
tmp = re * (1.0 + t_0);
}
return tmp;
}
def code(re, im): t_0 = -0.5 * (im * im) tmp = 0 if re <= -3.2: tmp = (re + 1.0) * t_0 elif re <= 7.8e-38: tmp = re + 1.0 else: tmp = re * (1.0 + t_0) return tmp
function code(re, im) t_0 = Float64(-0.5 * Float64(im * im)) tmp = 0.0 if (re <= -3.2) tmp = Float64(Float64(re + 1.0) * t_0); elseif (re <= 7.8e-38) tmp = Float64(re + 1.0); else tmp = Float64(re * Float64(1.0 + t_0)); end return tmp end
function tmp_2 = code(re, im) t_0 = -0.5 * (im * im); tmp = 0.0; if (re <= -3.2) tmp = (re + 1.0) * t_0; elseif (re <= 7.8e-38) tmp = re + 1.0; else tmp = re * (1.0 + t_0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -3.2], N[(N[(re + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[re, 7.8e-38], N[(re + 1.0), $MachinePrecision], N[(re * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(im \cdot im\right)\\
\mathbf{if}\;re \leq -3.2:\\
\;\;\;\;\left(re + 1\right) \cdot t\_0\\
\mathbf{elif}\;re \leq 7.8 \cdot 10^{-38}:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(1 + t\_0\right)\\
\end{array}
\end{array}
if re < -3.2000000000000002Initial program 100.0%
Taylor expanded in re around 0 2.2%
distribute-rgt1-in2.2%
Simplified2.2%
Taylor expanded in im around 0 1.9%
associate-+r+1.9%
+-commutative1.9%
*-lft-identity1.9%
associate-*r*1.9%
+-commutative1.9%
distribute-rgt-out1.9%
Simplified1.9%
Taylor expanded in im around inf 24.5%
unpow224.5%
Applied egg-rr24.5%
if -3.2000000000000002 < re < 7.7999999999999998e-38Initial program 100.0%
Taylor expanded in re around 0 99.2%
distribute-rgt1-in99.2%
Simplified99.2%
Taylor expanded in im around 0 62.4%
+-commutative62.4%
Simplified62.4%
if 7.7999999999999998e-38 < re Initial program 100.0%
Taylor expanded in re around 0 12.1%
distribute-rgt1-in12.1%
Simplified12.1%
Taylor expanded in im around 0 20.1%
associate-+r+20.1%
+-commutative20.1%
*-lft-identity20.1%
associate-*r*20.1%
+-commutative20.1%
distribute-rgt-out20.1%
Simplified20.1%
unpow218.4%
Applied egg-rr20.1%
Taylor expanded in re around inf 20.1%
(FPCore (re im) :precision binary64 (if (<= re -3.1) (* (+ 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 <= -3.1) {
tmp = (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 <= (-3.1d0)) then
tmp = (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 <= -3.1) {
tmp = (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 <= -3.1: tmp = (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 <= -3.1) tmp = Float64(Float64(re + 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 <= -3.1) tmp = (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, -3.1], N[(N[(re + 1.0), $MachinePrecision] * N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -3.1:\\
\;\;\;\;\left(re + 1\right) \cdot \left(-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 < -3.10000000000000009Initial program 100.0%
Taylor expanded in re around 0 2.2%
distribute-rgt1-in2.2%
Simplified2.2%
Taylor expanded in im around 0 1.9%
associate-+r+1.9%
+-commutative1.9%
*-lft-identity1.9%
associate-*r*1.9%
+-commutative1.9%
distribute-rgt-out1.9%
Simplified1.9%
Taylor expanded in im around inf 24.5%
unpow224.5%
Applied egg-rr24.5%
if -3.10000000000000009 < re Initial program 100.0%
Taylor expanded in im around 0 64.0%
Taylor expanded in re around 0 56.8%
*-commutative86.6%
Simplified56.8%
(FPCore (re im) :precision binary64 (if (<= re -19000000000.0) (* (+ re 1.0) (* -0.5 (* im im))) (+ 1.0 (* re (+ 1.0 (* re 0.5))))))
double code(double re, double im) {
double tmp;
if (re <= -19000000000.0) {
tmp = (re + 1.0) * (-0.5 * (im * im));
} else {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-19000000000.0d0)) then
tmp = (re + 1.0d0) * ((-0.5d0) * (im * im))
else
tmp = 1.0d0 + (re * (1.0d0 + (re * 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -19000000000.0) {
tmp = (re + 1.0) * (-0.5 * (im * im));
} else {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -19000000000.0: tmp = (re + 1.0) * (-0.5 * (im * im)) else: tmp = 1.0 + (re * (1.0 + (re * 0.5))) return tmp
function code(re, im) tmp = 0.0 if (re <= -19000000000.0) tmp = Float64(Float64(re + 1.0) * Float64(-0.5 * Float64(im * im))); else tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -19000000000.0) tmp = (re + 1.0) * (-0.5 * (im * im)); else tmp = 1.0 + (re * (1.0 + (re * 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -19000000000.0], N[(N[(re + 1.0), $MachinePrecision] * N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -19000000000:\\
\;\;\;\;\left(re + 1\right) \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -1.9e10Initial program 100.0%
Taylor expanded in re around 0 2.2%
distribute-rgt1-in2.2%
Simplified2.2%
Taylor expanded in im around 0 2.0%
associate-+r+2.0%
+-commutative2.0%
*-lft-identity2.0%
associate-*r*2.0%
+-commutative2.0%
distribute-rgt-out2.0%
Simplified2.0%
Taylor expanded in im around inf 25.1%
unpow225.1%
Applied egg-rr25.1%
if -1.9e10 < re Initial program 100.0%
Taylor expanded in im around 0 64.4%
Taylor expanded in re around 0 53.5%
*-commutative82.2%
Simplified53.5%
(FPCore (re im) :precision binary64 (if (<= re 7.8e-38) 1.0 (* re (+ 1.0 (* -0.5 (* im im))))))
double code(double re, double im) {
double tmp;
if (re <= 7.8e-38) {
tmp = 1.0;
} 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 <= 7.8d-38) then
tmp = 1.0d0
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 <= 7.8e-38) {
tmp = 1.0;
} else {
tmp = re * (1.0 + (-0.5 * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 7.8e-38: tmp = 1.0 else: tmp = re * (1.0 + (-0.5 * (im * im))) return tmp
function code(re, im) tmp = 0.0 if (re <= 7.8e-38) tmp = 1.0; 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 <= 7.8e-38) tmp = 1.0; else tmp = re * (1.0 + (-0.5 * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 7.8e-38], 1.0, 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 7.8 \cdot 10^{-38}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if re < 7.7999999999999998e-38Initial program 100.0%
Taylor expanded in im around 0 78.4%
Taylor expanded in re around 0 37.6%
if 7.7999999999999998e-38 < re Initial program 100.0%
Taylor expanded in re around 0 12.1%
distribute-rgt1-in12.1%
Simplified12.1%
Taylor expanded in im around 0 20.1%
associate-+r+20.1%
+-commutative20.1%
*-lft-identity20.1%
associate-*r*20.1%
+-commutative20.1%
distribute-rgt-out20.1%
Simplified20.1%
unpow218.4%
Applied egg-rr20.1%
Taylor expanded in re around inf 20.1%
(FPCore (re im) :precision binary64 (+ 1.0 (* -0.5 (* im im))))
double code(double re, double im) {
return 1.0 + (-0.5 * (im * im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0 + ((-0.5d0) * (im * im))
end function
public static double code(double re, double im) {
return 1.0 + (-0.5 * (im * im));
}
def code(re, im): return 1.0 + (-0.5 * (im * im))
function code(re, im) return Float64(1.0 + Float64(-0.5 * Float64(im * im))) end
function tmp = code(re, im) tmp = 1.0 + (-0.5 * (im * im)); end
code[re_, im_] := N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + -0.5 \cdot \left(im \cdot im\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 47.1%
distribute-rgt1-in47.1%
Simplified47.1%
Taylor expanded in im around 0 31.7%
associate-+r+31.7%
+-commutative31.7%
*-lft-identity31.7%
associate-*r*31.7%
+-commutative31.7%
distribute-rgt-out31.7%
Simplified31.7%
unpow213.5%
Applied egg-rr31.7%
Taylor expanded in re around 0 30.3%
Final simplification30.3%
(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 47.1%
distribute-rgt1-in47.1%
Simplified47.1%
Taylor expanded in im around 0 29.0%
+-commutative29.0%
Simplified29.0%
(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 75.1%
Taylor expanded in re around 0 28.7%
herbie shell --seed 2024141
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))