
(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 11 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.99998) (not (<= (exp re) 1.0))) (exp re) (cos im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.99998) || !(exp(re) <= 1.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) <= 0.99998d0) .or. (.not. (exp(re) <= 1.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) <= 0.99998) || !(Math.exp(re) <= 1.0)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.99998) or not (math.exp(re) <= 1.0): tmp = math.exp(re) else: tmp = math.cos(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.99998) || !(exp(re) <= 1.0)) tmp = exp(re); else tmp = cos(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 0.99998) || ~((exp(re) <= 1.0))) tmp = exp(re); else tmp = cos(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.99998], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.0]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[Cos[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.99998 \lor \neg \left(e^{re} \leq 1\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.99997999999999998 or 1 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 78.5%
if 0.99997999999999998 < (exp.f64 re) < 1Initial program 100.0%
Taylor expanded in re around 0 99.4%
Final simplification89.3%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.38) (and (not (<= re 0.185)) (<= re 3.9e+87)))
(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.38) || (!(re <= 0.185) && (re <= 3.9e+87))) {
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.38d0)) .or. (.not. (re <= 0.185d0)) .and. (re <= 3.9d+87)) 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.38) || (!(re <= 0.185) && (re <= 3.9e+87))) {
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.38) or (not (re <= 0.185) and (re <= 3.9e+87)): 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.38) || (!(re <= 0.185) && (re <= 3.9e+87))) 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.38) || (~((re <= 0.185)) && (re <= 3.9e+87))) 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.38], And[N[Not[LessEqual[re, 0.185]], $MachinePrecision], LessEqual[re, 3.9e+87]]], 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.38 \lor \neg \left(re \leq 0.185\right) \land re \leq 3.9 \cdot 10^{+87}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if re < -0.38 or 0.185 < re < 3.9000000000000002e87Initial program 100.0%
Taylor expanded in im around 0 94.5%
if -0.38 < re < 0.185 or 3.9000000000000002e87 < re Initial program 100.0%
Taylor expanded in re around 0 98.3%
*-commutative98.3%
Simplified98.3%
Final simplification97.2%
(FPCore (re im) :precision binary64 (if (or (<= re -0.38) (and (not (<= re 0.015)) (<= 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.38) || (!(re <= 0.015) && (re <= 1.9e+154))) {
tmp = exp(re);
} else {
tmp = cos(im) * (1.0 + (re * (1.0 + (re * 0.5))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((re <= (-0.38d0)) .or. (.not. (re <= 0.015d0)) .and. (re <= 1.9d+154)) then
tmp = exp(re)
else
tmp = cos(im) * (1.0d0 + (re * (1.0d0 + (re * 0.5d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.38) || (!(re <= 0.015) && (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.38) or (not (re <= 0.015) and (re <= 1.9e+154)): tmp = math.exp(re) else: tmp = math.cos(im) * (1.0 + (re * (1.0 + (re * 0.5)))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.38) || (!(re <= 0.015) && (re <= 1.9e+154))) tmp = exp(re); else tmp = Float64(cos(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.38) || (~((re <= 0.015)) && (re <= 1.9e+154))) tmp = exp(re); else tmp = cos(im) * (1.0 + (re * (1.0 + (re * 0.5)))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.38], And[N[Not[LessEqual[re, 0.015]], $MachinePrecision], LessEqual[re, 1.9e+154]]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.38 \lor \neg \left(re \leq 0.015\right) \land re \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.38 or 0.014999999999999999 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 89.0%
if -0.38 < re < 0.014999999999999999 or 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 99.1%
*-commutative99.1%
Simplified99.1%
Final simplification95.5%
(FPCore (re im) :precision binary64 (if (or (<= re -3e-5) (not (<= re 0.0003))) (exp re) (* (cos im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((re <= -3e-5) || !(re <= 0.0003)) {
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 <= (-3d-5)) .or. (.not. (re <= 0.0003d0))) 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 <= -3e-5) || !(re <= 0.0003)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -3e-5) or not (re <= 0.0003): tmp = math.exp(re) else: tmp = math.cos(im) * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if ((re <= -3e-5) || !(re <= 0.0003)) 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 <= -3e-5) || ~((re <= 0.0003))) tmp = exp(re); else tmp = cos(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -3e-5], N[Not[LessEqual[re, 0.0003]], $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 -3 \cdot 10^{-5} \lor \neg \left(re \leq 0.0003\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -3.00000000000000008e-5 or 2.99999999999999974e-4 < re Initial program 100.0%
Taylor expanded in im around 0 78.6%
if -3.00000000000000008e-5 < re < 2.99999999999999974e-4Initial program 100.0%
Taylor expanded in re around 0 99.9%
distribute-rgt1-in99.9%
Simplified99.9%
Final simplification89.9%
(FPCore (re im)
:precision binary64
(if (<= re 5.2e+33)
(cos im)
(if (<= re 1.7e+117)
(+ 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 <= 5.2e+33) {
tmp = cos(im);
} else if (re <= 1.7e+117) {
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 <= 5.2d+33) then
tmp = cos(im)
else if (re <= 1.7d+117) 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 <= 5.2e+33) {
tmp = Math.cos(im);
} else if (re <= 1.7e+117) {
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 <= 5.2e+33: tmp = math.cos(im) elif re <= 1.7e+117: 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 <= 5.2e+33) tmp = cos(im); elseif (re <= 1.7e+117) 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 <= 5.2e+33) tmp = cos(im); elseif (re <= 1.7e+117) 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, 5.2e+33], N[Cos[im], $MachinePrecision], If[LessEqual[re, 1.7e+117], 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 5.2 \cdot 10^{+33}:\\
\;\;\;\;\cos im\\
\mathbf{elif}\;re \leq 1.7 \cdot 10^{+117}:\\
\;\;\;\;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 < 5.1999999999999995e33Initial program 100.0%
Taylor expanded in re around 0 68.6%
if 5.1999999999999995e33 < re < 1.7e117Initial program 100.0%
Taylor expanded in re around 0 3.7%
distribute-rgt1-in3.7%
Simplified3.7%
Taylor expanded in re around inf 3.7%
*-commutative3.7%
Simplified3.7%
Taylor expanded in im around 0 37.5%
unpow237.5%
Applied egg-rr37.5%
if 1.7e117 < re Initial program 100.0%
Taylor expanded in im around 0 57.9%
Taylor expanded in re around 0 57.9%
*-commutative100.0%
Simplified57.9%
Final simplification64.9%
(FPCore (re im) :precision binary64 (if (<= im 9.8e+70) (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))) (+ re (* -0.5 (* re (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 9.8e+70) {
tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
} 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 <= 9.8d+70) then
tmp = 1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0)))))
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 <= 9.8e+70) {
tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
} else {
tmp = re + (-0.5 * (re * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 9.8e+70: tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))) else: tmp = re + (-0.5 * (re * (im * im))) return tmp
function code(re, im) tmp = 0.0 if (im <= 9.8e+70) tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666)))))); 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 <= 9.8e+70) tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))); else tmp = re + (-0.5 * (re * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 9.8e+70], N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $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 9.8 \cdot 10^{+70}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\\
\mathbf{else}:\\
\;\;\;\;re + -0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 9.80000000000000056e70Initial program 100.0%
Taylor expanded in im around 0 74.4%
Taylor expanded in re around 0 44.5%
*-commutative68.2%
Simplified44.5%
if 9.80000000000000056e70 < im Initial program 99.9%
Taylor expanded in re around 0 60.2%
distribute-rgt1-in60.2%
Simplified60.2%
Taylor expanded in re around inf 3.9%
*-commutative3.9%
Simplified3.9%
Taylor expanded in im around 0 18.4%
unpow218.4%
Applied egg-rr18.4%
Final simplification38.5%
(FPCore (re im) :precision binary64 (if (<= im 9.8e+70) (+ 1.0 (* re (+ 1.0 (* re 0.5)))) (+ re (* -0.5 (* re (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 9.8e+70) {
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 <= 9.8d+70) 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 <= 9.8e+70) {
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 <= 9.8e+70: 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 <= 9.8e+70) 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 <= 9.8e+70) 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, 9.8e+70], 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 9.8 \cdot 10^{+70}:\\
\;\;\;\;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 < 9.80000000000000056e70Initial program 100.0%
Taylor expanded in im around 0 74.4%
Taylor expanded in re around 0 39.9%
*-commutative62.6%
Simplified39.9%
if 9.80000000000000056e70 < im Initial program 99.9%
Taylor expanded in re around 0 60.2%
distribute-rgt1-in60.2%
Simplified60.2%
Taylor expanded in re around inf 3.9%
*-commutative3.9%
Simplified3.9%
Taylor expanded in im around 0 18.4%
unpow218.4%
Applied egg-rr18.4%
Final simplification34.9%
(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 63.6%
Taylor expanded in re around 0 33.2%
*-commutative65.5%
Simplified33.2%
(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 55.4%
distribute-rgt1-in55.4%
Simplified55.4%
Taylor expanded in im around 0 28.5%
+-commutative28.5%
Simplified28.5%
(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 63.6%
Taylor expanded in re around 0 28.3%
herbie shell --seed 2024165
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))