
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))) (t_1 (* 0.5 (cos re))))
(if (or (<= t_0 -10.0) (not (<= t_0 0.0004)))
(* t_1 t_0)
(*
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 * cos(re);
double tmp;
if ((t_0 <= -10.0) || !(t_0 <= 0.0004)) {
tmp = t_1 * t_0;
} 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 * cos(re)
if ((t_0 <= (-10.0d0)) .or. (.not. (t_0 <= 0.0004d0))) then
tmp = t_1 * t_0
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.cos(re);
double tmp;
if ((t_0 <= -10.0) || !(t_0 <= 0.0004)) {
tmp = t_1 * t_0;
} 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.cos(re) tmp = 0 if (t_0 <= -10.0) or not (t_0 <= 0.0004): tmp = t_1 * t_0 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 * cos(re)) tmp = 0.0 if ((t_0 <= -10.0) || !(t_0 <= 0.0004)) tmp = Float64(t_1 * t_0); 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 * cos(re); tmp = 0.0; if ((t_0 <= -10.0) || ~((t_0 <= 0.0004))) tmp = t_1 * t_0; 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[Cos[re], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -10.0], N[Not[LessEqual[t$95$0, 0.0004]], $MachinePrecision]], N[(t$95$1 * t$95$0), $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 \cos re\\
\mathbf{if}\;t_0 \leq -10 \lor \neg \left(t_0 \leq 0.0004\right):\\
\;\;\;\;t_1 \cdot t_0\\
\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 (-.f64 0 im)) (exp.f64 im)) < -10 or 4.00000000000000019e-4 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
if -10 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 4.00000000000000019e-4Initial program 9.9%
neg-sub09.9%
Simplified9.9%
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.005) (not (<= t_0 0.0004)))
(* (* 0.5 (cos re)) t_0)
(- (* -0.16666666666666666 (* (cos re) (pow im 3.0))) (* im (cos re))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -0.005) || !(t_0 <= 0.0004)) {
tmp = (0.5 * cos(re)) * t_0;
} else {
tmp = (-0.16666666666666666 * (cos(re) * pow(im, 3.0))) - (im * cos(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 <= (-0.005d0)) .or. (.not. (t_0 <= 0.0004d0))) then
tmp = (0.5d0 * cos(re)) * t_0
else
tmp = ((-0.16666666666666666d0) * (cos(re) * (im ** 3.0d0))) - (im * cos(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 <= -0.005) || !(t_0 <= 0.0004)) {
tmp = (0.5 * Math.cos(re)) * t_0;
} else {
tmp = (-0.16666666666666666 * (Math.cos(re) * Math.pow(im, 3.0))) - (im * Math.cos(re));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -0.005) or not (t_0 <= 0.0004): tmp = (0.5 * math.cos(re)) * t_0 else: tmp = (-0.16666666666666666 * (math.cos(re) * math.pow(im, 3.0))) - (im * math.cos(re)) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= -0.005) || !(t_0 <= 0.0004)) tmp = Float64(Float64(0.5 * cos(re)) * t_0); else tmp = Float64(Float64(-0.16666666666666666 * Float64(cos(re) * (im ^ 3.0))) - Float64(im * cos(re))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -0.005) || ~((t_0 <= 0.0004))) tmp = (0.5 * cos(re)) * t_0; else tmp = (-0.16666666666666666 * (cos(re) * (im ^ 3.0))) - (im * cos(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, -0.005], N[Not[LessEqual[t$95$0, 0.0004]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(-0.16666666666666666 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -0.005 \lor \neg \left(t_0 \leq 0.0004\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - im \cdot \cos re\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -0.0050000000000000001 or 4.00000000000000019e-4 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 99.9%
neg-sub099.9%
Simplified99.9%
if -0.0050000000000000001 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 4.00000000000000019e-4Initial program 9.1%
neg-sub09.1%
Simplified9.1%
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.005) (not (<= t_0 0.0004)))
(* (* 0.5 (cos re)) t_0)
(* (cos 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.005) || !(t_0 <= 0.0004)) {
tmp = (0.5 * cos(re)) * t_0;
} else {
tmp = cos(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.005d0)) .or. (.not. (t_0 <= 0.0004d0))) then
tmp = (0.5d0 * cos(re)) * t_0
else
tmp = cos(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.005) || !(t_0 <= 0.0004)) {
tmp = (0.5 * Math.cos(re)) * t_0;
} else {
tmp = Math.cos(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.005) or not (t_0 <= 0.0004): tmp = (0.5 * math.cos(re)) * t_0 else: tmp = math.cos(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.005) || !(t_0 <= 0.0004)) tmp = Float64(Float64(0.5 * cos(re)) * t_0); else tmp = Float64(cos(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.005) || ~((t_0 <= 0.0004))) tmp = (0.5 * cos(re)) * t_0; else tmp = cos(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.005], N[Not[LessEqual[t$95$0, 0.0004]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[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.005 \lor \neg \left(t_0 \leq 0.0004\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -0.0050000000000000001 or 4.00000000000000019e-4 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 99.9%
neg-sub099.9%
Simplified99.9%
if -0.0050000000000000001 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 4.00000000000000019e-4Initial program 9.1%
neg-sub09.1%
Simplified9.1%
Taylor expanded in im around 0 99.8%
+-commutative99.8%
mul-1-neg99.8%
unsub-neg99.8%
associate-*r*99.8%
distribute-rgt-out--99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
(t_1 (* (pow im 5.0) (* (cos re) -0.008333333333333333))))
(if (<= im -4.4e+74)
t_1
(if (<= im -0.072)
t_0
(if (<= im 0.14)
(/
(* 0.5 (cos re))
(+ (* im 0.08333333333333333) (* 0.5 (/ -1.0 im))))
(if (<= im 4.5e+61) t_0 t_1))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(-im) - exp(im));
double t_1 = pow(im, 5.0) * (cos(re) * -0.008333333333333333);
double tmp;
if (im <= -4.4e+74) {
tmp = t_1;
} else if (im <= -0.072) {
tmp = t_0;
} else if (im <= 0.14) {
tmp = (0.5 * cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.0 / im)));
} else if (im <= 4.5e+61) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * (exp(-im) - exp(im))
t_1 = (im ** 5.0d0) * (cos(re) * (-0.008333333333333333d0))
if (im <= (-4.4d+74)) then
tmp = t_1
else if (im <= (-0.072d0)) then
tmp = t_0
else if (im <= 0.14d0) then
tmp = (0.5d0 * cos(re)) / ((im * 0.08333333333333333d0) + (0.5d0 * ((-1.0d0) / im)))
else if (im <= 4.5d+61) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
double t_1 = Math.pow(im, 5.0) * (Math.cos(re) * -0.008333333333333333);
double tmp;
if (im <= -4.4e+74) {
tmp = t_1;
} else if (im <= -0.072) {
tmp = t_0;
} else if (im <= 0.14) {
tmp = (0.5 * Math.cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.0 / im)));
} else if (im <= 4.5e+61) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.exp(-im) - math.exp(im)) t_1 = math.pow(im, 5.0) * (math.cos(re) * -0.008333333333333333) tmp = 0 if im <= -4.4e+74: tmp = t_1 elif im <= -0.072: tmp = t_0 elif im <= 0.14: tmp = (0.5 * math.cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.0 / im))) elif im <= 4.5e+61: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))) t_1 = Float64((im ^ 5.0) * Float64(cos(re) * -0.008333333333333333)) tmp = 0.0 if (im <= -4.4e+74) tmp = t_1; elseif (im <= -0.072) tmp = t_0; elseif (im <= 0.14) tmp = Float64(Float64(0.5 * cos(re)) / Float64(Float64(im * 0.08333333333333333) + Float64(0.5 * Float64(-1.0 / im)))); elseif (im <= 4.5e+61) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (exp(-im) - exp(im)); t_1 = (im ^ 5.0) * (cos(re) * -0.008333333333333333); tmp = 0.0; if (im <= -4.4e+74) tmp = t_1; elseif (im <= -0.072) tmp = t_0; elseif (im <= 0.14) tmp = (0.5 * cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.0 / im))); elseif (im <= 4.5e+61) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[im, 5.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4.4e+74], t$95$1, If[LessEqual[im, -0.072], t$95$0, If[LessEqual[im, 0.14], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] / N[(N[(im * 0.08333333333333333), $MachinePrecision] + N[(0.5 * N[(-1.0 / im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.5e+61], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := {im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\
\mathbf{if}\;im \leq -4.4 \cdot 10^{+74}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.072:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.14:\\
\;\;\;\;\frac{0.5 \cdot \cos re}{im \cdot 0.08333333333333333 + 0.5 \cdot \frac{-1}{im}}\\
\mathbf{elif}\;im \leq 4.5 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -4.4000000000000002e74 or 4.5e61 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
if -4.4000000000000002e74 < im < -0.0719999999999999946 or 0.14000000000000001 < im < 4.5e61Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 81.0%
if -0.0719999999999999946 < im < 0.14000000000000001Initial program 9.9%
neg-sub09.9%
Simplified9.9%
Taylor expanded in im around 0 99.8%
flip-+60.7%
associate-*r/60.5%
Applied egg-rr60.5%
associate-/l*60.4%
*-commutative60.4%
*-commutative60.4%
Simplified60.4%
Taylor expanded in im around 0 99.3%
Final simplification97.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
(t_1 (* (pow im 5.0) (* (cos re) -0.008333333333333333))))
(if (<= im -4.4e+74)
t_1
(if (<= im -0.122)
t_0
(if (<= im 2.6)
(* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))
(if (<= im 4.5e+61) t_0 t_1))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(-im) - exp(im));
double t_1 = pow(im, 5.0) * (cos(re) * -0.008333333333333333);
double tmp;
if (im <= -4.4e+74) {
tmp = t_1;
} else if (im <= -0.122) {
tmp = t_0;
} else if (im <= 2.6) {
tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 4.5e+61) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * (exp(-im) - exp(im))
t_1 = (im ** 5.0d0) * (cos(re) * (-0.008333333333333333d0))
if (im <= (-4.4d+74)) then
tmp = t_1
else if (im <= (-0.122d0)) then
tmp = t_0
else if (im <= 2.6d0) then
tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else if (im <= 4.5d+61) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
double t_1 = Math.pow(im, 5.0) * (Math.cos(re) * -0.008333333333333333);
double tmp;
if (im <= -4.4e+74) {
tmp = t_1;
} else if (im <= -0.122) {
tmp = t_0;
} else if (im <= 2.6) {
tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 4.5e+61) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.exp(-im) - math.exp(im)) t_1 = math.pow(im, 5.0) * (math.cos(re) * -0.008333333333333333) tmp = 0 if im <= -4.4e+74: tmp = t_1 elif im <= -0.122: tmp = t_0 elif im <= 2.6: tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) elif im <= 4.5e+61: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))) t_1 = Float64((im ^ 5.0) * Float64(cos(re) * -0.008333333333333333)) tmp = 0.0 if (im <= -4.4e+74) tmp = t_1; elseif (im <= -0.122) tmp = t_0; elseif (im <= 2.6) tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); elseif (im <= 4.5e+61) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (exp(-im) - exp(im)); t_1 = (im ^ 5.0) * (cos(re) * -0.008333333333333333); tmp = 0.0; if (im <= -4.4e+74) tmp = t_1; elseif (im <= -0.122) tmp = t_0; elseif (im <= 2.6) tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im); elseif (im <= 4.5e+61) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[im, 5.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4.4e+74], t$95$1, If[LessEqual[im, -0.122], t$95$0, If[LessEqual[im, 2.6], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.5e+61], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := {im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\
\mathbf{if}\;im \leq -4.4 \cdot 10^{+74}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.122:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 2.6:\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{elif}\;im \leq 4.5 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -4.4000000000000002e74 or 4.5e61 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
if -4.4000000000000002e74 < im < -0.122 or 2.60000000000000009 < im < 4.5e61Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 82.9%
if -0.122 < im < 2.60000000000000009Initial program 10.6%
neg-sub010.6%
Simplified10.6%
Taylor expanded in im around 0 99.0%
+-commutative99.0%
mul-1-neg99.0%
unsub-neg99.0%
associate-*r*99.0%
distribute-rgt-out--99.0%
*-commutative99.0%
Simplified99.0%
Final simplification97.2%
(FPCore (re im) :precision binary64 (if (or (<= im -0.19) (not (<= im 0.0295))) (* 0.5 (- (exp (- im)) (exp im))) (/ (* 0.5 (cos re)) (+ (* im 0.08333333333333333) (* 0.5 (/ -1.0 im))))))
double code(double re, double im) {
double tmp;
if ((im <= -0.19) || !(im <= 0.0295)) {
tmp = 0.5 * (exp(-im) - exp(im));
} else {
tmp = (0.5 * cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.0 / im)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-0.19d0)) .or. (.not. (im <= 0.0295d0))) then
tmp = 0.5d0 * (exp(-im) - exp(im))
else
tmp = (0.5d0 * cos(re)) / ((im * 0.08333333333333333d0) + (0.5d0 * ((-1.0d0) / im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -0.19) || !(im <= 0.0295)) {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
} else {
tmp = (0.5 * Math.cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.0 / im)));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -0.19) or not (im <= 0.0295): tmp = 0.5 * (math.exp(-im) - math.exp(im)) else: tmp = (0.5 * math.cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.0 / im))) return tmp
function code(re, im) tmp = 0.0 if ((im <= -0.19) || !(im <= 0.0295)) tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); else tmp = Float64(Float64(0.5 * cos(re)) / Float64(Float64(im * 0.08333333333333333) + Float64(0.5 * Float64(-1.0 / im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -0.19) || ~((im <= 0.0295))) tmp = 0.5 * (exp(-im) - exp(im)); else tmp = (0.5 * cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.0 / im))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -0.19], N[Not[LessEqual[im, 0.0295]], $MachinePrecision]], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] / N[(N[(im * 0.08333333333333333), $MachinePrecision] + N[(0.5 * N[(-1.0 / im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.19 \lor \neg \left(im \leq 0.0295\right):\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 \cdot \cos re}{im \cdot 0.08333333333333333 + 0.5 \cdot \frac{-1}{im}}\\
\end{array}
\end{array}
if im < -0.19 or 0.029499999999999998 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 79.0%
if -0.19 < im < 0.029499999999999998Initial program 9.9%
neg-sub09.9%
Simplified9.9%
Taylor expanded in im around 0 99.8%
flip-+60.7%
associate-*r/60.5%
Applied egg-rr60.5%
associate-/l*60.4%
*-commutative60.4%
*-commutative60.4%
Simplified60.4%
Taylor expanded in im around 0 99.3%
Final simplification88.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im)))
(if (<= im -2.4)
t_0
(if (<= im 2.6)
(/ (* 0.5 (cos re)) (+ (* im 0.08333333333333333) (* 0.5 (/ -1.0 im))))
(if (<= im 7e+96) (- (* 0.5 (* im (pow re 2.0))) im) t_0)))))
double code(double re, double im) {
double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
double tmp;
if (im <= -2.4) {
tmp = t_0;
} else if (im <= 2.6) {
tmp = (0.5 * cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.0 / im)));
} else if (im <= 7e+96) {
tmp = (0.5 * (im * pow(re, 2.0))) - 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 ** 3.0d0) * (-0.16666666666666666d0)) - im
if (im <= (-2.4d0)) then
tmp = t_0
else if (im <= 2.6d0) then
tmp = (0.5d0 * cos(re)) / ((im * 0.08333333333333333d0) + (0.5d0 * ((-1.0d0) / im)))
else if (im <= 7d+96) then
tmp = (0.5d0 * (im * (re ** 2.0d0))) - 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, 3.0) * -0.16666666666666666) - im;
double tmp;
if (im <= -2.4) {
tmp = t_0;
} else if (im <= 2.6) {
tmp = (0.5 * Math.cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.0 / im)));
} else if (im <= 7e+96) {
tmp = (0.5 * (im * Math.pow(re, 2.0))) - im;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = (math.pow(im, 3.0) * -0.16666666666666666) - im tmp = 0 if im <= -2.4: tmp = t_0 elif im <= 2.6: tmp = (0.5 * math.cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.0 / im))) elif im <= 7e+96: tmp = (0.5 * (im * math.pow(re, 2.0))) - im else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) tmp = 0.0 if (im <= -2.4) tmp = t_0; elseif (im <= 2.6) tmp = Float64(Float64(0.5 * cos(re)) / Float64(Float64(im * 0.08333333333333333) + Float64(0.5 * Float64(-1.0 / im)))); elseif (im <= 7e+96) tmp = Float64(Float64(0.5 * Float64(im * (re ^ 2.0))) - im); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = ((im ^ 3.0) * -0.16666666666666666) - im; tmp = 0.0; if (im <= -2.4) tmp = t_0; elseif (im <= 2.6) tmp = (0.5 * cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.0 / im))); elseif (im <= 7e+96) tmp = (0.5 * (im * (re ^ 2.0))) - im; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, If[LessEqual[im, -2.4], t$95$0, If[LessEqual[im, 2.6], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] / N[(N[(im * 0.08333333333333333), $MachinePrecision] + N[(0.5 * N[(-1.0 / im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 7e+96], N[(N[(0.5 * N[(im * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{if}\;im \leq -2.4:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 2.6:\\
\;\;\;\;\frac{0.5 \cdot \cos re}{im \cdot 0.08333333333333333 + 0.5 \cdot \frac{-1}{im}}\\
\mathbf{elif}\;im \leq 7 \cdot 10^{+96}:\\
\;\;\;\;0.5 \cdot \left(im \cdot {re}^{2}\right) - im\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -2.39999999999999991 or 6.9999999999999998e96 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 79.2%
+-commutative79.2%
mul-1-neg79.2%
unsub-neg79.2%
associate-*r*79.2%
distribute-rgt-out--79.2%
*-commutative79.2%
Simplified79.2%
Taylor expanded in re around 0 64.0%
*-commutative64.0%
Simplified64.0%
if -2.39999999999999991 < im < 2.60000000000000009Initial program 10.6%
neg-sub010.6%
Simplified10.6%
Taylor expanded in im around 0 99.2%
flip-+60.4%
associate-*r/60.2%
Applied egg-rr60.2%
associate-/l*60.1%
*-commutative60.1%
*-commutative60.1%
Simplified60.1%
Taylor expanded in im around 0 98.4%
if 2.60000000000000009 < im < 6.9999999999999998e96Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 3.5%
associate-*r*3.5%
neg-mul-13.5%
Simplified3.5%
Taylor expanded in re around 0 20.4%
Final simplification74.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im)))
(if (<= im -2.25e+55)
t_0
(if (<= im 460.0)
(* (cos re) (- im))
(if (<= im 3.7e+96) (- (* 0.5 (* im (pow re 2.0))) im) t_0)))))
double code(double re, double im) {
double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
double tmp;
if (im <= -2.25e+55) {
tmp = t_0;
} else if (im <= 460.0) {
tmp = cos(re) * -im;
} else if (im <= 3.7e+96) {
tmp = (0.5 * (im * pow(re, 2.0))) - 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 ** 3.0d0) * (-0.16666666666666666d0)) - im
if (im <= (-2.25d+55)) then
tmp = t_0
else if (im <= 460.0d0) then
tmp = cos(re) * -im
else if (im <= 3.7d+96) then
tmp = (0.5d0 * (im * (re ** 2.0d0))) - 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, 3.0) * -0.16666666666666666) - im;
double tmp;
if (im <= -2.25e+55) {
tmp = t_0;
} else if (im <= 460.0) {
tmp = Math.cos(re) * -im;
} else if (im <= 3.7e+96) {
tmp = (0.5 * (im * Math.pow(re, 2.0))) - im;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = (math.pow(im, 3.0) * -0.16666666666666666) - im tmp = 0 if im <= -2.25e+55: tmp = t_0 elif im <= 460.0: tmp = math.cos(re) * -im elif im <= 3.7e+96: tmp = (0.5 * (im * math.pow(re, 2.0))) - im else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) tmp = 0.0 if (im <= -2.25e+55) tmp = t_0; elseif (im <= 460.0) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 3.7e+96) tmp = Float64(Float64(0.5 * Float64(im * (re ^ 2.0))) - im); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = ((im ^ 3.0) * -0.16666666666666666) - im; tmp = 0.0; if (im <= -2.25e+55) tmp = t_0; elseif (im <= 460.0) tmp = cos(re) * -im; elseif (im <= 3.7e+96) tmp = (0.5 * (im * (re ^ 2.0))) - im; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, If[LessEqual[im, -2.25e+55], t$95$0, If[LessEqual[im, 460.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 3.7e+96], N[(N[(0.5 * N[(im * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{if}\;im \leq -2.25 \cdot 10^{+55}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 460:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 3.7 \cdot 10^{+96}:\\
\;\;\;\;0.5 \cdot \left(im \cdot {re}^{2}\right) - im\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -2.24999999999999999e55 or 3.69999999999999991e96 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 88.2%
+-commutative88.2%
mul-1-neg88.2%
unsub-neg88.2%
associate-*r*88.2%
distribute-rgt-out--88.2%
*-commutative88.2%
Simplified88.2%
Taylor expanded in re around 0 71.2%
*-commutative71.2%
Simplified71.2%
if -2.24999999999999999e55 < im < 460Initial program 19.1%
neg-sub019.1%
Simplified19.1%
Taylor expanded in im around 0 88.7%
associate-*r*88.7%
neg-mul-188.7%
Simplified88.7%
if 460 < im < 3.69999999999999991e96Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 3.5%
associate-*r*3.5%
neg-mul-13.5%
Simplified3.5%
Taylor expanded in re around 0 20.4%
Final simplification74.3%
(FPCore (re im) :precision binary64 (if (or (<= im -6.4e+50) (not (<= im 4.2e+65))) (- (* (pow im 3.0) -0.16666666666666666) im) (* (cos re) (- im))))
double code(double re, double im) {
double tmp;
if ((im <= -6.4e+50) || !(im <= 4.2e+65)) {
tmp = (pow(im, 3.0) * -0.16666666666666666) - im;
} else {
tmp = cos(re) * -im;
}
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+50)) .or. (.not. (im <= 4.2d+65))) then
tmp = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
else
tmp = cos(re) * -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -6.4e+50) || !(im <= 4.2e+65)) {
tmp = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
} else {
tmp = Math.cos(re) * -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -6.4e+50) or not (im <= 4.2e+65): tmp = (math.pow(im, 3.0) * -0.16666666666666666) - im else: tmp = math.cos(re) * -im return tmp
function code(re, im) tmp = 0.0 if ((im <= -6.4e+50) || !(im <= 4.2e+65)) tmp = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im); else tmp = Float64(cos(re) * Float64(-im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -6.4e+50) || ~((im <= 4.2e+65))) tmp = ((im ^ 3.0) * -0.16666666666666666) - im; else tmp = cos(re) * -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -6.4e+50], N[Not[LessEqual[im, 4.2e+65]], $MachinePrecision]], N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -6.4 \cdot 10^{+50} \lor \neg \left(im \leq 4.2 \cdot 10^{+65}\right):\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\end{array}
\end{array}
if im < -6.39999999999999966e50 or 4.19999999999999983e65 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 82.9%
+-commutative82.9%
mul-1-neg82.9%
unsub-neg82.9%
associate-*r*82.9%
distribute-rgt-out--82.9%
*-commutative82.9%
Simplified82.9%
Taylor expanded in re around 0 66.9%
*-commutative66.9%
Simplified66.9%
if -6.39999999999999966e50 < im < 4.19999999999999983e65Initial program 30.6%
neg-sub030.6%
Simplified30.6%
Taylor expanded in im around 0 76.6%
associate-*r*76.6%
neg-mul-176.6%
Simplified76.6%
Final simplification72.5%
(FPCore (re im) :precision binary64 (* (cos re) (- im)))
double code(double re, double im) {
return cos(re) * -im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = cos(re) * -im
end function
public static double code(double re, double im) {
return Math.cos(re) * -im;
}
def code(re, im): return math.cos(re) * -im
function code(re, im) return Float64(cos(re) * Float64(-im)) end
function tmp = code(re, im) tmp = cos(re) * -im; end
code[re_, im_] := N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision]
\begin{array}{l}
\\
\cos re \cdot \left(-im\right)
\end{array}
Initial program 59.9%
neg-sub059.9%
Simplified59.9%
Taylor expanded in im around 0 46.8%
associate-*r*46.8%
neg-mul-146.8%
Simplified46.8%
Final simplification46.8%
(FPCore (re im) :precision binary64 (- im))
double code(double re, double im) {
return -im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -im
end function
public static double code(double re, double im) {
return -im;
}
def code(re, im): return -im
function code(re, im) return Float64(-im) end
function tmp = code(re, im) tmp = -im; end
code[re_, im_] := (-im)
\begin{array}{l}
\\
-im
\end{array}
Initial program 59.9%
neg-sub059.9%
Simplified59.9%
Taylor expanded in im around 0 46.8%
associate-*r*46.8%
neg-mul-146.8%
Simplified46.8%
Taylor expanded in re around 0 24.8%
mul-1-neg24.8%
Simplified24.8%
Final simplification24.8%
(FPCore (re im)
:precision binary64
(if (< (fabs im) 1.0)
(-
(*
(cos re)
(+
(+ im (* (* (* 0.16666666666666666 im) im) im))
(* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
double code(double re, double im) {
double tmp;
if (fabs(im) < 1.0) {
tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * cos(re)) * (exp((0.0 - 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 = -(cos(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
else
tmp = (0.5d0 * cos(re)) * (exp((0.0d0 - 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.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if math.fabs(im) < 1.0: tmp = -(math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))) else: tmp = (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (abs(im) < 1.0) tmp = Float64(-Float64(cos(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 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (abs(im) < 1.0) tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))); else tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Cos[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[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\cos 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 \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\
\end{array}
\end{array}
herbie shell --seed 2023312
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
:herbie-target
(if (< (fabs im) 1.0) (- (* (cos re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))