
(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 (- (exp (- im)) (exp im))) (t_1 (* 0.5 (sin re))))
(if (or (<= t_0 -5.0) (not (<= t_0 2e-12)))
(* 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 <= -5.0) || !(t_0 <= 2e-12)) {
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 <= (-5.0d0)) .or. (.not. (t_0 <= 2d-12))) 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 <= -5.0) || !(t_0 <= 2e-12)) {
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 <= -5.0) or not (t_0 <= 2e-12): 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 <= -5.0) || !(t_0 <= 2e-12)) 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 <= -5.0) || ~((t_0 <= 2e-12))) 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, -5.0], N[Not[LessEqual[t$95$0, 2e-12]], $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 -5 \lor \neg \left(t_0 \leq 2 \cdot 10^{-12}\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)) < -5 or 1.99999999999999996e-12 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
if -5 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 1.99999999999999996e-12Initial program 29.5%
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.002) (not (<= t_0 2e-12)))
(* 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.002) || !(t_0 <= 2e-12)) {
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.002d0)) .or. (.not. (t_0 <= 2d-12))) 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.002) || !(t_0 <= 2e-12)) {
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.002) or not (t_0 <= 2e-12): 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.002) || !(t_0 <= 2e-12)) 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.002) || ~((t_0 <= 2e-12))) 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.002], N[Not[LessEqual[t$95$0, 2e-12]], $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.002 \lor \neg \left(t_0 \leq 2 \cdot 10^{-12}\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)) < -2e-3 or 1.99999999999999996e-12 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 99.9%
if -2e-3 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 1.99999999999999996e-12Initial program 29.0%
Taylor expanded in im around 0 99.8%
associate-*r*99.8%
neg-mul-199.8%
associate-*r*99.8%
distribute-rgt-out99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in re around inf 99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (sin re) (* (pow im 5.0) -0.008333333333333333))))
(if (<= im -2.2e+70)
t_0
(if (<= im -130.0)
(* (- (exp (- im)) (exp im)) (* 0.5 re))
(if (<= im 5.0)
(* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
t_0)))))
double code(double re, double im) {
double t_0 = sin(re) * (pow(im, 5.0) * -0.008333333333333333);
double tmp;
if (im <= -2.2e+70) {
tmp = t_0;
} else if (im <= -130.0) {
tmp = (exp(-im) - exp(im)) * (0.5 * re);
} else if (im <= 5.0) {
tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = sin(re) * ((im ** 5.0d0) * (-0.008333333333333333d0))
if (im <= (-2.2d+70)) then
tmp = t_0
else if (im <= (-130.0d0)) then
tmp = (exp(-im) - exp(im)) * (0.5d0 * re)
else if (im <= 5.0d0) then
tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.sin(re) * (Math.pow(im, 5.0) * -0.008333333333333333);
double tmp;
if (im <= -2.2e+70) {
tmp = t_0;
} else if (im <= -130.0) {
tmp = (Math.exp(-im) - Math.exp(im)) * (0.5 * re);
} else if (im <= 5.0) {
tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = math.sin(re) * (math.pow(im, 5.0) * -0.008333333333333333) tmp = 0 if im <= -2.2e+70: tmp = t_0 elif im <= -130.0: tmp = (math.exp(-im) - math.exp(im)) * (0.5 * re) elif im <= 5.0: tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(sin(re) * Float64((im ^ 5.0) * -0.008333333333333333)) tmp = 0.0 if (im <= -2.2e+70) tmp = t_0; elseif (im <= -130.0) tmp = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 * re)); elseif (im <= 5.0) tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = sin(re) * ((im ^ 5.0) * -0.008333333333333333); tmp = 0.0; if (im <= -2.2e+70) tmp = t_0; elseif (im <= -130.0) tmp = (exp(-im) - exp(im)) * (0.5 * re); elseif (im <= 5.0) tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Sin[re], $MachinePrecision] * N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.2e+70], t$95$0, If[LessEqual[im, -130.0], N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5.0], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin re \cdot \left({im}^{5} \cdot -0.008333333333333333\right)\\
\mathbf{if}\;im \leq -2.2 \cdot 10^{+70}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -130:\\
\;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{elif}\;im \leq 5:\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -2.20000000000000001e70 or 5 < im Initial program 100.0%
Taylor expanded in im around 0 93.8%
Taylor expanded in im around inf 93.8%
associate-*r*93.8%
*-commutative93.8%
Simplified93.8%
if -2.20000000000000001e70 < im < -130Initial program 100.0%
Taylor expanded in re around 0 81.3%
associate-*r*81.3%
*-commutative81.3%
Simplified81.3%
if -130 < im < 5Initial program 30.6%
Taylor expanded in im around 0 98.5%
associate-*r*98.5%
neg-mul-198.5%
associate-*r*98.5%
distribute-rgt-out98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in re around inf 98.5%
Final simplification95.5%
(FPCore (re im) :precision binary64 (if (or (<= im -5.0) (not (<= im 5.0))) (* (sin re) (* (pow im 5.0) -0.008333333333333333)) (* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))))
double code(double re, double im) {
double tmp;
if ((im <= -5.0) || !(im <= 5.0)) {
tmp = sin(re) * (pow(im, 5.0) * -0.008333333333333333);
} 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) :: tmp
if ((im <= (-5.0d0)) .or. (.not. (im <= 5.0d0))) then
tmp = sin(re) * ((im ** 5.0d0) * (-0.008333333333333333d0))
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 tmp;
if ((im <= -5.0) || !(im <= 5.0)) {
tmp = Math.sin(re) * (Math.pow(im, 5.0) * -0.008333333333333333);
} else {
tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -5.0) or not (im <= 5.0): tmp = math.sin(re) * (math.pow(im, 5.0) * -0.008333333333333333) else: tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) return tmp
function code(re, im) tmp = 0.0 if ((im <= -5.0) || !(im <= 5.0)) tmp = Float64(sin(re) * Float64((im ^ 5.0) * -0.008333333333333333)); else tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -5.0) || ~((im <= 5.0))) tmp = sin(re) * ((im ^ 5.0) * -0.008333333333333333); else tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -5.0], N[Not[LessEqual[im, 5.0]], $MachinePrecision]], N[(N[Sin[re], $MachinePrecision] * N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $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}
\mathbf{if}\;im \leq -5 \lor \neg \left(im \leq 5\right):\\
\;\;\;\;\sin re \cdot \left({im}^{5} \cdot -0.008333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if im < -5 or 5 < im Initial program 100.0%
Taylor expanded in im around 0 83.8%
Taylor expanded in im around inf 83.8%
associate-*r*83.8%
*-commutative83.8%
Simplified83.8%
if -5 < im < 5Initial program 30.0%
Taylor expanded in im around 0 99.2%
associate-*r*99.2%
neg-mul-199.2%
associate-*r*99.2%
distribute-rgt-out99.2%
*-commutative99.2%
Simplified99.2%
Taylor expanded in re around inf 99.2%
Final simplification91.8%
(FPCore (re im) :precision binary64 (if (or (<= im -3.3) (not (<= im 3.3))) (* (sin re) (* (pow im 5.0) -0.008333333333333333)) (* im (- (sin re)))))
double code(double re, double im) {
double tmp;
if ((im <= -3.3) || !(im <= 3.3)) {
tmp = sin(re) * (pow(im, 5.0) * -0.008333333333333333);
} 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 = sin(re) * ((im ** 5.0d0) * (-0.008333333333333333d0))
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 = Math.sin(re) * (Math.pow(im, 5.0) * -0.008333333333333333);
} else {
tmp = im * -Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -3.3) or not (im <= 3.3): tmp = math.sin(re) * (math.pow(im, 5.0) * -0.008333333333333333) else: tmp = im * -math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -3.3) || !(im <= 3.3)) tmp = Float64(sin(re) * Float64((im ^ 5.0) * -0.008333333333333333)); 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 = sin(re) * ((im ^ 5.0) * -0.008333333333333333); 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[(N[Sin[re], $MachinePrecision] * N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $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):\\
\;\;\;\;\sin re \cdot \left({im}^{5} \cdot -0.008333333333333333\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 83.8%
Taylor expanded in im around inf 83.8%
associate-*r*83.8%
*-commutative83.8%
Simplified83.8%
if -3.2999999999999998 < im < 3.2999999999999998Initial program 30.0%
Taylor expanded in im around 0 98.5%
associate-*r*98.5%
neg-mul-198.5%
Simplified98.5%
Final simplification91.4%
(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 63.6%
Taylor expanded in im around 0 91.8%
Taylor expanded in im around inf 91.4%
Taylor expanded in im around 0 91.4%
associate-*r*91.4%
neg-mul-191.4%
associate-*r*91.4%
distribute-rgt-out91.4%
*-commutative91.4%
Simplified91.4%
Taylor expanded in re around inf 91.4%
*-commutative91.4%
Simplified91.4%
Final simplification91.4%
(FPCore (re im) :precision binary64 (if (or (<= im -4.8e+51) (not (<= im 8.2e+41))) (* re (- (* (pow im 5.0) -0.008333333333333333) im)) (* im (- (sin re)))))
double code(double re, double im) {
double tmp;
if ((im <= -4.8e+51) || !(im <= 8.2e+41)) {
tmp = re * ((pow(im, 5.0) * -0.008333333333333333) - im);
} 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 <= (-4.8d+51)) .or. (.not. (im <= 8.2d+41))) then
tmp = re * (((im ** 5.0d0) * (-0.008333333333333333d0)) - im)
else
tmp = im * -sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -4.8e+51) || !(im <= 8.2e+41)) {
tmp = re * ((Math.pow(im, 5.0) * -0.008333333333333333) - im);
} else {
tmp = im * -Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -4.8e+51) or not (im <= 8.2e+41): tmp = re * ((math.pow(im, 5.0) * -0.008333333333333333) - im) else: tmp = im * -math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -4.8e+51) || !(im <= 8.2e+41)) tmp = Float64(re * Float64(Float64((im ^ 5.0) * -0.008333333333333333) - im)); else tmp = Float64(im * Float64(-sin(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -4.8e+51) || ~((im <= 8.2e+41))) tmp = re * (((im ^ 5.0) * -0.008333333333333333) - im); else tmp = im * -sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -4.8e+51], N[Not[LessEqual[im, 8.2e+41]], $MachinePrecision]], N[(re * N[(N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.8 \cdot 10^{+51} \lor \neg \left(im \leq 8.2 \cdot 10^{+41}\right):\\
\;\;\;\;re \cdot \left({im}^{5} \cdot -0.008333333333333333 - im\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\end{array}
\end{array}
if im < -4.7999999999999997e51 or 8.2000000000000007e41 < im Initial program 100.0%
Taylor expanded in im around 0 97.3%
Taylor expanded in im around inf 97.3%
Taylor expanded in im around 0 97.3%
associate-*r*97.3%
neg-mul-197.3%
associate-*r*97.3%
distribute-rgt-out97.3%
*-commutative97.3%
Simplified97.3%
Taylor expanded in re around 0 69.6%
if -4.7999999999999997e51 < im < 8.2000000000000007e41Initial program 38.4%
Taylor expanded in im around 0 87.2%
associate-*r*87.2%
neg-mul-187.2%
Simplified87.2%
Final simplification80.0%
(FPCore (re im)
:precision binary64
(if (<= im -4.8e+51)
(* -0.16666666666666666 (* re (pow im 3.0)))
(if (<= im 2.5e+45)
(* im (- (sin re)))
(* re (- (* (pow im 3.0) -0.16666666666666666) im)))))
double code(double re, double im) {
double tmp;
if (im <= -4.8e+51) {
tmp = -0.16666666666666666 * (re * pow(im, 3.0));
} else if (im <= 2.5e+45) {
tmp = im * -sin(re);
} else {
tmp = 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) :: tmp
if (im <= (-4.8d+51)) then
tmp = (-0.16666666666666666d0) * (re * (im ** 3.0d0))
else if (im <= 2.5d+45) then
tmp = im * -sin(re)
else
tmp = re * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -4.8e+51) {
tmp = -0.16666666666666666 * (re * Math.pow(im, 3.0));
} else if (im <= 2.5e+45) {
tmp = im * -Math.sin(re);
} else {
tmp = re * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -4.8e+51: tmp = -0.16666666666666666 * (re * math.pow(im, 3.0)) elif im <= 2.5e+45: tmp = im * -math.sin(re) else: tmp = re * ((math.pow(im, 3.0) * -0.16666666666666666) - im) return tmp
function code(re, im) tmp = 0.0 if (im <= -4.8e+51) tmp = Float64(-0.16666666666666666 * Float64(re * (im ^ 3.0))); elseif (im <= 2.5e+45) tmp = Float64(im * Float64(-sin(re))); else tmp = Float64(re * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -4.8e+51) tmp = -0.16666666666666666 * (re * (im ^ 3.0)); elseif (im <= 2.5e+45) tmp = im * -sin(re); else tmp = re * (((im ^ 3.0) * -0.16666666666666666) - im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -4.8e+51], N[(-0.16666666666666666 * N[(re * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.5e+45], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], N[(re * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.8 \cdot 10^{+51}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+45}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if im < -4.7999999999999997e51Initial program 100.0%
Taylor expanded in im around 0 83.8%
associate-*r*83.8%
neg-mul-183.8%
associate-*r*83.8%
distribute-rgt-out83.8%
*-commutative83.8%
Simplified83.8%
Taylor expanded in re around 0 67.4%
Taylor expanded in im around inf 67.4%
if -4.7999999999999997e51 < im < 2.5e45Initial program 38.4%
Taylor expanded in im around 0 87.2%
associate-*r*87.2%
neg-mul-187.2%
Simplified87.2%
if 2.5e45 < im Initial program 100.0%
Taylor expanded in im around 0 83.8%
associate-*r*83.8%
neg-mul-183.8%
associate-*r*83.8%
distribute-rgt-out83.8%
*-commutative83.8%
Simplified83.8%
Taylor expanded in re around 0 56.1%
Final simplification77.0%
(FPCore (re im) :precision binary64 (if (or (<= im -4.8e+51) (not (<= im 8.2e+41))) (* -0.16666666666666666 (* re (pow im 3.0))) (* im (- (sin re)))))
double code(double re, double im) {
double tmp;
if ((im <= -4.8e+51) || !(im <= 8.2e+41)) {
tmp = -0.16666666666666666 * (re * pow(im, 3.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 <= (-4.8d+51)) .or. (.not. (im <= 8.2d+41))) then
tmp = (-0.16666666666666666d0) * (re * (im ** 3.0d0))
else
tmp = im * -sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -4.8e+51) || !(im <= 8.2e+41)) {
tmp = -0.16666666666666666 * (re * Math.pow(im, 3.0));
} else {
tmp = im * -Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -4.8e+51) or not (im <= 8.2e+41): tmp = -0.16666666666666666 * (re * math.pow(im, 3.0)) else: tmp = im * -math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -4.8e+51) || !(im <= 8.2e+41)) tmp = Float64(-0.16666666666666666 * Float64(re * (im ^ 3.0))); else tmp = Float64(im * Float64(-sin(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -4.8e+51) || ~((im <= 8.2e+41))) tmp = -0.16666666666666666 * (re * (im ^ 3.0)); else tmp = im * -sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -4.8e+51], N[Not[LessEqual[im, 8.2e+41]], $MachinePrecision]], N[(-0.16666666666666666 * N[(re * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.8 \cdot 10^{+51} \lor \neg \left(im \leq 8.2 \cdot 10^{+41}\right):\\
\;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\end{array}
\end{array}
if im < -4.7999999999999997e51 or 8.2000000000000007e41 < im Initial program 100.0%
Taylor expanded in im around 0 83.8%
associate-*r*83.8%
neg-mul-183.8%
associate-*r*83.8%
distribute-rgt-out83.8%
*-commutative83.8%
Simplified83.8%
Taylor expanded in re around 0 62.3%
Taylor expanded in im around inf 62.3%
if -4.7999999999999997e51 < im < 8.2000000000000007e41Initial program 38.4%
Taylor expanded in im around 0 87.2%
associate-*r*87.2%
neg-mul-187.2%
Simplified87.2%
Final simplification77.0%
(FPCore (re im) :precision binary64 (if (or (<= im -1.1e+54) (not (<= im 1.12e+117))) (* im (- re)) (* im (- (sin re)))))
double code(double re, double im) {
double tmp;
if ((im <= -1.1e+54) || !(im <= 1.12e+117)) {
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 <= (-1.1d+54)) .or. (.not. (im <= 1.12d+117))) 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 <= -1.1e+54) || !(im <= 1.12e+117)) {
tmp = im * -re;
} else {
tmp = im * -Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -1.1e+54) or not (im <= 1.12e+117): tmp = im * -re else: tmp = im * -math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -1.1e+54) || !(im <= 1.12e+117)) 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 <= -1.1e+54) || ~((im <= 1.12e+117))) tmp = im * -re; else tmp = im * -sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -1.1e+54], N[Not[LessEqual[im, 1.12e+117]], $MachinePrecision]], N[(im * (-re)), $MachinePrecision], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.1 \cdot 10^{+54} \lor \neg \left(im \leq 1.12 \cdot 10^{+117}\right):\\
\;\;\;\;im \cdot \left(-re\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\end{array}
\end{array}
if im < -1.09999999999999995e54 or 1.12000000000000002e117 < im Initial program 100.0%
Taylor expanded in im around 0 5.0%
associate-*r*5.0%
neg-mul-15.0%
Simplified5.0%
Taylor expanded in re around 0 20.1%
associate-*r*20.1%
neg-mul-120.1%
Simplified20.1%
if -1.09999999999999995e54 < im < 1.12000000000000002e117Initial program 42.2%
Taylor expanded in im around 0 82.0%
associate-*r*82.0%
neg-mul-182.0%
Simplified82.0%
Final simplification59.0%
(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 63.6%
Taylor expanded in im around 0 53.4%
associate-*r*53.4%
neg-mul-153.4%
Simplified53.4%
Taylor expanded in re around 0 33.3%
associate-*r*33.3%
neg-mul-133.3%
Simplified33.3%
Final simplification33.3%
(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 63.6%
Taylor expanded in im around 0 53.4%
associate-*r*53.4%
neg-mul-153.4%
Simplified53.4%
Applied egg-rr2.7%
Final simplification2.7%
(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 63.6%
Taylor expanded in im around 0 53.4%
associate-*r*53.4%
neg-mul-153.4%
Simplified53.4%
Applied egg-rr2.8%
Final simplification2.8%
(FPCore (re im) :precision binary64 -9.922903012752122e-17)
double code(double re, double im) {
return -9.922903012752122e-17;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -9.922903012752122d-17
end function
public static double code(double re, double im) {
return -9.922903012752122e-17;
}
def code(re, im): return -9.922903012752122e-17
function code(re, im) return -9.922903012752122e-17 end
function tmp = code(re, im) tmp = -9.922903012752122e-17; end
code[re_, im_] := -9.922903012752122e-17
\begin{array}{l}
\\
-9.922903012752122 \cdot 10^{-17}
\end{array}
Initial program 63.6%
Taylor expanded in im around 0 53.4%
associate-*r*53.4%
neg-mul-153.4%
Simplified53.4%
Applied egg-rr2.9%
Final simplification2.9%
(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 63.6%
Taylor expanded in im around 0 53.4%
associate-*r*53.4%
neg-mul-153.4%
Simplified53.4%
Applied egg-rr13.9%
Final simplification13.9%
(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 2023279
(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))))