
(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 14 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) 2e-10) (exp re) (if (<= (exp re) 1.00000005) (+ re (cos im)) (exp re))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 2e-10) {
tmp = exp(re);
} else if (exp(re) <= 1.00000005) {
tmp = re + 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) <= 2d-10) then
tmp = exp(re)
else if (exp(re) <= 1.00000005d0) then
tmp = re + 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) <= 2e-10) {
tmp = Math.exp(re);
} else if (Math.exp(re) <= 1.00000005) {
tmp = re + Math.cos(im);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 2e-10: tmp = math.exp(re) elif math.exp(re) <= 1.00000005: tmp = re + math.cos(im) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 2e-10) tmp = exp(re); elseif (exp(re) <= 1.00000005) tmp = Float64(re + cos(im)); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (exp(re) <= 2e-10) tmp = exp(re); elseif (exp(re) <= 1.00000005) tmp = re + cos(im); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 2e-10], N[Exp[re], $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 1.00000005], N[(re + N[Cos[im], $MachinePrecision]), $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;e^{re} \leq 1.00000005:\\
\;\;\;\;re + \cos im\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 2.00000000000000007e-10 or 1.00000004999999992 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 84.5%
if 2.00000000000000007e-10 < (exp.f64 re) < 1.00000004999999992Initial program 100.0%
Taylor expanded in re around 0 99.7%
distribute-rgt1-in99.7%
Simplified99.7%
*-commutative99.7%
distribute-lft-in99.7%
*-commutative99.7%
*-un-lft-identity99.7%
Applied egg-rr99.7%
Taylor expanded in im around 0 99.0%
Final simplification92.4%
(FPCore (re im) :precision binary64 (if (<= (exp re) 2e-10) (exp re) (if (<= (exp re) 1.00000005) (cos im) (exp re))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 2e-10) {
tmp = exp(re);
} else if (exp(re) <= 1.00000005) {
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) <= 2d-10) then
tmp = exp(re)
else if (exp(re) <= 1.00000005d0) 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) <= 2e-10) {
tmp = Math.exp(re);
} else if (Math.exp(re) <= 1.00000005) {
tmp = Math.cos(im);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 2e-10: tmp = math.exp(re) elif math.exp(re) <= 1.00000005: tmp = math.cos(im) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 2e-10) tmp = exp(re); elseif (exp(re) <= 1.00000005) tmp = cos(im); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (exp(re) <= 2e-10) tmp = exp(re); elseif (exp(re) <= 1.00000005) tmp = cos(im); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 2e-10], N[Exp[re], $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 1.00000005], N[Cos[im], $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;e^{re} \leq 1.00000005:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 2.00000000000000007e-10 or 1.00000004999999992 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 84.5%
if 2.00000000000000007e-10 < (exp.f64 re) < 1.00000004999999992Initial program 100.0%
Taylor expanded in re around 0 98.8%
Final simplification92.3%
(FPCore (re im)
:precision binary64
(if (<= re -0.0205)
(exp re)
(if (or (<= re 1700000.0) (not (<= re 1.05e+103)))
(*
(cos im)
(+ (* (* re re) (+ (* re 0.16666666666666666) 0.5)) (+ re 1.0)))
(* (exp re) (+ 1.0 (* -0.5 (* im im)))))))
double code(double re, double im) {
double tmp;
if (re <= -0.0205) {
tmp = exp(re);
} else if ((re <= 1700000.0) || !(re <= 1.05e+103)) {
tmp = cos(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0));
} else {
tmp = exp(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 <= (-0.0205d0)) then
tmp = exp(re)
else if ((re <= 1700000.0d0) .or. (.not. (re <= 1.05d+103))) then
tmp = cos(im) * (((re * re) * ((re * 0.16666666666666666d0) + 0.5d0)) + (re + 1.0d0))
else
tmp = exp(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 <= -0.0205) {
tmp = Math.exp(re);
} else if ((re <= 1700000.0) || !(re <= 1.05e+103)) {
tmp = Math.cos(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0));
} else {
tmp = Math.exp(re) * (1.0 + (-0.5 * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.0205: tmp = math.exp(re) elif (re <= 1700000.0) or not (re <= 1.05e+103): tmp = math.cos(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0)) else: tmp = math.exp(re) * (1.0 + (-0.5 * (im * im))) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.0205) tmp = exp(re); elseif ((re <= 1700000.0) || !(re <= 1.05e+103)) tmp = Float64(cos(im) * Float64(Float64(Float64(re * re) * Float64(Float64(re * 0.16666666666666666) + 0.5)) + Float64(re + 1.0))); else tmp = Float64(exp(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 <= -0.0205) tmp = exp(re); elseif ((re <= 1700000.0) || ~((re <= 1.05e+103))) tmp = cos(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0)); else tmp = exp(re) * (1.0 + (-0.5 * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.0205], N[Exp[re], $MachinePrecision], If[Or[LessEqual[re, 1700000.0], N[Not[LessEqual[re, 1.05e+103]], $MachinePrecision]], N[(N[Cos[im], $MachinePrecision] * N[(N[(N[(re * re), $MachinePrecision] * N[(N[(re * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[(re + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[re], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.0205:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 1700000 \lor \neg \left(re \leq 1.05 \cdot 10^{+103}\right):\\
\;\;\;\;\cos im \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot 0.16666666666666666 + 0.5\right) + \left(re + 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if re < -0.0205000000000000009Initial program 100.0%
Taylor expanded in im around 0 96.5%
if -0.0205000000000000009 < re < 1.7e6 or 1.0500000000000001e103 < re Initial program 100.0%
add-cube-cbrt99.1%
pow299.1%
Applied egg-rr99.1%
Taylor expanded in re around 0 99.4%
+-commutative99.4%
associate-+r+99.4%
associate-+l+99.4%
associate-*r*99.4%
associate-*r*99.4%
distribute-rgt-out99.4%
distribute-lft1-in99.4%
*-commutative99.4%
distribute-lft-out99.4%
Simplified99.4%
if 1.7e6 < re < 1.0500000000000001e103Initial program 100.0%
Taylor expanded in im around 0 77.3%
unpow220.3%
Simplified77.3%
Final simplification96.9%
(FPCore (re im)
:precision binary64
(if (<= re -0.0063)
(exp re)
(if (or (<= re 1700000.0) (not (<= re 1.35e+154)))
(* (cos im) (+ 1.0 (+ re (* (* re re) 0.5))))
(* (exp re) (+ 1.0 (* -0.5 (* im im)))))))
double code(double re, double im) {
double tmp;
if (re <= -0.0063) {
tmp = exp(re);
} else if ((re <= 1700000.0) || !(re <= 1.35e+154)) {
tmp = cos(im) * (1.0 + (re + ((re * re) * 0.5)));
} else {
tmp = exp(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 <= (-0.0063d0)) then
tmp = exp(re)
else if ((re <= 1700000.0d0) .or. (.not. (re <= 1.35d+154))) then
tmp = cos(im) * (1.0d0 + (re + ((re * re) * 0.5d0)))
else
tmp = exp(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 <= -0.0063) {
tmp = Math.exp(re);
} else if ((re <= 1700000.0) || !(re <= 1.35e+154)) {
tmp = Math.cos(im) * (1.0 + (re + ((re * re) * 0.5)));
} else {
tmp = Math.exp(re) * (1.0 + (-0.5 * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.0063: tmp = math.exp(re) elif (re <= 1700000.0) or not (re <= 1.35e+154): tmp = math.cos(im) * (1.0 + (re + ((re * re) * 0.5))) else: tmp = math.exp(re) * (1.0 + (-0.5 * (im * im))) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.0063) tmp = exp(re); elseif ((re <= 1700000.0) || !(re <= 1.35e+154)) tmp = Float64(cos(im) * Float64(1.0 + Float64(re + Float64(Float64(re * re) * 0.5)))); else tmp = Float64(exp(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 <= -0.0063) tmp = exp(re); elseif ((re <= 1700000.0) || ~((re <= 1.35e+154))) tmp = cos(im) * (1.0 + (re + ((re * re) * 0.5))); else tmp = exp(re) * (1.0 + (-0.5 * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.0063], N[Exp[re], $MachinePrecision], If[Or[LessEqual[re, 1700000.0], N[Not[LessEqual[re, 1.35e+154]], $MachinePrecision]], N[(N[Cos[im], $MachinePrecision] * N[(1.0 + N[(re + N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[re], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.0063:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 1700000 \lor \neg \left(re \leq 1.35 \cdot 10^{+154}\right):\\
\;\;\;\;\cos im \cdot \left(1 + \left(re + \left(re \cdot re\right) \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if re < -0.0063Initial program 100.0%
Taylor expanded in im around 0 96.5%
if -0.0063 < re < 1.7e6 or 1.35000000000000003e154 < re Initial program 100.0%
add-cube-cbrt99.1%
pow299.1%
Applied egg-rr99.1%
Taylor expanded in re around 0 99.4%
*-rgt-identity99.4%
+-commutative99.4%
associate-*r*99.4%
distribute-rgt-out99.4%
distribute-lft-out99.3%
unpow299.3%
Simplified99.3%
if 1.7e6 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0 78.6%
unpow216.6%
Simplified78.6%
Final simplification96.4%
(FPCore (re im) :precision binary64 (if (<= re -0.0305) (exp re) (if (<= re 5.5e-8) (* (cos im) (+ re 1.0)) (exp re))))
double code(double re, double im) {
double tmp;
if (re <= -0.0305) {
tmp = exp(re);
} else if (re <= 5.5e-8) {
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.0305d0)) then
tmp = exp(re)
else if (re <= 5.5d-8) 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.0305) {
tmp = Math.exp(re);
} else if (re <= 5.5e-8) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.0305: tmp = math.exp(re) elif re <= 5.5e-8: tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.0305) tmp = exp(re); elseif (re <= 5.5e-8) 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.0305) tmp = exp(re); elseif (re <= 5.5e-8) tmp = cos(im) * (re + 1.0); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.0305], N[Exp[re], $MachinePrecision], If[LessEqual[re, 5.5e-8], 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.0305:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 5.5 \cdot 10^{-8}:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if re < -0.030499999999999999 or 5.5000000000000003e-8 < re Initial program 100.0%
Taylor expanded in im around 0 84.5%
if -0.030499999999999999 < re < 5.5000000000000003e-8Initial program 100.0%
Taylor expanded in re around 0 99.7%
distribute-rgt1-in99.7%
Simplified99.7%
Final simplification92.8%
(FPCore (re im)
:precision binary64
(if (<= re -2.8e+27)
(* -0.5 (* (+ re 1.0) (* im im)))
(if (<= re 2.95e-8)
(cos im)
(*
(+ (* (* re re) (+ (* re 0.16666666666666666) 0.5)) (+ re 1.0))
(+ 1.0 (* -0.5 (* im im)))))))
double code(double re, double im) {
double tmp;
if (re <= -2.8e+27) {
tmp = -0.5 * ((re + 1.0) * (im * im));
} else if (re <= 2.95e-8) {
tmp = cos(im);
} else {
tmp = (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0)) * (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 <= (-2.8d+27)) then
tmp = (-0.5d0) * ((re + 1.0d0) * (im * im))
else if (re <= 2.95d-8) then
tmp = cos(im)
else
tmp = (((re * re) * ((re * 0.16666666666666666d0) + 0.5d0)) + (re + 1.0d0)) * (1.0d0 + ((-0.5d0) * (im * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -2.8e+27) {
tmp = -0.5 * ((re + 1.0) * (im * im));
} else if (re <= 2.95e-8) {
tmp = Math.cos(im);
} else {
tmp = (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0)) * (1.0 + (-0.5 * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -2.8e+27: tmp = -0.5 * ((re + 1.0) * (im * im)) elif re <= 2.95e-8: tmp = math.cos(im) else: tmp = (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0)) * (1.0 + (-0.5 * (im * im))) return tmp
function code(re, im) tmp = 0.0 if (re <= -2.8e+27) tmp = Float64(-0.5 * Float64(Float64(re + 1.0) * Float64(im * im))); elseif (re <= 2.95e-8) tmp = cos(im); else tmp = Float64(Float64(Float64(Float64(re * re) * Float64(Float64(re * 0.16666666666666666) + 0.5)) + Float64(re + 1.0)) * Float64(1.0 + Float64(-0.5 * Float64(im * im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -2.8e+27) tmp = -0.5 * ((re + 1.0) * (im * im)); elseif (re <= 2.95e-8) tmp = cos(im); else tmp = (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0)) * (1.0 + (-0.5 * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -2.8e+27], N[(-0.5 * N[(N[(re + 1.0), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 2.95e-8], N[Cos[im], $MachinePrecision], N[(N[(N[(N[(re * re), $MachinePrecision] * N[(N[(re * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[(re + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -2.8 \cdot 10^{+27}:\\
\;\;\;\;-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)\\
\mathbf{elif}\;re \leq 2.95 \cdot 10^{-8}:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;\left(\left(re \cdot re\right) \cdot \left(re \cdot 0.16666666666666666 + 0.5\right) + \left(re + 1\right)\right) \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if re < -2.7999999999999999e27Initial program 100.0%
Taylor expanded in re around 0 2.1%
distribute-rgt1-in2.1%
Simplified2.1%
Taylor expanded in im around 0 1.9%
unpow22.7%
Simplified1.9%
Taylor expanded in im around inf 28.2%
+-commutative28.2%
unpow228.2%
Simplified28.2%
if -2.7999999999999999e27 < re < 2.9499999999999999e-8Initial program 100.0%
Taylor expanded in re around 0 94.4%
if 2.9499999999999999e-8 < re Initial program 100.0%
add-cube-cbrt100.0%
pow2100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 63.6%
+-commutative63.6%
associate-+r+63.6%
associate-+l+63.6%
associate-*r*63.6%
associate-*r*63.6%
distribute-rgt-out63.6%
distribute-lft1-in63.6%
*-commutative63.6%
distribute-lft-out63.6%
Simplified63.6%
Taylor expanded in im around 0 49.7%
unpow214.7%
Simplified49.7%
Final simplification71.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (+ (* (* re re) (+ (* re 0.16666666666666666) 0.5)) (+ re 1.0))))
(if (<= re -1.15e+24)
(* -0.5 (* (+ re 1.0) (* im im)))
(if (<= re 1700000.0)
(+
(+ re 1.0)
(+ (* (* re re) (* re 0.16666666666666666)) (* (* re re) 0.5)))
(if (<= re 1.75e+133) (* t_0 (+ 1.0 (* -0.5 (* im im)))) t_0)))))
double code(double re, double im) {
double t_0 = ((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0);
double tmp;
if (re <= -1.15e+24) {
tmp = -0.5 * ((re + 1.0) * (im * im));
} else if (re <= 1700000.0) {
tmp = (re + 1.0) + (((re * re) * (re * 0.16666666666666666)) + ((re * re) * 0.5));
} else if (re <= 1.75e+133) {
tmp = t_0 * (1.0 + (-0.5 * (im * im)));
} else {
tmp = 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 = ((re * re) * ((re * 0.16666666666666666d0) + 0.5d0)) + (re + 1.0d0)
if (re <= (-1.15d+24)) then
tmp = (-0.5d0) * ((re + 1.0d0) * (im * im))
else if (re <= 1700000.0d0) then
tmp = (re + 1.0d0) + (((re * re) * (re * 0.16666666666666666d0)) + ((re * re) * 0.5d0))
else if (re <= 1.75d+133) then
tmp = t_0 * (1.0d0 + ((-0.5d0) * (im * im)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = ((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0);
double tmp;
if (re <= -1.15e+24) {
tmp = -0.5 * ((re + 1.0) * (im * im));
} else if (re <= 1700000.0) {
tmp = (re + 1.0) + (((re * re) * (re * 0.16666666666666666)) + ((re * re) * 0.5));
} else if (re <= 1.75e+133) {
tmp = t_0 * (1.0 + (-0.5 * (im * im)));
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = ((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0) tmp = 0 if re <= -1.15e+24: tmp = -0.5 * ((re + 1.0) * (im * im)) elif re <= 1700000.0: tmp = (re + 1.0) + (((re * re) * (re * 0.16666666666666666)) + ((re * re) * 0.5)) elif re <= 1.75e+133: tmp = t_0 * (1.0 + (-0.5 * (im * im))) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(Float64(Float64(re * re) * Float64(Float64(re * 0.16666666666666666) + 0.5)) + Float64(re + 1.0)) tmp = 0.0 if (re <= -1.15e+24) tmp = Float64(-0.5 * Float64(Float64(re + 1.0) * Float64(im * im))); elseif (re <= 1700000.0) tmp = Float64(Float64(re + 1.0) + Float64(Float64(Float64(re * re) * Float64(re * 0.16666666666666666)) + Float64(Float64(re * re) * 0.5))); elseif (re <= 1.75e+133) tmp = Float64(t_0 * Float64(1.0 + Float64(-0.5 * Float64(im * im)))); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = ((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0); tmp = 0.0; if (re <= -1.15e+24) tmp = -0.5 * ((re + 1.0) * (im * im)); elseif (re <= 1700000.0) tmp = (re + 1.0) + (((re * re) * (re * 0.16666666666666666)) + ((re * re) * 0.5)); elseif (re <= 1.75e+133) tmp = t_0 * (1.0 + (-0.5 * (im * im))); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(re * re), $MachinePrecision] * N[(N[(re * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[(re + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -1.15e+24], N[(-0.5 * N[(N[(re + 1.0), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1700000.0], N[(N[(re + 1.0), $MachinePrecision] + N[(N[(N[(re * re), $MachinePrecision] * N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] + N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.75e+133], N[(t$95$0 * N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(re \cdot re\right) \cdot \left(re \cdot 0.16666666666666666 + 0.5\right) + \left(re + 1\right)\\
\mathbf{if}\;re \leq -1.15 \cdot 10^{+24}:\\
\;\;\;\;-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)\\
\mathbf{elif}\;re \leq 1700000:\\
\;\;\;\;\left(re + 1\right) + \left(\left(re \cdot re\right) \cdot \left(re \cdot 0.16666666666666666\right) + \left(re \cdot re\right) \cdot 0.5\right)\\
\mathbf{elif}\;re \leq 1.75 \cdot 10^{+133}:\\
\;\;\;\;t_0 \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if re < -1.15e24Initial program 100.0%
Taylor expanded in re around 0 2.1%
distribute-rgt1-in2.1%
Simplified2.1%
Taylor expanded in im around 0 2.0%
unpow22.7%
Simplified2.0%
Taylor expanded in im around inf 27.7%
+-commutative27.7%
unpow227.7%
Simplified27.7%
if -1.15e24 < re < 1.7e6Initial program 100.0%
add-cube-cbrt98.9%
pow298.9%
Applied egg-rr98.9%
Taylor expanded in re around 0 95.4%
+-commutative95.4%
associate-+r+95.4%
associate-+l+95.4%
associate-*r*95.4%
associate-*r*95.4%
distribute-rgt-out95.4%
distribute-lft1-in95.3%
*-commutative95.3%
distribute-lft-out95.3%
Simplified95.3%
Taylor expanded in im around 0 50.5%
distribute-lft-in50.5%
Applied egg-rr50.5%
if 1.7e6 < re < 1.7499999999999999e133Initial program 100.0%
add-cube-cbrt100.0%
pow2100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 16.6%
+-commutative16.6%
associate-+r+16.6%
associate-+l+16.6%
associate-*r*16.6%
associate-*r*16.6%
distribute-rgt-out16.6%
distribute-lft1-in16.6%
*-commutative16.6%
distribute-lft-out16.6%
Simplified16.6%
Taylor expanded in im around 0 31.2%
unpow218.3%
Simplified31.2%
if 1.7499999999999999e133 < re Initial program 100.0%
add-cube-cbrt100.0%
pow2100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 100.0%
+-commutative100.0%
associate-+r+100.0%
associate-+l+100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-lft1-in100.0%
*-commutative100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in im around 0 72.7%
Final simplification47.1%
(FPCore (re im) :precision binary64 (if (<= re -1.15e+24) (* -0.5 (* (+ re 1.0) (* im im))) (+ (* (* re re) (+ (* re 0.16666666666666666) 0.5)) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if (re <= -1.15e+24) {
tmp = -0.5 * ((re + 1.0) * (im * im));
} else {
tmp = ((re * re) * ((re * 0.16666666666666666) + 0.5)) + (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 <= (-1.15d+24)) then
tmp = (-0.5d0) * ((re + 1.0d0) * (im * im))
else
tmp = ((re * re) * ((re * 0.16666666666666666d0) + 0.5d0)) + (re + 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1.15e+24) {
tmp = -0.5 * ((re + 1.0) * (im * im));
} else {
tmp = ((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.15e+24: tmp = -0.5 * ((re + 1.0) * (im * im)) else: tmp = ((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if (re <= -1.15e+24) tmp = Float64(-0.5 * Float64(Float64(re + 1.0) * Float64(im * im))); else tmp = Float64(Float64(Float64(re * re) * Float64(Float64(re * 0.16666666666666666) + 0.5)) + Float64(re + 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1.15e+24) tmp = -0.5 * ((re + 1.0) * (im * im)); else tmp = ((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.15e+24], N[(-0.5 * N[(N[(re + 1.0), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(re * re), $MachinePrecision] * N[(N[(re * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[(re + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.15 \cdot 10^{+24}:\\
\;\;\;\;-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(re \cdot 0.16666666666666666 + 0.5\right) + \left(re + 1\right)\\
\end{array}
\end{array}
if re < -1.15e24Initial program 100.0%
Taylor expanded in re around 0 2.1%
distribute-rgt1-in2.1%
Simplified2.1%
Taylor expanded in im around 0 2.0%
unpow22.7%
Simplified2.0%
Taylor expanded in im around inf 27.7%
+-commutative27.7%
unpow227.7%
Simplified27.7%
if -1.15e24 < re Initial program 100.0%
add-cube-cbrt99.2%
pow299.2%
Applied egg-rr99.2%
Taylor expanded in re around 0 86.5%
+-commutative86.5%
associate-+r+86.5%
associate-+l+86.5%
associate-*r*86.5%
associate-*r*86.5%
distribute-rgt-out86.5%
distribute-lft1-in86.5%
*-commutative86.5%
distribute-lft-out86.5%
Simplified86.5%
Taylor expanded in im around 0 49.4%
Final simplification45.1%
(FPCore (re im) :precision binary64 (if (or (<= re -1.15e+24) (not (<= re 1700000.0))) (* -0.5 (* (+ re 1.0) (* im im))) (+ re 1.0)))
double code(double re, double im) {
double tmp;
if ((re <= -1.15e+24) || !(re <= 1700000.0)) {
tmp = -0.5 * ((re + 1.0) * (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 <= (-1.15d+24)) .or. (.not. (re <= 1700000.0d0))) then
tmp = (-0.5d0) * ((re + 1.0d0) * (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 <= -1.15e+24) || !(re <= 1700000.0)) {
tmp = -0.5 * ((re + 1.0) * (im * im));
} else {
tmp = re + 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -1.15e+24) or not (re <= 1700000.0): tmp = -0.5 * ((re + 1.0) * (im * im)) else: tmp = re + 1.0 return tmp
function code(re, im) tmp = 0.0 if ((re <= -1.15e+24) || !(re <= 1700000.0)) tmp = Float64(-0.5 * Float64(Float64(re + 1.0) * Float64(im * im))); else tmp = Float64(re + 1.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -1.15e+24) || ~((re <= 1700000.0))) tmp = -0.5 * ((re + 1.0) * (im * im)); else tmp = re + 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -1.15e+24], N[Not[LessEqual[re, 1700000.0]], $MachinePrecision]], N[(-0.5 * N[(N[(re + 1.0), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.15 \cdot 10^{+24} \lor \neg \left(re \leq 1700000\right):\\
\;\;\;\;-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;re + 1\\
\end{array}
\end{array}
if re < -1.15e24 or 1.7e6 < re Initial program 100.0%
Taylor expanded in re around 0 3.9%
distribute-rgt1-in3.9%
Simplified3.9%
Taylor expanded in im around 0 12.8%
unpow28.9%
Simplified12.8%
Taylor expanded in im around inf 23.6%
+-commutative23.6%
unpow223.6%
Simplified23.6%
if -1.15e24 < re < 1.7e6Initial program 100.0%
Taylor expanded in re around 0 95.1%
distribute-rgt1-in95.1%
Simplified95.1%
Taylor expanded in im around 0 50.5%
Final simplification39.2%
(FPCore (re im) :precision binary64 (if (<= re -1.15e+24) (* -0.5 (* (+ re 1.0) (* im im))) (+ 1.0 (+ re (* (* re re) 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= -1.15e+24) {
tmp = -0.5 * ((re + 1.0) * (im * im));
} else {
tmp = 1.0 + (re + ((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 <= (-1.15d+24)) then
tmp = (-0.5d0) * ((re + 1.0d0) * (im * im))
else
tmp = 1.0d0 + (re + ((re * re) * 0.5d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1.15e+24) {
tmp = -0.5 * ((re + 1.0) * (im * im));
} else {
tmp = 1.0 + (re + ((re * re) * 0.5));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.15e+24: tmp = -0.5 * ((re + 1.0) * (im * im)) else: tmp = 1.0 + (re + ((re * re) * 0.5)) return tmp
function code(re, im) tmp = 0.0 if (re <= -1.15e+24) tmp = Float64(-0.5 * Float64(Float64(re + 1.0) * Float64(im * im))); else tmp = Float64(1.0 + Float64(re + Float64(Float64(re * re) * 0.5))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1.15e+24) tmp = -0.5 * ((re + 1.0) * (im * im)); else tmp = 1.0 + (re + ((re * re) * 0.5)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.15e+24], N[(-0.5 * N[(N[(re + 1.0), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(re + N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.15 \cdot 10^{+24}:\\
\;\;\;\;-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(re + \left(re \cdot re\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -1.15e24Initial program 100.0%
Taylor expanded in re around 0 2.1%
distribute-rgt1-in2.1%
Simplified2.1%
Taylor expanded in im around 0 2.0%
unpow22.7%
Simplified2.0%
Taylor expanded in im around inf 27.7%
+-commutative27.7%
unpow227.7%
Simplified27.7%
if -1.15e24 < re Initial program 100.0%
add-cube-cbrt99.2%
pow299.2%
Applied egg-rr99.2%
Taylor expanded in re around 0 86.5%
+-commutative86.5%
associate-+r+86.5%
associate-+l+86.5%
associate-*r*86.5%
associate-*r*86.5%
distribute-rgt-out86.5%
distribute-lft1-in86.5%
*-commutative86.5%
distribute-lft-out86.5%
Simplified86.5%
Taylor expanded in re around 0 83.8%
unpow283.8%
associate-*r*83.8%
Simplified83.8%
Taylor expanded in im around 0 47.5%
unpow247.5%
Simplified47.5%
Final simplification43.6%
(FPCore (re im) :precision binary64 (if (<= re 1700000.0) (+ re 1.0) (+ 1.0 (* -0.5 (* im im)))))
double code(double re, double im) {
double tmp;
if (re <= 1700000.0) {
tmp = re + 1.0;
} 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 <= 1700000.0d0) then
tmp = re + 1.0d0
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 <= 1700000.0) {
tmp = re + 1.0;
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1700000.0: tmp = re + 1.0 else: tmp = 1.0 + (-0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (re <= 1700000.0) tmp = Float64(re + 1.0); 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 <= 1700000.0) tmp = re + 1.0; else tmp = 1.0 + (-0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1700000.0], N[(re + 1.0), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1700000:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if re < 1.7e6Initial program 100.0%
Taylor expanded in re around 0 71.6%
distribute-rgt1-in71.6%
Simplified71.6%
Taylor expanded in im around 0 38.3%
if 1.7e6 < re Initial program 100.0%
Taylor expanded in re around 0 3.1%
Taylor expanded in im around 0 14.2%
unpow214.2%
Simplified14.2%
Final simplification32.8%
(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 56.6%
distribute-rgt1-in56.6%
Simplified56.6%
Taylor expanded in im around 0 30.6%
Final simplification30.6%
(FPCore (re im) :precision binary64 1.0)
double code(double re, double im) {
return 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0
end function
public static double code(double re, double im) {
return 1.0;
}
def code(re, im): return 1.0
function code(re, im) return 1.0 end
function tmp = code(re, im) tmp = 1.0; end
code[re_, im_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 55.8%
Taylor expanded in im around 0 30.2%
Final simplification30.2%
herbie shell --seed 2023293
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))