
(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 (/ (cos im) (/ 1.0 (exp re))))
double code(double re, double im) {
return cos(im) / (1.0 / exp(re));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = cos(im) / (1.0d0 / exp(re))
end function
public static double code(double re, double im) {
return Math.cos(im) / (1.0 / Math.exp(re));
}
def code(re, im): return math.cos(im) / (1.0 / math.exp(re))
function code(re, im) return Float64(cos(im) / Float64(1.0 / exp(re))) end
function tmp = code(re, im) tmp = cos(im) / (1.0 / exp(re)); end
code[re_, im_] := N[(N[Cos[im], $MachinePrecision] / N[(1.0 / N[Exp[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos im}{\frac{1}{e^{re}}}
\end{array}
Initial program 100.0%
expm1-log1p-u71.5%
expm1-undefine71.5%
exp-diff71.5%
log1p-undefine71.5%
rem-exp-log100.0%
exp-1-e100.0%
Applied egg-rr100.0%
*-commutative100.0%
clear-num100.0%
un-div-inv100.0%
clear-num100.0%
e-exp-1100.0%
div-exp100.0%
add-exp-log71.5%
expm1-undefine71.5%
log1p-define71.5%
*-rgt-identity71.5%
expm1-log1p-u100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 0.02) (not (<= (exp re) 1.01))) (exp re) (cos im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.02) || !(exp(re) <= 1.01)) {
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.02d0) .or. (.not. (exp(re) <= 1.01d0))) 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.02) || !(Math.exp(re) <= 1.01)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.02) or not (math.exp(re) <= 1.01): tmp = math.exp(re) else: tmp = math.cos(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.02) || !(exp(re) <= 1.01)) tmp = exp(re); else tmp = cos(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 0.02) || ~((exp(re) <= 1.01))) tmp = exp(re); else tmp = cos(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.02], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.01]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[Cos[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.02 \lor \neg \left(e^{re} \leq 1.01\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0200000000000000004 or 1.01000000000000001 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 85.8%
if 0.0200000000000000004 < (exp.f64 re) < 1.01000000000000001Initial program 100.0%
Taylor expanded in re around 0 98.4%
Final simplification91.5%
(FPCore (re im) :precision binary64 (* (cos im) (exp re)))
double code(double re, double im) {
return cos(im) * exp(re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = cos(im) * exp(re)
end function
public static double code(double re, double im) {
return Math.cos(im) * Math.exp(re);
}
def code(re, im): return math.cos(im) * math.exp(re)
function code(re, im) return Float64(cos(im) * exp(re)) end
function tmp = code(re, im) tmp = cos(im) * exp(re); end
code[re_, im_] := N[(N[Cos[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos im \cdot e^{re}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.065) (and (not (<= re 0.0126)) (<= re 7.5e+82)))
(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.065) || (!(re <= 0.0126) && (re <= 7.5e+82))) {
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.065d0)) .or. (.not. (re <= 0.0126d0)) .and. (re <= 7.5d+82)) 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.065) || (!(re <= 0.0126) && (re <= 7.5e+82))) {
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.065) or (not (re <= 0.0126) and (re <= 7.5e+82)): 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.065) || (!(re <= 0.0126) && (re <= 7.5e+82))) 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.065) || (~((re <= 0.0126)) && (re <= 7.5e+82))) 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.065], And[N[Not[LessEqual[re, 0.0126]], $MachinePrecision], LessEqual[re, 7.5e+82]]], 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.065 \lor \neg \left(re \leq 0.0126\right) \land re \leq 7.5 \cdot 10^{+82}:\\
\;\;\;\;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.065000000000000002 or 0.0126 < re < 7.4999999999999999e82Initial program 100.0%
Taylor expanded in im around 0 97.8%
if -0.065000000000000002 < re < 0.0126 or 7.4999999999999999e82 < re Initial program 100.0%
Taylor expanded in re around 0 98.5%
*-commutative98.5%
Simplified98.5%
Final simplification98.3%
(FPCore (re im) :precision binary64 (if (or (<= re -0.034) (and (not (<= re 0.0068)) (<= re 1.85e+154))) (exp re) (* (cos im) (+ 1.0 (* re (+ 1.0 (* re 0.5)))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.034) || (!(re <= 0.0068) && (re <= 1.85e+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.034d0)) .or. (.not. (re <= 0.0068d0)) .and. (re <= 1.85d+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.034) || (!(re <= 0.0068) && (re <= 1.85e+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.034) or (not (re <= 0.0068) and (re <= 1.85e+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.034) || (!(re <= 0.0068) && (re <= 1.85e+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.034) || (~((re <= 0.0068)) && (re <= 1.85e+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.034], And[N[Not[LessEqual[re, 0.0068]], $MachinePrecision], LessEqual[re, 1.85e+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.034 \lor \neg \left(re \leq 0.0068\right) \land re \leq 1.85 \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.034000000000000002 or 0.00679999999999999962 < re < 1.84999999999999997e154Initial program 100.0%
Taylor expanded in im around 0 96.2%
if -0.034000000000000002 < re < 0.00679999999999999962 or 1.84999999999999997e154 < re Initial program 100.0%
Taylor expanded in re around 0 99.4%
*-commutative99.4%
Simplified99.4%
Final simplification98.1%
(FPCore (re im) :precision binary64 (if (or (<= re -0.034) (not (<= re 0.00185))) (exp re) (* (cos im) (+ 1.0 re))))
double code(double re, double im) {
double tmp;
if ((re <= -0.034) || !(re <= 0.00185)) {
tmp = exp(re);
} else {
tmp = cos(im) * (1.0 + re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((re <= (-0.034d0)) .or. (.not. (re <= 0.00185d0))) then
tmp = exp(re)
else
tmp = cos(im) * (1.0d0 + re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.034) || !(re <= 0.00185)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (1.0 + re);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.034) or not (re <= 0.00185): tmp = math.exp(re) else: tmp = math.cos(im) * (1.0 + re) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.034) || !(re <= 0.00185)) tmp = exp(re); else tmp = Float64(cos(im) * Float64(1.0 + re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.034) || ~((re <= 0.00185))) tmp = exp(re); else tmp = cos(im) * (1.0 + re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.034], N[Not[LessEqual[re, 0.00185]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(1.0 + re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.034 \lor \neg \left(re \leq 0.00185\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(1 + re\right)\\
\end{array}
\end{array}
if re < -0.034000000000000002 or 0.0018500000000000001 < re Initial program 100.0%
Taylor expanded in im around 0 85.8%
if -0.034000000000000002 < re < 0.0018500000000000001Initial program 100.0%
Taylor expanded in re around 0 99.0%
distribute-rgt1-in99.0%
Simplified99.0%
Final simplification91.7%
(FPCore (re im)
:precision binary64
(if (<= re -0.07)
(/ 1.0 (+ 1.0 (* re (+ (* re 0.5) -1.0))))
(if (<= re 0.00155)
(cos im)
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if (re <= -0.07) {
tmp = 1.0 / (1.0 + (re * ((re * 0.5) + -1.0)));
} else if (re <= 0.00155) {
tmp = cos(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.07d0)) then
tmp = 1.0d0 / (1.0d0 + (re * ((re * 0.5d0) + (-1.0d0))))
else if (re <= 0.00155d0) then
tmp = cos(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.07) {
tmp = 1.0 / (1.0 + (re * ((re * 0.5) + -1.0)));
} else if (re <= 0.00155) {
tmp = Math.cos(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.07: tmp = 1.0 / (1.0 + (re * ((re * 0.5) + -1.0))) elif re <= 0.00155: tmp = math.cos(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.07) tmp = Float64(1.0 / Float64(1.0 + Float64(re * Float64(Float64(re * 0.5) + -1.0)))); elseif (re <= 0.00155) tmp = cos(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.07) tmp = 1.0 / (1.0 + (re * ((re * 0.5) + -1.0))); elseif (re <= 0.00155) tmp = cos(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.07], N[(1.0 / N[(1.0 + N[(re * N[(N[(re * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 0.00155], 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]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.07:\\
\;\;\;\;\frac{1}{1 + re \cdot \left(re \cdot 0.5 + -1\right)}\\
\mathbf{elif}\;re \leq 0.00155:\\
\;\;\;\;\cos im\\
\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.070000000000000007Initial program 100.0%
expm1-log1p-u0.0%
expm1-undefine0.0%
exp-diff0.0%
log1p-undefine0.0%
rem-exp-log100.0%
exp-1-e100.0%
Applied egg-rr100.0%
*-commutative100.0%
clear-num100.0%
un-div-inv100.0%
clear-num100.0%
e-exp-1100.0%
div-exp100.0%
add-exp-log0.0%
expm1-undefine0.0%
log1p-define0.0%
*-rgt-identity0.0%
expm1-log1p-u100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 53.7%
Taylor expanded in im around 0 53.7%
if -0.070000000000000007 < re < 0.00154999999999999995Initial program 100.0%
Taylor expanded in re around 0 98.4%
if 0.00154999999999999995 < re Initial program 100.0%
Taylor expanded in im around 0 70.6%
Taylor expanded in re around 0 49.0%
*-commutative72.8%
Simplified49.0%
Final simplification72.6%
(FPCore (re im) :precision binary64 (if (<= re -1.1) (/ 1.0 (+ 1.0 (* re (+ (* re 0.5) -1.0)))) (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666))))))))
double code(double re, double im) {
double tmp;
if (re <= -1.1) {
tmp = 1.0 / (1.0 + (re * ((re * 0.5) + -1.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) :: tmp
if (re <= (-1.1d0)) then
tmp = 1.0d0 / (1.0d0 + (re * ((re * 0.5d0) + (-1.0d0))))
else
tmp = 1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0)))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1.1) {
tmp = 1.0 / (1.0 + (re * ((re * 0.5) + -1.0)));
} else {
tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.1: tmp = 1.0 / (1.0 + (re * ((re * 0.5) + -1.0))) else: tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))) return tmp
function code(re, im) tmp = 0.0 if (re <= -1.1) tmp = Float64(1.0 / Float64(1.0 + Float64(re * Float64(Float64(re * 0.5) + -1.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) tmp = 0.0; if (re <= -1.1) tmp = 1.0 / (1.0 + (re * ((re * 0.5) + -1.0))); else tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.1], N[(1.0 / N[(1.0 + N[(re * N[(N[(re * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.1:\\
\;\;\;\;\frac{1}{1 + re \cdot \left(re \cdot 0.5 + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\\
\end{array}
\end{array}
if re < -1.1000000000000001Initial program 100.0%
expm1-log1p-u0.0%
expm1-undefine0.0%
exp-diff0.0%
log1p-undefine0.0%
rem-exp-log100.0%
exp-1-e100.0%
Applied egg-rr100.0%
*-commutative100.0%
clear-num100.0%
un-div-inv100.0%
clear-num100.0%
e-exp-1100.0%
div-exp100.0%
add-exp-log0.0%
expm1-undefine0.0%
log1p-define0.0%
*-rgt-identity0.0%
expm1-log1p-u100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 53.7%
Taylor expanded in im around 0 53.7%
if -1.1000000000000001 < re Initial program 100.0%
Taylor expanded in im around 0 58.4%
Taylor expanded in re around 0 50.4%
*-commutative89.6%
Simplified50.4%
Final simplification51.3%
(FPCore (re im) :precision binary64 (if (<= re -0.0001) (/ 1.0 (+ 1.0 (* re (+ (* re 0.5) -1.0)))) (+ 1.0 (* re (+ 1.0 (* re 0.5))))))
double code(double re, double im) {
double tmp;
if (re <= -0.0001) {
tmp = 1.0 / (1.0 + (re * ((re * 0.5) + -1.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) :: tmp
if (re <= (-0.0001d0)) then
tmp = 1.0d0 / (1.0d0 + (re * ((re * 0.5d0) + (-1.0d0))))
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 <= -0.0001) {
tmp = 1.0 / (1.0 + (re * ((re * 0.5) + -1.0)));
} else {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.0001: tmp = 1.0 / (1.0 + (re * ((re * 0.5) + -1.0))) else: tmp = 1.0 + (re * (1.0 + (re * 0.5))) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.0001) tmp = Float64(1.0 / Float64(1.0 + Float64(re * Float64(Float64(re * 0.5) + -1.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) tmp = 0.0; if (re <= -0.0001) tmp = 1.0 / (1.0 + (re * ((re * 0.5) + -1.0))); else tmp = 1.0 + (re * (1.0 + (re * 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.0001], N[(1.0 / N[(1.0 + N[(re * N[(N[(re * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $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 -0.0001:\\
\;\;\;\;\frac{1}{1 + re \cdot \left(re \cdot 0.5 + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -1.00000000000000005e-4Initial program 100.0%
expm1-log1p-u1.3%
expm1-undefine1.4%
exp-diff1.4%
log1p-undefine1.4%
rem-exp-log100.0%
exp-1-e100.0%
Applied egg-rr100.0%
*-commutative100.0%
clear-num100.0%
un-div-inv100.0%
clear-num100.0%
e-exp-1100.0%
div-exp100.0%
add-exp-log1.4%
expm1-undefine1.4%
log1p-define1.4%
*-rgt-identity1.4%
expm1-log1p-u100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 53.6%
Taylor expanded in im around 0 53.3%
if -1.00000000000000005e-4 < re Initial program 100.0%
Taylor expanded in im around 0 58.6%
Taylor expanded in re around 0 44.9%
*-commutative83.9%
Simplified44.9%
Final simplification47.3%
(FPCore (re im) :precision binary64 (if (<= im 1.95e+164) (+ 1.0 (* re (+ 1.0 (* re 0.5)))) (+ 1.0 (* -0.5 (* im im)))))
double code(double re, double im) {
double tmp;
if (im <= 1.95e+164) {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.95d+164) then
tmp = 1.0d0 + (re * (1.0d0 + (re * 0.5d0)))
else
tmp = 1.0d0 + ((-0.5d0) * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.95e+164) {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.95e+164: tmp = 1.0 + (re * (1.0 + (re * 0.5))) else: tmp = 1.0 + (-0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.95e+164) tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))); else tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.95e+164) tmp = 1.0 + (re * (1.0 + (re * 0.5))); else tmp = 1.0 + (-0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.95e+164], N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.95 \cdot 10^{+164}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 1.94999999999999993e164Initial program 100.0%
Taylor expanded in im around 0 74.9%
Taylor expanded in re around 0 35.7%
*-commutative60.0%
Simplified35.7%
if 1.94999999999999993e164 < im Initial program 100.0%
Taylor expanded in re around 0 39.5%
Taylor expanded in im around 0 29.3%
unpow229.3%
Applied egg-rr29.3%
(FPCore (re im) :precision binary64 (if (<= im 1.95e+164) (+ 1.0 (* re (* re 0.5))) (+ 1.0 (* -0.5 (* im im)))))
double code(double re, double im) {
double tmp;
if (im <= 1.95e+164) {
tmp = 1.0 + (re * (re * 0.5));
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.95d+164) then
tmp = 1.0d0 + (re * (re * 0.5d0))
else
tmp = 1.0d0 + ((-0.5d0) * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.95e+164) {
tmp = 1.0 + (re * (re * 0.5));
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.95e+164: tmp = 1.0 + (re * (re * 0.5)) else: tmp = 1.0 + (-0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.95e+164) tmp = Float64(1.0 + Float64(re * Float64(re * 0.5))); else tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.95e+164) tmp = 1.0 + (re * (re * 0.5)); else tmp = 1.0 + (-0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.95e+164], N[(1.0 + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.95 \cdot 10^{+164}:\\
\;\;\;\;1 + re \cdot \left(re \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 1.94999999999999993e164Initial program 100.0%
Taylor expanded in im around 0 74.9%
Taylor expanded in re around 0 35.7%
*-commutative60.0%
Simplified35.7%
Taylor expanded in re around inf 35.7%
Taylor expanded in re around inf 35.5%
if 1.94999999999999993e164 < im Initial program 100.0%
Taylor expanded in re around 0 39.5%
Taylor expanded in im around 0 29.3%
unpow229.3%
Applied egg-rr29.3%
(FPCore (re im) :precision binary64 (if (<= re 28000.0) (/ 1.0 (- 1.0 re)) (+ 1.0 (* -0.5 (* im im)))))
double code(double re, double im) {
double tmp;
if (re <= 28000.0) {
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 <= 28000.0d0) 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 <= 28000.0) {
tmp = 1.0 / (1.0 - re);
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 28000.0: 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 <= 28000.0) 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 <= 28000.0) 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, 28000.0], 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 28000:\\
\;\;\;\;\frac{1}{1 - re}\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if re < 28000Initial program 100.0%
expm1-log1p-u61.6%
expm1-undefine61.6%
exp-diff61.6%
log1p-undefine61.6%
rem-exp-log100.0%
exp-1-e100.0%
Applied egg-rr100.0%
*-commutative100.0%
clear-num100.0%
un-div-inv100.0%
clear-num100.0%
e-exp-1100.0%
div-exp100.0%
add-exp-log61.6%
expm1-undefine61.6%
log1p-define61.6%
*-rgt-identity61.6%
expm1-log1p-u100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 62.3%
neg-mul-162.3%
unsub-neg62.3%
Simplified62.3%
Taylor expanded in im around 0 33.4%
if 28000 < re Initial program 100.0%
Taylor expanded in re around 0 3.1%
Taylor expanded in im around 0 21.9%
unpow221.9%
Applied egg-rr21.9%
(FPCore (re im) :precision binary64 (/ 1.0 (- 1.0 re)))
double code(double re, double im) {
return 1.0 / (1.0 - re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0 / (1.0d0 - re)
end function
public static double code(double re, double im) {
return 1.0 / (1.0 - re);
}
def code(re, im): return 1.0 / (1.0 - re)
function code(re, im) return Float64(1.0 / Float64(1.0 - re)) end
function tmp = code(re, im) tmp = 1.0 / (1.0 - re); end
code[re_, im_] := N[(1.0 / N[(1.0 - re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{1 - re}
\end{array}
Initial program 100.0%
expm1-log1p-u71.5%
expm1-undefine71.5%
exp-diff71.5%
log1p-undefine71.5%
rem-exp-log100.0%
exp-1-e100.0%
Applied egg-rr100.0%
*-commutative100.0%
clear-num100.0%
un-div-inv100.0%
clear-num100.0%
e-exp-1100.0%
div-exp100.0%
add-exp-log71.5%
expm1-undefine71.5%
log1p-define71.5%
*-rgt-identity71.5%
expm1-log1p-u100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 46.5%
neg-mul-146.5%
unsub-neg46.5%
Simplified46.5%
Taylor expanded in im around 0 25.1%
(FPCore (re im) :precision binary64 (+ 1.0 re))
double code(double re, double im) {
return 1.0 + re;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0 + re
end function
public static double code(double re, double im) {
return 1.0 + re;
}
def code(re, im): return 1.0 + re
function code(re, im) return Float64(1.0 + re) end
function tmp = code(re, im) tmp = 1.0 + re; end
code[re_, im_] := N[(1.0 + re), $MachinePrecision]
\begin{array}{l}
\\
1 + re
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 70.3%
Taylor expanded in re around 0 24.7%
+-commutative24.7%
Simplified24.7%
Final simplification24.7%
(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 70.3%
Taylor expanded in re around 0 24.6%
herbie shell --seed 2024150
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))