
(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 12 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.9999998)
(exp re)
(if (<= (exp re) 2.0)
(* (cos im) (+ re 1.0))
(* (exp re) (+ 1.0 (* -0.5 (* im im)))))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.9999998) {
tmp = exp(re);
} else if (exp(re) <= 2.0) {
tmp = cos(im) * (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 (exp(re) <= 0.9999998d0) then
tmp = exp(re)
else if (exp(re) <= 2.0d0) then
tmp = cos(im) * (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 (Math.exp(re) <= 0.9999998) {
tmp = Math.exp(re);
} else if (Math.exp(re) <= 2.0) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re) * (1.0 + (-0.5 * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 0.9999998: tmp = math.exp(re) elif math.exp(re) <= 2.0: tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) * (1.0 + (-0.5 * (im * im))) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 0.9999998) tmp = exp(re); elseif (exp(re) <= 2.0) tmp = Float64(cos(im) * 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 (exp(re) <= 0.9999998) tmp = exp(re); elseif (exp(re) <= 2.0) tmp = cos(im) * (re + 1.0); else tmp = exp(re) * (1.0 + (-0.5 * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.9999998], N[Exp[re], $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 2.0], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $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}\;e^{re} \leq 0.9999998:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;e^{re} \leq 2:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 0.999999799999999994Initial program 100.0%
Taylor expanded in im around 0 100.0%
if 0.999999799999999994 < (exp.f64 re) < 2Initial program 100.0%
Taylor expanded in re around 0 100.0%
+-commutative100.0%
*-rgt-identity100.0%
distribute-lft-out100.0%
Simplified100.0%
if 2 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 72.1%
unpow272.1%
Simplified72.1%
Final simplification93.3%
(FPCore (re im) :precision binary64 (if (<= re -2.15e-7) (exp re) (if (<= re 3.8e+23) (* (cos im) (+ re 1.0)) (exp re))))
double code(double re, double im) {
double tmp;
if (re <= -2.15e-7) {
tmp = exp(re);
} else if (re <= 3.8e+23) {
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 <= (-2.15d-7)) then
tmp = exp(re)
else if (re <= 3.8d+23) 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 <= -2.15e-7) {
tmp = Math.exp(re);
} else if (re <= 3.8e+23) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -2.15e-7: tmp = math.exp(re) elif re <= 3.8e+23: tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -2.15e-7) tmp = exp(re); elseif (re <= 3.8e+23) 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 <= -2.15e-7) tmp = exp(re); elseif (re <= 3.8e+23) tmp = cos(im) * (re + 1.0); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -2.15e-7], N[Exp[re], $MachinePrecision], If[LessEqual[re, 3.8e+23], 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 -2.15 \cdot 10^{-7}:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 3.8 \cdot 10^{+23}:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if re < -2.1500000000000001e-7 or 3.79999999999999975e23 < re Initial program 100.0%
Taylor expanded in im around 0 84.7%
if -2.1500000000000001e-7 < re < 3.79999999999999975e23Initial program 100.0%
Taylor expanded in re around 0 98.5%
+-commutative98.5%
*-rgt-identity98.5%
distribute-lft-out98.5%
Simplified98.5%
Final simplification91.8%
(FPCore (re im)
:precision binary64
(if (<= re -6.8e+16)
(* -0.5 (* im im))
(if (<= re 620.0)
(cos im)
(if (<= re 2.85e+146)
(*
(* im im)
(+
(+ -0.5 (* -0.25 (* re re)))
(* re (+ -0.5 (* (* re re) -0.08333333333333333)))))
(/ (- 1.0 (* re re)) (- 1.0 re))))))
double code(double re, double im) {
double tmp;
if (re <= -6.8e+16) {
tmp = -0.5 * (im * im);
} else if (re <= 620.0) {
tmp = cos(im);
} else if (re <= 2.85e+146) {
tmp = (im * im) * ((-0.5 + (-0.25 * (re * re))) + (re * (-0.5 + ((re * re) * -0.08333333333333333))));
} else {
tmp = (1.0 - (re * re)) / (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 <= (-6.8d+16)) then
tmp = (-0.5d0) * (im * im)
else if (re <= 620.0d0) then
tmp = cos(im)
else if (re <= 2.85d+146) then
tmp = (im * im) * (((-0.5d0) + ((-0.25d0) * (re * re))) + (re * ((-0.5d0) + ((re * re) * (-0.08333333333333333d0)))))
else
tmp = (1.0d0 - (re * re)) / (1.0d0 - re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -6.8e+16) {
tmp = -0.5 * (im * im);
} else if (re <= 620.0) {
tmp = Math.cos(im);
} else if (re <= 2.85e+146) {
tmp = (im * im) * ((-0.5 + (-0.25 * (re * re))) + (re * (-0.5 + ((re * re) * -0.08333333333333333))));
} else {
tmp = (1.0 - (re * re)) / (1.0 - re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -6.8e+16: tmp = -0.5 * (im * im) elif re <= 620.0: tmp = math.cos(im) elif re <= 2.85e+146: tmp = (im * im) * ((-0.5 + (-0.25 * (re * re))) + (re * (-0.5 + ((re * re) * -0.08333333333333333)))) else: tmp = (1.0 - (re * re)) / (1.0 - re) return tmp
function code(re, im) tmp = 0.0 if (re <= -6.8e+16) tmp = Float64(-0.5 * Float64(im * im)); elseif (re <= 620.0) tmp = cos(im); elseif (re <= 2.85e+146) tmp = Float64(Float64(im * im) * Float64(Float64(-0.5 + Float64(-0.25 * Float64(re * re))) + Float64(re * Float64(-0.5 + Float64(Float64(re * re) * -0.08333333333333333))))); else tmp = Float64(Float64(1.0 - Float64(re * re)) / Float64(1.0 - re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -6.8e+16) tmp = -0.5 * (im * im); elseif (re <= 620.0) tmp = cos(im); elseif (re <= 2.85e+146) tmp = (im * im) * ((-0.5 + (-0.25 * (re * re))) + (re * (-0.5 + ((re * re) * -0.08333333333333333)))); else tmp = (1.0 - (re * re)) / (1.0 - re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -6.8e+16], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 620.0], N[Cos[im], $MachinePrecision], If[LessEqual[re, 2.85e+146], N[(N[(im * im), $MachinePrecision] * N[(N[(-0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(re * N[(-0.5 + N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(1.0 - re), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -6.8 \cdot 10^{+16}:\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;re \leq 620:\\
\;\;\;\;\cos im\\
\mathbf{elif}\;re \leq 2.85 \cdot 10^{+146}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left(\left(-0.5 + -0.25 \cdot \left(re \cdot re\right)\right) + re \cdot \left(-0.5 + \left(re \cdot re\right) \cdot -0.08333333333333333\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - re \cdot re}{1 - re}\\
\end{array}
\end{array}
if re < -6.8e16Initial program 100.0%
Taylor expanded in im around 0 81.0%
unpow281.0%
Simplified81.0%
Taylor expanded in im around inf 81.0%
*-commutative81.0%
associate-*r*81.0%
*-commutative81.0%
unpow281.0%
Simplified81.0%
Taylor expanded in re around 0 29.9%
unpow229.9%
Simplified29.9%
if -6.8e16 < re < 620Initial program 100.0%
Taylor expanded in re around 0 95.6%
if 620 < re < 2.85e146Initial program 100.0%
Taylor expanded in im around 0 73.1%
unpow273.1%
Simplified73.1%
Taylor expanded in im around inf 42.3%
*-commutative42.3%
associate-*r*42.3%
*-commutative42.3%
unpow242.3%
Simplified42.3%
Taylor expanded in re around 0 31.9%
associate-+r+31.9%
+-commutative31.9%
+-commutative31.9%
associate-*r*31.9%
distribute-rgt-out31.9%
associate-*r*31.9%
associate-*r*31.9%
distribute-rgt-out31.9%
distribute-lft-out31.9%
unpow231.9%
+-commutative31.9%
unpow231.9%
Simplified31.9%
if 2.85e146 < re Initial program 100.0%
Taylor expanded in re around 0 6.5%
+-commutative6.5%
*-rgt-identity6.5%
distribute-lft-out6.5%
Simplified6.5%
Taylor expanded in im around 0 29.3%
unpow271.4%
Simplified29.3%
*-commutative29.3%
distribute-lft-in29.3%
*-commutative29.3%
*-un-lft-identity29.3%
flip-+48.6%
div-inv48.6%
fma-def48.6%
metadata-eval48.6%
*-commutative48.6%
associate-*l*48.6%
Applied egg-rr48.6%
fma-udef48.6%
+-commutative48.6%
*-commutative48.6%
*-commutative48.6%
associate-*r*48.6%
associate-*r/48.6%
*-rgt-identity48.6%
Simplified48.6%
Taylor expanded in im around 0 63.3%
unpow263.3%
div-sub63.3%
Simplified63.3%
Final simplification69.8%
(FPCore (re im) :precision binary64 (if (<= re -4.9e-8) (exp re) (if (<= re 3.8e+23) (cos im) (exp re))))
double code(double re, double im) {
double tmp;
if (re <= -4.9e-8) {
tmp = exp(re);
} else if (re <= 3.8e+23) {
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 (re <= (-4.9d-8)) then
tmp = exp(re)
else if (re <= 3.8d+23) 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 (re <= -4.9e-8) {
tmp = Math.exp(re);
} else if (re <= 3.8e+23) {
tmp = Math.cos(im);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -4.9e-8: tmp = math.exp(re) elif re <= 3.8e+23: tmp = math.cos(im) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -4.9e-8) tmp = exp(re); elseif (re <= 3.8e+23) tmp = cos(im); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -4.9e-8) tmp = exp(re); elseif (re <= 3.8e+23) tmp = cos(im); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -4.9e-8], N[Exp[re], $MachinePrecision], If[LessEqual[re, 3.8e+23], N[Cos[im], $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -4.9 \cdot 10^{-8}:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 3.8 \cdot 10^{+23}:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if re < -4.9000000000000002e-8 or 3.79999999999999975e23 < re Initial program 100.0%
Taylor expanded in im around 0 84.7%
if -4.9000000000000002e-8 < re < 3.79999999999999975e23Initial program 100.0%
Taylor expanded in re around 0 98.2%
Final simplification91.6%
(FPCore (re im)
:precision binary64
(if (<= re -82.0)
(* -0.5 (* im im))
(if (or (<= re 1.05e-15) (not (<= re 2.8e+146)))
(/ (- 1.0 (* re re)) (- 1.0 re))
(*
(* im im)
(+
(+ -0.5 (* -0.25 (* re re)))
(* re (+ -0.5 (* (* re re) -0.08333333333333333))))))))
double code(double re, double im) {
double tmp;
if (re <= -82.0) {
tmp = -0.5 * (im * im);
} else if ((re <= 1.05e-15) || !(re <= 2.8e+146)) {
tmp = (1.0 - (re * re)) / (1.0 - re);
} else {
tmp = (im * im) * ((-0.5 + (-0.25 * (re * re))) + (re * (-0.5 + ((re * re) * -0.08333333333333333))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-82.0d0)) then
tmp = (-0.5d0) * (im * im)
else if ((re <= 1.05d-15) .or. (.not. (re <= 2.8d+146))) then
tmp = (1.0d0 - (re * re)) / (1.0d0 - re)
else
tmp = (im * im) * (((-0.5d0) + ((-0.25d0) * (re * re))) + (re * ((-0.5d0) + ((re * re) * (-0.08333333333333333d0)))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -82.0) {
tmp = -0.5 * (im * im);
} else if ((re <= 1.05e-15) || !(re <= 2.8e+146)) {
tmp = (1.0 - (re * re)) / (1.0 - re);
} else {
tmp = (im * im) * ((-0.5 + (-0.25 * (re * re))) + (re * (-0.5 + ((re * re) * -0.08333333333333333))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -82.0: tmp = -0.5 * (im * im) elif (re <= 1.05e-15) or not (re <= 2.8e+146): tmp = (1.0 - (re * re)) / (1.0 - re) else: tmp = (im * im) * ((-0.5 + (-0.25 * (re * re))) + (re * (-0.5 + ((re * re) * -0.08333333333333333)))) return tmp
function code(re, im) tmp = 0.0 if (re <= -82.0) tmp = Float64(-0.5 * Float64(im * im)); elseif ((re <= 1.05e-15) || !(re <= 2.8e+146)) tmp = Float64(Float64(1.0 - Float64(re * re)) / Float64(1.0 - re)); else tmp = Float64(Float64(im * im) * Float64(Float64(-0.5 + Float64(-0.25 * Float64(re * re))) + Float64(re * Float64(-0.5 + Float64(Float64(re * re) * -0.08333333333333333))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -82.0) tmp = -0.5 * (im * im); elseif ((re <= 1.05e-15) || ~((re <= 2.8e+146))) tmp = (1.0 - (re * re)) / (1.0 - re); else tmp = (im * im) * ((-0.5 + (-0.25 * (re * re))) + (re * (-0.5 + ((re * re) * -0.08333333333333333)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -82.0], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[re, 1.05e-15], N[Not[LessEqual[re, 2.8e+146]], $MachinePrecision]], N[(N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(1.0 - re), $MachinePrecision]), $MachinePrecision], N[(N[(im * im), $MachinePrecision] * N[(N[(-0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(re * N[(-0.5 + N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -82:\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;re \leq 1.05 \cdot 10^{-15} \lor \neg \left(re \leq 2.8 \cdot 10^{+146}\right):\\
\;\;\;\;\frac{1 - re \cdot re}{1 - re}\\
\mathbf{else}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left(\left(-0.5 + -0.25 \cdot \left(re \cdot re\right)\right) + re \cdot \left(-0.5 + \left(re \cdot re\right) \cdot -0.08333333333333333\right)\right)\\
\end{array}
\end{array}
if re < -82Initial program 100.0%
Taylor expanded in im around 0 82.3%
unpow282.3%
Simplified82.3%
Taylor expanded in im around inf 82.3%
*-commutative82.3%
associate-*r*82.3%
*-commutative82.3%
unpow282.3%
Simplified82.3%
Taylor expanded in re around 0 28.2%
unpow228.2%
Simplified28.2%
if -82 < re < 1.0499999999999999e-15 or 2.8000000000000001e146 < re Initial program 100.0%
Taylor expanded in re around 0 79.9%
+-commutative79.9%
*-rgt-identity79.9%
distribute-lft-out79.9%
Simplified79.9%
Taylor expanded in im around 0 48.1%
unpow257.5%
Simplified48.1%
*-commutative48.1%
distribute-lft-in48.1%
*-commutative48.1%
*-un-lft-identity48.1%
flip-+52.2%
div-inv52.2%
fma-def52.2%
metadata-eval52.2%
*-commutative52.2%
associate-*l*52.2%
Applied egg-rr52.2%
fma-udef52.2%
+-commutative52.2%
*-commutative52.2%
*-commutative52.2%
associate-*r*52.2%
associate-*r/52.2%
*-rgt-identity52.2%
Simplified52.2%
Taylor expanded in im around 0 57.5%
unpow257.5%
div-sub57.5%
Simplified57.5%
if 1.0499999999999999e-15 < re < 2.8000000000000001e146Initial program 100.0%
Taylor expanded in im around 0 70.5%
unpow270.5%
Simplified70.5%
Taylor expanded in im around inf 40.9%
*-commutative40.9%
associate-*r*40.9%
*-commutative40.9%
unpow240.9%
Simplified40.9%
Taylor expanded in re around 0 30.8%
associate-+r+30.8%
+-commutative30.8%
+-commutative30.8%
associate-*r*30.8%
distribute-rgt-out30.8%
associate-*r*30.8%
associate-*r*30.8%
distribute-rgt-out30.8%
distribute-lft-out30.8%
unpow230.8%
+-commutative30.8%
unpow230.8%
Simplified30.8%
Final simplification47.6%
(FPCore (re im) :precision binary64 (if (<= re -460.0) (* -0.5 (* im im)) (if (<= re 1.05e-15) (+ re 1.0) (* -0.25 (* (* re im) (* re im))))))
double code(double re, double im) {
double tmp;
if (re <= -460.0) {
tmp = -0.5 * (im * im);
} else if (re <= 1.05e-15) {
tmp = re + 1.0;
} else {
tmp = -0.25 * ((re * im) * (re * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-460.0d0)) then
tmp = (-0.5d0) * (im * im)
else if (re <= 1.05d-15) then
tmp = re + 1.0d0
else
tmp = (-0.25d0) * ((re * im) * (re * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -460.0) {
tmp = -0.5 * (im * im);
} else if (re <= 1.05e-15) {
tmp = re + 1.0;
} else {
tmp = -0.25 * ((re * im) * (re * im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -460.0: tmp = -0.5 * (im * im) elif re <= 1.05e-15: tmp = re + 1.0 else: tmp = -0.25 * ((re * im) * (re * im)) return tmp
function code(re, im) tmp = 0.0 if (re <= -460.0) tmp = Float64(-0.5 * Float64(im * im)); elseif (re <= 1.05e-15) tmp = Float64(re + 1.0); else tmp = Float64(-0.25 * Float64(Float64(re * im) * Float64(re * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -460.0) tmp = -0.5 * (im * im); elseif (re <= 1.05e-15) tmp = re + 1.0; else tmp = -0.25 * ((re * im) * (re * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -460.0], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.05e-15], N[(re + 1.0), $MachinePrecision], N[(-0.25 * N[(N[(re * im), $MachinePrecision] * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -460:\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;re \leq 1.05 \cdot 10^{-15}:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;-0.25 \cdot \left(\left(re \cdot im\right) \cdot \left(re \cdot im\right)\right)\\
\end{array}
\end{array}
if re < -460Initial program 100.0%
Taylor expanded in im around 0 82.3%
unpow282.3%
Simplified82.3%
Taylor expanded in im around inf 82.3%
*-commutative82.3%
associate-*r*82.3%
*-commutative82.3%
unpow282.3%
Simplified82.3%
Taylor expanded in re around 0 28.2%
unpow228.2%
Simplified28.2%
if -460 < re < 1.0499999999999999e-15Initial program 100.0%
Taylor expanded in re around 0 99.3%
+-commutative99.3%
*-rgt-identity99.3%
distribute-lft-out99.3%
Simplified99.3%
Taylor expanded in im around 0 56.0%
if 1.0499999999999999e-15 < re Initial program 100.0%
Taylor expanded in im around 0 71.0%
unpow271.0%
Simplified71.0%
Taylor expanded in im around inf 33.9%
*-commutative33.9%
associate-*r*33.9%
*-commutative33.9%
unpow233.9%
Simplified33.9%
Taylor expanded in re around 0 28.1%
associate-*r*28.1%
*-commutative28.1%
+-commutative28.1%
associate-*r*28.1%
distribute-rgt-out28.1%
distribute-lft-out28.1%
unpow228.1%
*-commutative28.1%
+-commutative28.1%
unpow228.1%
Simplified28.1%
Taylor expanded in re around inf 28.1%
unpow228.1%
unpow228.1%
*-commutative28.1%
unswap-sqr28.2%
Simplified28.2%
Final simplification42.5%
(FPCore (re im) :precision binary64 (if (<= re -310.0) (* -0.5 (* im im)) (if (<= re 1.05e-15) (+ re 1.0) (* -0.5 (* re (* im im))))))
double code(double re, double im) {
double tmp;
if (re <= -310.0) {
tmp = -0.5 * (im * im);
} else if (re <= 1.05e-15) {
tmp = re + 1.0;
} else {
tmp = -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 <= (-310.0d0)) then
tmp = (-0.5d0) * (im * im)
else if (re <= 1.05d-15) then
tmp = re + 1.0d0
else
tmp = (-0.5d0) * (re * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -310.0) {
tmp = -0.5 * (im * im);
} else if (re <= 1.05e-15) {
tmp = re + 1.0;
} else {
tmp = -0.5 * (re * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -310.0: tmp = -0.5 * (im * im) elif re <= 1.05e-15: tmp = re + 1.0 else: tmp = -0.5 * (re * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (re <= -310.0) tmp = Float64(-0.5 * Float64(im * im)); elseif (re <= 1.05e-15) tmp = Float64(re + 1.0); else tmp = Float64(-0.5 * Float64(re * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -310.0) tmp = -0.5 * (im * im); elseif (re <= 1.05e-15) tmp = re + 1.0; else tmp = -0.5 * (re * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -310.0], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.05e-15], N[(re + 1.0), $MachinePrecision], N[(-0.5 * N[(re * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -310:\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;re \leq 1.05 \cdot 10^{-15}:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if re < -310Initial program 100.0%
Taylor expanded in im around 0 82.3%
unpow282.3%
Simplified82.3%
Taylor expanded in im around inf 82.3%
*-commutative82.3%
associate-*r*82.3%
*-commutative82.3%
unpow282.3%
Simplified82.3%
Taylor expanded in re around 0 28.2%
unpow228.2%
Simplified28.2%
if -310 < re < 1.0499999999999999e-15Initial program 100.0%
Taylor expanded in re around 0 99.3%
+-commutative99.3%
*-rgt-identity99.3%
distribute-lft-out99.3%
Simplified99.3%
Taylor expanded in im around 0 56.0%
if 1.0499999999999999e-15 < re Initial program 100.0%
Taylor expanded in re around 0 6.9%
+-commutative6.9%
*-rgt-identity6.9%
distribute-lft-out6.9%
Simplified6.9%
Taylor expanded in im around 0 28.7%
unpow271.0%
Simplified28.7%
Taylor expanded in im around inf 26.8%
*-commutative26.8%
associate-*r*26.8%
*-commutative26.8%
unpow226.8%
Simplified26.8%
Taylor expanded in re around inf 26.8%
unpow226.8%
Simplified26.8%
Final simplification42.2%
(FPCore (re im) :precision binary64 (if (<= re -125.0) (* -0.5 (* im im)) (/ (- 1.0 (* re re)) (- 1.0 re))))
double code(double re, double im) {
double tmp;
if (re <= -125.0) {
tmp = -0.5 * (im * im);
} else {
tmp = (1.0 - (re * re)) / (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 <= (-125.0d0)) then
tmp = (-0.5d0) * (im * im)
else
tmp = (1.0d0 - (re * re)) / (1.0d0 - re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -125.0) {
tmp = -0.5 * (im * im);
} else {
tmp = (1.0 - (re * re)) / (1.0 - re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -125.0: tmp = -0.5 * (im * im) else: tmp = (1.0 - (re * re)) / (1.0 - re) return tmp
function code(re, im) tmp = 0.0 if (re <= -125.0) tmp = Float64(-0.5 * Float64(im * im)); else tmp = Float64(Float64(1.0 - Float64(re * re)) / Float64(1.0 - re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -125.0) tmp = -0.5 * (im * im); else tmp = (1.0 - (re * re)) / (1.0 - re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -125.0], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(1.0 - re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -125:\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - re \cdot re}{1 - re}\\
\end{array}
\end{array}
if re < -125Initial program 100.0%
Taylor expanded in im around 0 82.3%
unpow282.3%
Simplified82.3%
Taylor expanded in im around inf 82.3%
*-commutative82.3%
associate-*r*82.3%
*-commutative82.3%
unpow282.3%
Simplified82.3%
Taylor expanded in re around 0 28.2%
unpow228.2%
Simplified28.2%
if -125 < re Initial program 100.0%
Taylor expanded in re around 0 69.8%
+-commutative69.8%
*-rgt-identity69.8%
distribute-lft-out69.8%
Simplified69.8%
Taylor expanded in im around 0 45.3%
unpow259.3%
Simplified45.3%
*-commutative45.3%
distribute-lft-in45.3%
*-commutative45.3%
*-un-lft-identity45.3%
flip-+48.8%
div-inv48.8%
fma-def48.8%
metadata-eval48.8%
*-commutative48.8%
associate-*l*48.8%
Applied egg-rr48.8%
fma-udef48.8%
+-commutative48.8%
*-commutative48.8%
*-commutative48.8%
associate-*r*48.8%
associate-*r/48.8%
*-rgt-identity48.8%
Simplified48.8%
Taylor expanded in im around 0 49.9%
unpow249.9%
div-sub49.9%
Simplified49.9%
Final simplification44.6%
(FPCore (re im) :precision binary64 (if (or (<= re -360.0) (not (<= re 1.05e-15))) (* -0.5 (* im im)) (+ re 1.0)))
double code(double re, double im) {
double tmp;
if ((re <= -360.0) || !(re <= 1.05e-15)) {
tmp = -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 <= (-360.0d0)) .or. (.not. (re <= 1.05d-15))) then
tmp = (-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 <= -360.0) || !(re <= 1.05e-15)) {
tmp = -0.5 * (im * im);
} else {
tmp = re + 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -360.0) or not (re <= 1.05e-15): tmp = -0.5 * (im * im) else: tmp = re + 1.0 return tmp
function code(re, im) tmp = 0.0 if ((re <= -360.0) || !(re <= 1.05e-15)) tmp = Float64(-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 <= -360.0) || ~((re <= 1.05e-15))) tmp = -0.5 * (im * im); else tmp = re + 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -360.0], N[Not[LessEqual[re, 1.05e-15]], $MachinePrecision]], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], N[(re + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -360 \lor \neg \left(re \leq 1.05 \cdot 10^{-15}\right):\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;re + 1\\
\end{array}
\end{array}
if re < -360 or 1.0499999999999999e-15 < re Initial program 100.0%
Taylor expanded in im around 0 76.6%
unpow276.6%
Simplified76.6%
Taylor expanded in im around inf 58.1%
*-commutative58.1%
associate-*r*58.1%
*-commutative58.1%
unpow258.1%
Simplified58.1%
Taylor expanded in re around 0 21.5%
unpow221.5%
Simplified21.5%
if -360 < re < 1.0499999999999999e-15Initial program 100.0%
Taylor expanded in re around 0 99.3%
+-commutative99.3%
*-rgt-identity99.3%
distribute-lft-out99.3%
Simplified99.3%
Taylor expanded in im around 0 56.0%
Final simplification39.3%
(FPCore (re im) :precision binary64 (+ re 1.0))
double code(double re, double im) {
return re + 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re + 1.0d0
end function
public static double code(double re, double im) {
return re + 1.0;
}
def code(re, im): return re + 1.0
function code(re, im) return Float64(re + 1.0) end
function tmp = code(re, im) tmp = re + 1.0; end
code[re_, im_] := N[(re + 1.0), $MachinePrecision]
\begin{array}{l}
\\
re + 1
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 53.4%
+-commutative53.4%
*-rgt-identity53.4%
distribute-lft-out53.4%
Simplified53.4%
Taylor expanded in im around 0 30.4%
Final simplification30.4%
(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 52.6%
Taylor expanded in im around 0 29.8%
Final simplification29.8%
herbie shell --seed 2023200
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))