
(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 14 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 -5.0) (not (<= t_0 2e-12)))
(* t_0 (* 0.5 (sin re)))
(*
(sin re)
(+
(* (pow im 3.0) -0.16666666666666666)
(- (* (pow im 5.0) -0.008333333333333333) im))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -5.0) || !(t_0 <= 2e-12)) {
tmp = t_0 * (0.5 * sin(re));
} else {
tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) + ((pow(im, 5.0) * -0.008333333333333333) - 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 <= (-5.0d0)) .or. (.not. (t_0 <= 2d-12))) then
tmp = t_0 * (0.5d0 * sin(re))
else
tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) + (((im ** 5.0d0) * (-0.008333333333333333d0)) - 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 <= -5.0) || !(t_0 <= 2e-12)) {
tmp = t_0 * (0.5 * Math.sin(re));
} else {
tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) + ((Math.pow(im, 5.0) * -0.008333333333333333) - im));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -5.0) 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) + ((math.pow(im, 5.0) * -0.008333333333333333) - im)) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= -5.0) || !(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) + Float64(Float64((im ^ 5.0) * -0.008333333333333333) - im))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -5.0) || ~((t_0 <= 2e-12))) tmp = t_0 * (0.5 * sin(re)); else tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) + (((im ^ 5.0) * -0.008333333333333333) - 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, -5.0], 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] + N[(N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -5 \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 + \left({im}^{5} \cdot -0.008333333333333333 - im\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%
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.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%
mul-1-neg99.8%
unsub-neg99.8%
*-commutative99.8%
associate-*l*99.8%
distribute-lft-out--99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (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%
associate-*r*93.8%
*-commutative93.8%
associate-*l*93.8%
+-commutative93.8%
mul-1-neg93.8%
distribute-rgt-neg-in93.8%
*-commutative93.8%
associate-*l*93.8%
distribute-lft-out93.8%
distribute-lft-out93.8%
*-commutative93.8%
+-commutative93.8%
sub-neg93.8%
Simplified93.8%
Taylor expanded in im around inf 93.8%
*-commutative93.8%
associate-*l*93.8%
*-commutative93.8%
Simplified93.8%
if -2.20000000000000001e70 < im < -130Initial program 100.0%
Taylor expanded in re around 0 81.3%
if -130 < im < 5Initial program 30.6%
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 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%
associate-*r*83.8%
*-commutative83.8%
associate-*l*83.8%
+-commutative83.8%
mul-1-neg83.8%
distribute-rgt-neg-in83.8%
*-commutative83.8%
associate-*l*83.8%
distribute-lft-out83.8%
distribute-lft-out83.8%
*-commutative83.8%
+-commutative83.8%
sub-neg83.8%
Simplified83.8%
Taylor expanded in im around inf 83.8%
*-commutative83.8%
associate-*l*83.8%
*-commutative83.8%
Simplified83.8%
if -5 < im < 5Initial program 30.0%
Taylor expanded in im around 0 99.2%
mul-1-neg99.2%
unsub-neg99.2%
*-commutative99.2%
associate-*l*99.2%
distribute-lft-out--99.2%
Simplified99.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(Float64(-im) * 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}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\end{array}
\end{array}
if im < -3.2999999999999998 or 3.2999999999999998 < im Initial program 100.0%
Taylor expanded in im around 0 83.8%
associate-*r*83.8%
*-commutative83.8%
associate-*l*83.8%
+-commutative83.8%
mul-1-neg83.8%
distribute-rgt-neg-in83.8%
*-commutative83.8%
associate-*l*83.8%
distribute-lft-out83.8%
distribute-lft-out83.8%
*-commutative83.8%
+-commutative83.8%
sub-neg83.8%
Simplified83.8%
Taylor expanded in im around inf 83.8%
*-commutative83.8%
associate-*l*83.8%
*-commutative83.8%
Simplified83.8%
if -3.2999999999999998 < im < 3.2999999999999998Initial program 30.0%
Taylor expanded in im around 0 98.5%
mul-1-neg98.5%
*-commutative98.5%
distribute-lft-neg-in98.5%
Simplified98.5%
Final simplification91.4%
(FPCore (re im)
:precision binary64
(if (<= im -8.2e+18)
(* re (sqrt (* (pow im 10.0) 6.944444444444444e-5)))
(if (<= im 8.2e+41)
(* (- im) (sin re))
(* -0.008333333333333333 (* re (pow im 5.0))))))
double code(double re, double im) {
double tmp;
if (im <= -8.2e+18) {
tmp = re * sqrt((pow(im, 10.0) * 6.944444444444444e-5));
} else if (im <= 8.2e+41) {
tmp = -im * sin(re);
} else {
tmp = -0.008333333333333333 * (re * pow(im, 5.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-8.2d+18)) then
tmp = re * sqrt(((im ** 10.0d0) * 6.944444444444444d-5))
else if (im <= 8.2d+41) then
tmp = -im * sin(re)
else
tmp = (-0.008333333333333333d0) * (re * (im ** 5.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -8.2e+18) {
tmp = re * Math.sqrt((Math.pow(im, 10.0) * 6.944444444444444e-5));
} else if (im <= 8.2e+41) {
tmp = -im * Math.sin(re);
} else {
tmp = -0.008333333333333333 * (re * Math.pow(im, 5.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -8.2e+18: tmp = re * math.sqrt((math.pow(im, 10.0) * 6.944444444444444e-5)) elif im <= 8.2e+41: tmp = -im * math.sin(re) else: tmp = -0.008333333333333333 * (re * math.pow(im, 5.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= -8.2e+18) tmp = Float64(re * sqrt(Float64((im ^ 10.0) * 6.944444444444444e-5))); elseif (im <= 8.2e+41) tmp = Float64(Float64(-im) * sin(re)); else tmp = Float64(-0.008333333333333333 * Float64(re * (im ^ 5.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -8.2e+18) tmp = re * sqrt(((im ^ 10.0) * 6.944444444444444e-5)); elseif (im <= 8.2e+41) tmp = -im * sin(re); else tmp = -0.008333333333333333 * (re * (im ^ 5.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -8.2e+18], N[(re * N[Sqrt[N[(N[Power[im, 10.0], $MachinePrecision] * 6.944444444444444e-5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 8.2e+41], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision], N[(-0.008333333333333333 * N[(re * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -8.2 \cdot 10^{+18}:\\
\;\;\;\;re \cdot \sqrt{{im}^{10} \cdot 6.944444444444444 \cdot 10^{-5}}\\
\mathbf{elif}\;im \leq 8.2 \cdot 10^{+41}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\mathbf{else}:\\
\;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\
\end{array}
\end{array}
if im < -8.2e18Initial program 100.0%
Taylor expanded in im around 0 90.8%
associate-*r*90.8%
*-commutative90.8%
associate-*l*90.8%
+-commutative90.8%
mul-1-neg90.8%
distribute-rgt-neg-in90.8%
*-commutative90.8%
associate-*l*90.8%
distribute-lft-out90.8%
distribute-lft-out90.8%
*-commutative90.8%
+-commutative90.8%
sub-neg90.8%
Simplified90.8%
Taylor expanded in im around inf 90.8%
*-commutative90.8%
associate-*l*90.8%
*-commutative90.8%
Simplified90.8%
Taylor expanded in re around 0 66.4%
add-sqr-sqrt66.4%
sqrt-unprod71.0%
*-commutative71.0%
*-commutative71.0%
swap-sqr71.0%
pow-prod-up71.0%
metadata-eval71.0%
metadata-eval71.0%
Applied egg-rr71.0%
if -8.2e18 < im < 8.2000000000000007e41Initial program 36.7%
Taylor expanded in im around 0 89.5%
mul-1-neg89.5%
*-commutative89.5%
distribute-lft-neg-in89.5%
Simplified89.5%
if 8.2000000000000007e41 < im Initial program 100.0%
Taylor expanded in im around 0 98.0%
associate-*r*98.0%
*-commutative98.0%
associate-*l*98.0%
+-commutative98.0%
mul-1-neg98.0%
distribute-rgt-neg-in98.0%
*-commutative98.0%
associate-*l*98.0%
distribute-lft-out98.0%
distribute-lft-out98.0%
*-commutative98.0%
+-commutative98.0%
sub-neg98.0%
Simplified98.0%
Taylor expanded in im around inf 98.0%
*-commutative98.0%
associate-*l*98.0%
*-commutative98.0%
Simplified98.0%
Taylor expanded in re around 0 68.2%
Final simplification81.1%
(FPCore (re im) :precision binary64 (if (or (<= im -4.8e+51) (not (<= im 8.2e+41))) (* -0.008333333333333333 (* re (pow im 5.0))) (* (- im) (sin re))))
double code(double re, double im) {
double tmp;
if ((im <= -4.8e+51) || !(im <= 8.2e+41)) {
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 <= (-4.8d+51)) .or. (.not. (im <= 8.2d+41))) 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 <= -4.8e+51) || !(im <= 8.2e+41)) {
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 <= -4.8e+51) or not (im <= 8.2e+41): 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 <= -4.8e+51) || !(im <= 8.2e+41)) tmp = Float64(-0.008333333333333333 * Float64(re * (im ^ 5.0))); else tmp = Float64(Float64(-im) * sin(re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -4.8e+51) || ~((im <= 8.2e+41))) tmp = -0.008333333333333333 * (re * (im ^ 5.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.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 -4.8 \cdot 10^{+51} \lor \neg \left(im \leq 8.2 \cdot 10^{+41}\right):\\
\;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\end{array}
\end{array}
if im < -4.7999999999999997e51 or 8.2000000000000007e41 < im Initial program 100.0%
Taylor expanded in im around 0 97.3%
associate-*r*97.3%
*-commutative97.3%
associate-*l*97.3%
+-commutative97.3%
mul-1-neg97.3%
distribute-rgt-neg-in97.3%
*-commutative97.3%
associate-*l*97.3%
distribute-lft-out97.3%
distribute-lft-out97.3%
*-commutative97.3%
+-commutative97.3%
sub-neg97.3%
Simplified97.3%
Taylor expanded in im around inf 97.3%
*-commutative97.3%
associate-*l*97.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%
mul-1-neg87.2%
*-commutative87.2%
distribute-lft-neg-in87.2%
Simplified87.2%
Final simplification80.0%
(FPCore (re im) :precision binary64 (if (<= im -5.5e+53) (- (* im re)) (if (<= im 1.85e+161) (* (- im) (sin re)) (* im re))))
double code(double re, double im) {
double tmp;
if (im <= -5.5e+53) {
tmp = -(im * re);
} else if (im <= 1.85e+161) {
tmp = -im * sin(re);
} else {
tmp = im * re;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-5.5d+53)) then
tmp = -(im * re)
else if (im <= 1.85d+161) then
tmp = -im * sin(re)
else
tmp = im * re
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -5.5e+53) {
tmp = -(im * re);
} else if (im <= 1.85e+161) {
tmp = -im * Math.sin(re);
} else {
tmp = im * re;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -5.5e+53: tmp = -(im * re) elif im <= 1.85e+161: tmp = -im * math.sin(re) else: tmp = im * re return tmp
function code(re, im) tmp = 0.0 if (im <= -5.5e+53) tmp = Float64(-Float64(im * re)); elseif (im <= 1.85e+161) tmp = Float64(Float64(-im) * sin(re)); else tmp = Float64(im * re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -5.5e+53) tmp = -(im * re); elseif (im <= 1.85e+161) tmp = -im * sin(re); else tmp = im * re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -5.5e+53], (-N[(im * re), $MachinePrecision]), If[LessEqual[im, 1.85e+161], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision], N[(im * re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -5.5 \cdot 10^{+53}:\\
\;\;\;\;-im \cdot re\\
\mathbf{elif}\;im \leq 1.85 \cdot 10^{+161}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\mathbf{else}:\\
\;\;\;\;im \cdot re\\
\end{array}
\end{array}
if im < -5.49999999999999975e53Initial program 100.0%
Taylor expanded in im around 0 4.9%
mul-1-neg4.9%
*-commutative4.9%
distribute-lft-neg-in4.9%
Simplified4.9%
Taylor expanded in re around 0 19.5%
if -5.49999999999999975e53 < im < 1.8499999999999999e161Initial program 44.9%
Taylor expanded in im around 0 78.3%
mul-1-neg78.3%
*-commutative78.3%
distribute-lft-neg-in78.3%
Simplified78.3%
if 1.8499999999999999e161 < 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 11.7%
expm1-log1p-u11.3%
expm1-udef11.2%
+-commutative11.2%
fma-def11.2%
*-commutative11.2%
add-sqr-sqrt0.7%
sqrt-unprod35.0%
mul-1-neg35.0%
mul-1-neg35.0%
sqr-neg35.0%
sqrt-unprod24.3%
add-sqr-sqrt24.3%
Applied egg-rr24.3%
expm1-def24.3%
expm1-log1p41.5%
fma-udef41.5%
*-commutative41.5%
associate-*r*41.5%
distribute-rgt-out41.5%
*-commutative41.5%
Simplified41.5%
Taylor expanded in re around 0 32.2%
Final simplification59.7%
(FPCore (re im) :precision binary64 (- (* im re)))
double code(double re, double im) {
return -(im * re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -(im * re)
end function
public static double code(double re, double im) {
return -(im * re);
}
def code(re, im): return -(im * re)
function code(re, im) return Float64(-Float64(im * re)) end
function tmp = code(re, im) tmp = -(im * re); end
code[re_, im_] := (-N[(im * re), $MachinePrecision])
\begin{array}{l}
\\
-im \cdot re
\end{array}
Initial program 63.6%
Taylor expanded in im around 0 53.4%
mul-1-neg53.4%
*-commutative53.4%
distribute-lft-neg-in53.4%
Simplified53.4%
Taylor expanded in re around 0 33.3%
Final simplification33.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 * re) end
function tmp = code(re, im) tmp = im * re; end
code[re_, im_] := N[(im * re), $MachinePrecision]
\begin{array}{l}
\\
im \cdot re
\end{array}
Initial program 63.6%
Taylor expanded in im around 0 53.4%
mul-1-neg53.4%
*-commutative53.4%
distribute-lft-neg-in53.4%
Simplified53.4%
Taylor expanded in re around 0 31.8%
expm1-log1p-u29.7%
expm1-udef16.8%
+-commutative16.8%
fma-def16.8%
*-commutative16.8%
add-sqr-sqrt11.5%
sqrt-unprod23.4%
mul-1-neg23.4%
mul-1-neg23.4%
sqr-neg23.4%
sqrt-unprod18.6%
add-sqr-sqrt20.2%
Applied egg-rr20.2%
expm1-def19.8%
expm1-log1p24.8%
fma-udef24.8%
*-commutative24.8%
associate-*r*24.8%
distribute-rgt-out24.8%
*-commutative24.8%
Simplified24.8%
Taylor expanded in re around 0 19.7%
Final simplification19.7%
(FPCore (re im) :precision binary64 -3.0)
double code(double re, double im) {
return -3.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -3.0d0
end function
public static double code(double re, double im) {
return -3.0;
}
def code(re, im): return -3.0
function code(re, im) return -3.0 end
function tmp = code(re, im) tmp = -3.0; end
code[re_, im_] := -3.0
\begin{array}{l}
\\
-3
\end{array}
Initial program 63.6%
Taylor expanded in im around 0 53.4%
mul-1-neg53.4%
*-commutative53.4%
distribute-lft-neg-in53.4%
Simplified53.4%
Applied egg-rr2.8%
Final simplification2.8%
(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%
mul-1-neg53.4%
*-commutative53.4%
distribute-lft-neg-in53.4%
Simplified53.4%
Applied egg-rr2.8%
Final simplification2.8%
(FPCore (re im) :precision binary64 -1.9380669946781487e-19)
double code(double re, double im) {
return -1.9380669946781487e-19;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -1.9380669946781487d-19
end function
public static double code(double re, double im) {
return -1.9380669946781487e-19;
}
def code(re, im): return -1.9380669946781487e-19
function code(re, im) return -1.9380669946781487e-19 end
function tmp = code(re, im) tmp = -1.9380669946781487e-19; end
code[re_, im_] := -1.9380669946781487e-19
\begin{array}{l}
\\
-1.9380669946781487 \cdot 10^{-19}
\end{array}
Initial program 63.6%
Taylor expanded in im around 0 53.4%
mul-1-neg53.4%
*-commutative53.4%
distribute-lft-neg-in53.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%
mul-1-neg53.4%
*-commutative53.4%
distribute-lft-neg-in53.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))))