
(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%
Final simplification100.0%
(FPCore (re im) :precision binary64 (if (<= (exp re) 0.4) (exp re) (if (<= (exp re) 1.0000000002) (cos im) (exp re))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.4) {
tmp = exp(re);
} else if (exp(re) <= 1.0000000002) {
tmp = cos(im);
} else {
tmp = exp(re);
}
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.4d0) then
tmp = exp(re)
else if (exp(re) <= 1.0000000002d0) then
tmp = cos(im)
else
tmp = exp(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.exp(re) <= 0.4) {
tmp = Math.exp(re);
} else if (Math.exp(re) <= 1.0000000002) {
tmp = Math.cos(im);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 0.4: tmp = math.exp(re) elif math.exp(re) <= 1.0000000002: tmp = math.cos(im) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 0.4) tmp = exp(re); elseif (exp(re) <= 1.0000000002) tmp = cos(im); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (exp(re) <= 0.4) tmp = exp(re); elseif (exp(re) <= 1.0000000002) tmp = cos(im); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.4], N[Exp[re], $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 1.0000000002], N[Cos[im], $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.4:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;e^{re} \leq 1.0000000002:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 0.40000000000000002 or 1.0000000002 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 90.4%
if 0.40000000000000002 < (exp.f64 re) < 1.0000000002Initial program 100.0%
Taylor expanded in re around 0 99.5%
Final simplification95.2%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.03) (and (not (<= re 0.75)) (<= re 1.05e+103)))
(exp re)
(*
(cos im)
(+ (+ re 1.0) (* (* re re) (+ 0.5 (* re 0.16666666666666666)))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.03) || (!(re <= 0.75) && (re <= 1.05e+103))) {
tmp = exp(re);
} else {
tmp = cos(im) * ((re + 1.0) + ((re * 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.03d0)) .or. (.not. (re <= 0.75d0)) .and. (re <= 1.05d+103)) then
tmp = exp(re)
else
tmp = cos(im) * ((re + 1.0d0) + ((re * 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.03) || (!(re <= 0.75) && (re <= 1.05e+103))) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * ((re + 1.0) + ((re * re) * (0.5 + (re * 0.16666666666666666))));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.03) or (not (re <= 0.75) and (re <= 1.05e+103)): tmp = math.exp(re) else: tmp = math.cos(im) * ((re + 1.0) + ((re * re) * (0.5 + (re * 0.16666666666666666)))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.03) || (!(re <= 0.75) && (re <= 1.05e+103))) tmp = exp(re); else tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(Float64(re * re) * Float64(0.5 + Float64(re * 0.16666666666666666))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.03) || (~((re <= 0.75)) && (re <= 1.05e+103))) tmp = exp(re); else tmp = cos(im) * ((re + 1.0) + ((re * re) * (0.5 + (re * 0.16666666666666666)))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.03], And[N[Not[LessEqual[re, 0.75]], $MachinePrecision], LessEqual[re, 1.05e+103]]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(N[(re * re), $MachinePrecision] * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.03 \lor \neg \left(re \leq 0.75\right) \land re \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + \left(re \cdot re\right) \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\\
\end{array}
\end{array}
if re < -0.029999999999999999 or 0.75 < re < 1.0500000000000001e103Initial program 100.0%
Taylor expanded in im around 0 96.2%
if -0.029999999999999999 < re < 0.75 or 1.0500000000000001e103 < re Initial program 100.0%
Taylor expanded in re around 0 99.4%
associate-+r+99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
associate-*r*99.4%
distribute-rgt-out99.4%
*-commutative99.4%
*-commutative99.4%
distribute-lft1-in99.4%
distribute-rgt-out99.4%
+-commutative99.4%
cube-mult99.4%
unpow299.4%
associate-*r*99.4%
Simplified99.4%
Final simplification98.4%
(FPCore (re im) :precision binary64 (if (or (<= re -0.0022) (and (not (<= re 0.75)) (<= re 1.9e+154))) (exp re) (* (cos im) (+ (+ re 1.0) (* re (* re 0.5))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.0022) || (!(re <= 0.75) && (re <= 1.9e+154))) {
tmp = exp(re);
} else {
tmp = cos(im) * ((re + 1.0) + (re * (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.0022d0)) .or. (.not. (re <= 0.75d0)) .and. (re <= 1.9d+154)) then
tmp = exp(re)
else
tmp = cos(im) * ((re + 1.0d0) + (re * (re * 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.0022) || (!(re <= 0.75) && (re <= 1.9e+154))) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * ((re + 1.0) + (re * (re * 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.0022) or (not (re <= 0.75) and (re <= 1.9e+154)): tmp = math.exp(re) else: tmp = math.cos(im) * ((re + 1.0) + (re * (re * 0.5))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.0022) || (!(re <= 0.75) && (re <= 1.9e+154))) tmp = exp(re); else tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(re * Float64(re * 0.5)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.0022) || (~((re <= 0.75)) && (re <= 1.9e+154))) tmp = exp(re); else tmp = cos(im) * ((re + 1.0) + (re * (re * 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.0022], And[N[Not[LessEqual[re, 0.75]], $MachinePrecision], LessEqual[re, 1.9e+154]]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.0022 \lor \neg \left(re \leq 0.75\right) \land re \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.00220000000000000013 or 0.75 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 96.3%
if -0.00220000000000000013 < re < 0.75 or 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 99.0%
*-commutative99.0%
associate-*r*99.0%
*-commutative99.0%
distribute-lft1-in99.0%
distribute-rgt-out99.0%
+-commutative99.0%
*-commutative99.0%
unpow299.0%
associate-*l*99.0%
Simplified99.0%
Final simplification98.2%
(FPCore (re im) :precision binary64 (if (<= re -0.00066) (exp re) (if (<= re 3.2e-10) (* (cos im) (+ re 1.0)) (exp re))))
double code(double re, double im) {
double tmp;
if (re <= -0.00066) {
tmp = exp(re);
} else if (re <= 3.2e-10) {
tmp = cos(im) * (re + 1.0);
} else {
tmp = exp(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.00066d0)) then
tmp = exp(re)
else if (re <= 3.2d-10) then
tmp = cos(im) * (re + 1.0d0)
else
tmp = exp(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -0.00066) {
tmp = Math.exp(re);
} else if (re <= 3.2e-10) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.00066: tmp = math.exp(re) elif re <= 3.2e-10: tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.00066) tmp = exp(re); elseif (re <= 3.2e-10) tmp = Float64(cos(im) * Float64(re + 1.0)); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -0.00066) tmp = exp(re); elseif (re <= 3.2e-10) tmp = cos(im) * (re + 1.0); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.00066], N[Exp[re], $MachinePrecision], If[LessEqual[re, 3.2e-10], 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 -0.00066:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 3.2 \cdot 10^{-10}:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if re < -6.6e-4 or 3.19999999999999981e-10 < re Initial program 100.0%
Taylor expanded in im around 0 90.4%
if -6.6e-4 < re < 3.19999999999999981e-10Initial program 100.0%
Taylor expanded in re around 0 99.7%
*-rgt-identity99.7%
distribute-lft-in99.7%
Simplified99.7%
Final simplification95.3%
(FPCore (re im)
:precision binary64
(if (<= re -2.7e+17)
(* (* re -0.5) (* im im))
(if (<= re 3.2e-10)
(cos im)
(+ 1.0 (+ re (* -0.5 (/ (* im im) (- 1.0 re))))))))
double code(double re, double im) {
double tmp;
if (re <= -2.7e+17) {
tmp = (re * -0.5) * (im * im);
} else if (re <= 3.2e-10) {
tmp = cos(im);
} else {
tmp = 1.0 + (re + (-0.5 * ((im * 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 <= (-2.7d+17)) then
tmp = (re * (-0.5d0)) * (im * im)
else if (re <= 3.2d-10) then
tmp = cos(im)
else
tmp = 1.0d0 + (re + ((-0.5d0) * ((im * im) / (1.0d0 - re))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -2.7e+17) {
tmp = (re * -0.5) * (im * im);
} else if (re <= 3.2e-10) {
tmp = Math.cos(im);
} else {
tmp = 1.0 + (re + (-0.5 * ((im * im) / (1.0 - re))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -2.7e+17: tmp = (re * -0.5) * (im * im) elif re <= 3.2e-10: tmp = math.cos(im) else: tmp = 1.0 + (re + (-0.5 * ((im * im) / (1.0 - re)))) return tmp
function code(re, im) tmp = 0.0 if (re <= -2.7e+17) tmp = Float64(Float64(re * -0.5) * Float64(im * im)); elseif (re <= 3.2e-10) tmp = cos(im); else tmp = Float64(1.0 + Float64(re + Float64(-0.5 * Float64(Float64(im * im) / Float64(1.0 - re))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -2.7e+17) tmp = (re * -0.5) * (im * im); elseif (re <= 3.2e-10) tmp = cos(im); else tmp = 1.0 + (re + (-0.5 * ((im * im) / (1.0 - re)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -2.7e+17], N[(N[(re * -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 3.2e-10], N[Cos[im], $MachinePrecision], N[(1.0 + N[(re + N[(-0.5 * N[(N[(im * im), $MachinePrecision] / N[(1.0 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -2.7 \cdot 10^{+17}:\\
\;\;\;\;\left(re \cdot -0.5\right) \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;re \leq 3.2 \cdot 10^{-10}:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;1 + \left(re + -0.5 \cdot \frac{im \cdot im}{1 - re}\right)\\
\end{array}
\end{array}
if re < -2.7e17Initial program 100.0%
Taylor expanded in re around 0 2.2%
*-rgt-identity2.2%
distribute-lft-in2.2%
Simplified2.2%
Taylor expanded in im around 0 2.0%
+-commutative2.0%
*-commutative2.0%
unpow22.0%
Simplified2.0%
Taylor expanded in re around inf 2.0%
unpow22.0%
Simplified2.0%
Taylor expanded in im around inf 31.4%
unpow231.4%
associate-*r*31.4%
*-commutative31.4%
Simplified31.4%
if -2.7e17 < re < 3.19999999999999981e-10Initial program 100.0%
Taylor expanded in re around 0 96.8%
if 3.19999999999999981e-10 < re Initial program 100.0%
Taylor expanded in re around 0 10.3%
*-rgt-identity10.3%
distribute-lft-in10.3%
Simplified10.3%
Taylor expanded in im around 0 21.8%
+-commutative21.8%
*-commutative21.8%
unpow221.8%
Simplified21.8%
flip-+19.9%
associate-*r/19.9%
metadata-eval19.9%
fma-neg19.9%
metadata-eval19.9%
sub-neg19.9%
metadata-eval19.9%
Applied egg-rr19.9%
associate-/l*19.9%
Simplified19.9%
Taylor expanded in re around 0 23.9%
+-commutative23.9%
mul-1-neg23.9%
unsub-neg23.9%
Simplified23.9%
Final simplification65.2%
(FPCore (re im)
:precision binary64
(if (<= re -2.7e+17)
(* (* re -0.5) (* im im))
(if (<= re 0.85)
(+ re 1.0)
(+ 1.0 (+ re (* -0.5 (/ (* im im) (- 1.0 re))))))))
double code(double re, double im) {
double tmp;
if (re <= -2.7e+17) {
tmp = (re * -0.5) * (im * im);
} else if (re <= 0.85) {
tmp = re + 1.0;
} else {
tmp = 1.0 + (re + (-0.5 * ((im * 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 <= (-2.7d+17)) then
tmp = (re * (-0.5d0)) * (im * im)
else if (re <= 0.85d0) then
tmp = re + 1.0d0
else
tmp = 1.0d0 + (re + ((-0.5d0) * ((im * im) / (1.0d0 - re))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -2.7e+17) {
tmp = (re * -0.5) * (im * im);
} else if (re <= 0.85) {
tmp = re + 1.0;
} else {
tmp = 1.0 + (re + (-0.5 * ((im * im) / (1.0 - re))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -2.7e+17: tmp = (re * -0.5) * (im * im) elif re <= 0.85: tmp = re + 1.0 else: tmp = 1.0 + (re + (-0.5 * ((im * im) / (1.0 - re)))) return tmp
function code(re, im) tmp = 0.0 if (re <= -2.7e+17) tmp = Float64(Float64(re * -0.5) * Float64(im * im)); elseif (re <= 0.85) tmp = Float64(re + 1.0); else tmp = Float64(1.0 + Float64(re + Float64(-0.5 * Float64(Float64(im * im) / Float64(1.0 - re))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -2.7e+17) tmp = (re * -0.5) * (im * im); elseif (re <= 0.85) tmp = re + 1.0; else tmp = 1.0 + (re + (-0.5 * ((im * im) / (1.0 - re)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -2.7e+17], N[(N[(re * -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 0.85], N[(re + 1.0), $MachinePrecision], N[(1.0 + N[(re + N[(-0.5 * N[(N[(im * im), $MachinePrecision] / N[(1.0 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -2.7 \cdot 10^{+17}:\\
\;\;\;\;\left(re \cdot -0.5\right) \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;re \leq 0.85:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;1 + \left(re + -0.5 \cdot \frac{im \cdot im}{1 - re}\right)\\
\end{array}
\end{array}
if re < -2.7e17Initial program 100.0%
Taylor expanded in re around 0 2.2%
*-rgt-identity2.2%
distribute-lft-in2.2%
Simplified2.2%
Taylor expanded in im around 0 2.0%
+-commutative2.0%
*-commutative2.0%
unpow22.0%
Simplified2.0%
Taylor expanded in re around inf 2.0%
unpow22.0%
Simplified2.0%
Taylor expanded in im around inf 31.4%
unpow231.4%
associate-*r*31.4%
*-commutative31.4%
Simplified31.4%
if -2.7e17 < re < 0.849999999999999978Initial program 100.0%
Taylor expanded in re around 0 95.5%
*-rgt-identity95.5%
distribute-lft-in95.5%
Simplified95.5%
Taylor expanded in im around 0 55.8%
+-commutative55.8%
Simplified55.8%
if 0.849999999999999978 < re Initial program 100.0%
Taylor expanded in re around 0 5.9%
*-rgt-identity5.9%
distribute-lft-in5.9%
Simplified5.9%
Taylor expanded in im around 0 19.6%
+-commutative19.6%
*-commutative19.6%
unpow219.6%
Simplified19.6%
flip-+17.6%
associate-*r/17.6%
metadata-eval17.6%
fma-neg17.6%
metadata-eval17.6%
sub-neg17.6%
metadata-eval17.6%
Applied egg-rr17.6%
associate-/l*17.6%
Simplified17.6%
Taylor expanded in re around 0 21.9%
+-commutative21.9%
mul-1-neg21.9%
unsub-neg21.9%
Simplified21.9%
Final simplification43.1%
(FPCore (re im) :precision binary64 (if (<= re -2.7e+17) (* (* re -0.5) (* im im)) (if (<= re 1.4e+31) (+ re 1.0) (+ 1.0 (+ re (* -0.5 (* re (* im im))))))))
double code(double re, double im) {
double tmp;
if (re <= -2.7e+17) {
tmp = (re * -0.5) * (im * im);
} else if (re <= 1.4e+31) {
tmp = re + 1.0;
} else {
tmp = 1.0 + (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 (re <= (-2.7d+17)) then
tmp = (re * (-0.5d0)) * (im * im)
else if (re <= 1.4d+31) then
tmp = re + 1.0d0
else
tmp = 1.0d0 + (re + ((-0.5d0) * (re * (im * im))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -2.7e+17) {
tmp = (re * -0.5) * (im * im);
} else if (re <= 1.4e+31) {
tmp = re + 1.0;
} else {
tmp = 1.0 + (re + (-0.5 * (re * (im * im))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -2.7e+17: tmp = (re * -0.5) * (im * im) elif re <= 1.4e+31: tmp = re + 1.0 else: tmp = 1.0 + (re + (-0.5 * (re * (im * im)))) return tmp
function code(re, im) tmp = 0.0 if (re <= -2.7e+17) tmp = Float64(Float64(re * -0.5) * Float64(im * im)); elseif (re <= 1.4e+31) tmp = Float64(re + 1.0); else tmp = Float64(1.0 + Float64(re + Float64(-0.5 * Float64(re * Float64(im * im))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -2.7e+17) tmp = (re * -0.5) * (im * im); elseif (re <= 1.4e+31) tmp = re + 1.0; else tmp = 1.0 + (re + (-0.5 * (re * (im * im)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -2.7e+17], N[(N[(re * -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.4e+31], N[(re + 1.0), $MachinePrecision], N[(1.0 + N[(re + N[(-0.5 * N[(re * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -2.7 \cdot 10^{+17}:\\
\;\;\;\;\left(re \cdot -0.5\right) \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;re \leq 1.4 \cdot 10^{+31}:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;1 + \left(re + -0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right)\right)\\
\end{array}
\end{array}
if re < -2.7e17Initial program 100.0%
Taylor expanded in re around 0 2.2%
*-rgt-identity2.2%
distribute-lft-in2.2%
Simplified2.2%
Taylor expanded in im around 0 2.0%
+-commutative2.0%
*-commutative2.0%
unpow22.0%
Simplified2.0%
Taylor expanded in re around inf 2.0%
unpow22.0%
Simplified2.0%
Taylor expanded in im around inf 31.4%
unpow231.4%
associate-*r*31.4%
*-commutative31.4%
Simplified31.4%
if -2.7e17 < re < 1.40000000000000008e31Initial program 100.0%
Taylor expanded in re around 0 92.6%
*-rgt-identity92.6%
distribute-lft-in92.6%
Simplified92.6%
Taylor expanded in im around 0 54.2%
+-commutative54.2%
Simplified54.2%
if 1.40000000000000008e31 < re Initial program 100.0%
Taylor expanded in re around 0 5.9%
*-rgt-identity5.9%
distribute-lft-in5.9%
Simplified5.9%
Taylor expanded in im around 0 20.9%
+-commutative20.9%
*-commutative20.9%
unpow220.9%
Simplified20.9%
Taylor expanded in re around inf 20.9%
unpow220.9%
Simplified20.9%
Final simplification42.6%
(FPCore (re im) :precision binary64 (if (or (<= re -2.7e+17) (not (<= re 1.6e+31))) (* (* re -0.5) (* im im)) (+ re 1.0)))
double code(double re, double im) {
double tmp;
if ((re <= -2.7e+17) || !(re <= 1.6e+31)) {
tmp = (re * -0.5) * (im * im);
} else {
tmp = 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 <= (-2.7d+17)) .or. (.not. (re <= 1.6d+31))) then
tmp = (re * (-0.5d0)) * (im * im)
else
tmp = re + 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -2.7e+17) || !(re <= 1.6e+31)) {
tmp = (re * -0.5) * (im * im);
} else {
tmp = re + 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -2.7e+17) or not (re <= 1.6e+31): tmp = (re * -0.5) * (im * im) else: tmp = re + 1.0 return tmp
function code(re, im) tmp = 0.0 if ((re <= -2.7e+17) || !(re <= 1.6e+31)) tmp = Float64(Float64(re * -0.5) * Float64(im * im)); else tmp = Float64(re + 1.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -2.7e+17) || ~((re <= 1.6e+31))) tmp = (re * -0.5) * (im * im); else tmp = re + 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -2.7e+17], N[Not[LessEqual[re, 1.6e+31]], $MachinePrecision]], N[(N[(re * -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision], N[(re + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -2.7 \cdot 10^{+17} \lor \neg \left(re \leq 1.6 \cdot 10^{+31}\right):\\
\;\;\;\;\left(re \cdot -0.5\right) \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;re + 1\\
\end{array}
\end{array}
if re < -2.7e17 or 1.6e31 < re Initial program 100.0%
Taylor expanded in re around 0 3.9%
*-rgt-identity3.9%
distribute-lft-in3.9%
Simplified3.9%
Taylor expanded in im around 0 10.8%
+-commutative10.8%
*-commutative10.8%
unpow210.8%
Simplified10.8%
Taylor expanded in re around inf 10.8%
unpow210.8%
Simplified10.8%
Taylor expanded in im around inf 25.5%
unpow225.5%
associate-*r*25.5%
*-commutative25.5%
Simplified25.5%
if -2.7e17 < re < 1.6e31Initial program 100.0%
Taylor expanded in re around 0 92.6%
*-rgt-identity92.6%
distribute-lft-in92.6%
Simplified92.6%
Taylor expanded in im around 0 54.2%
+-commutative54.2%
Simplified54.2%
Final simplification42.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.5%
*-rgt-identity55.5%
distribute-lft-in55.5%
Simplified55.5%
Taylor expanded in im around 0 32.9%
+-commutative32.9%
Simplified32.9%
Final simplification32.9%
(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 re around 0 55.5%
*-rgt-identity55.5%
distribute-lft-in55.5%
Simplified55.5%
Taylor expanded in im around 0 33.1%
+-commutative33.1%
*-commutative33.1%
unpow233.1%
Simplified33.1%
Taylor expanded in re around inf 33.5%
unpow233.5%
Simplified33.5%
Taylor expanded in re around 0 32.5%
Final simplification32.5%
herbie shell --seed 2023207
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))