
(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 15 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 (* 0.5 (sin re))) (t_1 (- (exp (- im)) (exp im))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 0.02)))
(* t_1 t_0)
(*
t_0
(+
(* im -2.0)
(+
(* -0.3333333333333333 (pow im 3.0))
(* -0.016666666666666666 (pow im 5.0))))))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double t_1 = exp(-im) - exp(im);
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 0.02)) {
tmp = t_1 * t_0;
} else {
tmp = t_0 * ((im * -2.0) + ((-0.3333333333333333 * pow(im, 3.0)) + (-0.016666666666666666 * pow(im, 5.0))));
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = 0.5 * Math.sin(re);
double t_1 = Math.exp(-im) - Math.exp(im);
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 0.02)) {
tmp = t_1 * t_0;
} else {
tmp = t_0 * ((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 = 0.5 * math.sin(re) t_1 = math.exp(-im) - math.exp(im) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 0.02): tmp = t_1 * t_0 else: tmp = t_0 * ((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(0.5 * sin(re)) t_1 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 0.02)) tmp = Float64(t_1 * t_0); else tmp = Float64(t_0 * 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 = 0.5 * sin(re); t_1 = exp(-im) - exp(im); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 0.02))) tmp = t_1 * t_0; else tmp = t_0 * ((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[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 0.02]], $MachinePrecision]], N[(t$95$1 * t$95$0), $MachinePrecision], N[(t$95$0 * 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 := 0.5 \cdot \sin re\\
t_1 := e^{-im} - e^{im}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 0.02\right):\\
\;\;\;\;t_1 \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 \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)) < -inf.0 or 0.0200000000000000004 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 99.2%
if -inf.0 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 0.0200000000000000004Initial program 32.5%
Taylor expanded in im around 0 99.8%
Final simplification99.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e-15)))
(* 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 <= -((double) INFINITY)) || !(t_0 <= 2e-15)) {
tmp = t_0 * (0.5 * sin(re));
} else {
tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - 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 <= 2e-15)) {
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 <= -math.inf) or not (t_0 <= 2e-15): 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 <= Float64(-Inf)) || !(t_0 <= 2e-15)) 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 <= -Inf) || ~((t_0 <= 2e-15))) 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, (-Infinity)], N[Not[LessEqual[t$95$0, 2e-15]], $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 -\infty \lor \neg \left(t_0 \leq 2 \cdot 10^{-15}\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)) < -inf.0 or 2.0000000000000002e-15 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 99.2%
if -inf.0 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 2.0000000000000002e-15Initial program 32.0%
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.5%
(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 -2.1e+98)
t_1
(if (<= im -0.058)
t_0
(if (<= im 0.14)
(* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
(if (<= im 4.4e+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 <= -2.1e+98) {
tmp = t_1;
} else if (im <= -0.058) {
tmp = t_0;
} else if (im <= 0.14) {
tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 4.4e+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 <= (-2.1d+98)) then
tmp = t_1
else if (im <= (-0.058d0)) then
tmp = t_0
else if (im <= 0.14d0) then
tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else if (im <= 4.4d+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 <= -2.1e+98) {
tmp = t_1;
} else if (im <= -0.058) {
tmp = t_0;
} else if (im <= 0.14) {
tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 4.4e+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 <= -2.1e+98: tmp = t_1 elif im <= -0.058: tmp = t_0 elif im <= 0.14: tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) elif im <= 4.4e+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 <= -2.1e+98) tmp = t_1; elseif (im <= -0.058) tmp = t_0; elseif (im <= 0.14) tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); elseif (im <= 4.4e+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 <= -2.1e+98) tmp = t_1; elseif (im <= -0.058) tmp = t_0; elseif (im <= 0.14) tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im); elseif (im <= 4.4e+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, -2.1e+98], t$95$1, If[LessEqual[im, -0.058], t$95$0, If[LessEqual[im, 0.14], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.4e+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 -2.1 \cdot 10^{+98}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.058:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.14:\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -2.10000000000000004e98 or 4.4000000000000001e61 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
if -2.10000000000000004e98 < im < -0.0580000000000000029 or 0.14000000000000001 < im < 4.4000000000000001e61Initial program 97.1%
Taylor expanded in re around 0 84.8%
associate-*r*84.8%
*-commutative84.8%
Simplified84.8%
if -0.0580000000000000029 < im < 0.14000000000000001Initial program 32.5%
Taylor expanded in im around 0 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
associate-*r*99.6%
distribute-rgt-out--99.6%
*-commutative99.6%
Simplified99.6%
Final simplification97.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (cbrt (* (pow im 15.0) -5.787037037037037e-7))))
(t_1 (* -0.008333333333333333 (* (sin re) (pow im 5.0)))))
(if (<= im -2.1e+98)
t_1
(if (<= im -64000.0)
t_0
(if (<= im 90000.0)
(* im (- (sin re)))
(if (<= im 4.4e+61) t_0 t_1))))))
double code(double re, double im) {
double t_0 = re * cbrt((pow(im, 15.0) * -5.787037037037037e-7));
double t_1 = -0.008333333333333333 * (sin(re) * pow(im, 5.0));
double tmp;
if (im <= -2.1e+98) {
tmp = t_1;
} else if (im <= -64000.0) {
tmp = t_0;
} else if (im <= 90000.0) {
tmp = im * -sin(re);
} else if (im <= 4.4e+61) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = re * Math.cbrt((Math.pow(im, 15.0) * -5.787037037037037e-7));
double t_1 = -0.008333333333333333 * (Math.sin(re) * Math.pow(im, 5.0));
double tmp;
if (im <= -2.1e+98) {
tmp = t_1;
} else if (im <= -64000.0) {
tmp = t_0;
} else if (im <= 90000.0) {
tmp = im * -Math.sin(re);
} else if (im <= 4.4e+61) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(re, im) t_0 = Float64(re * cbrt(Float64((im ^ 15.0) * -5.787037037037037e-7))) t_1 = Float64(-0.008333333333333333 * Float64(sin(re) * (im ^ 5.0))) tmp = 0.0 if (im <= -2.1e+98) tmp = t_1; elseif (im <= -64000.0) tmp = t_0; elseif (im <= 90000.0) tmp = Float64(im * Float64(-sin(re))); elseif (im <= 4.4e+61) tmp = t_0; else tmp = t_1; end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(re * N[Power[N[(N[Power[im, 15.0], $MachinePrecision] * -5.787037037037037e-7), $MachinePrecision], 1/3], $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, -2.1e+98], t$95$1, If[LessEqual[im, -64000.0], t$95$0, If[LessEqual[im, 90000.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 4.4e+61], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \sqrt[3]{{im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}}\\
t_1 := -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+98}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -64000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 90000:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -2.10000000000000004e98 or 4.4000000000000001e61 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
if -2.10000000000000004e98 < im < -64000 or 9e4 < im < 4.4000000000000001e61Initial program 100.0%
Taylor expanded in im around 0 28.1%
Taylor expanded in im around inf 28.1%
Taylor expanded in re around 0 37.8%
*-commutative37.8%
*-commutative37.8%
associate-*l*37.8%
Simplified37.8%
add-cbrt-cube75.6%
pow1/353.9%
pow353.9%
unpow-prod-down53.9%
pow353.9%
pow-prod-up53.9%
metadata-eval53.9%
pow-prod-up53.9%
metadata-eval53.9%
metadata-eval53.9%
Applied egg-rr53.9%
unpow1/375.6%
Simplified75.6%
if -64000 < im < 9e4Initial program 33.8%
Taylor expanded in im around 0 96.4%
associate-*r*96.4%
neg-mul-196.4%
Simplified96.4%
Final simplification95.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (cbrt (* (pow im 15.0) -5.787037037037037e-7))))
(t_1 (* -0.008333333333333333 (* (sin re) (pow im 5.0)))))
(if (<= im -2.1e+98)
t_1
(if (<= im -31000.0)
t_0
(if (<= im 920.0)
(* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
(if (<= im 4.4e+61) t_0 t_1))))))
double code(double re, double im) {
double t_0 = re * cbrt((pow(im, 15.0) * -5.787037037037037e-7));
double t_1 = -0.008333333333333333 * (sin(re) * pow(im, 5.0));
double tmp;
if (im <= -2.1e+98) {
tmp = t_1;
} else if (im <= -31000.0) {
tmp = t_0;
} else if (im <= 920.0) {
tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 4.4e+61) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = re * Math.cbrt((Math.pow(im, 15.0) * -5.787037037037037e-7));
double t_1 = -0.008333333333333333 * (Math.sin(re) * Math.pow(im, 5.0));
double tmp;
if (im <= -2.1e+98) {
tmp = t_1;
} else if (im <= -31000.0) {
tmp = t_0;
} else if (im <= 920.0) {
tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 4.4e+61) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(re, im) t_0 = Float64(re * cbrt(Float64((im ^ 15.0) * -5.787037037037037e-7))) t_1 = Float64(-0.008333333333333333 * Float64(sin(re) * (im ^ 5.0))) tmp = 0.0 if (im <= -2.1e+98) tmp = t_1; elseif (im <= -31000.0) tmp = t_0; elseif (im <= 920.0) tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); elseif (im <= 4.4e+61) tmp = t_0; else tmp = t_1; end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(re * N[Power[N[(N[Power[im, 15.0], $MachinePrecision] * -5.787037037037037e-7), $MachinePrecision], 1/3], $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, -2.1e+98], t$95$1, If[LessEqual[im, -31000.0], t$95$0, If[LessEqual[im, 920.0], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.4e+61], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \sqrt[3]{{im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}}\\
t_1 := -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+98}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -31000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 920:\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -2.10000000000000004e98 or 4.4000000000000001e61 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
if -2.10000000000000004e98 < im < -31000 or 920 < im < 4.4000000000000001e61Initial program 100.0%
Taylor expanded in im around 0 28.1%
Taylor expanded in im around inf 28.1%
Taylor expanded in re around 0 37.8%
*-commutative37.8%
*-commutative37.8%
associate-*l*37.8%
Simplified37.8%
add-cbrt-cube75.6%
pow1/353.9%
pow353.9%
unpow-prod-down53.9%
pow353.9%
pow-prod-up53.9%
metadata-eval53.9%
pow-prod-up53.9%
metadata-eval53.9%
metadata-eval53.9%
Applied egg-rr53.9%
unpow1/375.6%
Simplified75.6%
if -31000 < im < 920Initial program 33.8%
Taylor expanded in im around 0 97.2%
+-commutative97.2%
mul-1-neg97.2%
unsub-neg97.2%
associate-*r*97.2%
distribute-rgt-out--97.2%
*-commutative97.2%
Simplified97.2%
Final simplification95.8%
(FPCore (re im) :precision binary64 (if (or (<= im -3.3) (not (<= im 3.4))) (* -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.4)) {
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.4d0))) 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.4)) {
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.4): 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.4)) 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.4))) 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.4]], $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.4\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.39999999999999991 < im Initial program 99.3%
Taylor expanded in im around 0 81.0%
Taylor expanded in im around inf 81.0%
if -3.2999999999999998 < im < 3.39999999999999991Initial program 33.0%
Taylor expanded in im around 0 98.5%
associate-*r*98.5%
neg-mul-198.5%
Simplified98.5%
Final simplification90.2%
(FPCore (re im) :precision binary64 (* (sin re) (- (* (pow im 5.0) -0.008333333333333333) im)))
double code(double re, double im) {
return sin(re) * ((pow(im, 5.0) * -0.008333333333333333) - im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = sin(re) * (((im ** 5.0d0) * (-0.008333333333333333d0)) - im)
end function
public static double code(double re, double im) {
return Math.sin(re) * ((Math.pow(im, 5.0) * -0.008333333333333333) - im);
}
def code(re, im): return math.sin(re) * ((math.pow(im, 5.0) * -0.008333333333333333) - im)
function code(re, im) return Float64(sin(re) * Float64(Float64((im ^ 5.0) * -0.008333333333333333) - im)) end
function tmp = code(re, im) tmp = sin(re) * (((im ^ 5.0) * -0.008333333333333333) - im); end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin re \cdot \left({im}^{5} \cdot -0.008333333333333333 - im\right)
\end{array}
Initial program 64.3%
Taylor expanded in im around 0 90.8%
Taylor expanded in im around inf 90.2%
Taylor expanded in im around 0 90.2%
associate-*r*90.2%
neg-mul-190.2%
associate-*r*90.2%
*-commutative90.2%
distribute-rgt-out90.2%
Simplified90.2%
Taylor expanded in re around inf 90.2%
Final simplification90.2%
(FPCore (re im) :precision binary64 (if (or (<= im -47000.0) (not (<= im 7500.0))) (* -0.008333333333333333 (* re (pow im 5.0))) (* im (- (sin re)))))
double code(double re, double im) {
double tmp;
if ((im <= -47000.0) || !(im <= 7500.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 <= (-47000.0d0)) .or. (.not. (im <= 7500.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 <= -47000.0) || !(im <= 7500.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 <= -47000.0) or not (im <= 7500.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 <= -47000.0) || !(im <= 7500.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 <= -47000.0) || ~((im <= 7500.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, -47000.0], N[Not[LessEqual[im, 7500.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 -47000 \lor \neg \left(im \leq 7500\right):\\
\;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\end{array}
\end{array}
if im < -47000 or 7500 < im Initial program 100.0%
Taylor expanded in im around 0 82.9%
Taylor expanded in im around inf 82.9%
Taylor expanded in re around 0 66.6%
if -47000 < im < 7500Initial program 33.8%
Taylor expanded in im around 0 96.4%
associate-*r*96.4%
neg-mul-196.4%
Simplified96.4%
Final simplification82.7%
(FPCore (re im) :precision binary64 (if (or (<= im -9.5e+57) (not (<= im 1900000000.0))) (* im (- re)) (* im (- (sin re)))))
double code(double re, double im) {
double tmp;
if ((im <= -9.5e+57) || !(im <= 1900000000.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 <= (-9.5d+57)) .or. (.not. (im <= 1900000000.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 <= -9.5e+57) || !(im <= 1900000000.0)) {
tmp = im * -re;
} else {
tmp = im * -Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -9.5e+57) or not (im <= 1900000000.0): tmp = im * -re else: tmp = im * -math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -9.5e+57) || !(im <= 1900000000.0)) 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 <= -9.5e+57) || ~((im <= 1900000000.0))) tmp = im * -re; else tmp = im * -sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -9.5e+57], N[Not[LessEqual[im, 1900000000.0]], $MachinePrecision]], N[(im * (-re)), $MachinePrecision], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -9.5 \cdot 10^{+57} \lor \neg \left(im \leq 1900000000\right):\\
\;\;\;\;im \cdot \left(-re\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\end{array}
\end{array}
if im < -9.4999999999999997e57 or 1.9e9 < im Initial program 100.0%
Taylor expanded in im around 0 4.2%
associate-*r*4.2%
neg-mul-14.2%
Simplified4.2%
Taylor expanded in re around 0 19.2%
associate-*r*19.2%
neg-mul-119.2%
Simplified19.2%
if -9.4999999999999997e57 < im < 1.9e9Initial program 38.7%
Taylor expanded in im around 0 89.5%
associate-*r*89.5%
neg-mul-189.5%
Simplified89.5%
Final simplification60.1%
(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 64.3%
Taylor expanded in im around 0 53.8%
associate-*r*53.8%
neg-mul-153.8%
Simplified53.8%
Taylor expanded in re around 0 32.6%
associate-*r*32.6%
neg-mul-132.6%
Simplified32.6%
Final simplification32.6%
(FPCore (re im) :precision binary64 -512.0)
double code(double re, double im) {
return -512.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -512.0d0
end function
public static double code(double re, double im) {
return -512.0;
}
def code(re, im): return -512.0
function code(re, im) return -512.0 end
function tmp = code(re, im) tmp = -512.0; end
code[re_, im_] := -512.0
\begin{array}{l}
\\
-512
\end{array}
Initial program 64.3%
Taylor expanded in im around 0 53.8%
associate-*r*53.8%
neg-mul-153.8%
Simplified53.8%
Applied egg-rr2.9%
Final simplification2.9%
(FPCore (re im) :precision binary64 -0.004629629629629629)
double code(double re, double im) {
return -0.004629629629629629;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -0.004629629629629629d0
end function
public static double code(double re, double im) {
return -0.004629629629629629;
}
def code(re, im): return -0.004629629629629629
function code(re, im) return -0.004629629629629629 end
function tmp = code(re, im) tmp = -0.004629629629629629; end
code[re_, im_] := -0.004629629629629629
\begin{array}{l}
\\
-0.004629629629629629
\end{array}
Initial program 64.3%
Taylor expanded in im around 0 53.8%
associate-*r*53.8%
neg-mul-153.8%
Simplified53.8%
Applied egg-rr2.9%
Final simplification2.9%
(FPCore (re im) :precision binary64 -5.080526342529086e-5)
double code(double re, double im) {
return -5.080526342529086e-5;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -5.080526342529086d-5
end function
public static double code(double re, double im) {
return -5.080526342529086e-5;
}
def code(re, im): return -5.080526342529086e-5
function code(re, im) return -5.080526342529086e-5 end
function tmp = code(re, im) tmp = -5.080526342529086e-5; end
code[re_, im_] := -5.080526342529086e-5
\begin{array}{l}
\\
-5.080526342529086 \cdot 10^{-5}
\end{array}
Initial program 64.3%
Taylor expanded in im around 0 53.8%
associate-*r*53.8%
neg-mul-153.8%
Simplified53.8%
Applied egg-rr2.9%
Final simplification2.9%
(FPCore (re im) :precision binary64 -9.92290301275212e-8)
double code(double re, double im) {
return -9.92290301275212e-8;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -9.92290301275212d-8
end function
public static double code(double re, double im) {
return -9.92290301275212e-8;
}
def code(re, im): return -9.92290301275212e-8
function code(re, im) return -9.92290301275212e-8 end
function tmp = code(re, im) tmp = -9.92290301275212e-8; end
code[re_, im_] := -9.92290301275212e-8
\begin{array}{l}
\\
-9.92290301275212 \cdot 10^{-8}
\end{array}
Initial program 64.3%
Taylor expanded in im around 0 53.8%
associate-*r*53.8%
neg-mul-153.8%
Simplified53.8%
Applied egg-rr3.0%
Final simplification3.0%
(FPCore (re im) :precision binary64 0.0)
double code(double re, double im) {
return 0.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.0d0
end function
public static double code(double re, double im) {
return 0.0;
}
def code(re, im): return 0.0
function code(re, im) return 0.0 end
function tmp = code(re, im) tmp = 0.0; end
code[re_, im_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 64.3%
Taylor expanded in im around 0 53.8%
associate-*r*53.8%
neg-mul-153.8%
Simplified53.8%
Applied egg-rr16.2%
Final simplification16.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 2023283
(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))))