
(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 13 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))) (t_1 (* 0.5 (cos re))))
(if (or (<= t_0 -5e+66) (not (<= t_0 2e-5)))
(* t_1 t_0)
(*
t_1
(+
(* -0.0003968253968253968 (pow im 7.0))
(+
(* im -2.0)
(+
(* -0.016666666666666666 (pow im 5.0))
(* -0.3333333333333333 (pow im 3.0)))))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double t_1 = 0.5 * cos(re);
double tmp;
if ((t_0 <= -5e+66) || !(t_0 <= 2e-5)) {
tmp = t_1 * t_0;
} else {
tmp = t_1 * ((-0.0003968253968253968 * pow(im, 7.0)) + ((im * -2.0) + ((-0.016666666666666666 * pow(im, 5.0)) + (-0.3333333333333333 * pow(im, 3.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) :: t_1
real(8) :: tmp
t_0 = exp(-im) - exp(im)
t_1 = 0.5d0 * cos(re)
if ((t_0 <= (-5d+66)) .or. (.not. (t_0 <= 2d-5))) then
tmp = t_1 * t_0
else
tmp = t_1 * (((-0.0003968253968253968d0) * (im ** 7.0d0)) + ((im * (-2.0d0)) + (((-0.016666666666666666d0) * (im ** 5.0d0)) + ((-0.3333333333333333d0) * (im ** 3.0d0)))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double t_1 = 0.5 * Math.cos(re);
double tmp;
if ((t_0 <= -5e+66) || !(t_0 <= 2e-5)) {
tmp = t_1 * t_0;
} else {
tmp = t_1 * ((-0.0003968253968253968 * Math.pow(im, 7.0)) + ((im * -2.0) + ((-0.016666666666666666 * Math.pow(im, 5.0)) + (-0.3333333333333333 * Math.pow(im, 3.0)))));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) t_1 = 0.5 * math.cos(re) tmp = 0 if (t_0 <= -5e+66) or not (t_0 <= 2e-5): tmp = t_1 * t_0 else: tmp = t_1 * ((-0.0003968253968253968 * math.pow(im, 7.0)) + ((im * -2.0) + ((-0.016666666666666666 * math.pow(im, 5.0)) + (-0.3333333333333333 * math.pow(im, 3.0))))) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) t_1 = Float64(0.5 * cos(re)) tmp = 0.0 if ((t_0 <= -5e+66) || !(t_0 <= 2e-5)) tmp = Float64(t_1 * t_0); else tmp = Float64(t_1 * Float64(Float64(-0.0003968253968253968 * (im ^ 7.0)) + Float64(Float64(im * -2.0) + Float64(Float64(-0.016666666666666666 * (im ^ 5.0)) + Float64(-0.3333333333333333 * (im ^ 3.0)))))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); t_1 = 0.5 * cos(re); tmp = 0.0; if ((t_0 <= -5e+66) || ~((t_0 <= 2e-5))) tmp = t_1 * t_0; else tmp = t_1 * ((-0.0003968253968253968 * (im ^ 7.0)) + ((im * -2.0) + ((-0.016666666666666666 * (im ^ 5.0)) + (-0.3333333333333333 * (im ^ 3.0))))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e+66], N[Not[LessEqual[t$95$0, 2e-5]], $MachinePrecision]], N[(t$95$1 * t$95$0), $MachinePrecision], N[(t$95$1 * N[(N[(-0.0003968253968253968 * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision] + N[(N[(im * -2.0), $MachinePrecision] + N[(N[(-0.016666666666666666 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision] + N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := 0.5 \cdot \cos re\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+66} \lor \neg \left(t_0 \leq 2 \cdot 10^{-5}\right):\\
\;\;\;\;t_1 \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(-0.0003968253968253968 \cdot {im}^{7} + \left(im \cdot -2 + \left(-0.016666666666666666 \cdot {im}^{5} + -0.3333333333333333 \cdot {im}^{3}\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -4.99999999999999991e66 or 2.00000000000000016e-5 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
if -4.99999999999999991e66 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 2.00000000000000016e-5Initial program 7.9%
sub0-neg7.9%
Simplified7.9%
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 -5e+66) (not (<= t_0 2e-5)))
(* (* 0.5 (cos re)) t_0)
(*
(cos re)
(+
(- (* (pow im 3.0) -0.16666666666666666) im)
(+
(* (pow im 7.0) -0.0001984126984126984)
(* (pow im 5.0) -0.008333333333333333)))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -5e+66) || !(t_0 <= 2e-5)) {
tmp = (0.5 * cos(re)) * t_0;
} else {
tmp = cos(re) * (((pow(im, 3.0) * -0.16666666666666666) - im) + ((pow(im, 7.0) * -0.0001984126984126984) + (pow(im, 5.0) * -0.008333333333333333)));
}
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 <= (-5d+66)) .or. (.not. (t_0 <= 2d-5))) then
tmp = (0.5d0 * cos(re)) * t_0
else
tmp = cos(re) * ((((im ** 3.0d0) * (-0.16666666666666666d0)) - im) + (((im ** 7.0d0) * (-0.0001984126984126984d0)) + ((im ** 5.0d0) * (-0.008333333333333333d0))))
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 <= -5e+66) || !(t_0 <= 2e-5)) {
tmp = (0.5 * Math.cos(re)) * t_0;
} else {
tmp = Math.cos(re) * (((Math.pow(im, 3.0) * -0.16666666666666666) - im) + ((Math.pow(im, 7.0) * -0.0001984126984126984) + (Math.pow(im, 5.0) * -0.008333333333333333)));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -5e+66) or not (t_0 <= 2e-5): tmp = (0.5 * math.cos(re)) * t_0 else: tmp = math.cos(re) * (((math.pow(im, 3.0) * -0.16666666666666666) - im) + ((math.pow(im, 7.0) * -0.0001984126984126984) + (math.pow(im, 5.0) * -0.008333333333333333))) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= -5e+66) || !(t_0 <= 2e-5)) tmp = Float64(Float64(0.5 * cos(re)) * t_0); else tmp = Float64(cos(re) * Float64(Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) + Float64(Float64((im ^ 7.0) * -0.0001984126984126984) + Float64((im ^ 5.0) * -0.008333333333333333)))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -5e+66) || ~((t_0 <= 2e-5))) tmp = (0.5 * cos(re)) * t_0; else tmp = cos(re) * ((((im ^ 3.0) * -0.16666666666666666) - im) + (((im ^ 7.0) * -0.0001984126984126984) + ((im ^ 5.0) * -0.008333333333333333))); 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, -5e+66], N[Not[LessEqual[t$95$0, 2e-5]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision] + N[(N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+66} \lor \neg \left(t_0 \leq 2 \cdot 10^{-5}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(\left({im}^{3} \cdot -0.16666666666666666 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -4.99999999999999991e66 or 2.00000000000000016e-5 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
if -4.99999999999999991e66 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 2.00000000000000016e-5Initial program 7.9%
sub0-neg7.9%
Simplified7.9%
Taylor expanded in im around 0 99.8%
associate-+r+99.8%
+-commutative99.8%
mul-1-neg99.8%
*-commutative99.8%
distribute-lft-neg-in99.8%
*-commutative99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
*-commutative99.8%
associate-*l*99.8%
*-commutative99.8%
associate-*l*99.8%
distribute-lft-out99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (or (<= t_0 -0.05) (not (<= t_0 2e-5)))
(* (* 0.5 (cos re)) t_0)
(* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im)))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -0.05) || !(t_0 <= 2e-5)) {
tmp = (0.5 * cos(re)) * t_0;
} else {
tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - 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.05d0)) .or. (.not. (t_0 <= 2d-5))) then
tmp = (0.5d0 * cos(re)) * t_0
else
tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - 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.05) || !(t_0 <= 2e-5)) {
tmp = (0.5 * Math.cos(re)) * t_0;
} else {
tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -0.05) or not (t_0 <= 2e-5): tmp = (0.5 * math.cos(re)) * t_0 else: tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= -0.05) || !(t_0 <= 2e-5)) tmp = Float64(Float64(0.5 * cos(re)) * t_0); else tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -0.05) || ~((t_0 <= 2e-5))) tmp = (0.5 * cos(re)) * t_0; else tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - 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.05], N[Not[LessEqual[t$95$0, 2e-5]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -0.05 \lor \neg \left(t_0 \leq 2 \cdot 10^{-5}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -0.050000000000000003 or 2.00000000000000016e-5 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
if -0.050000000000000003 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 2.00000000000000016e-5Initial program 7.2%
sub0-neg7.2%
Simplified7.2%
Taylor expanded in im around 0 99.8%
mul-1-neg99.8%
unsub-neg99.8%
*-commutative99.8%
associate-*l*99.8%
distribute-lft-out--99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im)))
(t_1 (* (pow im 7.0) (* (cos re) -0.0001984126984126984))))
(if (<= im -3.3e+85)
t_1
(if (<= im -0.55)
(* t_0 (+ 0.5 (* re (* re -0.25))))
(if (<= im 0.0275)
(* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))
(if (<= im 2.5e+36) (* 0.5 t_0) t_1))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double t_1 = pow(im, 7.0) * (cos(re) * -0.0001984126984126984);
double tmp;
if (im <= -3.3e+85) {
tmp = t_1;
} else if (im <= -0.55) {
tmp = t_0 * (0.5 + (re * (re * -0.25)));
} else if (im <= 0.0275) {
tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 2.5e+36) {
tmp = 0.5 * 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 = exp(-im) - exp(im)
t_1 = (im ** 7.0d0) * (cos(re) * (-0.0001984126984126984d0))
if (im <= (-3.3d+85)) then
tmp = t_1
else if (im <= (-0.55d0)) then
tmp = t_0 * (0.5d0 + (re * (re * (-0.25d0))))
else if (im <= 0.0275d0) then
tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else if (im <= 2.5d+36) then
tmp = 0.5d0 * t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double t_1 = Math.pow(im, 7.0) * (Math.cos(re) * -0.0001984126984126984);
double tmp;
if (im <= -3.3e+85) {
tmp = t_1;
} else if (im <= -0.55) {
tmp = t_0 * (0.5 + (re * (re * -0.25)));
} else if (im <= 0.0275) {
tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 2.5e+36) {
tmp = 0.5 * t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) t_1 = math.pow(im, 7.0) * (math.cos(re) * -0.0001984126984126984) tmp = 0 if im <= -3.3e+85: tmp = t_1 elif im <= -0.55: tmp = t_0 * (0.5 + (re * (re * -0.25))) elif im <= 0.0275: tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) elif im <= 2.5e+36: tmp = 0.5 * t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) t_1 = Float64((im ^ 7.0) * Float64(cos(re) * -0.0001984126984126984)) tmp = 0.0 if (im <= -3.3e+85) tmp = t_1; elseif (im <= -0.55) tmp = Float64(t_0 * Float64(0.5 + Float64(re * Float64(re * -0.25)))); elseif (im <= 0.0275) tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); elseif (im <= 2.5e+36) tmp = Float64(0.5 * t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); t_1 = (im ^ 7.0) * (cos(re) * -0.0001984126984126984); tmp = 0.0; if (im <= -3.3e+85) tmp = t_1; elseif (im <= -0.55) tmp = t_0 * (0.5 + (re * (re * -0.25))); elseif (im <= 0.0275) tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im); elseif (im <= 2.5e+36) tmp = 0.5 * t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[im, 7.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -3.3e+85], t$95$1, If[LessEqual[im, -0.55], N[(t$95$0 * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 0.0275], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.5e+36], N[(0.5 * t$95$0), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -3.3 \cdot 10^{+85}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.55:\\
\;\;\;\;t_0 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\
\mathbf{elif}\;im \leq 0.0275:\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+36}:\\
\;\;\;\;0.5 \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -3.2999999999999999e85 or 2.49999999999999988e36 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 99.1%
Taylor expanded in im around inf 99.1%
*-commutative99.1%
*-commutative99.1%
associate-*l*99.1%
Simplified99.1%
if -3.2999999999999999e85 < im < -0.55000000000000004Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
associate-*r*0.0%
distribute-rgt-out95.7%
+-commutative95.7%
*-commutative95.7%
unpow295.7%
associate-*l*95.7%
Simplified95.7%
if -0.55000000000000004 < im < 0.0275000000000000001Initial program 7.2%
sub0-neg7.2%
Simplified7.2%
Taylor expanded in im around 0 99.8%
mul-1-neg99.8%
unsub-neg99.8%
*-commutative99.8%
associate-*l*99.8%
distribute-lft-out--99.8%
Simplified99.8%
if 0.0275000000000000001 < im < 2.49999999999999988e36Initial program 99.5%
sub0-neg99.5%
Simplified99.5%
Taylor expanded in re around 0 89.6%
Final simplification98.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (- (exp (- im)) (exp im)))))
(if (<= im -0.00032)
t_0
(if (<= im 0.00112)
(* (cos re) (- im))
(if (<= im 1.02e+101)
t_0
(*
(- (* (pow im 3.0) -0.16666666666666666) im)
(+ (* (* re re) -0.5) 1.0)))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(-im) - exp(im));
double tmp;
if (im <= -0.00032) {
tmp = t_0;
} else if (im <= 0.00112) {
tmp = cos(re) * -im;
} else if (im <= 1.02e+101) {
tmp = t_0;
} else {
tmp = ((pow(im, 3.0) * -0.16666666666666666) - im) * (((re * re) * -0.5) + 1.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 = 0.5d0 * (exp(-im) - exp(im))
if (im <= (-0.00032d0)) then
tmp = t_0
else if (im <= 0.00112d0) then
tmp = cos(re) * -im
else if (im <= 1.02d+101) then
tmp = t_0
else
tmp = (((im ** 3.0d0) * (-0.16666666666666666d0)) - im) * (((re * re) * (-0.5d0)) + 1.0d0)
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 tmp;
if (im <= -0.00032) {
tmp = t_0;
} else if (im <= 0.00112) {
tmp = Math.cos(re) * -im;
} else if (im <= 1.02e+101) {
tmp = t_0;
} else {
tmp = ((Math.pow(im, 3.0) * -0.16666666666666666) - im) * (((re * re) * -0.5) + 1.0);
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.exp(-im) - math.exp(im)) tmp = 0 if im <= -0.00032: tmp = t_0 elif im <= 0.00112: tmp = math.cos(re) * -im elif im <= 1.02e+101: tmp = t_0 else: tmp = ((math.pow(im, 3.0) * -0.16666666666666666) - im) * (((re * re) * -0.5) + 1.0) return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))) tmp = 0.0 if (im <= -0.00032) tmp = t_0; elseif (im <= 0.00112) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 1.02e+101) tmp = t_0; else tmp = Float64(Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) * Float64(Float64(Float64(re * re) * -0.5) + 1.0)); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (exp(-im) - exp(im)); tmp = 0.0; if (im <= -0.00032) tmp = t_0; elseif (im <= 0.00112) tmp = cos(re) * -im; elseif (im <= 1.02e+101) tmp = t_0; else tmp = (((im ^ 3.0) * -0.16666666666666666) - im) * (((re * re) * -0.5) + 1.0); 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]}, If[LessEqual[im, -0.00032], t$95$0, If[LessEqual[im, 0.00112], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 1.02e+101], t$95$0, N[(N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision] * N[(N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{if}\;im \leq -0.00032:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.00112:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 1.02 \cdot 10^{+101}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(\left(re \cdot re\right) \cdot -0.5 + 1\right)\\
\end{array}
\end{array}
if im < -3.20000000000000026e-4 or 0.0011199999999999999 < im < 1.02000000000000002e101Initial program 99.9%
sub0-neg99.9%
Simplified99.9%
Taylor expanded in re around 0 78.2%
if -3.20000000000000026e-4 < im < 0.0011199999999999999Initial program 7.2%
sub0-neg7.2%
Simplified7.2%
Taylor expanded in im around 0 99.3%
mul-1-neg99.3%
*-commutative99.3%
distribute-lft-neg-in99.3%
Simplified99.3%
if 1.02000000000000002e101 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 98.0%
mul-1-neg98.0%
unsub-neg98.0%
*-commutative98.0%
associate-*l*98.0%
distribute-lft-out--98.0%
Simplified98.0%
Taylor expanded in re around 0 2.3%
sub-neg2.3%
*-commutative2.3%
associate-+r+2.3%
fma-def2.3%
associate-*r*2.3%
*-commutative2.3%
fma-neg2.3%
*-lft-identity2.3%
distribute-rgt-out81.4%
fma-neg81.4%
*-commutative81.4%
unpow281.4%
Simplified81.4%
Final simplification88.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (pow im 7.0) (* (cos re) -0.0001984126984126984))))
(if (<= im -4.2)
t_0
(if (<= im 0.00089)
(* (cos re) (- im))
(if (<= im 2.5e+36) (* 0.5 (- (exp (- im)) (exp im))) t_0)))))
double code(double re, double im) {
double t_0 = pow(im, 7.0) * (cos(re) * -0.0001984126984126984);
double tmp;
if (im <= -4.2) {
tmp = t_0;
} else if (im <= 0.00089) {
tmp = cos(re) * -im;
} else if (im <= 2.5e+36) {
tmp = 0.5 * (exp(-im) - exp(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 = (im ** 7.0d0) * (cos(re) * (-0.0001984126984126984d0))
if (im <= (-4.2d0)) then
tmp = t_0
else if (im <= 0.00089d0) then
tmp = cos(re) * -im
else if (im <= 2.5d+36) then
tmp = 0.5d0 * (exp(-im) - exp(im))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.pow(im, 7.0) * (Math.cos(re) * -0.0001984126984126984);
double tmp;
if (im <= -4.2) {
tmp = t_0;
} else if (im <= 0.00089) {
tmp = Math.cos(re) * -im;
} else if (im <= 2.5e+36) {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = math.pow(im, 7.0) * (math.cos(re) * -0.0001984126984126984) tmp = 0 if im <= -4.2: tmp = t_0 elif im <= 0.00089: tmp = math.cos(re) * -im elif im <= 2.5e+36: tmp = 0.5 * (math.exp(-im) - math.exp(im)) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64((im ^ 7.0) * Float64(cos(re) * -0.0001984126984126984)) tmp = 0.0 if (im <= -4.2) tmp = t_0; elseif (im <= 0.00089) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 2.5e+36) tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = (im ^ 7.0) * (cos(re) * -0.0001984126984126984); tmp = 0.0; if (im <= -4.2) tmp = t_0; elseif (im <= 0.00089) tmp = cos(re) * -im; elseif (im <= 2.5e+36) tmp = 0.5 * (exp(-im) - exp(im)); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 7.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4.2], t$95$0, If[LessEqual[im, 0.00089], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 2.5e+36], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -4.2:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.00089:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+36}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -4.20000000000000018 or 2.49999999999999988e36 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 93.2%
Taylor expanded in im around inf 93.2%
*-commutative93.2%
*-commutative93.2%
associate-*l*93.2%
Simplified93.2%
if -4.20000000000000018 < im < 8.8999999999999995e-4Initial program 7.2%
sub0-neg7.2%
Simplified7.2%
Taylor expanded in im around 0 99.3%
mul-1-neg99.3%
*-commutative99.3%
distribute-lft-neg-in99.3%
Simplified99.3%
if 8.8999999999999995e-4 < im < 2.49999999999999988e36Initial program 99.5%
sub0-neg99.5%
Simplified99.5%
Taylor expanded in re around 0 89.6%
Final simplification95.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (pow im 7.0) (* (cos re) -0.0001984126984126984))))
(if (<= im -5.6)
t_0
(if (<= im 0.03)
(* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))
(if (<= im 2.5e+36) (* 0.5 (- (exp (- im)) (exp im))) t_0)))))
double code(double re, double im) {
double t_0 = pow(im, 7.0) * (cos(re) * -0.0001984126984126984);
double tmp;
if (im <= -5.6) {
tmp = t_0;
} else if (im <= 0.03) {
tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 2.5e+36) {
tmp = 0.5 * (exp(-im) - exp(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 = (im ** 7.0d0) * (cos(re) * (-0.0001984126984126984d0))
if (im <= (-5.6d0)) then
tmp = t_0
else if (im <= 0.03d0) then
tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else if (im <= 2.5d+36) then
tmp = 0.5d0 * (exp(-im) - exp(im))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.pow(im, 7.0) * (Math.cos(re) * -0.0001984126984126984);
double tmp;
if (im <= -5.6) {
tmp = t_0;
} else if (im <= 0.03) {
tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 2.5e+36) {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = math.pow(im, 7.0) * (math.cos(re) * -0.0001984126984126984) tmp = 0 if im <= -5.6: tmp = t_0 elif im <= 0.03: tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) elif im <= 2.5e+36: tmp = 0.5 * (math.exp(-im) - math.exp(im)) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64((im ^ 7.0) * Float64(cos(re) * -0.0001984126984126984)) tmp = 0.0 if (im <= -5.6) tmp = t_0; elseif (im <= 0.03) tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); elseif (im <= 2.5e+36) tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = (im ^ 7.0) * (cos(re) * -0.0001984126984126984); tmp = 0.0; if (im <= -5.6) tmp = t_0; elseif (im <= 0.03) tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im); elseif (im <= 2.5e+36) tmp = 0.5 * (exp(-im) - exp(im)); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 7.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.6], t$95$0, If[LessEqual[im, 0.03], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.5e+36], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -5.6:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.03:\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+36}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -5.5999999999999996 or 2.49999999999999988e36 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 93.2%
Taylor expanded in im around inf 93.2%
*-commutative93.2%
*-commutative93.2%
associate-*l*93.2%
Simplified93.2%
if -5.5999999999999996 < im < 0.029999999999999999Initial program 7.2%
sub0-neg7.2%
Simplified7.2%
Taylor expanded in im around 0 99.8%
mul-1-neg99.8%
unsub-neg99.8%
*-commutative99.8%
associate-*l*99.8%
distribute-lft-out--99.8%
Simplified99.8%
if 0.029999999999999999 < im < 2.49999999999999988e36Initial program 99.5%
sub0-neg99.5%
Simplified99.5%
Taylor expanded in re around 0 89.6%
Final simplification96.2%
(FPCore (re im)
:precision binary64
(if (<= im -9e+23)
(* (pow im 7.0) -0.0001984126984126984)
(if (<= im 0.023)
(* (cos re) (- im))
(*
(- (* (pow im 3.0) -0.16666666666666666) im)
(+ (* (* re re) -0.5) 1.0)))))
double code(double re, double im) {
double tmp;
if (im <= -9e+23) {
tmp = pow(im, 7.0) * -0.0001984126984126984;
} else if (im <= 0.023) {
tmp = cos(re) * -im;
} else {
tmp = ((pow(im, 3.0) * -0.16666666666666666) - im) * (((re * re) * -0.5) + 1.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-9d+23)) then
tmp = (im ** 7.0d0) * (-0.0001984126984126984d0)
else if (im <= 0.023d0) then
tmp = cos(re) * -im
else
tmp = (((im ** 3.0d0) * (-0.16666666666666666d0)) - im) * (((re * re) * (-0.5d0)) + 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -9e+23) {
tmp = Math.pow(im, 7.0) * -0.0001984126984126984;
} else if (im <= 0.023) {
tmp = Math.cos(re) * -im;
} else {
tmp = ((Math.pow(im, 3.0) * -0.16666666666666666) - im) * (((re * re) * -0.5) + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -9e+23: tmp = math.pow(im, 7.0) * -0.0001984126984126984 elif im <= 0.023: tmp = math.cos(re) * -im else: tmp = ((math.pow(im, 3.0) * -0.16666666666666666) - im) * (((re * re) * -0.5) + 1.0) return tmp
function code(re, im) tmp = 0.0 if (im <= -9e+23) tmp = Float64((im ^ 7.0) * -0.0001984126984126984); elseif (im <= 0.023) tmp = Float64(cos(re) * Float64(-im)); else tmp = Float64(Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) * Float64(Float64(Float64(re * re) * -0.5) + 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -9e+23) tmp = (im ^ 7.0) * -0.0001984126984126984; elseif (im <= 0.023) tmp = cos(re) * -im; else tmp = (((im ^ 3.0) * -0.16666666666666666) - im) * (((re * re) * -0.5) + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -9e+23], N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision], If[LessEqual[im, 0.023], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision] * N[(N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -9 \cdot 10^{+23}:\\
\;\;\;\;{im}^{7} \cdot -0.0001984126984126984\\
\mathbf{elif}\;im \leq 0.023:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{else}:\\
\;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(\left(re \cdot re\right) \cdot -0.5 + 1\right)\\
\end{array}
\end{array}
if im < -8.99999999999999958e23Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 97.2%
Taylor expanded in im around inf 97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.2%
Simplified97.2%
Taylor expanded in re around 0 80.3%
if -8.99999999999999958e23 < im < 0.023Initial program 11.6%
sub0-neg11.6%
Simplified11.6%
Taylor expanded in im around 0 94.7%
mul-1-neg94.7%
*-commutative94.7%
distribute-lft-neg-in94.7%
Simplified94.7%
if 0.023 < im Initial program 99.9%
sub0-neg99.9%
Simplified99.9%
Taylor expanded in im around 0 68.2%
mul-1-neg68.2%
unsub-neg68.2%
*-commutative68.2%
associate-*l*68.2%
distribute-lft-out--68.2%
Simplified68.2%
Taylor expanded in re around 0 8.1%
sub-neg8.1%
*-commutative8.1%
associate-+r+8.1%
fma-def8.1%
associate-*r*8.1%
*-commutative8.1%
fma-neg8.1%
*-lft-identity8.1%
distribute-rgt-out61.2%
fma-neg61.2%
*-commutative61.2%
unpow261.2%
Simplified61.2%
Final simplification82.7%
(FPCore (re im) :precision binary64 (if (or (<= im -480.0) (not (<= im 2.65e+32))) (- (* (* re re) (* im 0.5)) im) (* (cos re) (- im))))
double code(double re, double im) {
double tmp;
if ((im <= -480.0) || !(im <= 2.65e+32)) {
tmp = ((re * re) * (im * 0.5)) - im;
} 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 <= (-480.0d0)) .or. (.not. (im <= 2.65d+32))) then
tmp = ((re * re) * (im * 0.5d0)) - im
else
tmp = cos(re) * -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -480.0) || !(im <= 2.65e+32)) {
tmp = ((re * re) * (im * 0.5)) - im;
} else {
tmp = Math.cos(re) * -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -480.0) or not (im <= 2.65e+32): tmp = ((re * re) * (im * 0.5)) - im else: tmp = math.cos(re) * -im return tmp
function code(re, im) tmp = 0.0 if ((im <= -480.0) || !(im <= 2.65e+32)) tmp = Float64(Float64(Float64(re * re) * Float64(im * 0.5)) - im); else tmp = Float64(cos(re) * Float64(-im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -480.0) || ~((im <= 2.65e+32))) tmp = ((re * re) * (im * 0.5)) - im; else tmp = cos(re) * -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -480.0], N[Not[LessEqual[im, 2.65e+32]], $MachinePrecision]], N[(N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -480 \lor \neg \left(im \leq 2.65 \cdot 10^{+32}\right):\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\end{array}
\end{array}
if im < -480 or 2.65e32 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 5.5%
mul-1-neg5.5%
*-commutative5.5%
distribute-lft-neg-in5.5%
Simplified5.5%
Taylor expanded in re around 0 23.5%
neg-mul-123.5%
+-commutative23.5%
unsub-neg23.5%
*-commutative23.5%
associate-*l*23.5%
unpow223.5%
*-commutative23.5%
Simplified23.5%
if -480 < im < 2.65e32Initial program 13.6%
sub0-neg13.6%
Simplified13.6%
Taylor expanded in im around 0 92.9%
mul-1-neg92.9%
*-commutative92.9%
distribute-lft-neg-in92.9%
Simplified92.9%
Final simplification58.7%
(FPCore (re im) :precision binary64 (if (or (<= im -1.9e+20) (not (<= im 560000000.0))) (* (pow im 7.0) -0.0001984126984126984) (* (cos re) (- im))))
double code(double re, double im) {
double tmp;
if ((im <= -1.9e+20) || !(im <= 560000000.0)) {
tmp = pow(im, 7.0) * -0.0001984126984126984;
} 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 <= (-1.9d+20)) .or. (.not. (im <= 560000000.0d0))) then
tmp = (im ** 7.0d0) * (-0.0001984126984126984d0)
else
tmp = cos(re) * -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -1.9e+20) || !(im <= 560000000.0)) {
tmp = Math.pow(im, 7.0) * -0.0001984126984126984;
} else {
tmp = Math.cos(re) * -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -1.9e+20) or not (im <= 560000000.0): tmp = math.pow(im, 7.0) * -0.0001984126984126984 else: tmp = math.cos(re) * -im return tmp
function code(re, im) tmp = 0.0 if ((im <= -1.9e+20) || !(im <= 560000000.0)) tmp = Float64((im ^ 7.0) * -0.0001984126984126984); else tmp = Float64(cos(re) * Float64(-im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -1.9e+20) || ~((im <= 560000000.0))) tmp = (im ^ 7.0) * -0.0001984126984126984; else tmp = cos(re) * -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -1.9e+20], N[Not[LessEqual[im, 560000000.0]], $MachinePrecision]], N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.9 \cdot 10^{+20} \lor \neg \left(im \leq 560000000\right):\\
\;\;\;\;{im}^{7} \cdot -0.0001984126984126984\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\end{array}
\end{array}
if im < -1.9e20 or 5.6e8 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 91.8%
Taylor expanded in im around inf 91.8%
*-commutative91.8%
*-commutative91.8%
associate-*l*91.8%
Simplified91.8%
Taylor expanded in re around 0 68.9%
if -1.9e20 < im < 5.6e8Initial program 12.9%
sub0-neg12.9%
Simplified12.9%
Taylor expanded in im around 0 93.6%
mul-1-neg93.6%
*-commutative93.6%
distribute-lft-neg-in93.6%
Simplified93.6%
Final simplification81.4%
(FPCore (re im) :precision binary64 (if (<= re 2.7e+181) (- im) (* (+ 0.5 (* re (* re -0.25))) -3.0)))
double code(double re, double im) {
double tmp;
if (re <= 2.7e+181) {
tmp = -im;
} else {
tmp = (0.5 + (re * (re * -0.25))) * -3.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 2.7d+181) then
tmp = -im
else
tmp = (0.5d0 + (re * (re * (-0.25d0)))) * (-3.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 2.7e+181) {
tmp = -im;
} else {
tmp = (0.5 + (re * (re * -0.25))) * -3.0;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 2.7e+181: tmp = -im else: tmp = (0.5 + (re * (re * -0.25))) * -3.0 return tmp
function code(re, im) tmp = 0.0 if (re <= 2.7e+181) tmp = Float64(-im); else tmp = Float64(Float64(0.5 + Float64(re * Float64(re * -0.25))) * -3.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 2.7e+181) tmp = -im; else tmp = (0.5 + (re * (re * -0.25))) * -3.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 2.7e+181], (-im), N[(N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -3.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 2.7 \cdot 10^{+181}:\\
\;\;\;\;-im\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\\
\end{array}
\end{array}
if re < 2.70000000000000007e181Initial program 56.5%
sub0-neg56.5%
Simplified56.5%
Taylor expanded in im around 0 49.5%
mul-1-neg49.5%
*-commutative49.5%
distribute-lft-neg-in49.5%
Simplified49.5%
Taylor expanded in re around 0 29.0%
neg-mul-129.0%
Simplified29.0%
if 2.70000000000000007e181 < re Initial program 50.0%
sub0-neg50.0%
Simplified50.0%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
associate-*r*0.0%
distribute-rgt-out23.5%
+-commutative23.5%
*-commutative23.5%
unpow223.5%
associate-*l*23.5%
Simplified23.5%
Applied egg-rr30.3%
Final simplification29.1%
(FPCore (re im) :precision binary64 (if (<= re 3.1e+181) (- (* (* re re) (* im 0.5)) im) (* (+ 0.5 (* re (* re -0.25))) -3.0)))
double code(double re, double im) {
double tmp;
if (re <= 3.1e+181) {
tmp = ((re * re) * (im * 0.5)) - im;
} else {
tmp = (0.5 + (re * (re * -0.25))) * -3.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 3.1d+181) then
tmp = ((re * re) * (im * 0.5d0)) - im
else
tmp = (0.5d0 + (re * (re * (-0.25d0)))) * (-3.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 3.1e+181) {
tmp = ((re * re) * (im * 0.5)) - im;
} else {
tmp = (0.5 + (re * (re * -0.25))) * -3.0;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 3.1e+181: tmp = ((re * re) * (im * 0.5)) - im else: tmp = (0.5 + (re * (re * -0.25))) * -3.0 return tmp
function code(re, im) tmp = 0.0 if (re <= 3.1e+181) tmp = Float64(Float64(Float64(re * re) * Float64(im * 0.5)) - im); else tmp = Float64(Float64(0.5 + Float64(re * Float64(re * -0.25))) * -3.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 3.1e+181) tmp = ((re * re) * (im * 0.5)) - im; else tmp = (0.5 + (re * (re * -0.25))) * -3.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 3.1e+181], N[(N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], N[(N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -3.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.1 \cdot 10^{+181}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\\
\end{array}
\end{array}
if re < 3.09999999999999989e181Initial program 56.5%
sub0-neg56.5%
Simplified56.5%
Taylor expanded in im around 0 49.5%
mul-1-neg49.5%
*-commutative49.5%
distribute-lft-neg-in49.5%
Simplified49.5%
Taylor expanded in re around 0 34.9%
neg-mul-134.9%
+-commutative34.9%
unsub-neg34.9%
*-commutative34.9%
associate-*l*34.9%
unpow234.9%
*-commutative34.9%
Simplified34.9%
if 3.09999999999999989e181 < re Initial program 50.0%
sub0-neg50.0%
Simplified50.0%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
associate-*r*0.0%
distribute-rgt-out23.5%
+-commutative23.5%
*-commutative23.5%
unpow223.5%
associate-*l*23.5%
Simplified23.5%
Applied egg-rr30.3%
Final simplification34.6%
(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 56.1%
sub0-neg56.1%
Simplified56.1%
Taylor expanded in im around 0 49.9%
mul-1-neg49.9%
*-commutative49.9%
distribute-lft-neg-in49.9%
Simplified49.9%
Taylor expanded in re around 0 27.8%
neg-mul-127.8%
Simplified27.8%
Final simplification27.8%
(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 2023240
(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))))