
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(-im) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp(-im) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(-im) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(-im) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp(-im) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(-im) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
\end{array}
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))) (t_1 (* 0.5 (sin re))))
(if (or (<= t_0 -10.0) (not (<= t_0 0.0004)))
(* t_0 t_1)
(*
t_1
(+
(* im -2.0)
(+
(* -0.3333333333333333 (pow im 3.0))
(* -0.016666666666666666 (pow im 5.0))))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double t_1 = 0.5 * sin(re);
double tmp;
if ((t_0 <= -10.0) || !(t_0 <= 0.0004)) {
tmp = t_0 * t_1;
} else {
tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * pow(im, 3.0)) + (-0.016666666666666666 * pow(im, 5.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 * sin(re)
if ((t_0 <= (-10.0d0)) .or. (.not. (t_0 <= 0.0004d0))) then
tmp = t_0 * t_1
else
tmp = t_1 * ((im * (-2.0d0)) + (((-0.3333333333333333d0) * (im ** 3.0d0)) + ((-0.016666666666666666d0) * (im ** 5.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.sin(re);
double tmp;
if ((t_0 <= -10.0) || !(t_0 <= 0.0004)) {
tmp = t_0 * t_1;
} else {
tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * Math.pow(im, 3.0)) + (-0.016666666666666666 * Math.pow(im, 5.0))));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) t_1 = 0.5 * math.sin(re) tmp = 0 if (t_0 <= -10.0) or not (t_0 <= 0.0004): tmp = t_0 * t_1 else: tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * math.pow(im, 3.0)) + (-0.016666666666666666 * math.pow(im, 5.0)))) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) t_1 = Float64(0.5 * sin(re)) tmp = 0.0 if ((t_0 <= -10.0) || !(t_0 <= 0.0004)) tmp = Float64(t_0 * t_1); else tmp = Float64(t_1 * Float64(Float64(im * -2.0) + Float64(Float64(-0.3333333333333333 * (im ^ 3.0)) + Float64(-0.016666666666666666 * (im ^ 5.0))))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); t_1 = 0.5 * sin(re); tmp = 0.0; if ((t_0 <= -10.0) || ~((t_0 <= 0.0004))) tmp = t_0 * t_1; else tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * (im ^ 3.0)) + (-0.016666666666666666 * (im ^ 5.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[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -10.0], N[Not[LessEqual[t$95$0, 0.0004]], $MachinePrecision]], N[(t$95$0 * t$95$1), $MachinePrecision], N[(t$95$1 * N[(N[(im * -2.0), $MachinePrecision] + N[(N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.016666666666666666 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := 0.5 \cdot \sin re\\
\mathbf{if}\;t_0 \leq -10 \lor \neg \left(t_0 \leq 0.0004\right):\\
\;\;\;\;t_0 \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(im \cdot -2 + \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -10 or 4.00000000000000019e-4 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
if -10 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 4.00000000000000019e-4Initial program 28.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 -0.005) (not (<= t_0 0.0004)))
(* t_0 (* 0.5 (sin re)))
(* (sin 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.005) || !(t_0 <= 0.0004)) {
tmp = t_0 * (0.5 * sin(re));
} else {
tmp = sin(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.005d0)) .or. (.not. (t_0 <= 0.0004d0))) then
tmp = t_0 * (0.5d0 * sin(re))
else
tmp = sin(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.005) || !(t_0 <= 0.0004)) {
tmp = t_0 * (0.5 * Math.sin(re));
} else {
tmp = Math.sin(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.005) or not (t_0 <= 0.0004): tmp = t_0 * (0.5 * math.sin(re)) else: tmp = math.sin(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.005) || !(t_0 <= 0.0004)) tmp = Float64(t_0 * Float64(0.5 * sin(re))); else tmp = Float64(sin(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.005) || ~((t_0 <= 0.0004))) tmp = t_0 * (0.5 * sin(re)); else tmp = sin(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.005], N[Not[LessEqual[t$95$0, 0.0004]], $MachinePrecision]], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[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.005 \lor \neg \left(t_0 \leq 0.0004\right):\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -0.0050000000000000001 or 4.00000000000000019e-4 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 99.9%
if -0.0050000000000000001 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 4.00000000000000019e-4Initial program 28.4%
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
(let* ((t_0 (* (- (exp (- im)) (exp im)) (* 0.5 re)))
(t_1 (* (sin re) (* (pow im 5.0) -0.008333333333333333))))
(if (<= im -1.3e+61)
t_1
(if (<= im -0.28)
t_0
(if (<= im 2.6)
(* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
(if (<= im 4.5e+61) t_0 t_1))))))
double code(double re, double im) {
double t_0 = (exp(-im) - exp(im)) * (0.5 * re);
double t_1 = sin(re) * (pow(im, 5.0) * -0.008333333333333333);
double tmp;
if (im <= -1.3e+61) {
tmp = t_1;
} else if (im <= -0.28) {
tmp = t_0;
} else if (im <= 2.6) {
tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 4.5e+61) {
tmp = 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)) * (0.5d0 * re)
t_1 = sin(re) * ((im ** 5.0d0) * (-0.008333333333333333d0))
if (im <= (-1.3d+61)) then
tmp = t_1
else if (im <= (-0.28d0)) then
tmp = t_0
else if (im <= 2.6d0) then
tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else if (im <= 4.5d+61) then
tmp = 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)) * (0.5 * re);
double t_1 = Math.sin(re) * (Math.pow(im, 5.0) * -0.008333333333333333);
double tmp;
if (im <= -1.3e+61) {
tmp = t_1;
} else if (im <= -0.28) {
tmp = t_0;
} else if (im <= 2.6) {
tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 4.5e+61) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = (math.exp(-im) - math.exp(im)) * (0.5 * re) t_1 = math.sin(re) * (math.pow(im, 5.0) * -0.008333333333333333) tmp = 0 if im <= -1.3e+61: tmp = t_1 elif im <= -0.28: tmp = t_0 elif im <= 2.6: tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) elif im <= 4.5e+61: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 * re)) t_1 = Float64(sin(re) * Float64((im ^ 5.0) * -0.008333333333333333)) tmp = 0.0 if (im <= -1.3e+61) tmp = t_1; elseif (im <= -0.28) tmp = t_0; elseif (im <= 2.6) tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); elseif (im <= 4.5e+61) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = (exp(-im) - exp(im)) * (0.5 * re); t_1 = sin(re) * ((im ^ 5.0) * -0.008333333333333333); tmp = 0.0; if (im <= -1.3e+61) tmp = t_1; elseif (im <= -0.28) tmp = t_0; elseif (im <= 2.6) tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im); elseif (im <= 4.5e+61) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[re], $MachinePrecision] * N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.3e+61], t$95$1, If[LessEqual[im, -0.28], t$95$0, If[LessEqual[im, 2.6], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.5e+61], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
t_1 := \sin re \cdot \left({im}^{5} \cdot -0.008333333333333333\right)\\
\mathbf{if}\;im \leq -1.3 \cdot 10^{+61}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.28:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 2.6:\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{elif}\;im \leq 4.5 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -1.29999999999999986e61 or 4.5e61 < im Initial program 100.0%
Taylor expanded in im around 0 99.2%
Taylor expanded in im around inf 99.2%
*-commutative99.2%
*-commutative99.2%
associate-*l*99.2%
*-commutative99.2%
Simplified99.2%
if -1.29999999999999986e61 < im < -0.28000000000000003 or 2.60000000000000009 < im < 4.5e61Initial program 100.0%
Taylor expanded in re around 0 84.8%
associate-*r*84.8%
Simplified84.8%
if -0.28000000000000003 < im < 2.60000000000000009Initial program 29.5%
Taylor expanded in im around 0 98.9%
+-commutative98.9%
mul-1-neg98.9%
unsub-neg98.9%
associate-*r*98.9%
distribute-rgt-out--98.9%
*-commutative98.9%
Simplified98.9%
Final simplification97.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (- im) (pow (sin re) -3.0)))
(t_1 (* (sin re) (* (pow im 5.0) -0.008333333333333333))))
(if (<= im -1.3e+61)
t_1
(if (<= im -430.0)
t_0
(if (<= im 2.5) (* (- im) (sin re)) (if (<= im 7.2e+55) t_0 t_1))))))
double code(double re, double im) {
double t_0 = -im * pow(sin(re), -3.0);
double t_1 = sin(re) * (pow(im, 5.0) * -0.008333333333333333);
double tmp;
if (im <= -1.3e+61) {
tmp = t_1;
} else if (im <= -430.0) {
tmp = t_0;
} else if (im <= 2.5) {
tmp = -im * sin(re);
} else if (im <= 7.2e+55) {
tmp = 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 = -im * (sin(re) ** (-3.0d0))
t_1 = sin(re) * ((im ** 5.0d0) * (-0.008333333333333333d0))
if (im <= (-1.3d+61)) then
tmp = t_1
else if (im <= (-430.0d0)) then
tmp = t_0
else if (im <= 2.5d0) then
tmp = -im * sin(re)
else if (im <= 7.2d+55) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = -im * Math.pow(Math.sin(re), -3.0);
double t_1 = Math.sin(re) * (Math.pow(im, 5.0) * -0.008333333333333333);
double tmp;
if (im <= -1.3e+61) {
tmp = t_1;
} else if (im <= -430.0) {
tmp = t_0;
} else if (im <= 2.5) {
tmp = -im * Math.sin(re);
} else if (im <= 7.2e+55) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = -im * math.pow(math.sin(re), -3.0) t_1 = math.sin(re) * (math.pow(im, 5.0) * -0.008333333333333333) tmp = 0 if im <= -1.3e+61: tmp = t_1 elif im <= -430.0: tmp = t_0 elif im <= 2.5: tmp = -im * math.sin(re) elif im <= 7.2e+55: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(Float64(-im) * (sin(re) ^ -3.0)) t_1 = Float64(sin(re) * Float64((im ^ 5.0) * -0.008333333333333333)) tmp = 0.0 if (im <= -1.3e+61) tmp = t_1; elseif (im <= -430.0) tmp = t_0; elseif (im <= 2.5) tmp = Float64(Float64(-im) * sin(re)); elseif (im <= 7.2e+55) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = -im * (sin(re) ^ -3.0); t_1 = sin(re) * ((im ^ 5.0) * -0.008333333333333333); tmp = 0.0; if (im <= -1.3e+61) tmp = t_1; elseif (im <= -430.0) tmp = t_0; elseif (im <= 2.5) tmp = -im * sin(re); elseif (im <= 7.2e+55) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[((-im) * N[Power[N[Sin[re], $MachinePrecision], -3.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[re], $MachinePrecision] * N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.3e+61], t$95$1, If[LessEqual[im, -430.0], t$95$0, If[LessEqual[im, 2.5], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 7.2e+55], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-im\right) \cdot {\sin re}^{-3}\\
t_1 := \sin re \cdot \left({im}^{5} \cdot -0.008333333333333333\right)\\
\mathbf{if}\;im \leq -1.3 \cdot 10^{+61}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -430:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 2.5:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\mathbf{elif}\;im \leq 7.2 \cdot 10^{+55}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -1.29999999999999986e61 or 7.19999999999999975e55 < im Initial program 100.0%
Taylor expanded in im around 0 98.4%
Taylor expanded in im around inf 98.4%
*-commutative98.4%
*-commutative98.4%
associate-*l*98.4%
*-commutative98.4%
Simplified98.4%
if -1.29999999999999986e61 < im < -430 or 2.5 < im < 7.19999999999999975e55Initial program 100.0%
Taylor expanded in im around 0 3.3%
associate-*r*3.3%
neg-mul-13.3%
Simplified3.3%
Applied egg-rr36.7%
if -430 < im < 2.5Initial program 28.9%
Taylor expanded in im around 0 98.3%
associate-*r*98.3%
neg-mul-198.3%
Simplified98.3%
Final simplification90.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (- im) (pow (sin re) -3.0)))
(t_1 (* (sin re) (* (pow im 5.0) -0.008333333333333333))))
(if (<= im -1.3e+61)
t_1
(if (<= im -460.0)
t_0
(if (<= im 440.0)
(* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
(if (<= im 1.15e+56) t_0 t_1))))))
double code(double re, double im) {
double t_0 = -im * pow(sin(re), -3.0);
double t_1 = sin(re) * (pow(im, 5.0) * -0.008333333333333333);
double tmp;
if (im <= -1.3e+61) {
tmp = t_1;
} else if (im <= -460.0) {
tmp = t_0;
} else if (im <= 440.0) {
tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 1.15e+56) {
tmp = 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 = -im * (sin(re) ** (-3.0d0))
t_1 = sin(re) * ((im ** 5.0d0) * (-0.008333333333333333d0))
if (im <= (-1.3d+61)) then
tmp = t_1
else if (im <= (-460.0d0)) then
tmp = t_0
else if (im <= 440.0d0) then
tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else if (im <= 1.15d+56) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = -im * Math.pow(Math.sin(re), -3.0);
double t_1 = Math.sin(re) * (Math.pow(im, 5.0) * -0.008333333333333333);
double tmp;
if (im <= -1.3e+61) {
tmp = t_1;
} else if (im <= -460.0) {
tmp = t_0;
} else if (im <= 440.0) {
tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 1.15e+56) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = -im * math.pow(math.sin(re), -3.0) t_1 = math.sin(re) * (math.pow(im, 5.0) * -0.008333333333333333) tmp = 0 if im <= -1.3e+61: tmp = t_1 elif im <= -460.0: tmp = t_0 elif im <= 440.0: tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) elif im <= 1.15e+56: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(Float64(-im) * (sin(re) ^ -3.0)) t_1 = Float64(sin(re) * Float64((im ^ 5.0) * -0.008333333333333333)) tmp = 0.0 if (im <= -1.3e+61) tmp = t_1; elseif (im <= -460.0) tmp = t_0; elseif (im <= 440.0) tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); elseif (im <= 1.15e+56) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = -im * (sin(re) ^ -3.0); t_1 = sin(re) * ((im ^ 5.0) * -0.008333333333333333); tmp = 0.0; if (im <= -1.3e+61) tmp = t_1; elseif (im <= -460.0) tmp = t_0; elseif (im <= 440.0) tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im); elseif (im <= 1.15e+56) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[((-im) * N[Power[N[Sin[re], $MachinePrecision], -3.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[re], $MachinePrecision] * N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.3e+61], t$95$1, If[LessEqual[im, -460.0], t$95$0, If[LessEqual[im, 440.0], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.15e+56], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-im\right) \cdot {\sin re}^{-3}\\
t_1 := \sin re \cdot \left({im}^{5} \cdot -0.008333333333333333\right)\\
\mathbf{if}\;im \leq -1.3 \cdot 10^{+61}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -460:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 440:\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{elif}\;im \leq 1.15 \cdot 10^{+56}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -1.29999999999999986e61 or 1.15000000000000007e56 < im Initial program 100.0%
Taylor expanded in im around 0 98.4%
Taylor expanded in im around inf 98.4%
*-commutative98.4%
*-commutative98.4%
associate-*l*98.4%
*-commutative98.4%
Simplified98.4%
if -1.29999999999999986e61 < im < -460 or 440 < im < 1.15000000000000007e56Initial program 100.0%
Taylor expanded in im around 0 2.9%
associate-*r*2.9%
neg-mul-12.9%
Simplified2.9%
Applied egg-rr37.3%
if -460 < im < 440Initial program 29.5%
Taylor expanded in im around 0 98.9%
+-commutative98.9%
mul-1-neg98.9%
unsub-neg98.9%
associate-*r*98.9%
distribute-rgt-out--98.9%
*-commutative98.9%
Simplified98.9%
Final simplification91.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.008333333333333333 (* re (pow im 5.0)))))
(if (<= im -3.15e+41)
t_0
(if (<= im 2.5)
(* (- im) (sin re))
(if (<= im 9e+55) (* (- im) (pow (sin re) -3.0)) t_0)))))
double code(double re, double im) {
double t_0 = -0.008333333333333333 * (re * pow(im, 5.0));
double tmp;
if (im <= -3.15e+41) {
tmp = t_0;
} else if (im <= 2.5) {
tmp = -im * sin(re);
} else if (im <= 9e+55) {
tmp = -im * pow(sin(re), -3.0);
} 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 = (-0.008333333333333333d0) * (re * (im ** 5.0d0))
if (im <= (-3.15d+41)) then
tmp = t_0
else if (im <= 2.5d0) then
tmp = -im * sin(re)
else if (im <= 9d+55) then
tmp = -im * (sin(re) ** (-3.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = -0.008333333333333333 * (re * Math.pow(im, 5.0));
double tmp;
if (im <= -3.15e+41) {
tmp = t_0;
} else if (im <= 2.5) {
tmp = -im * Math.sin(re);
} else if (im <= 9e+55) {
tmp = -im * Math.pow(Math.sin(re), -3.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = -0.008333333333333333 * (re * math.pow(im, 5.0)) tmp = 0 if im <= -3.15e+41: tmp = t_0 elif im <= 2.5: tmp = -im * math.sin(re) elif im <= 9e+55: tmp = -im * math.pow(math.sin(re), -3.0) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(-0.008333333333333333 * Float64(re * (im ^ 5.0))) tmp = 0.0 if (im <= -3.15e+41) tmp = t_0; elseif (im <= 2.5) tmp = Float64(Float64(-im) * sin(re)); elseif (im <= 9e+55) tmp = Float64(Float64(-im) * (sin(re) ^ -3.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = -0.008333333333333333 * (re * (im ^ 5.0)); tmp = 0.0; if (im <= -3.15e+41) tmp = t_0; elseif (im <= 2.5) tmp = -im * sin(re); elseif (im <= 9e+55) tmp = -im * (sin(re) ^ -3.0); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(-0.008333333333333333 * N[(re * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -3.15e+41], t$95$0, If[LessEqual[im, 2.5], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 9e+55], N[((-im) * N[Power[N[Sin[re], $MachinePrecision], -3.0], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\
\mathbf{if}\;im \leq -3.15 \cdot 10^{+41}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 2.5:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\mathbf{elif}\;im \leq 9 \cdot 10^{+55}:\\
\;\;\;\;\left(-im\right) \cdot {\sin re}^{-3}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -3.1499999999999999e41 or 8.99999999999999996e55 < im Initial program 100.0%
Taylor expanded in im around 0 93.5%
Taylor expanded in im around inf 93.5%
*-commutative93.5%
*-commutative93.5%
associate-*l*93.5%
*-commutative93.5%
Simplified93.5%
Taylor expanded in re around 0 68.8%
if -3.1499999999999999e41 < im < 2.5Initial program 33.6%
Taylor expanded in im around 0 92.0%
associate-*r*92.0%
neg-mul-192.0%
Simplified92.0%
if 2.5 < im < 8.99999999999999996e55Initial program 100.0%
Taylor expanded in im around 0 3.6%
associate-*r*3.6%
neg-mul-13.6%
Simplified3.6%
Applied egg-rr35.8%
Final simplification77.4%
(FPCore (re im) :precision binary64 (if (or (<= im -3.15e+41) (not (<= im 480000.0))) (* -0.008333333333333333 (* re (pow im 5.0))) (* (- im) (sin re))))
double code(double re, double im) {
double tmp;
if ((im <= -3.15e+41) || !(im <= 480000.0)) {
tmp = -0.008333333333333333 * (re * pow(im, 5.0));
} else {
tmp = -im * sin(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-3.15d+41)) .or. (.not. (im <= 480000.0d0))) then
tmp = (-0.008333333333333333d0) * (re * (im ** 5.0d0))
else
tmp = -im * sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -3.15e+41) || !(im <= 480000.0)) {
tmp = -0.008333333333333333 * (re * Math.pow(im, 5.0));
} else {
tmp = -im * Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -3.15e+41) or not (im <= 480000.0): tmp = -0.008333333333333333 * (re * math.pow(im, 5.0)) else: tmp = -im * math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -3.15e+41) || !(im <= 480000.0)) tmp = Float64(-0.008333333333333333 * Float64(re * (im ^ 5.0))); else tmp = Float64(Float64(-im) * sin(re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -3.15e+41) || ~((im <= 480000.0))) tmp = -0.008333333333333333 * (re * (im ^ 5.0)); else tmp = -im * sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -3.15e+41], N[Not[LessEqual[im, 480000.0]], $MachinePrecision]], N[(-0.008333333333333333 * N[(re * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.15 \cdot 10^{+41} \lor \neg \left(im \leq 480000\right):\\
\;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\end{array}
\end{array}
if im < -3.1499999999999999e41 or 4.8e5 < im Initial program 100.0%
Taylor expanded in im around 0 81.4%
Taylor expanded in im around inf 81.4%
*-commutative81.4%
*-commutative81.4%
associate-*l*81.4%
*-commutative81.4%
Simplified81.4%
Taylor expanded in re around 0 61.4%
if -3.1499999999999999e41 < im < 4.8e5Initial program 34.1%
Taylor expanded in im around 0 91.4%
associate-*r*91.4%
neg-mul-191.4%
Simplified91.4%
Final simplification75.8%
(FPCore (re im) :precision binary64 (if (or (<= im -3.6e+41) (not (<= im 450.0))) (* (- im) re) (* (- im) (sin re))))
double code(double re, double im) {
double tmp;
if ((im <= -3.6e+41) || !(im <= 450.0)) {
tmp = -im * re;
} else {
tmp = -im * sin(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-3.6d+41)) .or. (.not. (im <= 450.0d0))) then
tmp = -im * re
else
tmp = -im * sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -3.6e+41) || !(im <= 450.0)) {
tmp = -im * re;
} else {
tmp = -im * Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -3.6e+41) or not (im <= 450.0): tmp = -im * re else: tmp = -im * math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -3.6e+41) || !(im <= 450.0)) tmp = Float64(Float64(-im) * re); else tmp = Float64(Float64(-im) * sin(re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -3.6e+41) || ~((im <= 450.0))) tmp = -im * re; else tmp = -im * sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -3.6e+41], N[Not[LessEqual[im, 450.0]], $MachinePrecision]], N[((-im) * re), $MachinePrecision], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.6 \cdot 10^{+41} \lor \neg \left(im \leq 450\right):\\
\;\;\;\;\left(-im\right) \cdot re\\
\mathbf{else}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\end{array}
\end{array}
if im < -3.60000000000000025e41 or 450 < im Initial program 100.0%
Taylor expanded in im around 0 4.4%
associate-*r*4.4%
neg-mul-14.4%
Simplified4.4%
Taylor expanded in re around 0 13.1%
if -3.60000000000000025e41 < im < 450Initial program 34.1%
Taylor expanded in im around 0 91.4%
associate-*r*91.4%
neg-mul-191.4%
Simplified91.4%
Final simplification50.7%
(FPCore (re im) :precision binary64 (* (- im) re))
double code(double re, double im) {
return -im * re;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -im * re
end function
public static double code(double re, double im) {
return -im * re;
}
def code(re, im): return -im * re
function code(re, im) return Float64(Float64(-im) * re) end
function tmp = code(re, im) tmp = -im * re; end
code[re_, im_] := N[((-im) * re), $MachinePrecision]
\begin{array}{l}
\\
\left(-im\right) \cdot re
\end{array}
Initial program 68.3%
Taylor expanded in im around 0 46.2%
associate-*r*46.2%
neg-mul-146.2%
Simplified46.2%
Taylor expanded in re around 0 27.8%
Final simplification27.8%
(FPCore (re im)
:precision binary64
(if (< (fabs im) 1.0)
(-
(*
(sin re)
(+
(+ im (* (* (* 0.16666666666666666 im) im) im))
(* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))))
double code(double re, double im) {
double tmp;
if (fabs(im) < 1.0) {
tmp = -(sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * sin(re)) * (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 (abs(im) < 1.0d0) then
tmp = -(sin(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
else
tmp = (0.5d0 * sin(re)) * (exp(-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.sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if math.fabs(im) < 1.0: tmp = -(math.sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))) else: tmp = (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (abs(im) < 1.0) tmp = Float64(-Float64(sin(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 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (abs(im) < 1.0) tmp = -(sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))); else tmp = (0.5 * sin(re)) * (exp(-im) - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Sin[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[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\sin 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 \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\
\end{array}
\end{array}
herbie shell --seed 2023312
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:precision binary64
:herbie-target
(if (< (fabs im) 1.0) (- (* (sin re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))