
(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 11 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))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e-6)))
(* t_0 (* 0.5 (sin re)))
(+
(* -0.16666666666666666 (* (sin re) (pow im 3.0)))
(-
(* -0.008333333333333333 (* (sin re) (pow im 5.0)))
(* im (sin re)))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 1e-6)) {
tmp = t_0 * (0.5 * sin(re));
} else {
tmp = (-0.16666666666666666 * (sin(re) * pow(im, 3.0))) + ((-0.008333333333333333 * (sin(re) * pow(im, 5.0))) - (im * sin(re)));
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 1e-6)) {
tmp = t_0 * (0.5 * Math.sin(re));
} else {
tmp = (-0.16666666666666666 * (Math.sin(re) * Math.pow(im, 3.0))) + ((-0.008333333333333333 * (Math.sin(re) * Math.pow(im, 5.0))) - (im * Math.sin(re)));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 1e-6): tmp = t_0 * (0.5 * math.sin(re)) else: tmp = (-0.16666666666666666 * (math.sin(re) * math.pow(im, 3.0))) + ((-0.008333333333333333 * (math.sin(re) * math.pow(im, 5.0))) - (im * math.sin(re))) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 1e-6)) tmp = Float64(t_0 * Float64(0.5 * sin(re))); else tmp = Float64(Float64(-0.16666666666666666 * Float64(sin(re) * (im ^ 3.0))) + Float64(Float64(-0.008333333333333333 * Float64(sin(re) * (im ^ 5.0))) - Float64(im * sin(re)))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 1e-6))) tmp = t_0 * (0.5 * sin(re)); else tmp = (-0.16666666666666666 * (sin(re) * (im ^ 3.0))) + ((-0.008333333333333333 * (sin(re) * (im ^ 5.0))) - (im * sin(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, (-Infinity)], N[Not[LessEqual[t$95$0, 1e-6]], $MachinePrecision]], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.16666666666666666 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 10^{-6}\right):\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) + \left(-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right) - im \cdot \sin re\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -inf.0 or 9.99999999999999955e-7 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
if -inf.0 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 9.99999999999999955e-7Initial program 36.8%
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 (- INFINITY)) (not (<= t_0 1e-6)))
(* t_0 (* 0.5 (sin re)))
(*
(sin re)
(+
(* -0.16666666666666666 (pow im 3.0))
(- (* -0.008333333333333333 (pow im 5.0)) im))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 1e-6)) {
tmp = t_0 * (0.5 * sin(re));
} else {
tmp = sin(re) * ((-0.16666666666666666 * pow(im, 3.0)) + ((-0.008333333333333333 * pow(im, 5.0)) - im));
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 1e-6)) {
tmp = t_0 * (0.5 * Math.sin(re));
} else {
tmp = Math.sin(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) + ((-0.008333333333333333 * Math.pow(im, 5.0)) - im));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 1e-6): tmp = t_0 * (0.5 * math.sin(re)) else: tmp = math.sin(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) + ((-0.008333333333333333 * math.pow(im, 5.0)) - im)) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 1e-6)) tmp = Float64(t_0 * Float64(0.5 * sin(re))); else tmp = Float64(sin(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) + Float64(Float64(-0.008333333333333333 * (im ^ 5.0)) - im))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 1e-6))) tmp = t_0 * (0.5 * sin(re)); else tmp = sin(re) * ((-0.16666666666666666 * (im ^ 3.0)) + ((-0.008333333333333333 * (im ^ 5.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, (-Infinity)], N[Not[LessEqual[t$95$0, 1e-6]], $MachinePrecision]], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-0.008333333333333333 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 10^{-6}\right):\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(-0.16666666666666666 \cdot {im}^{3} + \left(-0.008333333333333333 \cdot {im}^{5} - im\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -inf.0 or 9.99999999999999955e-7 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
if -inf.0 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 9.99999999999999955e-7Initial program 36.8%
Taylor expanded in im around 0 99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*l*99.8%
+-commutative99.8%
mul-1-neg99.8%
distribute-rgt-neg-in99.8%
*-commutative99.8%
associate-*l*99.8%
distribute-lft-out99.8%
distribute-lft-out99.8%
*-commutative99.8%
+-commutative99.8%
sub-neg99.8%
Simplified99.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 1e-6)))
(* t_0 (* 0.5 (sin re)))
(* (sin 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.005) || !(t_0 <= 1e-6)) {
tmp = t_0 * (0.5 * sin(re));
} else {
tmp = sin(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.005d0)) .or. (.not. (t_0 <= 1d-6))) then
tmp = t_0 * (0.5d0 * sin(re))
else
tmp = sin(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.005) || !(t_0 <= 1e-6)) {
tmp = t_0 * (0.5 * Math.sin(re));
} else {
tmp = Math.sin(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.005) or not (t_0 <= 1e-6): tmp = t_0 * (0.5 * math.sin(re)) else: tmp = math.sin(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.005) || !(t_0 <= 1e-6)) tmp = Float64(t_0 * Float64(0.5 * sin(re))); else tmp = Float64(sin(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.005) || ~((t_0 <= 1e-6))) tmp = t_0 * (0.5 * sin(re)); else tmp = sin(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.005], N[Not[LessEqual[t$95$0, 1e-6]], $MachinePrecision]], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[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.005 \lor \neg \left(t_0 \leq 10^{-6}\right):\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -0.0050000000000000001 or 9.99999999999999955e-7 < (-.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)) < 9.99999999999999955e-7Initial program 36.4%
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.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (- (exp (- im)) (exp im)) (* 0.5 re)))
(t_1 (* -0.008333333333333333 (* (sin re) (pow im 5.0)))))
(if (<= im -5e+97)
t_1
(if (<= im -18.0)
t_0
(if (<= im 0.9)
(* (sin re) (- (* -0.16666666666666666 (pow im 3.0)) 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 = -0.008333333333333333 * (sin(re) * pow(im, 5.0));
double tmp;
if (im <= -5e+97) {
tmp = t_1;
} else if (im <= -18.0) {
tmp = t_0;
} else if (im <= 0.9) {
tmp = sin(re) * ((-0.16666666666666666 * pow(im, 3.0)) - 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 = (-0.008333333333333333d0) * (sin(re) * (im ** 5.0d0))
if (im <= (-5d+97)) then
tmp = t_1
else if (im <= (-18.0d0)) then
tmp = t_0
else if (im <= 0.9d0) then
tmp = sin(re) * (((-0.16666666666666666d0) * (im ** 3.0d0)) - 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 = -0.008333333333333333 * (Math.sin(re) * Math.pow(im, 5.0));
double tmp;
if (im <= -5e+97) {
tmp = t_1;
} else if (im <= -18.0) {
tmp = t_0;
} else if (im <= 0.9) {
tmp = Math.sin(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - 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 = -0.008333333333333333 * (math.sin(re) * math.pow(im, 5.0)) tmp = 0 if im <= -5e+97: tmp = t_1 elif im <= -18.0: tmp = t_0 elif im <= 0.9: tmp = math.sin(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - 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(-0.008333333333333333 * Float64(sin(re) * (im ^ 5.0))) tmp = 0.0 if (im <= -5e+97) tmp = t_1; elseif (im <= -18.0) tmp = t_0; elseif (im <= 0.9) tmp = Float64(sin(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - 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 = -0.008333333333333333 * (sin(re) * (im ^ 5.0)); tmp = 0.0; if (im <= -5e+97) tmp = t_1; elseif (im <= -18.0) tmp = t_0; elseif (im <= 0.9) tmp = sin(re) * ((-0.16666666666666666 * (im ^ 3.0)) - 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[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5e+97], t$95$1, If[LessEqual[im, -18.0], t$95$0, If[LessEqual[im, 0.9], N[(N[Sin[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $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 := -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\
\mathbf{if}\;im \leq -5 \cdot 10^{+97}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -18:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.9:\\
\;\;\;\;\sin re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\
\mathbf{elif}\;im \leq 4.5 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -4.99999999999999999e97 or 4.5e61 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
mul-1-neg100.0%
distribute-rgt-neg-in100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out100.0%
distribute-lft-out100.0%
*-commutative100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
Simplified100.0%
if -4.99999999999999999e97 < im < -18 or 0.900000000000000022 < im < 4.5e61Initial program 100.0%
Taylor expanded in re around 0 82.9%
if -18 < im < 0.900000000000000022Initial program 37.7%
Taylor expanded in im around 0 98.5%
mul-1-neg98.5%
unsub-neg98.5%
*-commutative98.5%
associate-*l*98.5%
distribute-lft-out--98.5%
Simplified98.5%
Final simplification96.9%
(FPCore (re im) :precision binary64 (if (or (<= im -5.0) (not (<= im 5.0))) (* -0.008333333333333333 (* (sin re) (pow im 5.0))) (* (sin re) (- (* -0.16666666666666666 (pow im 3.0)) im))))
double code(double re, double im) {
double tmp;
if ((im <= -5.0) || !(im <= 5.0)) {
tmp = -0.008333333333333333 * (sin(re) * pow(im, 5.0));
} else {
tmp = sin(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) :: tmp
if ((im <= (-5.0d0)) .or. (.not. (im <= 5.0d0))) then
tmp = (-0.008333333333333333d0) * (sin(re) * (im ** 5.0d0))
else
tmp = sin(re) * (((-0.16666666666666666d0) * (im ** 3.0d0)) - im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -5.0) || !(im <= 5.0)) {
tmp = -0.008333333333333333 * (Math.sin(re) * Math.pow(im, 5.0));
} else {
tmp = Math.sin(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -5.0) or not (im <= 5.0): tmp = -0.008333333333333333 * (math.sin(re) * math.pow(im, 5.0)) else: tmp = math.sin(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im) return tmp
function code(re, im) tmp = 0.0 if ((im <= -5.0) || !(im <= 5.0)) tmp = Float64(-0.008333333333333333 * Float64(sin(re) * (im ^ 5.0))); else tmp = Float64(sin(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -5.0) || ~((im <= 5.0))) tmp = -0.008333333333333333 * (sin(re) * (im ^ 5.0)); else tmp = sin(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -5.0], N[Not[LessEqual[im, 5.0]], $MachinePrecision]], N[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -5 \lor \neg \left(im \leq 5\right):\\
\;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\
\end{array}
\end{array}
if im < -5 or 5 < im Initial program 100.0%
Taylor expanded in im around 0 75.9%
associate-*r*75.9%
*-commutative75.9%
associate-*l*75.9%
+-commutative75.9%
mul-1-neg75.9%
distribute-rgt-neg-in75.9%
*-commutative75.9%
associate-*l*75.9%
distribute-lft-out75.9%
distribute-lft-out75.9%
*-commutative75.9%
+-commutative75.9%
sub-neg75.9%
Simplified75.9%
Taylor expanded in im around inf 75.9%
*-commutative75.9%
Simplified75.9%
if -5 < im < 5Initial program 37.3%
Taylor expanded in im around 0 99.1%
mul-1-neg99.1%
unsub-neg99.1%
*-commutative99.1%
associate-*l*99.1%
distribute-lft-out--99.1%
Simplified99.1%
Final simplification88.0%
(FPCore (re im) :precision binary64 (if (or (<= im -3.3) (not (<= im 3.3))) (* -0.008333333333333333 (* (sin re) (pow im 5.0))) (* im (- (sin re)))))
double code(double re, double im) {
double tmp;
if ((im <= -3.3) || !(im <= 3.3)) {
tmp = -0.008333333333333333 * (sin(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.3d0)) .or. (.not. (im <= 3.3d0))) then
tmp = (-0.008333333333333333d0) * (sin(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.3) || !(im <= 3.3)) {
tmp = -0.008333333333333333 * (Math.sin(re) * Math.pow(im, 5.0));
} else {
tmp = im * -Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -3.3) or not (im <= 3.3): tmp = -0.008333333333333333 * (math.sin(re) * math.pow(im, 5.0)) else: tmp = im * -math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -3.3) || !(im <= 3.3)) tmp = Float64(-0.008333333333333333 * Float64(sin(re) * (im ^ 5.0))); else tmp = Float64(im * Float64(-sin(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -3.3) || ~((im <= 3.3))) tmp = -0.008333333333333333 * (sin(re) * (im ^ 5.0)); else tmp = im * -sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -3.3], N[Not[LessEqual[im, 3.3]], $MachinePrecision]], N[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * 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.3 \lor \neg \left(im \leq 3.3\right):\\
\;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\end{array}
\end{array}
if im < -3.2999999999999998 or 3.2999999999999998 < im Initial program 100.0%
Taylor expanded in im around 0 75.9%
associate-*r*75.9%
*-commutative75.9%
associate-*l*75.9%
+-commutative75.9%
mul-1-neg75.9%
distribute-rgt-neg-in75.9%
*-commutative75.9%
associate-*l*75.9%
distribute-lft-out75.9%
distribute-lft-out75.9%
*-commutative75.9%
+-commutative75.9%
sub-neg75.9%
Simplified75.9%
Taylor expanded in im around inf 75.9%
*-commutative75.9%
Simplified75.9%
if -3.2999999999999998 < im < 3.2999999999999998Initial program 37.3%
Taylor expanded in im around 0 98.2%
mul-1-neg98.2%
*-commutative98.2%
distribute-lft-neg-in98.2%
Simplified98.2%
Final simplification87.5%
(FPCore (re im) :precision binary64 (if (or (<= im -2.7e+43) (not (<= im 15000000000000.0))) (* im (* (pow re 3.0) 0.16666666666666666)) (* im (- (sin re)))))
double code(double re, double im) {
double tmp;
if ((im <= -2.7e+43) || !(im <= 15000000000000.0)) {
tmp = im * (pow(re, 3.0) * 0.16666666666666666);
} 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 <= (-2.7d+43)) .or. (.not. (im <= 15000000000000.0d0))) then
tmp = im * ((re ** 3.0d0) * 0.16666666666666666d0)
else
tmp = im * -sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -2.7e+43) || !(im <= 15000000000000.0)) {
tmp = im * (Math.pow(re, 3.0) * 0.16666666666666666);
} else {
tmp = im * -Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -2.7e+43) or not (im <= 15000000000000.0): tmp = im * (math.pow(re, 3.0) * 0.16666666666666666) else: tmp = im * -math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -2.7e+43) || !(im <= 15000000000000.0)) tmp = Float64(im * Float64((re ^ 3.0) * 0.16666666666666666)); else tmp = Float64(im * Float64(-sin(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -2.7e+43) || ~((im <= 15000000000000.0))) tmp = im * ((re ^ 3.0) * 0.16666666666666666); else tmp = im * -sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -2.7e+43], N[Not[LessEqual[im, 15000000000000.0]], $MachinePrecision]], N[(im * N[(N[Power[re, 3.0], $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.7 \cdot 10^{+43} \lor \neg \left(im \leq 15000000000000\right):\\
\;\;\;\;im \cdot \left({re}^{3} \cdot 0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\end{array}
\end{array}
if im < -2.7000000000000002e43 or 1.5e13 < im Initial program 100.0%
Taylor expanded in im around 0 4.7%
mul-1-neg4.7%
*-commutative4.7%
distribute-lft-neg-in4.7%
Simplified4.7%
Taylor expanded in re around 0 12.0%
+-commutative12.0%
mul-1-neg12.0%
unsub-neg12.0%
associate-*r*12.0%
distribute-rgt-out--27.6%
*-commutative27.6%
Simplified27.6%
Taylor expanded in re around inf 26.5%
associate-*r*26.5%
*-commutative26.5%
*-commutative26.5%
Simplified26.5%
if -2.7000000000000002e43 < im < 1.5e13Initial program 43.2%
Taylor expanded in im around 0 89.2%
mul-1-neg89.2%
*-commutative89.2%
distribute-lft-neg-in89.2%
Simplified89.2%
Final simplification62.5%
(FPCore (re im) :precision binary64 (if (or (<= im -2150000000000.0) (not (<= im 850.0))) (* -0.008333333333333333 (* re (pow im 5.0))) (* im (- (sin re)))))
double code(double re, double im) {
double tmp;
if ((im <= -2150000000000.0) || !(im <= 850.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 <= (-2150000000000.0d0)) .or. (.not. (im <= 850.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 <= -2150000000000.0) || !(im <= 850.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 <= -2150000000000.0) or not (im <= 850.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 <= -2150000000000.0) || !(im <= 850.0)) tmp = Float64(-0.008333333333333333 * Float64(re * (im ^ 5.0))); else tmp = Float64(im * Float64(-sin(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -2150000000000.0) || ~((im <= 850.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, -2150000000000.0], N[Not[LessEqual[im, 850.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 -2150000000000 \lor \neg \left(im \leq 850\right):\\
\;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\end{array}
\end{array}
if im < -2.15e12 or 850 < im Initial program 100.0%
Taylor expanded in im around 0 77.6%
associate-*r*77.6%
*-commutative77.6%
associate-*l*77.6%
+-commutative77.6%
mul-1-neg77.6%
distribute-rgt-neg-in77.6%
*-commutative77.6%
associate-*l*77.6%
distribute-lft-out77.6%
distribute-lft-out77.6%
*-commutative77.6%
+-commutative77.6%
sub-neg77.6%
Simplified77.6%
Taylor expanded in im around inf 77.6%
*-commutative77.6%
Simplified77.6%
Taylor expanded in re around 0 58.9%
*-commutative58.9%
Simplified58.9%
if -2.15e12 < im < 850Initial program 38.7%
Taylor expanded in im around 0 96.2%
mul-1-neg96.2%
*-commutative96.2%
distribute-lft-neg-in96.2%
Simplified96.2%
Final simplification78.7%
(FPCore (re im) :precision binary64 (if (or (<= im -7.2e+215) (not (<= im 3.2e+129))) (* im (- re)) (* im (- (sin re)))))
double code(double re, double im) {
double tmp;
if ((im <= -7.2e+215) || !(im <= 3.2e+129)) {
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 <= (-7.2d+215)) .or. (.not. (im <= 3.2d+129))) 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 <= -7.2e+215) || !(im <= 3.2e+129)) {
tmp = im * -re;
} else {
tmp = im * -Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -7.2e+215) or not (im <= 3.2e+129): tmp = im * -re else: tmp = im * -math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -7.2e+215) || !(im <= 3.2e+129)) tmp = Float64(im * Float64(-re)); else tmp = Float64(im * Float64(-sin(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -7.2e+215) || ~((im <= 3.2e+129))) tmp = im * -re; else tmp = im * -sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -7.2e+215], N[Not[LessEqual[im, 3.2e+129]], $MachinePrecision]], N[(im * (-re)), $MachinePrecision], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -7.2 \cdot 10^{+215} \lor \neg \left(im \leq 3.2 \cdot 10^{+129}\right):\\
\;\;\;\;im \cdot \left(-re\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\end{array}
\end{array}
if im < -7.19999999999999948e215 or 3.2000000000000002e129 < im Initial program 100.0%
Taylor expanded in im around 0 5.8%
mul-1-neg5.8%
*-commutative5.8%
distribute-lft-neg-in5.8%
Simplified5.8%
Taylor expanded in re around 0 28.6%
if -7.19999999999999948e215 < im < 3.2000000000000002e129Initial program 58.1%
Taylor expanded in im around 0 66.8%
mul-1-neg66.8%
*-commutative66.8%
distribute-lft-neg-in66.8%
Simplified66.8%
Final simplification58.3%
(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(im * Float64(-re)) end
function tmp = code(re, im) tmp = im * -re; end
code[re_, im_] := N[(im * (-re)), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(-re\right)
\end{array}
Initial program 67.4%
Taylor expanded in im around 0 53.2%
mul-1-neg53.2%
*-commutative53.2%
distribute-lft-neg-in53.2%
Simplified53.2%
Taylor expanded in re around 0 31.4%
Final simplification31.4%
(FPCore (re im) :precision binary64 (* re -1.5))
double code(double re, double im) {
return re * -1.5;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re * (-1.5d0)
end function
public static double code(double re, double im) {
return re * -1.5;
}
def code(re, im): return re * -1.5
function code(re, im) return Float64(re * -1.5) end
function tmp = code(re, im) tmp = re * -1.5; end
code[re_, im_] := N[(re * -1.5), $MachinePrecision]
\begin{array}{l}
\\
re \cdot -1.5
\end{array}
Initial program 67.4%
Taylor expanded in re around 0 53.0%
Applied egg-rr3.2%
Taylor expanded in re around 0 3.2%
Final simplification3.2%
(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 2023187
(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))))