
(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 -4e+23) (not (<= t_0 0.1)))
(* t_0 (* 0.5 (sin re)))
(*
(sin re)
(+
(* (pow im 5.0) -0.008333333333333333)
(+
(* (pow im 7.0) -0.0001984126984126984)
(- (* (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 <= -4e+23) || !(t_0 <= 0.1)) {
tmp = t_0 * (0.5 * sin(re));
} else {
tmp = sin(re) * ((pow(im, 5.0) * -0.008333333333333333) + ((pow(im, 7.0) * -0.0001984126984126984) + ((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 <= (-4d+23)) .or. (.not. (t_0 <= 0.1d0))) then
tmp = t_0 * (0.5d0 * sin(re))
else
tmp = sin(re) * (((im ** 5.0d0) * (-0.008333333333333333d0)) + (((im ** 7.0d0) * (-0.0001984126984126984d0)) + (((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 <= -4e+23) || !(t_0 <= 0.1)) {
tmp = t_0 * (0.5 * Math.sin(re));
} else {
tmp = Math.sin(re) * ((Math.pow(im, 5.0) * -0.008333333333333333) + ((Math.pow(im, 7.0) * -0.0001984126984126984) + ((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 <= -4e+23) or not (t_0 <= 0.1): tmp = t_0 * (0.5 * math.sin(re)) else: tmp = math.sin(re) * ((math.pow(im, 5.0) * -0.008333333333333333) + ((math.pow(im, 7.0) * -0.0001984126984126984) + ((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 <= -4e+23) || !(t_0 <= 0.1)) tmp = Float64(t_0 * Float64(0.5 * sin(re))); else tmp = Float64(sin(re) * Float64(Float64((im ^ 5.0) * -0.008333333333333333) + Float64(Float64((im ^ 7.0) * -0.0001984126984126984) + 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 <= -4e+23) || ~((t_0 <= 0.1))) tmp = t_0 * (0.5 * sin(re)); else tmp = sin(re) * (((im ^ 5.0) * -0.008333333333333333) + (((im ^ 7.0) * -0.0001984126984126984) + (((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, -4e+23], N[Not[LessEqual[t$95$0, 0.1]], $MachinePrecision]], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision] + N[(N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] + N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -4 \cdot 10^{+23} \lor \neg \left(t_0 \leq 0.1\right):\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left({im}^{5} \cdot -0.008333333333333333 + \left({im}^{7} \cdot -0.0001984126984126984 + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -3.9999999999999997e23 or 0.10000000000000001 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
if -3.9999999999999997e23 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 0.10000000000000001Initial program 30.1%
Taylor expanded in im around 0 99.8%
associate-+r+99.8%
+-commutative99.8%
associate-+l+99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*l*99.8%
+-commutative99.8%
mul-1-neg99.8%
unsub-neg99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (or (<= t_0 -4e+23) (not (<= t_0 2e-9)))
(* t_0 (* 0.5 (sin re)))
(* (- im) (sin re)))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -4e+23) || !(t_0 <= 2e-9)) {
tmp = t_0 * (0.5 * sin(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) :: t_0
real(8) :: tmp
t_0 = exp(-im) - exp(im)
if ((t_0 <= (-4d+23)) .or. (.not. (t_0 <= 2d-9))) then
tmp = t_0 * (0.5d0 * sin(re))
else
tmp = -im * sin(re)
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 <= -4e+23) || !(t_0 <= 2e-9)) {
tmp = t_0 * (0.5 * Math.sin(re));
} else {
tmp = -im * Math.sin(re);
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -4e+23) or not (t_0 <= 2e-9): tmp = t_0 * (0.5 * math.sin(re)) else: tmp = -im * math.sin(re) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= -4e+23) || !(t_0 <= 2e-9)) tmp = Float64(t_0 * Float64(0.5 * sin(re))); else tmp = Float64(Float64(-im) * sin(re)); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -4e+23) || ~((t_0 <= 2e-9))) tmp = t_0 * (0.5 * sin(re)); else tmp = -im * sin(re); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e+23], N[Not[LessEqual[t$95$0, 2e-9]], $MachinePrecision]], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -4 \cdot 10^{+23} \lor \neg \left(t_0 \leq 2 \cdot 10^{-9}\right):\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -3.9999999999999997e23 or 2.00000000000000012e-9 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
if -3.9999999999999997e23 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 2.00000000000000012e-9Initial program 29.6%
Taylor expanded in im around 0 99.8%
mul-1-neg99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (pow im 7.0) (* (sin re) -0.0001984126984126984))))
(if (<= im -2.45e+67)
t_0
(if (<= im -19.5)
(* 0.5 (* (- (exp (- im)) (exp im)) re))
(if (<= im 5.6)
(* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
t_0)))))
double code(double re, double im) {
double t_0 = pow(im, 7.0) * (sin(re) * -0.0001984126984126984);
double tmp;
if (im <= -2.45e+67) {
tmp = t_0;
} else if (im <= -19.5) {
tmp = 0.5 * ((exp(-im) - exp(im)) * re);
} else if (im <= 5.6) {
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 = (im ** 7.0d0) * (sin(re) * (-0.0001984126984126984d0))
if (im <= (-2.45d+67)) then
tmp = t_0
else if (im <= (-19.5d0)) then
tmp = 0.5d0 * ((exp(-im) - exp(im)) * re)
else if (im <= 5.6d0) 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.pow(im, 7.0) * (Math.sin(re) * -0.0001984126984126984);
double tmp;
if (im <= -2.45e+67) {
tmp = t_0;
} else if (im <= -19.5) {
tmp = 0.5 * ((Math.exp(-im) - Math.exp(im)) * re);
} else if (im <= 5.6) {
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.pow(im, 7.0) * (math.sin(re) * -0.0001984126984126984) tmp = 0 if im <= -2.45e+67: tmp = t_0 elif im <= -19.5: tmp = 0.5 * ((math.exp(-im) - math.exp(im)) * re) elif im <= 5.6: 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((im ^ 7.0) * Float64(sin(re) * -0.0001984126984126984)) tmp = 0.0 if (im <= -2.45e+67) tmp = t_0; elseif (im <= -19.5) tmp = Float64(0.5 * Float64(Float64(exp(Float64(-im)) - exp(im)) * re)); elseif (im <= 5.6) 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 = (im ^ 7.0) * (sin(re) * -0.0001984126984126984); tmp = 0.0; if (im <= -2.45e+67) tmp = t_0; elseif (im <= -19.5) tmp = 0.5 * ((exp(-im) - exp(im)) * re); elseif (im <= 5.6) 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[Power[im, 7.0], $MachinePrecision] * N[(N[Sin[re], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.45e+67], t$95$0, If[LessEqual[im, -19.5], N[(0.5 * N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5.6], 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 := {im}^{7} \cdot \left(\sin re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -2.45 \cdot 10^{+67}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -19.5:\\
\;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\
\mathbf{elif}\;im \leq 5.6:\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -2.44999999999999995e67 or 5.5999999999999996 < im Initial program 100.0%
Taylor expanded in im around 0 94.9%
associate-+r+94.9%
+-commutative94.9%
associate-+l+94.9%
associate-*r*94.9%
*-commutative94.9%
associate-*l*94.9%
+-commutative94.9%
mul-1-neg94.9%
unsub-neg94.9%
Simplified94.9%
Taylor expanded in im around inf 94.9%
*-commutative94.9%
*-commutative94.9%
associate-*l*94.9%
Simplified94.9%
if -2.44999999999999995e67 < im < -19.5Initial program 99.9%
Taylor expanded in re around 0 62.4%
if -19.5 < im < 5.5999999999999996Initial program 30.7%
Taylor expanded in im around 0 98.8%
mul-1-neg98.8%
unsub-neg98.8%
*-commutative98.8%
associate-*l*98.8%
distribute-lft-out--98.8%
Simplified98.8%
Final simplification94.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (pow im 7.0) (* (sin re) -0.0001984126984126984))))
(if (<= im -2.45e+67)
t_0
(if (<= im -19.5)
(* 0.5 (* (- (exp (- im)) (exp im)) re))
(if (<= im 4.2) (* (- im) (sin re)) t_0)))))
double code(double re, double im) {
double t_0 = pow(im, 7.0) * (sin(re) * -0.0001984126984126984);
double tmp;
if (im <= -2.45e+67) {
tmp = t_0;
} else if (im <= -19.5) {
tmp = 0.5 * ((exp(-im) - exp(im)) * re);
} else if (im <= 4.2) {
tmp = -im * sin(re);
} 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 = (im ** 7.0d0) * (sin(re) * (-0.0001984126984126984d0))
if (im <= (-2.45d+67)) then
tmp = t_0
else if (im <= (-19.5d0)) then
tmp = 0.5d0 * ((exp(-im) - exp(im)) * re)
else if (im <= 4.2d0) then
tmp = -im * sin(re)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.pow(im, 7.0) * (Math.sin(re) * -0.0001984126984126984);
double tmp;
if (im <= -2.45e+67) {
tmp = t_0;
} else if (im <= -19.5) {
tmp = 0.5 * ((Math.exp(-im) - Math.exp(im)) * re);
} else if (im <= 4.2) {
tmp = -im * Math.sin(re);
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = math.pow(im, 7.0) * (math.sin(re) * -0.0001984126984126984) tmp = 0 if im <= -2.45e+67: tmp = t_0 elif im <= -19.5: tmp = 0.5 * ((math.exp(-im) - math.exp(im)) * re) elif im <= 4.2: tmp = -im * math.sin(re) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64((im ^ 7.0) * Float64(sin(re) * -0.0001984126984126984)) tmp = 0.0 if (im <= -2.45e+67) tmp = t_0; elseif (im <= -19.5) tmp = Float64(0.5 * Float64(Float64(exp(Float64(-im)) - exp(im)) * re)); elseif (im <= 4.2) tmp = Float64(Float64(-im) * sin(re)); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = (im ^ 7.0) * (sin(re) * -0.0001984126984126984); tmp = 0.0; if (im <= -2.45e+67) tmp = t_0; elseif (im <= -19.5) tmp = 0.5 * ((exp(-im) - exp(im)) * re); elseif (im <= 4.2) tmp = -im * sin(re); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 7.0], $MachinePrecision] * N[(N[Sin[re], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.45e+67], t$95$0, If[LessEqual[im, -19.5], N[(0.5 * N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.2], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{7} \cdot \left(\sin re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -2.45 \cdot 10^{+67}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -19.5:\\
\;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\
\mathbf{elif}\;im \leq 4.2:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -2.44999999999999995e67 or 4.20000000000000018 < im Initial program 100.0%
Taylor expanded in im around 0 94.9%
associate-+r+94.9%
+-commutative94.9%
associate-+l+94.9%
associate-*r*94.9%
*-commutative94.9%
associate-*l*94.9%
+-commutative94.9%
mul-1-neg94.9%
unsub-neg94.9%
Simplified94.9%
Taylor expanded in im around inf 94.9%
*-commutative94.9%
*-commutative94.9%
associate-*l*94.9%
Simplified94.9%
if -2.44999999999999995e67 < im < -19.5Initial program 99.9%
Taylor expanded in re around 0 62.4%
if -19.5 < im < 4.20000000000000018Initial program 30.7%
Taylor expanded in im around 0 98.6%
mul-1-neg98.6%
*-commutative98.6%
distribute-rgt-neg-in98.6%
Simplified98.6%
Final simplification94.7%
(FPCore (re im) :precision binary64 (if (or (<= im -4.2) (not (<= im 4.2))) (* (pow im 7.0) (* (sin re) -0.0001984126984126984)) (* (- im) (sin re))))
double code(double re, double im) {
double tmp;
if ((im <= -4.2) || !(im <= 4.2)) {
tmp = pow(im, 7.0) * (sin(re) * -0.0001984126984126984);
} 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.2d0)) .or. (.not. (im <= 4.2d0))) then
tmp = (im ** 7.0d0) * (sin(re) * (-0.0001984126984126984d0))
else
tmp = -im * sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -4.2) || !(im <= 4.2)) {
tmp = Math.pow(im, 7.0) * (Math.sin(re) * -0.0001984126984126984);
} else {
tmp = -im * Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -4.2) or not (im <= 4.2): tmp = math.pow(im, 7.0) * (math.sin(re) * -0.0001984126984126984) else: tmp = -im * math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -4.2) || !(im <= 4.2)) tmp = Float64((im ^ 7.0) * Float64(sin(re) * -0.0001984126984126984)); else tmp = Float64(Float64(-im) * sin(re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -4.2) || ~((im <= 4.2))) tmp = (im ^ 7.0) * (sin(re) * -0.0001984126984126984); else tmp = -im * sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -4.2], N[Not[LessEqual[im, 4.2]], $MachinePrecision]], N[(N[Power[im, 7.0], $MachinePrecision] * N[(N[Sin[re], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.2 \lor \neg \left(im \leq 4.2\right):\\
\;\;\;\;{im}^{7} \cdot \left(\sin re \cdot -0.0001984126984126984\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\end{array}
\end{array}
if im < -4.20000000000000018 or 4.20000000000000018 < im Initial program 100.0%
Taylor expanded in im around 0 85.4%
associate-+r+85.4%
+-commutative85.4%
associate-+l+85.4%
associate-*r*85.4%
*-commutative85.4%
associate-*l*85.4%
+-commutative85.4%
mul-1-neg85.4%
unsub-neg85.4%
Simplified85.4%
Taylor expanded in im around inf 85.4%
*-commutative85.4%
*-commutative85.4%
associate-*l*85.4%
Simplified85.4%
if -4.20000000000000018 < im < 4.20000000000000018Initial program 30.1%
Taylor expanded in im around 0 99.3%
mul-1-neg99.3%
*-commutative99.3%
distribute-rgt-neg-in99.3%
Simplified99.3%
Final simplification92.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.16666666666666666 (* im (pow re 3.0)))))
(if (<= im -3.4e+14)
t_0
(if (<= im 580.0)
(* (- im) (sin re))
(if (<= im 6.4e+125) t_0 (* im (- re)))))))
double code(double re, double im) {
double t_0 = 0.16666666666666666 * (im * pow(re, 3.0));
double tmp;
if (im <= -3.4e+14) {
tmp = t_0;
} else if (im <= 580.0) {
tmp = -im * sin(re);
} else if (im <= 6.4e+125) {
tmp = t_0;
} else {
tmp = im * -re;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = 0.16666666666666666d0 * (im * (re ** 3.0d0))
if (im <= (-3.4d+14)) then
tmp = t_0
else if (im <= 580.0d0) then
tmp = -im * sin(re)
else if (im <= 6.4d+125) then
tmp = t_0
else
tmp = im * -re
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.16666666666666666 * (im * Math.pow(re, 3.0));
double tmp;
if (im <= -3.4e+14) {
tmp = t_0;
} else if (im <= 580.0) {
tmp = -im * Math.sin(re);
} else if (im <= 6.4e+125) {
tmp = t_0;
} else {
tmp = im * -re;
}
return tmp;
}
def code(re, im): t_0 = 0.16666666666666666 * (im * math.pow(re, 3.0)) tmp = 0 if im <= -3.4e+14: tmp = t_0 elif im <= 580.0: tmp = -im * math.sin(re) elif im <= 6.4e+125: tmp = t_0 else: tmp = im * -re return tmp
function code(re, im) t_0 = Float64(0.16666666666666666 * Float64(im * (re ^ 3.0))) tmp = 0.0 if (im <= -3.4e+14) tmp = t_0; elseif (im <= 580.0) tmp = Float64(Float64(-im) * sin(re)); elseif (im <= 6.4e+125) tmp = t_0; else tmp = Float64(im * Float64(-re)); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.16666666666666666 * (im * (re ^ 3.0)); tmp = 0.0; if (im <= -3.4e+14) tmp = t_0; elseif (im <= 580.0) tmp = -im * sin(re); elseif (im <= 6.4e+125) tmp = t_0; else tmp = im * -re; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.16666666666666666 * N[(im * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -3.4e+14], t$95$0, If[LessEqual[im, 580.0], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.4e+125], t$95$0, N[(im * (-re)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\
\mathbf{if}\;im \leq -3.4 \cdot 10^{+14}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 580:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\mathbf{elif}\;im \leq 6.4 \cdot 10^{+125}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-re\right)\\
\end{array}
\end{array}
if im < -3.4e14 or 580 < im < 6.39999999999999967e125Initial program 100.0%
Taylor expanded in im around 0 4.3%
mul-1-neg4.3%
*-commutative4.3%
distribute-rgt-neg-in4.3%
Simplified4.3%
Taylor expanded in re around 0 14.0%
associate-*r*14.0%
associate-*r*14.0%
distribute-rgt-out31.6%
mul-1-neg31.6%
Simplified31.6%
Taylor expanded in re around inf 30.7%
if -3.4e14 < im < 580Initial program 33.3%
Taylor expanded in im around 0 95.1%
mul-1-neg95.1%
*-commutative95.1%
distribute-rgt-neg-in95.1%
Simplified95.1%
if 6.39999999999999967e125 < im Initial program 100.0%
Taylor expanded in im around 0 5.0%
mul-1-neg5.0%
*-commutative5.0%
distribute-rgt-neg-in5.0%
Simplified5.0%
Taylor expanded in re around 0 24.4%
mul-1-neg24.4%
distribute-rgt-neg-in24.4%
Simplified24.4%
Final simplification63.4%
(FPCore (re im) :precision binary64 (if (or (<= im -22000000000000.0) (not (<= im 9.4e+29))) (* (pow im 7.0) (* re -0.0001984126984126984)) (* (- im) (sin re))))
double code(double re, double im) {
double tmp;
if ((im <= -22000000000000.0) || !(im <= 9.4e+29)) {
tmp = pow(im, 7.0) * (re * -0.0001984126984126984);
} 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 <= (-22000000000000.0d0)) .or. (.not. (im <= 9.4d+29))) then
tmp = (im ** 7.0d0) * (re * (-0.0001984126984126984d0))
else
tmp = -im * sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -22000000000000.0) || !(im <= 9.4e+29)) {
tmp = Math.pow(im, 7.0) * (re * -0.0001984126984126984);
} else {
tmp = -im * Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -22000000000000.0) or not (im <= 9.4e+29): tmp = math.pow(im, 7.0) * (re * -0.0001984126984126984) else: tmp = -im * math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -22000000000000.0) || !(im <= 9.4e+29)) tmp = Float64((im ^ 7.0) * Float64(re * -0.0001984126984126984)); else tmp = Float64(Float64(-im) * sin(re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -22000000000000.0) || ~((im <= 9.4e+29))) tmp = (im ^ 7.0) * (re * -0.0001984126984126984); else tmp = -im * sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -22000000000000.0], N[Not[LessEqual[im, 9.4e+29]], $MachinePrecision]], N[(N[Power[im, 7.0], $MachinePrecision] * N[(re * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -22000000000000 \lor \neg \left(im \leq 9.4 \cdot 10^{+29}\right):\\
\;\;\;\;{im}^{7} \cdot \left(re \cdot -0.0001984126984126984\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\end{array}
\end{array}
if im < -2.2e13 or 9.4000000000000004e29 < im Initial program 100.0%
Taylor expanded in im around 0 91.3%
associate-+r+91.3%
+-commutative91.3%
associate-+l+91.3%
associate-*r*91.3%
*-commutative91.3%
associate-*l*91.3%
+-commutative91.3%
mul-1-neg91.3%
unsub-neg91.3%
Simplified91.3%
Taylor expanded in im around inf 91.3%
*-commutative91.3%
*-commutative91.3%
associate-*l*91.3%
Simplified91.3%
Taylor expanded in re around 0 66.0%
associate-*r*66.0%
*-commutative66.0%
Simplified66.0%
if -2.2e13 < im < 9.4000000000000004e29Initial program 34.7%
Taylor expanded in im around 0 93.1%
mul-1-neg93.1%
*-commutative93.1%
distribute-rgt-neg-in93.1%
Simplified93.1%
Final simplification80.4%
(FPCore (re im) :precision binary64 (if (or (<= im -6.4e+103) (not (<= im 5.9e+134))) (* im (- re)) (* (- im) (sin re))))
double code(double re, double im) {
double tmp;
if ((im <= -6.4e+103) || !(im <= 5.9e+134)) {
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 <= (-6.4d+103)) .or. (.not. (im <= 5.9d+134))) 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 <= -6.4e+103) || !(im <= 5.9e+134)) {
tmp = im * -re;
} else {
tmp = -im * Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -6.4e+103) or not (im <= 5.9e+134): tmp = im * -re else: tmp = -im * math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -6.4e+103) || !(im <= 5.9e+134)) tmp = Float64(im * Float64(-re)); else tmp = Float64(Float64(-im) * sin(re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -6.4e+103) || ~((im <= 5.9e+134))) tmp = im * -re; else tmp = -im * sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -6.4e+103], N[Not[LessEqual[im, 5.9e+134]], $MachinePrecision]], N[(im * (-re)), $MachinePrecision], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -6.4 \cdot 10^{+103} \lor \neg \left(im \leq 5.9 \cdot 10^{+134}\right):\\
\;\;\;\;im \cdot \left(-re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\end{array}
\end{array}
if im < -6.39999999999999985e103 or 5.90000000000000008e134 < im Initial program 100.0%
Taylor expanded in im around 0 5.2%
mul-1-neg5.2%
*-commutative5.2%
distribute-rgt-neg-in5.2%
Simplified5.2%
Taylor expanded in re around 0 20.5%
mul-1-neg20.5%
distribute-rgt-neg-in20.5%
Simplified20.5%
if -6.39999999999999985e103 < im < 5.90000000000000008e134Initial program 50.4%
Taylor expanded in im around 0 71.5%
mul-1-neg71.5%
*-commutative71.5%
distribute-rgt-neg-in71.5%
Simplified71.5%
Final simplification56.2%
(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 65.3%
Taylor expanded in im around 0 51.6%
mul-1-neg51.6%
*-commutative51.6%
distribute-rgt-neg-in51.6%
Simplified51.6%
Taylor expanded in re around 0 30.2%
mul-1-neg30.2%
distribute-rgt-neg-in30.2%
Simplified30.2%
Final simplification30.2%
(FPCore (re im) :precision binary64 -1.5)
double code(double re, double im) {
return -1.5;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -1.5d0
end function
public static double code(double re, double im) {
return -1.5;
}
def code(re, im): return -1.5
function code(re, im) return -1.5 end
function tmp = code(re, im) tmp = -1.5; end
code[re_, im_] := -1.5
\begin{array}{l}
\\
-1.5
\end{array}
Initial program 65.3%
Taylor expanded in re around 0 48.6%
Applied egg-rr2.8%
Final simplification2.8%
(FPCore (re im) :precision binary64 -0.004166666666666667)
double code(double re, double im) {
return -0.004166666666666667;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -0.004166666666666667d0
end function
public static double code(double re, double im) {
return -0.004166666666666667;
}
def code(re, im): return -0.004166666666666667
function code(re, im) return -0.004166666666666667 end
function tmp = code(re, im) tmp = -0.004166666666666667; end
code[re_, im_] := -0.004166666666666667
\begin{array}{l}
\\
-0.004166666666666667
\end{array}
Initial program 65.3%
Taylor expanded in re around 0 48.6%
Applied egg-rr2.8%
Final simplification2.8%
(FPCore (re im) :precision binary64 -3.9055157630365495e-12)
double code(double re, double im) {
return -3.9055157630365495e-12;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -3.9055157630365495d-12
end function
public static double code(double re, double im) {
return -3.9055157630365495e-12;
}
def code(re, im): return -3.9055157630365495e-12
function code(re, im) return -3.9055157630365495e-12 end
function tmp = code(re, im) tmp = -3.9055157630365495e-12; end
code[re_, im_] := -3.9055157630365495e-12
\begin{array}{l}
\\
-3.9055157630365495 \cdot 10^{-12}
\end{array}
Initial program 65.3%
Taylor expanded in re around 0 48.6%
Applied egg-rr2.8%
Final simplification2.8%
(FPCore (re im) :precision binary64 -2.382841615671091e-34)
double code(double re, double im) {
return -2.382841615671091e-34;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -2.382841615671091d-34
end function
public static double code(double re, double im) {
return -2.382841615671091e-34;
}
def code(re, im): return -2.382841615671091e-34
function code(re, im) return -2.382841615671091e-34 end
function tmp = code(re, im) tmp = -2.382841615671091e-34; end
code[re_, im_] := -2.382841615671091e-34
\begin{array}{l}
\\
-2.382841615671091 \cdot 10^{-34}
\end{array}
Initial program 65.3%
Taylor expanded in re around 0 48.6%
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 65.3%
Taylor expanded in re around 0 48.6%
Applied egg-rr14.6%
Final simplification14.6%
(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 2023178
(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))))