
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (or (<= t_0 -0.4) (not (<= t_0 5e-5)))
(* (* 0.5 (cos re)) t_0)
(- (* -0.16666666666666666 (* (cos re) (pow im 3.0))) (* im (cos re))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -0.4) || !(t_0 <= 5e-5)) {
tmp = (0.5 * cos(re)) * t_0;
} else {
tmp = (-0.16666666666666666 * (cos(re) * pow(im, 3.0))) - (im * cos(re));
}
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 = exp(-im) - exp(im)
if ((t_0 <= (-0.4d0)) .or. (.not. (t_0 <= 5d-5))) then
tmp = (0.5d0 * cos(re)) * t_0
else
tmp = ((-0.16666666666666666d0) * (cos(re) * (im ** 3.0d0))) - (im * cos(re))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double tmp;
if ((t_0 <= -0.4) || !(t_0 <= 5e-5)) {
tmp = (0.5 * Math.cos(re)) * t_0;
} else {
tmp = (-0.16666666666666666 * (Math.cos(re) * Math.pow(im, 3.0))) - (im * Math.cos(re));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -0.4) or not (t_0 <= 5e-5): tmp = (0.5 * math.cos(re)) * t_0 else: tmp = (-0.16666666666666666 * (math.cos(re) * math.pow(im, 3.0))) - (im * math.cos(re)) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= -0.4) || !(t_0 <= 5e-5)) tmp = Float64(Float64(0.5 * cos(re)) * t_0); else tmp = Float64(Float64(-0.16666666666666666 * Float64(cos(re) * (im ^ 3.0))) - Float64(im * cos(re))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -0.4) || ~((t_0 <= 5e-5))) tmp = (0.5 * cos(re)) * t_0; else tmp = (-0.16666666666666666 * (cos(re) * (im ^ 3.0))) - (im * cos(re)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.4], N[Not[LessEqual[t$95$0, 5e-5]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(-0.16666666666666666 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -0.4 \lor \neg \left(t_0 \leq 5 \cdot 10^{-5}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - im \cdot \cos re\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -0.40000000000000002 or 5.00000000000000024e-5 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
if -0.40000000000000002 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 5.00000000000000024e-5Initial program 7.3%
neg-sub07.3%
Simplified7.3%
Taylor expanded in im around 0 99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (or (<= t_0 -0.4) (not (<= t_0 5e-5)))
(* (* 0.5 (cos re)) t_0)
(* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im)))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -0.4) || !(t_0 <= 5e-5)) {
tmp = (0.5 * cos(re)) * t_0;
} else {
tmp = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
}
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 = exp(-im) - exp(im)
if ((t_0 <= (-0.4d0)) .or. (.not. (t_0 <= 5d-5))) then
tmp = (0.5d0 * cos(re)) * t_0
else
tmp = cos(re) * (((-0.16666666666666666d0) * (im ** 3.0d0)) - im)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double tmp;
if ((t_0 <= -0.4) || !(t_0 <= 5e-5)) {
tmp = (0.5 * Math.cos(re)) * t_0;
} else {
tmp = Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -0.4) or not (t_0 <= 5e-5): tmp = (0.5 * math.cos(re)) * t_0 else: tmp = math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= -0.4) || !(t_0 <= 5e-5)) tmp = Float64(Float64(0.5 * cos(re)) * t_0); else tmp = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im)); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -0.4) || ~((t_0 <= 5e-5))) tmp = (0.5 * cos(re)) * t_0; else tmp = cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.4], N[Not[LessEqual[t$95$0, 5e-5]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -0.4 \lor \neg \left(t_0 \leq 5 \cdot 10^{-5}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -0.40000000000000002 or 5.00000000000000024e-5 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
if -0.40000000000000002 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 5.00000000000000024e-5Initial program 7.3%
neg-sub07.3%
Simplified7.3%
Taylor expanded in im around 0 99.8%
+-commutative99.8%
mul-1-neg99.8%
unsub-neg99.8%
associate-*r*99.8%
distribute-rgt-out--99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(if (or (<= im -4.5e+111)
(not (or (<= im -0.022) (and (not (<= im 0.06)) (<= im 6e+102)))))
(* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im))
(* (- (exp (- im)) (exp im)) (+ 0.5 (* -0.25 (* re re))))))
double code(double re, double im) {
double tmp;
if ((im <= -4.5e+111) || !((im <= -0.022) || (!(im <= 0.06) && (im <= 6e+102)))) {
tmp = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
} else {
tmp = (exp(-im) - exp(im)) * (0.5 + (-0.25 * (re * re)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-4.5d+111)) .or. (.not. (im <= (-0.022d0)) .or. (.not. (im <= 0.06d0)) .and. (im <= 6d+102))) then
tmp = cos(re) * (((-0.16666666666666666d0) * (im ** 3.0d0)) - im)
else
tmp = (exp(-im) - exp(im)) * (0.5d0 + ((-0.25d0) * (re * re)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -4.5e+111) || !((im <= -0.022) || (!(im <= 0.06) && (im <= 6e+102)))) {
tmp = Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
} else {
tmp = (Math.exp(-im) - Math.exp(im)) * (0.5 + (-0.25 * (re * re)));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -4.5e+111) or not ((im <= -0.022) or (not (im <= 0.06) and (im <= 6e+102))): tmp = math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im) else: tmp = (math.exp(-im) - math.exp(im)) * (0.5 + (-0.25 * (re * re))) return tmp
function code(re, im) tmp = 0.0 if ((im <= -4.5e+111) || !((im <= -0.022) || (!(im <= 0.06) && (im <= 6e+102)))) tmp = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im)); else tmp = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 + Float64(-0.25 * Float64(re * re)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -4.5e+111) || ~(((im <= -0.022) || (~((im <= 0.06)) && (im <= 6e+102))))) tmp = cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im); else tmp = (exp(-im) - exp(im)) * (0.5 + (-0.25 * (re * re))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -4.5e+111], N[Not[Or[LessEqual[im, -0.022], And[N[Not[LessEqual[im, 0.06]], $MachinePrecision], LessEqual[im, 6e+102]]]], $MachinePrecision]], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.5 \cdot 10^{+111} \lor \neg \left(im \leq -0.022 \lor \neg \left(im \leq 0.06\right) \land im \leq 6 \cdot 10^{+102}\right):\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if im < -4.50000000000000001e111 or -0.021999999999999999 < im < 0.059999999999999998 or 5.9999999999999996e102 < im Initial program 41.8%
neg-sub041.8%
Simplified41.8%
Taylor expanded in im around 0 99.9%
+-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
associate-*r*99.9%
distribute-rgt-out--99.9%
*-commutative99.9%
Simplified99.9%
if -4.50000000000000001e111 < im < -0.021999999999999999 or 0.059999999999999998 < im < 5.9999999999999996e102Initial program 99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in re around 0 6.1%
+-commutative6.1%
associate-*r*6.1%
distribute-rgt-out83.7%
unpow283.7%
Simplified83.7%
Final simplification96.8%
(FPCore (re im)
:precision binary64
(if (or (<= im -5.5e+102)
(and (not (<= im -0.0155)) (or (<= im 0.024) (not (<= im 2.7e+99)))))
(* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im))
(* 0.5 (- (exp (- im)) (exp im)))))
double code(double re, double im) {
double tmp;
if ((im <= -5.5e+102) || (!(im <= -0.0155) && ((im <= 0.024) || !(im <= 2.7e+99)))) {
tmp = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
} else {
tmp = 0.5 * (exp(-im) - exp(im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-5.5d+102)) .or. (.not. (im <= (-0.0155d0))) .and. (im <= 0.024d0) .or. (.not. (im <= 2.7d+99))) then
tmp = cos(re) * (((-0.16666666666666666d0) * (im ** 3.0d0)) - im)
else
tmp = 0.5d0 * (exp(-im) - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -5.5e+102) || (!(im <= -0.0155) && ((im <= 0.024) || !(im <= 2.7e+99)))) {
tmp = Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
} else {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -5.5e+102) or (not (im <= -0.0155) and ((im <= 0.024) or not (im <= 2.7e+99))): tmp = math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im) else: tmp = 0.5 * (math.exp(-im) - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if ((im <= -5.5e+102) || (!(im <= -0.0155) && ((im <= 0.024) || !(im <= 2.7e+99)))) tmp = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im)); else tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -5.5e+102) || (~((im <= -0.0155)) && ((im <= 0.024) || ~((im <= 2.7e+99))))) tmp = cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im); else tmp = 0.5 * (exp(-im) - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -5.5e+102], And[N[Not[LessEqual[im, -0.0155]], $MachinePrecision], Or[LessEqual[im, 0.024], N[Not[LessEqual[im, 2.7e+99]], $MachinePrecision]]]], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -5.5 \cdot 10^{+102} \lor \neg \left(im \leq -0.0155\right) \land \left(im \leq 0.024 \lor \neg \left(im \leq 2.7 \cdot 10^{+99}\right)\right):\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\end{array}
\end{array}
if im < -5.49999999999999981e102 or -0.0155 < im < 0.024 or 2.69999999999999989e99 < im Initial program 43.2%
neg-sub043.2%
Simplified43.2%
Taylor expanded in im around 0 99.5%
+-commutative99.5%
mul-1-neg99.5%
unsub-neg99.5%
associate-*r*99.5%
distribute-rgt-out--99.5%
*-commutative99.5%
Simplified99.5%
if -5.49999999999999981e102 < im < -0.0155 or 0.024 < im < 2.69999999999999989e99Initial program 99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in re around 0 72.7%
Final simplification94.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
(t_1
(*
(- (* (* im im) (* im -0.16666666666666666)) im)
(+ 1.0 (* re (* re -0.5))))))
(if (<= im -1.5e+103)
t_1
(if (<= im -0.00011)
t_0
(if (<= im 0.0012)
(* (cos re) (- im))
(if (<= im 6.5e+51)
t_0
(if (<= im 1.8e+133)
t_1
(- (* -0.16666666666666666 (pow im 3.0)) im))))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(-im) - exp(im));
double t_1 = (((im * im) * (im * -0.16666666666666666)) - im) * (1.0 + (re * (re * -0.5)));
double tmp;
if (im <= -1.5e+103) {
tmp = t_1;
} else if (im <= -0.00011) {
tmp = t_0;
} else if (im <= 0.0012) {
tmp = cos(re) * -im;
} else if (im <= 6.5e+51) {
tmp = t_0;
} else if (im <= 1.8e+133) {
tmp = t_1;
} else {
tmp = (-0.16666666666666666 * pow(im, 3.0)) - im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * (exp(-im) - exp(im))
t_1 = (((im * im) * (im * (-0.16666666666666666d0))) - im) * (1.0d0 + (re * (re * (-0.5d0))))
if (im <= (-1.5d+103)) then
tmp = t_1
else if (im <= (-0.00011d0)) then
tmp = t_0
else if (im <= 0.0012d0) then
tmp = cos(re) * -im
else if (im <= 6.5d+51) then
tmp = t_0
else if (im <= 1.8d+133) then
tmp = t_1
else
tmp = ((-0.16666666666666666d0) * (im ** 3.0d0)) - im
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
double t_1 = (((im * im) * (im * -0.16666666666666666)) - im) * (1.0 + (re * (re * -0.5)));
double tmp;
if (im <= -1.5e+103) {
tmp = t_1;
} else if (im <= -0.00011) {
tmp = t_0;
} else if (im <= 0.0012) {
tmp = Math.cos(re) * -im;
} else if (im <= 6.5e+51) {
tmp = t_0;
} else if (im <= 1.8e+133) {
tmp = t_1;
} else {
tmp = (-0.16666666666666666 * Math.pow(im, 3.0)) - im;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.exp(-im) - math.exp(im)) t_1 = (((im * im) * (im * -0.16666666666666666)) - im) * (1.0 + (re * (re * -0.5))) tmp = 0 if im <= -1.5e+103: tmp = t_1 elif im <= -0.00011: tmp = t_0 elif im <= 0.0012: tmp = math.cos(re) * -im elif im <= 6.5e+51: tmp = t_0 elif im <= 1.8e+133: tmp = t_1 else: tmp = (-0.16666666666666666 * math.pow(im, 3.0)) - im return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))) t_1 = Float64(Float64(Float64(Float64(im * im) * Float64(im * -0.16666666666666666)) - im) * Float64(1.0 + Float64(re * Float64(re * -0.5)))) tmp = 0.0 if (im <= -1.5e+103) tmp = t_1; elseif (im <= -0.00011) tmp = t_0; elseif (im <= 0.0012) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 6.5e+51) tmp = t_0; elseif (im <= 1.8e+133) tmp = t_1; else tmp = Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (exp(-im) - exp(im)); t_1 = (((im * im) * (im * -0.16666666666666666)) - im) * (1.0 + (re * (re * -0.5))); tmp = 0.0; if (im <= -1.5e+103) tmp = t_1; elseif (im <= -0.00011) tmp = t_0; elseif (im <= 0.0012) tmp = cos(re) * -im; elseif (im <= 6.5e+51) tmp = t_0; elseif (im <= 1.8e+133) tmp = t_1; else tmp = (-0.16666666666666666 * (im ^ 3.0)) - im; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(im * im), $MachinePrecision] * N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision] * N[(1.0 + N[(re * N[(re * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.5e+103], t$95$1, If[LessEqual[im, -0.00011], t$95$0, If[LessEqual[im, 0.0012], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 6.5e+51], t$95$0, If[LessEqual[im, 1.8e+133], t$95$1, N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := \left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) - im\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\
\mathbf{if}\;im \leq -1.5 \cdot 10^{+103}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.00011:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.0012:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 6.5 \cdot 10^{+51}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 1.8 \cdot 10^{+133}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot {im}^{3} - im\\
\end{array}
\end{array}
if im < -1.5e103 or 6.5e51 < im < 1.79999999999999989e133Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 90.2%
+-commutative90.2%
mul-1-neg90.2%
unsub-neg90.2%
associate-*r*90.2%
distribute-rgt-out--90.2%
*-commutative90.2%
Simplified90.2%
Taylor expanded in re around 0 7.3%
associate--l+7.3%
associate-*r*7.3%
distribute-lft1-in82.7%
*-commutative82.7%
*-inverses82.7%
+-commutative82.7%
*-inverses82.7%
unpow282.7%
associate-*r*82.7%
*-commutative82.7%
*-commutative82.7%
Simplified82.7%
sub-neg82.7%
*-commutative82.7%
unpow382.7%
associate-*l*82.7%
fma-def82.7%
Applied egg-rr82.7%
fma-udef82.7%
Applied egg-rr82.7%
if -1.5e103 < im < -1.10000000000000004e-4 or 0.00119999999999999989 < im < 6.5e51Initial program 99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in re around 0 76.9%
if -1.10000000000000004e-4 < im < 0.00119999999999999989Initial program 7.3%
neg-sub07.3%
Simplified7.3%
Taylor expanded in im around 0 99.6%
associate-*r*99.6%
neg-mul-199.6%
Simplified99.6%
if 1.79999999999999989e133 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 90.0%
+-commutative90.0%
neg-mul-190.0%
sub-neg90.0%
Simplified90.0%
Final simplification91.3%
(FPCore (re im)
:precision binary64
(if (or (<= im -6.2e+15) (not (<= im 4.8e-20)))
(*
(- (* (* im im) (* im -0.16666666666666666)) im)
(+ 1.0 (* re (* re -0.5))))
(* (cos re) (- im))))
double code(double re, double im) {
double tmp;
if ((im <= -6.2e+15) || !(im <= 4.8e-20)) {
tmp = (((im * im) * (im * -0.16666666666666666)) - im) * (1.0 + (re * (re * -0.5)));
} else {
tmp = cos(re) * -im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-6.2d+15)) .or. (.not. (im <= 4.8d-20))) then
tmp = (((im * im) * (im * (-0.16666666666666666d0))) - im) * (1.0d0 + (re * (re * (-0.5d0))))
else
tmp = cos(re) * -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -6.2e+15) || !(im <= 4.8e-20)) {
tmp = (((im * im) * (im * -0.16666666666666666)) - im) * (1.0 + (re * (re * -0.5)));
} else {
tmp = Math.cos(re) * -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -6.2e+15) or not (im <= 4.8e-20): tmp = (((im * im) * (im * -0.16666666666666666)) - im) * (1.0 + (re * (re * -0.5))) else: tmp = math.cos(re) * -im return tmp
function code(re, im) tmp = 0.0 if ((im <= -6.2e+15) || !(im <= 4.8e-20)) tmp = Float64(Float64(Float64(Float64(im * im) * Float64(im * -0.16666666666666666)) - im) * Float64(1.0 + Float64(re * Float64(re * -0.5)))); else tmp = Float64(cos(re) * Float64(-im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -6.2e+15) || ~((im <= 4.8e-20))) tmp = (((im * im) * (im * -0.16666666666666666)) - im) * (1.0 + (re * (re * -0.5))); else tmp = cos(re) * -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -6.2e+15], N[Not[LessEqual[im, 4.8e-20]], $MachinePrecision]], N[(N[(N[(N[(im * im), $MachinePrecision] * N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision] * N[(1.0 + N[(re * N[(re * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -6.2 \cdot 10^{+15} \lor \neg \left(im \leq 4.8 \cdot 10^{-20}\right):\\
\;\;\;\;\left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) - im\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\end{array}
\end{array}
if im < -6.2e15 or 4.79999999999999986e-20 < im Initial program 99.2%
neg-sub099.2%
Simplified99.2%
Taylor expanded in im around 0 67.9%
+-commutative67.9%
mul-1-neg67.9%
unsub-neg67.9%
associate-*r*67.9%
distribute-rgt-out--67.9%
*-commutative67.9%
Simplified67.9%
Taylor expanded in re around 0 9.0%
associate--l+9.0%
associate-*r*9.0%
distribute-lft1-in63.4%
*-commutative63.4%
*-inverses63.4%
+-commutative63.4%
*-inverses63.4%
unpow263.4%
associate-*r*63.4%
*-commutative63.4%
*-commutative63.4%
Simplified63.4%
sub-neg63.4%
*-commutative63.4%
unpow363.4%
associate-*l*63.4%
fma-def63.4%
Applied egg-rr63.4%
fma-udef63.4%
Applied egg-rr63.4%
if -6.2e15 < im < 4.79999999999999986e-20Initial program 8.7%
neg-sub08.7%
Simplified8.7%
Taylor expanded in im around 0 98.1%
associate-*r*98.1%
neg-mul-198.1%
Simplified98.1%
Final simplification81.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (* 0.5 re))) (t_1 (/ (* im im) (* im (- -1.0 t_0)))))
(if (<= im -1.3e+170)
t_1
(if (<= im -7.2e+19)
(- (* im (* 0.5 (* re re))) im)
(if (<= im 1.4)
(- im)
(if (<= im 1.6e+155)
(* (+ im 1.1666666666666667) (+ -1.0 t_0))
t_1))))))
double code(double re, double im) {
double t_0 = re * (0.5 * re);
double t_1 = (im * im) / (im * (-1.0 - t_0));
double tmp;
if (im <= -1.3e+170) {
tmp = t_1;
} else if (im <= -7.2e+19) {
tmp = (im * (0.5 * (re * re))) - im;
} else if (im <= 1.4) {
tmp = -im;
} else if (im <= 1.6e+155) {
tmp = (im + 1.1666666666666667) * (-1.0 + t_0);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = re * (0.5d0 * re)
t_1 = (im * im) / (im * ((-1.0d0) - t_0))
if (im <= (-1.3d+170)) then
tmp = t_1
else if (im <= (-7.2d+19)) then
tmp = (im * (0.5d0 * (re * re))) - im
else if (im <= 1.4d0) then
tmp = -im
else if (im <= 1.6d+155) then
tmp = (im + 1.1666666666666667d0) * ((-1.0d0) + t_0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = re * (0.5 * re);
double t_1 = (im * im) / (im * (-1.0 - t_0));
double tmp;
if (im <= -1.3e+170) {
tmp = t_1;
} else if (im <= -7.2e+19) {
tmp = (im * (0.5 * (re * re))) - im;
} else if (im <= 1.4) {
tmp = -im;
} else if (im <= 1.6e+155) {
tmp = (im + 1.1666666666666667) * (-1.0 + t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = re * (0.5 * re) t_1 = (im * im) / (im * (-1.0 - t_0)) tmp = 0 if im <= -1.3e+170: tmp = t_1 elif im <= -7.2e+19: tmp = (im * (0.5 * (re * re))) - im elif im <= 1.4: tmp = -im elif im <= 1.6e+155: tmp = (im + 1.1666666666666667) * (-1.0 + t_0) else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(re * Float64(0.5 * re)) t_1 = Float64(Float64(im * im) / Float64(im * Float64(-1.0 - t_0))) tmp = 0.0 if (im <= -1.3e+170) tmp = t_1; elseif (im <= -7.2e+19) tmp = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im); elseif (im <= 1.4) tmp = Float64(-im); elseif (im <= 1.6e+155) tmp = Float64(Float64(im + 1.1666666666666667) * Float64(-1.0 + t_0)); else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = re * (0.5 * re); t_1 = (im * im) / (im * (-1.0 - t_0)); tmp = 0.0; if (im <= -1.3e+170) tmp = t_1; elseif (im <= -7.2e+19) tmp = (im * (0.5 * (re * re))) - im; elseif (im <= 1.4) tmp = -im; elseif (im <= 1.6e+155) tmp = (im + 1.1666666666666667) * (-1.0 + t_0); else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(im * im), $MachinePrecision] / N[(im * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.3e+170], t$95$1, If[LessEqual[im, -7.2e+19], N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 1.4], (-im), If[LessEqual[im, 1.6e+155], N[(N[(im + 1.1666666666666667), $MachinePrecision] * N[(-1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \left(0.5 \cdot re\right)\\
t_1 := \frac{im \cdot im}{im \cdot \left(-1 - t_0\right)}\\
\mathbf{if}\;im \leq -1.3 \cdot 10^{+170}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -7.2 \cdot 10^{+19}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\
\mathbf{elif}\;im \leq 1.4:\\
\;\;\;\;-im\\
\mathbf{elif}\;im \leq 1.6 \cdot 10^{+155}:\\
\;\;\;\;\left(im + 1.1666666666666667\right) \cdot \left(-1 + t_0\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -1.2999999999999999e170 or 1.60000000000000006e155 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 0.0%
+-commutative0.0%
associate-*r*0.0%
distribute-rgt-out85.2%
unpow285.2%
Simplified85.2%
Taylor expanded in im around 0 14.4%
distribute-lft-in14.4%
flip-+57.4%
Applied egg-rr57.4%
Simplified75.9%
Taylor expanded in re around 0 70.4%
unpow270.4%
Simplified70.4%
if -1.2999999999999999e170 < im < -7.2e19Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 3.9%
associate-*r*3.9%
neg-mul-13.9%
Simplified3.9%
Taylor expanded in re around 0 26.8%
+-commutative26.8%
neg-mul-126.8%
unsub-neg26.8%
*-commutative26.8%
associate-*l*26.8%
*-commutative26.8%
unpow226.8%
Simplified26.8%
if -7.2e19 < im < 1.3999999999999999Initial program 10.7%
neg-sub010.7%
Simplified10.7%
Taylor expanded in im around 0 96.2%
associate-*r*96.2%
neg-mul-196.2%
Simplified96.2%
Taylor expanded in re around 0 55.0%
neg-mul-155.0%
Simplified55.0%
if 1.3999999999999999 < im < 1.60000000000000006e155Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 47.8%
+-commutative47.8%
mul-1-neg47.8%
unsub-neg47.8%
associate-*r*47.8%
distribute-rgt-out--47.8%
*-commutative47.8%
Simplified47.8%
Applied egg-rr4.9%
Taylor expanded in re around 0 24.2%
distribute-lft-in24.2%
metadata-eval24.2%
neg-mul-124.2%
sub-neg24.2%
+-commutative24.2%
unpow224.2%
associate-*r*24.2%
*-commutative24.2%
associate-*r*24.2%
sub-neg24.2%
metadata-eval24.2%
neg-mul-124.2%
distribute-lft-in24.2%
distribute-rgt-out24.2%
+-commutative24.2%
Simplified24.2%
Final simplification50.5%
(FPCore (re im)
:precision binary64
(if (or (<= im -2.1e+15) (not (<= im 1.7e-24)))
(*
(- (* (* im im) (* im -0.16666666666666666)) im)
(+ 1.0 (* re (* re -0.5))))
(- im)))
double code(double re, double im) {
double tmp;
if ((im <= -2.1e+15) || !(im <= 1.7e-24)) {
tmp = (((im * im) * (im * -0.16666666666666666)) - im) * (1.0 + (re * (re * -0.5)));
} else {
tmp = -im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-2.1d+15)) .or. (.not. (im <= 1.7d-24))) then
tmp = (((im * im) * (im * (-0.16666666666666666d0))) - im) * (1.0d0 + (re * (re * (-0.5d0))))
else
tmp = -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -2.1e+15) || !(im <= 1.7e-24)) {
tmp = (((im * im) * (im * -0.16666666666666666)) - im) * (1.0 + (re * (re * -0.5)));
} else {
tmp = -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -2.1e+15) or not (im <= 1.7e-24): tmp = (((im * im) * (im * -0.16666666666666666)) - im) * (1.0 + (re * (re * -0.5))) else: tmp = -im return tmp
function code(re, im) tmp = 0.0 if ((im <= -2.1e+15) || !(im <= 1.7e-24)) tmp = Float64(Float64(Float64(Float64(im * im) * Float64(im * -0.16666666666666666)) - im) * Float64(1.0 + Float64(re * Float64(re * -0.5)))); else tmp = Float64(-im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -2.1e+15) || ~((im <= 1.7e-24))) tmp = (((im * im) * (im * -0.16666666666666666)) - im) * (1.0 + (re * (re * -0.5))); else tmp = -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -2.1e+15], N[Not[LessEqual[im, 1.7e-24]], $MachinePrecision]], N[(N[(N[(N[(im * im), $MachinePrecision] * N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision] * N[(1.0 + N[(re * N[(re * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-im)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.1 \cdot 10^{+15} \lor \neg \left(im \leq 1.7 \cdot 10^{-24}\right):\\
\;\;\;\;\left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) - im\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-im\\
\end{array}
\end{array}
if im < -2.1e15 or 1.69999999999999996e-24 < im Initial program 98.4%
neg-sub098.4%
Simplified98.4%
Taylor expanded in im around 0 68.2%
+-commutative68.2%
mul-1-neg68.2%
unsub-neg68.2%
associate-*r*68.2%
distribute-rgt-out--68.2%
*-commutative68.2%
Simplified68.2%
Taylor expanded in re around 0 8.9%
associate--l+8.9%
associate-*r*8.9%
distribute-lft1-in62.9%
*-commutative62.9%
*-inverses62.9%
+-commutative62.9%
*-inverses62.9%
unpow262.9%
associate-*r*62.9%
*-commutative62.9%
*-commutative62.9%
Simplified62.9%
sub-neg62.9%
*-commutative62.9%
unpow362.9%
associate-*l*62.9%
fma-def62.9%
Applied egg-rr62.9%
fma-udef62.9%
Applied egg-rr62.9%
if -2.1e15 < im < 1.69999999999999996e-24Initial program 8.8%
neg-sub08.8%
Simplified8.8%
Taylor expanded in im around 0 98.1%
associate-*r*98.1%
neg-mul-198.1%
Simplified98.1%
Taylor expanded in re around 0 56.1%
neg-mul-156.1%
Simplified56.1%
Final simplification59.4%
(FPCore (re im) :precision binary64 (if (<= re 5.7e+110) (- im) (* 0.5 (* im (* re re)))))
double code(double re, double im) {
double tmp;
if (re <= 5.7e+110) {
tmp = -im;
} else {
tmp = 0.5 * (im * (re * re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 5.7d+110) then
tmp = -im
else
tmp = 0.5d0 * (im * (re * re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 5.7e+110) {
tmp = -im;
} else {
tmp = 0.5 * (im * (re * re));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 5.7e+110: tmp = -im else: tmp = 0.5 * (im * (re * re)) return tmp
function code(re, im) tmp = 0.0 if (re <= 5.7e+110) tmp = Float64(-im); else tmp = Float64(0.5 * Float64(im * Float64(re * re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 5.7e+110) tmp = -im; else tmp = 0.5 * (im * (re * re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 5.7e+110], (-im), N[(0.5 * N[(im * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 5.7 \cdot 10^{+110}:\\
\;\;\;\;-im\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if re < 5.7000000000000002e110Initial program 55.1%
neg-sub055.1%
Simplified55.1%
Taylor expanded in im around 0 51.2%
associate-*r*51.2%
neg-mul-151.2%
Simplified51.2%
Taylor expanded in re around 0 35.3%
neg-mul-135.3%
Simplified35.3%
if 5.7000000000000002e110 < re Initial program 41.5%
neg-sub041.5%
Simplified41.5%
Taylor expanded in re around 0 1.1%
+-commutative1.1%
associate-*r*1.1%
distribute-rgt-out23.0%
unpow223.0%
Simplified23.0%
Taylor expanded in im around 0 23.2%
Taylor expanded in re around inf 23.2%
unpow223.2%
Simplified23.2%
Final simplification33.4%
(FPCore (re im) :precision binary64 (if (<= re 5.7e+110) (- im) (* re (* re (* im 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= 5.7e+110) {
tmp = -im;
} else {
tmp = re * (re * (im * 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 <= 5.7d+110) then
tmp = -im
else
tmp = re * (re * (im * 0.5d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 5.7e+110) {
tmp = -im;
} else {
tmp = re * (re * (im * 0.5));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 5.7e+110: tmp = -im else: tmp = re * (re * (im * 0.5)) return tmp
function code(re, im) tmp = 0.0 if (re <= 5.7e+110) tmp = Float64(-im); else tmp = Float64(re * Float64(re * Float64(im * 0.5))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 5.7e+110) tmp = -im; else tmp = re * (re * (im * 0.5)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 5.7e+110], (-im), N[(re * N[(re * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 5.7 \cdot 10^{+110}:\\
\;\;\;\;-im\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < 5.7000000000000002e110Initial program 55.1%
neg-sub055.1%
Simplified55.1%
Taylor expanded in im around 0 51.2%
associate-*r*51.2%
neg-mul-151.2%
Simplified51.2%
Taylor expanded in re around 0 35.3%
neg-mul-135.3%
Simplified35.3%
if 5.7000000000000002e110 < re Initial program 41.5%
neg-sub041.5%
Simplified41.5%
Taylor expanded in re around 0 1.1%
+-commutative1.1%
associate-*r*1.1%
distribute-rgt-out23.0%
unpow223.0%
Simplified23.0%
Taylor expanded in im around 0 23.2%
Taylor expanded in re around inf 23.2%
*-commutative23.2%
unpow223.2%
*-commutative23.2%
associate-*r*23.2%
associate-*l*23.3%
Simplified23.3%
Final simplification33.4%
(FPCore (re im) :precision binary64 (- (* im (* 0.5 (* re re))) im))
double code(double re, double im) {
return (im * (0.5 * (re * re))) - im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (im * (0.5d0 * (re * re))) - im
end function
public static double code(double re, double im) {
return (im * (0.5 * (re * re))) - im;
}
def code(re, im): return (im * (0.5 * (re * re))) - im
function code(re, im) return Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im) end
function tmp = code(re, im) tmp = (im * (0.5 * (re * re))) - im; end
code[re_, im_] := N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im
\end{array}
Initial program 52.9%
neg-sub052.9%
Simplified52.9%
Taylor expanded in im around 0 53.3%
associate-*r*53.3%
neg-mul-153.3%
Simplified53.3%
Taylor expanded in re around 0 36.3%
+-commutative36.3%
neg-mul-136.3%
unsub-neg36.3%
*-commutative36.3%
associate-*l*36.3%
*-commutative36.3%
unpow236.3%
Simplified36.3%
Final simplification36.3%
(FPCore (re im) :precision binary64 (- (* re (* re (* im 0.5))) im))
double code(double re, double im) {
return (re * (re * (im * 0.5))) - im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (re * (re * (im * 0.5d0))) - im
end function
public static double code(double re, double im) {
return (re * (re * (im * 0.5))) - im;
}
def code(re, im): return (re * (re * (im * 0.5))) - im
function code(re, im) return Float64(Float64(re * Float64(re * Float64(im * 0.5))) - im) end
function tmp = code(re, im) tmp = (re * (re * (im * 0.5))) - im; end
code[re_, im_] := N[(N[(re * N[(re * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]
\begin{array}{l}
\\
re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im
\end{array}
Initial program 52.9%
neg-sub052.9%
Simplified52.9%
Taylor expanded in re around 0 3.8%
+-commutative3.8%
associate-*r*3.8%
distribute-rgt-out43.6%
unpow243.6%
Simplified43.6%
Taylor expanded in im around 0 36.3%
Taylor expanded in im around 0 36.3%
distribute-lft-in36.3%
unpow236.3%
*-commutative36.3%
associate-*r*36.3%
distribute-lft-in36.3%
*-commutative36.3%
associate-*r*36.3%
metadata-eval36.3%
neg-mul-136.3%
associate-*r*36.3%
*-commutative36.3%
associate-*r*36.3%
*-commutative36.3%
associate-*r*36.3%
associate-*l*36.3%
metadata-eval36.3%
*-commutative36.3%
associate-*r*36.3%
unpow236.3%
+-commutative36.3%
unsub-neg36.3%
Simplified36.4%
Final simplification36.4%
(FPCore (re im) :precision binary64 (if (<= re 4.4e+171) (- im) (* re re)))
double code(double re, double im) {
double tmp;
if (re <= 4.4e+171) {
tmp = -im;
} else {
tmp = re * 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.4d+171) then
tmp = -im
else
tmp = re * re
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 4.4e+171) {
tmp = -im;
} else {
tmp = re * re;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 4.4e+171: tmp = -im else: tmp = re * re return tmp
function code(re, im) tmp = 0.0 if (re <= 4.4e+171) tmp = Float64(-im); else tmp = Float64(re * re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 4.4e+171) tmp = -im; else tmp = re * re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 4.4e+171], (-im), N[(re * re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 4.4 \cdot 10^{+171}:\\
\;\;\;\;-im\\
\mathbf{else}:\\
\;\;\;\;re \cdot re\\
\end{array}
\end{array}
if re < 4.3999999999999999e171Initial program 53.0%
neg-sub053.0%
Simplified53.0%
Taylor expanded in im around 0 53.1%
associate-*r*53.1%
neg-mul-153.1%
Simplified53.1%
Taylor expanded in re around 0 33.8%
neg-mul-133.8%
Simplified33.8%
if 4.3999999999999999e171 < re Initial program 51.9%
neg-sub051.9%
Simplified51.9%
Taylor expanded in re around 0 0.1%
+-commutative0.1%
associate-*r*0.1%
distribute-rgt-out25.1%
unpow225.1%
Simplified25.1%
Applied egg-rr25.8%
fma-neg25.8%
Simplified25.8%
Taylor expanded in re around inf 25.8%
unpow225.8%
Simplified25.8%
Final simplification32.9%
(FPCore (re im) :precision binary64 (- im))
double code(double re, double im) {
return -im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -im
end function
public static double code(double re, double im) {
return -im;
}
def code(re, im): return -im
function code(re, im) return Float64(-im) end
function tmp = code(re, im) tmp = -im; end
code[re_, im_] := (-im)
\begin{array}{l}
\\
-im
\end{array}
Initial program 52.9%
neg-sub052.9%
Simplified52.9%
Taylor expanded in im around 0 53.3%
associate-*r*53.3%
neg-mul-153.3%
Simplified53.3%
Taylor expanded in re around 0 31.0%
neg-mul-131.0%
Simplified31.0%
Final simplification31.0%
(FPCore (re im) :precision binary64 re)
double code(double re, double im) {
return re;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re
end function
public static double code(double re, double im) {
return re;
}
def code(re, im): return re
function code(re, im) return re end
function tmp = code(re, im) tmp = re; end
code[re_, im_] := re
\begin{array}{l}
\\
re
\end{array}
Initial program 52.9%
neg-sub052.9%
Simplified52.9%
Taylor expanded in re around 0 3.8%
+-commutative3.8%
associate-*r*3.8%
distribute-rgt-out43.6%
unpow243.6%
Simplified43.6%
Applied egg-rr2.9%
unpow12.9%
*-inverses2.9%
sqr-pow1.7%
fabs-sqr1.7%
sqr-pow3.1%
*-inverses3.1%
unpow13.1%
Simplified3.1%
Final simplification3.1%
(FPCore (re im)
:precision binary64
(if (< (fabs im) 1.0)
(-
(*
(cos re)
(+
(+ im (* (* (* 0.16666666666666666 im) im) im))
(* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
double code(double re, double im) {
double tmp;
if (fabs(im) < 1.0) {
tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (abs(im) < 1.0d0) then
tmp = -(cos(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
else
tmp = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.abs(im) < 1.0) {
tmp = -(Math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if math.fabs(im) < 1.0: tmp = -(math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))) else: tmp = (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (abs(im) < 1.0) tmp = Float64(-Float64(cos(re) * Float64(Float64(im + Float64(Float64(Float64(0.16666666666666666 * im) * im) * im)) + Float64(Float64(Float64(Float64(Float64(0.008333333333333333 * im) * im) * im) * im) * im)))); else tmp = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (abs(im) < 1.0) tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))); else tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Cos[re], $MachinePrecision] * N[(N[(im + N[(N[(N[(0.16666666666666666 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[(0.008333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\
\end{array}
\end{array}
herbie shell --seed 2023275
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
:herbie-target
(if (< (fabs im) 1.0) (- (* (cos re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))