
(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 14 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))))
(if (or (<= t_0 -0.01) (not (<= t_0 1e-6)))
(* (* (cos re) 0.5) 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.01) || !(t_0 <= 1e-6)) {
tmp = (cos(re) * 0.5) * 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.01d0)) .or. (.not. (t_0 <= 1d-6))) then
tmp = (cos(re) * 0.5d0) * 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.01) || !(t_0 <= 1e-6)) {
tmp = (Math.cos(re) * 0.5) * 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.01) or not (t_0 <= 1e-6): tmp = (math.cos(re) * 0.5) * 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.01) || !(t_0 <= 1e-6)) tmp = Float64(Float64(cos(re) * 0.5) * 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.01) || ~((t_0 <= 1e-6))) tmp = (cos(re) * 0.5) * 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.01], N[Not[LessEqual[t$95$0, 1e-6]], $MachinePrecision]], N[(N[(N[Cos[re], $MachinePrecision] * 0.5), $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.01 \lor \neg \left(t_0 \leq 10^{-6}\right):\\
\;\;\;\;\left(\cos re \cdot 0.5\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.0100000000000000002 or 9.99999999999999955e-7 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 99.9%
sub0-neg99.9%
Simplified99.9%
if -0.0100000000000000002 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 9.99999999999999955e-7Initial program 7.7%
sub0-neg7.7%
Simplified7.7%
Taylor expanded in im around 0 99.9%
mul-1-neg99.9%
unsub-neg99.9%
*-commutative99.9%
associate-*l*99.9%
distribute-lft-out--99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (<= t_0 0.005)
(*
(cos re)
(+
(fma (pow im 5.0) -0.008333333333333333 (- im))
(+
(* (pow im 7.0) -0.0001984126984126984)
(* (pow im 3.0) -0.16666666666666666))))
(* (* (cos re) 0.5) t_0))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if (t_0 <= 0.005) {
tmp = cos(re) * (fma(pow(im, 5.0), -0.008333333333333333, -im) + ((pow(im, 7.0) * -0.0001984126984126984) + (pow(im, 3.0) * -0.16666666666666666)));
} else {
tmp = (cos(re) * 0.5) * t_0;
}
return tmp;
}
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if (t_0 <= 0.005) tmp = Float64(cos(re) * Float64(fma((im ^ 5.0), -0.008333333333333333, Float64(-im)) + Float64(Float64((im ^ 7.0) * -0.0001984126984126984) + Float64((im ^ 3.0) * -0.16666666666666666)))); else tmp = Float64(Float64(cos(re) * 0.5) * t_0); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.005], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333 + (-im)), $MachinePrecision] + N[(N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] + N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq 0.005:\\
\;\;\;\;\cos re \cdot \left(\mathsf{fma}\left({im}^{5}, -0.008333333333333333, -im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{3} \cdot -0.16666666666666666\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\cos re \cdot 0.5\right) \cdot t_0\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 0.0050000000000000001Initial program 35.3%
sub0-neg35.3%
Simplified35.3%
Taylor expanded in im around 0 98.5%
+-commutative98.5%
associate-+r+98.5%
associate-+l+98.5%
mul-1-neg98.5%
distribute-rgt-neg-in98.5%
*-commutative98.5%
associate-*l*98.5%
distribute-lft-out98.5%
*-commutative98.5%
associate-*r*98.5%
*-commutative98.5%
associate-*r*98.5%
Simplified98.5%
if 0.0050000000000000001 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Final simplification98.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))) (t_1 (* (cos re) 0.5)))
(if (<= t_0 0.005)
(*
t_1
(+
(* im -2.0)
(+
(* (pow im 5.0) -0.016666666666666666)
(* (pow im 3.0) -0.3333333333333333))))
(* t_1 t_0))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double t_1 = cos(re) * 0.5;
double tmp;
if (t_0 <= 0.005) {
tmp = t_1 * ((im * -2.0) + ((pow(im, 5.0) * -0.016666666666666666) + (pow(im, 3.0) * -0.3333333333333333)));
} else {
tmp = t_1 * 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) :: t_1
real(8) :: tmp
t_0 = exp(-im) - exp(im)
t_1 = cos(re) * 0.5d0
if (t_0 <= 0.005d0) then
tmp = t_1 * ((im * (-2.0d0)) + (((im ** 5.0d0) * (-0.016666666666666666d0)) + ((im ** 3.0d0) * (-0.3333333333333333d0))))
else
tmp = t_1 * t_0
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 = Math.cos(re) * 0.5;
double tmp;
if (t_0 <= 0.005) {
tmp = t_1 * ((im * -2.0) + ((Math.pow(im, 5.0) * -0.016666666666666666) + (Math.pow(im, 3.0) * -0.3333333333333333)));
} else {
tmp = t_1 * t_0;
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) t_1 = math.cos(re) * 0.5 tmp = 0 if t_0 <= 0.005: tmp = t_1 * ((im * -2.0) + ((math.pow(im, 5.0) * -0.016666666666666666) + (math.pow(im, 3.0) * -0.3333333333333333))) else: tmp = t_1 * t_0 return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) t_1 = Float64(cos(re) * 0.5) tmp = 0.0 if (t_0 <= 0.005) tmp = Float64(t_1 * Float64(Float64(im * -2.0) + Float64(Float64((im ^ 5.0) * -0.016666666666666666) + Float64((im ^ 3.0) * -0.3333333333333333)))); else tmp = Float64(t_1 * t_0); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); t_1 = cos(re) * 0.5; tmp = 0.0; if (t_0 <= 0.005) tmp = t_1 * ((im * -2.0) + (((im ^ 5.0) * -0.016666666666666666) + ((im ^ 3.0) * -0.3333333333333333))); else tmp = t_1 * t_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[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[t$95$0, 0.005], N[(t$95$1 * N[(N[(im * -2.0), $MachinePrecision] + N[(N[(N[Power[im, 5.0], $MachinePrecision] * -0.016666666666666666), $MachinePrecision] + N[(N[Power[im, 3.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := \cos re \cdot 0.5\\
\mathbf{if}\;t_0 \leq 0.005:\\
\;\;\;\;t_1 \cdot \left(im \cdot -2 + \left({im}^{5} \cdot -0.016666666666666666 + {im}^{3} \cdot -0.3333333333333333\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot t_0\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 0.0050000000000000001Initial program 35.3%
sub0-neg35.3%
Simplified35.3%
Taylor expanded in im around 0 98.0%
if 0.0050000000000000001 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Final simplification98.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (pow im 3.0) -0.16666666666666666))
(t_1 (* 0.5 (- (exp (- im)) (exp im))))
(t_2 (- t_0 im))
(t_3 (* t_2 (+ (* -0.5 (* re re)) 1.0))))
(if (<= im -2e+238)
t_0
(if (<= im -2e+167)
t_3
(if (<= im -0.00098)
t_1
(if (<= im 0.00115)
(* (cos re) (- im))
(if (<= im 3.8e+241) t_1 (if (<= im 7.2e+280) t_3 t_2))))))))
double code(double re, double im) {
double t_0 = pow(im, 3.0) * -0.16666666666666666;
double t_1 = 0.5 * (exp(-im) - exp(im));
double t_2 = t_0 - im;
double t_3 = t_2 * ((-0.5 * (re * re)) + 1.0);
double tmp;
if (im <= -2e+238) {
tmp = t_0;
} else if (im <= -2e+167) {
tmp = t_3;
} else if (im <= -0.00098) {
tmp = t_1;
} else if (im <= 0.00115) {
tmp = cos(re) * -im;
} else if (im <= 3.8e+241) {
tmp = t_1;
} else if (im <= 7.2e+280) {
tmp = t_3;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = (im ** 3.0d0) * (-0.16666666666666666d0)
t_1 = 0.5d0 * (exp(-im) - exp(im))
t_2 = t_0 - im
t_3 = t_2 * (((-0.5d0) * (re * re)) + 1.0d0)
if (im <= (-2d+238)) then
tmp = t_0
else if (im <= (-2d+167)) then
tmp = t_3
else if (im <= (-0.00098d0)) then
tmp = t_1
else if (im <= 0.00115d0) then
tmp = cos(re) * -im
else if (im <= 3.8d+241) then
tmp = t_1
else if (im <= 7.2d+280) then
tmp = t_3
else
tmp = t_2
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.pow(im, 3.0) * -0.16666666666666666;
double t_1 = 0.5 * (Math.exp(-im) - Math.exp(im));
double t_2 = t_0 - im;
double t_3 = t_2 * ((-0.5 * (re * re)) + 1.0);
double tmp;
if (im <= -2e+238) {
tmp = t_0;
} else if (im <= -2e+167) {
tmp = t_3;
} else if (im <= -0.00098) {
tmp = t_1;
} else if (im <= 0.00115) {
tmp = Math.cos(re) * -im;
} else if (im <= 3.8e+241) {
tmp = t_1;
} else if (im <= 7.2e+280) {
tmp = t_3;
} else {
tmp = t_2;
}
return tmp;
}
def code(re, im): t_0 = math.pow(im, 3.0) * -0.16666666666666666 t_1 = 0.5 * (math.exp(-im) - math.exp(im)) t_2 = t_0 - im t_3 = t_2 * ((-0.5 * (re * re)) + 1.0) tmp = 0 if im <= -2e+238: tmp = t_0 elif im <= -2e+167: tmp = t_3 elif im <= -0.00098: tmp = t_1 elif im <= 0.00115: tmp = math.cos(re) * -im elif im <= 3.8e+241: tmp = t_1 elif im <= 7.2e+280: tmp = t_3 else: tmp = t_2 return tmp
function code(re, im) t_0 = Float64((im ^ 3.0) * -0.16666666666666666) t_1 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))) t_2 = Float64(t_0 - im) t_3 = Float64(t_2 * Float64(Float64(-0.5 * Float64(re * re)) + 1.0)) tmp = 0.0 if (im <= -2e+238) tmp = t_0; elseif (im <= -2e+167) tmp = t_3; elseif (im <= -0.00098) tmp = t_1; elseif (im <= 0.00115) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 3.8e+241) tmp = t_1; elseif (im <= 7.2e+280) tmp = t_3; else tmp = t_2; end return tmp end
function tmp_2 = code(re, im) t_0 = (im ^ 3.0) * -0.16666666666666666; t_1 = 0.5 * (exp(-im) - exp(im)); t_2 = t_0 - im; t_3 = t_2 * ((-0.5 * (re * re)) + 1.0); tmp = 0.0; if (im <= -2e+238) tmp = t_0; elseif (im <= -2e+167) tmp = t_3; elseif (im <= -0.00098) tmp = t_1; elseif (im <= 0.00115) tmp = cos(re) * -im; elseif (im <= 3.8e+241) tmp = t_1; elseif (im <= 7.2e+280) tmp = t_3; else tmp = t_2; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - im), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2e+238], t$95$0, If[LessEqual[im, -2e+167], t$95$3, If[LessEqual[im, -0.00098], t$95$1, If[LessEqual[im, 0.00115], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 3.8e+241], t$95$1, If[LessEqual[im, 7.2e+280], t$95$3, t$95$2]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
t_1 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_2 := t_0 - im\\
t_3 := t_2 \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\
\mathbf{if}\;im \leq -2 \cdot 10^{+238}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -2 \cdot 10^{+167}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;im \leq -0.00098:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 0.00115:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 3.8 \cdot 10^{+241}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 7.2 \cdot 10^{+280}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if im < -2.0000000000000001e238Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in re around 0 92.3%
Taylor expanded in im around inf 92.3%
if -2.0000000000000001e238 < im < -2.0000000000000001e167 or 3.79999999999999972e241 < im < 7.1999999999999999e280Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
associate-+r-0.0%
associate-*r*0.0%
*-commutative0.0%
fma-neg0.0%
fma-neg0.0%
*-lft-identity0.0%
distribute-rgt-out82.1%
fma-neg82.1%
*-commutative82.1%
unpow282.1%
Simplified82.1%
if -2.0000000000000001e167 < im < -9.7999999999999997e-4 or 0.00115 < im < 3.79999999999999972e241Initial program 99.8%
sub0-neg99.8%
Simplified99.8%
Taylor expanded in re around 0 83.6%
if -9.7999999999999997e-4 < im < 0.00115Initial program 7.7%
sub0-neg7.7%
Simplified7.7%
Taylor expanded in im around 0 99.6%
mul-1-neg99.6%
*-commutative99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
if 7.1999999999999999e280 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in re around 0 71.4%
Final simplification92.3%
(FPCore (re im) :precision binary64 (if (<= re 12.0) (- (* (pow im 7.0) -0.0001984126984126984) im) (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))))
double code(double re, double im) {
double tmp;
if (re <= 12.0) {
tmp = (pow(im, 7.0) * -0.0001984126984126984) - im;
} 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) :: tmp
if (re <= 12.0d0) then
tmp = ((im ** 7.0d0) * (-0.0001984126984126984d0)) - im
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 tmp;
if (re <= 12.0) {
tmp = (Math.pow(im, 7.0) * -0.0001984126984126984) - im;
} else {
tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 12.0: tmp = (math.pow(im, 7.0) * -0.0001984126984126984) - im else: tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) return tmp
function code(re, im) tmp = 0.0 if (re <= 12.0) tmp = Float64(Float64((im ^ 7.0) * -0.0001984126984126984) - im); else tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 12.0) tmp = ((im ^ 7.0) * -0.0001984126984126984) - im; else tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 12.0], N[(N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] - im), $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}
\mathbf{if}\;re \leq 12:\\
\;\;\;\;{im}^{7} \cdot -0.0001984126984126984 - im\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if re < 12Initial program 51.1%
sub0-neg51.1%
Simplified51.1%
Taylor expanded in im around 0 94.8%
+-commutative94.8%
associate-+r+94.8%
associate-+l+94.8%
mul-1-neg94.8%
distribute-rgt-neg-in94.8%
*-commutative94.8%
associate-*l*94.8%
distribute-lft-out94.8%
*-commutative94.8%
associate-*r*94.8%
*-commutative94.8%
associate-*r*94.8%
Simplified94.8%
Taylor expanded in re around 0 72.1%
Taylor expanded in im around inf 71.5%
if 12 < re Initial program 43.8%
sub0-neg43.8%
Simplified43.8%
Taylor expanded in im around 0 98.2%
mul-1-neg98.2%
unsub-neg98.2%
*-commutative98.2%
associate-*l*98.2%
distribute-lft-out--98.3%
Simplified98.3%
Final simplification77.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (pow im 3.0) -0.16666666666666666))
(t_1 (- (* (pow im 7.0) -0.0001984126984126984) im))
(t_2 (- t_0 im))
(t_3 (* t_2 (+ (* -0.5 (* re re)) 1.0))))
(if (<= im -5e+237)
t_0
(if (<= im -6e+165)
t_3
(if (<= im -1.1e+37)
t_1
(if (<= im 15000.0)
(* (cos re) (- im))
(if (<= im 3.5e+241) t_1 (if (<= im 8.2e+280) t_3 t_2))))))))
double code(double re, double im) {
double t_0 = pow(im, 3.0) * -0.16666666666666666;
double t_1 = (pow(im, 7.0) * -0.0001984126984126984) - im;
double t_2 = t_0 - im;
double t_3 = t_2 * ((-0.5 * (re * re)) + 1.0);
double tmp;
if (im <= -5e+237) {
tmp = t_0;
} else if (im <= -6e+165) {
tmp = t_3;
} else if (im <= -1.1e+37) {
tmp = t_1;
} else if (im <= 15000.0) {
tmp = cos(re) * -im;
} else if (im <= 3.5e+241) {
tmp = t_1;
} else if (im <= 8.2e+280) {
tmp = t_3;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = (im ** 3.0d0) * (-0.16666666666666666d0)
t_1 = ((im ** 7.0d0) * (-0.0001984126984126984d0)) - im
t_2 = t_0 - im
t_3 = t_2 * (((-0.5d0) * (re * re)) + 1.0d0)
if (im <= (-5d+237)) then
tmp = t_0
else if (im <= (-6d+165)) then
tmp = t_3
else if (im <= (-1.1d+37)) then
tmp = t_1
else if (im <= 15000.0d0) then
tmp = cos(re) * -im
else if (im <= 3.5d+241) then
tmp = t_1
else if (im <= 8.2d+280) then
tmp = t_3
else
tmp = t_2
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.pow(im, 3.0) * -0.16666666666666666;
double t_1 = (Math.pow(im, 7.0) * -0.0001984126984126984) - im;
double t_2 = t_0 - im;
double t_3 = t_2 * ((-0.5 * (re * re)) + 1.0);
double tmp;
if (im <= -5e+237) {
tmp = t_0;
} else if (im <= -6e+165) {
tmp = t_3;
} else if (im <= -1.1e+37) {
tmp = t_1;
} else if (im <= 15000.0) {
tmp = Math.cos(re) * -im;
} else if (im <= 3.5e+241) {
tmp = t_1;
} else if (im <= 8.2e+280) {
tmp = t_3;
} else {
tmp = t_2;
}
return tmp;
}
def code(re, im): t_0 = math.pow(im, 3.0) * -0.16666666666666666 t_1 = (math.pow(im, 7.0) * -0.0001984126984126984) - im t_2 = t_0 - im t_3 = t_2 * ((-0.5 * (re * re)) + 1.0) tmp = 0 if im <= -5e+237: tmp = t_0 elif im <= -6e+165: tmp = t_3 elif im <= -1.1e+37: tmp = t_1 elif im <= 15000.0: tmp = math.cos(re) * -im elif im <= 3.5e+241: tmp = t_1 elif im <= 8.2e+280: tmp = t_3 else: tmp = t_2 return tmp
function code(re, im) t_0 = Float64((im ^ 3.0) * -0.16666666666666666) t_1 = Float64(Float64((im ^ 7.0) * -0.0001984126984126984) - im) t_2 = Float64(t_0 - im) t_3 = Float64(t_2 * Float64(Float64(-0.5 * Float64(re * re)) + 1.0)) tmp = 0.0 if (im <= -5e+237) tmp = t_0; elseif (im <= -6e+165) tmp = t_3; elseif (im <= -1.1e+37) tmp = t_1; elseif (im <= 15000.0) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 3.5e+241) tmp = t_1; elseif (im <= 8.2e+280) tmp = t_3; else tmp = t_2; end return tmp end
function tmp_2 = code(re, im) t_0 = (im ^ 3.0) * -0.16666666666666666; t_1 = ((im ^ 7.0) * -0.0001984126984126984) - im; t_2 = t_0 - im; t_3 = t_2 * ((-0.5 * (re * re)) + 1.0); tmp = 0.0; if (im <= -5e+237) tmp = t_0; elseif (im <= -6e+165) tmp = t_3; elseif (im <= -1.1e+37) tmp = t_1; elseif (im <= 15000.0) tmp = cos(re) * -im; elseif (im <= 3.5e+241) tmp = t_1; elseif (im <= 8.2e+280) tmp = t_3; else tmp = t_2; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] - im), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - im), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5e+237], t$95$0, If[LessEqual[im, -6e+165], t$95$3, If[LessEqual[im, -1.1e+37], t$95$1, If[LessEqual[im, 15000.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 3.5e+241], t$95$1, If[LessEqual[im, 8.2e+280], t$95$3, t$95$2]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
t_1 := {im}^{7} \cdot -0.0001984126984126984 - im\\
t_2 := t_0 - im\\
t_3 := t_2 \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\
\mathbf{if}\;im \leq -5 \cdot 10^{+237}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -6 \cdot 10^{+165}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;im \leq -1.1 \cdot 10^{+37}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 15000:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 3.5 \cdot 10^{+241}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 8.2 \cdot 10^{+280}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if im < -5.0000000000000002e237Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in re around 0 92.3%
Taylor expanded in im around inf 92.3%
if -5.0000000000000002e237 < im < -5.99999999999999981e165 or 3.5e241 < im < 8.19999999999999995e280Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
associate-+r-0.0%
associate-*r*0.0%
*-commutative0.0%
fma-neg0.0%
fma-neg0.0%
*-lft-identity0.0%
distribute-rgt-out82.1%
fma-neg82.1%
*-commutative82.1%
unpow282.1%
Simplified82.1%
if -5.99999999999999981e165 < im < -1.1e37 or 15000 < im < 3.5e241Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 90.9%
+-commutative90.9%
associate-+r+90.9%
associate-+l+90.9%
mul-1-neg90.9%
distribute-rgt-neg-in90.9%
*-commutative90.9%
associate-*l*90.9%
distribute-lft-out90.9%
*-commutative90.9%
associate-*r*90.9%
*-commutative90.9%
associate-*r*90.9%
Simplified90.9%
Taylor expanded in re around 0 76.2%
Taylor expanded in im around inf 76.2%
if -1.1e37 < im < 15000Initial program 12.0%
sub0-neg12.0%
Simplified12.0%
Taylor expanded in im around 0 95.6%
mul-1-neg95.6%
*-commutative95.6%
distribute-lft-neg-in95.6%
Simplified95.6%
if 8.19999999999999995e280 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in re around 0 71.4%
Final simplification88.7%
(FPCore (re im) :precision binary64 (if (or (<= im -0.00044) (not (<= im 0.00062))) (- (* (pow im 3.0) -0.16666666666666666) im) (* (cos re) (- im))))
double code(double re, double im) {
double tmp;
if ((im <= -0.00044) || !(im <= 0.00062)) {
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 <= (-0.00044d0)) .or. (.not. (im <= 0.00062d0))) 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 <= -0.00044) || !(im <= 0.00062)) {
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 <= -0.00044) or not (im <= 0.00062): 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 <= -0.00044) || !(im <= 0.00062)) 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 <= -0.00044) || ~((im <= 0.00062))) tmp = ((im ^ 3.0) * -0.16666666666666666) - im; else tmp = cos(re) * -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -0.00044], N[Not[LessEqual[im, 0.00062]], $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 -0.00044 \lor \neg \left(im \leq 0.00062\right):\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\end{array}
\end{array}
if im < -4.40000000000000016e-4 or 6.2e-4 < im Initial program 99.9%
sub0-neg99.9%
Simplified99.9%
Taylor expanded in im around 0 82.5%
mul-1-neg82.5%
unsub-neg82.5%
*-commutative82.5%
associate-*l*82.5%
distribute-lft-out--82.5%
Simplified82.5%
Taylor expanded in re around 0 60.0%
if -4.40000000000000016e-4 < im < 6.2e-4Initial program 7.7%
sub0-neg7.7%
Simplified7.7%
Taylor expanded in im around 0 99.6%
mul-1-neg99.6%
*-commutative99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
Final simplification81.6%
(FPCore (re im) :precision binary64 (if (or (<= im -1.1e+37) (not (<= im 7.1))) (- (* (pow im 7.0) -0.0001984126984126984) im) (* (cos re) (- im))))
double code(double re, double im) {
double tmp;
if ((im <= -1.1e+37) || !(im <= 7.1)) {
tmp = (pow(im, 7.0) * -0.0001984126984126984) - 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 <= (-1.1d+37)) .or. (.not. (im <= 7.1d0))) then
tmp = ((im ** 7.0d0) * (-0.0001984126984126984d0)) - im
else
tmp = cos(re) * -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -1.1e+37) || !(im <= 7.1)) {
tmp = (Math.pow(im, 7.0) * -0.0001984126984126984) - im;
} else {
tmp = Math.cos(re) * -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -1.1e+37) or not (im <= 7.1): tmp = (math.pow(im, 7.0) * -0.0001984126984126984) - im else: tmp = math.cos(re) * -im return tmp
function code(re, im) tmp = 0.0 if ((im <= -1.1e+37) || !(im <= 7.1)) tmp = Float64(Float64((im ^ 7.0) * -0.0001984126984126984) - im); else tmp = Float64(cos(re) * Float64(-im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -1.1e+37) || ~((im <= 7.1))) tmp = ((im ^ 7.0) * -0.0001984126984126984) - im; else tmp = cos(re) * -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -1.1e+37], N[Not[LessEqual[im, 7.1]], $MachinePrecision]], N[(N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] - im), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.1 \cdot 10^{+37} \lor \neg \left(im \leq 7.1\right):\\
\;\;\;\;{im}^{7} \cdot -0.0001984126984126984 - im\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\end{array}
\end{array}
if im < -1.1e37 or 7.0999999999999996 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 94.9%
+-commutative94.9%
associate-+r+94.9%
associate-+l+94.9%
mul-1-neg94.9%
distribute-rgt-neg-in94.9%
*-commutative94.9%
associate-*l*94.9%
distribute-lft-out94.9%
*-commutative94.9%
associate-*r*94.9%
*-commutative94.9%
associate-*r*94.9%
Simplified94.9%
Taylor expanded in re around 0 70.2%
Taylor expanded in im around inf 70.2%
if -1.1e37 < im < 7.0999999999999996Initial program 12.0%
sub0-neg12.0%
Simplified12.0%
Taylor expanded in im around 0 95.6%
mul-1-neg95.6%
*-commutative95.6%
distribute-lft-neg-in95.6%
Simplified95.6%
Final simplification84.8%
(FPCore (re im) :precision binary64 (if (or (<= im -2.5) (not (<= im 2.5))) (* (pow im 3.0) -0.16666666666666666) (- im)))
double code(double re, double im) {
double tmp;
if ((im <= -2.5) || !(im <= 2.5)) {
tmp = pow(im, 3.0) * -0.16666666666666666;
} else {
tmp = -im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-2.5d0)) .or. (.not. (im <= 2.5d0))) then
tmp = (im ** 3.0d0) * (-0.16666666666666666d0)
else
tmp = -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -2.5) || !(im <= 2.5)) {
tmp = Math.pow(im, 3.0) * -0.16666666666666666;
} else {
tmp = -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -2.5) or not (im <= 2.5): tmp = math.pow(im, 3.0) * -0.16666666666666666 else: tmp = -im return tmp
function code(re, im) tmp = 0.0 if ((im <= -2.5) || !(im <= 2.5)) tmp = Float64((im ^ 3.0) * -0.16666666666666666); else tmp = Float64(-im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -2.5) || ~((im <= 2.5))) tmp = (im ^ 3.0) * -0.16666666666666666; else tmp = -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -2.5], N[Not[LessEqual[im, 2.5]], $MachinePrecision]], N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision], (-im)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.5 \lor \neg \left(im \leq 2.5\right):\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666\\
\mathbf{else}:\\
\;\;\;\;-im\\
\end{array}
\end{array}
if im < -2.5 or 2.5 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 82.5%
mul-1-neg82.5%
unsub-neg82.5%
*-commutative82.5%
associate-*l*82.5%
distribute-lft-out--82.5%
Simplified82.5%
Taylor expanded in re around 0 59.6%
Taylor expanded in im around inf 59.6%
if -2.5 < im < 2.5Initial program 8.9%
sub0-neg8.9%
Simplified8.9%
Taylor expanded in im around 0 98.9%
mul-1-neg98.9%
*-commutative98.9%
distribute-lft-neg-in98.9%
Simplified98.9%
Taylor expanded in re around 0 51.6%
neg-mul-151.6%
+-commutative51.6%
unsub-neg51.6%
*-commutative51.6%
*-commutative51.6%
associate-*l*51.6%
unpow251.6%
Simplified51.6%
Taylor expanded in re around 0 55.6%
neg-mul-155.6%
Simplified55.6%
Final simplification57.4%
(FPCore (re im) :precision binary64 (if (or (<= im -1.15e+37) (not (<= im 15000.0))) (* (pow im 3.0) -0.16666666666666666) (* (cos re) (- im))))
double code(double re, double im) {
double tmp;
if ((im <= -1.15e+37) || !(im <= 15000.0)) {
tmp = pow(im, 3.0) * -0.16666666666666666;
} 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 <= (-1.15d+37)) .or. (.not. (im <= 15000.0d0))) then
tmp = (im ** 3.0d0) * (-0.16666666666666666d0)
else
tmp = cos(re) * -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -1.15e+37) || !(im <= 15000.0)) {
tmp = Math.pow(im, 3.0) * -0.16666666666666666;
} else {
tmp = Math.cos(re) * -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -1.15e+37) or not (im <= 15000.0): tmp = math.pow(im, 3.0) * -0.16666666666666666 else: tmp = math.cos(re) * -im return tmp
function code(re, im) tmp = 0.0 if ((im <= -1.15e+37) || !(im <= 15000.0)) tmp = Float64((im ^ 3.0) * -0.16666666666666666); else tmp = Float64(cos(re) * Float64(-im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -1.15e+37) || ~((im <= 15000.0))) tmp = (im ^ 3.0) * -0.16666666666666666; else tmp = cos(re) * -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -1.15e+37], N[Not[LessEqual[im, 15000.0]], $MachinePrecision]], N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.15 \cdot 10^{+37} \lor \neg \left(im \leq 15000\right):\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\end{array}
\end{array}
if im < -1.15000000000000001e37 or 15000 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 86.2%
mul-1-neg86.2%
unsub-neg86.2%
*-commutative86.2%
associate-*l*86.2%
distribute-lft-out--86.2%
Simplified86.2%
Taylor expanded in re around 0 62.2%
Taylor expanded in im around inf 62.2%
if -1.15000000000000001e37 < im < 15000Initial program 12.0%
sub0-neg12.0%
Simplified12.0%
Taylor expanded in im around 0 95.6%
mul-1-neg95.6%
*-commutative95.6%
distribute-lft-neg-in95.6%
Simplified95.6%
Final simplification81.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (+ 0.5 (* re (* re -0.25)))))
(if (<= re 1.95e+154)
(- (* im (* 0.5 (* re re))) im)
(if (or (<= re 5.5e+257) (not (<= re 4.3e+287)))
(* -3.0 t_0)
(* t_0 27.0)))))
double code(double re, double im) {
double t_0 = 0.5 + (re * (re * -0.25));
double tmp;
if (re <= 1.95e+154) {
tmp = (im * (0.5 * (re * re))) - im;
} else if ((re <= 5.5e+257) || !(re <= 4.3e+287)) {
tmp = -3.0 * t_0;
} else {
tmp = t_0 * 27.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 = 0.5d0 + (re * (re * (-0.25d0)))
if (re <= 1.95d+154) then
tmp = (im * (0.5d0 * (re * re))) - im
else if ((re <= 5.5d+257) .or. (.not. (re <= 4.3d+287))) then
tmp = (-3.0d0) * t_0
else
tmp = t_0 * 27.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 + (re * (re * -0.25));
double tmp;
if (re <= 1.95e+154) {
tmp = (im * (0.5 * (re * re))) - im;
} else if ((re <= 5.5e+257) || !(re <= 4.3e+287)) {
tmp = -3.0 * t_0;
} else {
tmp = t_0 * 27.0;
}
return tmp;
}
def code(re, im): t_0 = 0.5 + (re * (re * -0.25)) tmp = 0 if re <= 1.95e+154: tmp = (im * (0.5 * (re * re))) - im elif (re <= 5.5e+257) or not (re <= 4.3e+287): tmp = -3.0 * t_0 else: tmp = t_0 * 27.0 return tmp
function code(re, im) t_0 = Float64(0.5 + Float64(re * Float64(re * -0.25))) tmp = 0.0 if (re <= 1.95e+154) tmp = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im); elseif ((re <= 5.5e+257) || !(re <= 4.3e+287)) tmp = Float64(-3.0 * t_0); else tmp = Float64(t_0 * 27.0); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 + (re * (re * -0.25)); tmp = 0.0; if (re <= 1.95e+154) tmp = (im * (0.5 * (re * re))) - im; elseif ((re <= 5.5e+257) || ~((re <= 4.3e+287))) tmp = -3.0 * t_0; else tmp = t_0 * 27.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, 1.95e+154], N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[Or[LessEqual[re, 5.5e+257], N[Not[LessEqual[re, 4.3e+287]], $MachinePrecision]], N[(-3.0 * t$95$0), $MachinePrecision], N[(t$95$0 * 27.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 + re \cdot \left(re \cdot -0.25\right)\\
\mathbf{if}\;re \leq 1.95 \cdot 10^{+154}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\
\mathbf{elif}\;re \leq 5.5 \cdot 10^{+257} \lor \neg \left(re \leq 4.3 \cdot 10^{+287}\right):\\
\;\;\;\;-3 \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot 27\\
\end{array}
\end{array}
if re < 1.9500000000000001e154Initial program 49.9%
sub0-neg49.9%
Simplified49.9%
Taylor expanded in im around 0 57.0%
mul-1-neg57.0%
*-commutative57.0%
distribute-lft-neg-in57.0%
Simplified57.0%
Taylor expanded in re around 0 39.1%
neg-mul-139.1%
+-commutative39.1%
unsub-neg39.1%
*-commutative39.1%
*-commutative39.1%
associate-*l*39.1%
unpow239.1%
Simplified39.1%
if 1.9500000000000001e154 < re < 5.49999999999999957e257 or 4.3e287 < re Initial program 41.2%
sub0-neg41.2%
Simplified41.2%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
associate-*r*0.0%
distribute-rgt-out25.0%
+-commutative25.0%
*-commutative25.0%
unpow225.0%
associate-*l*25.0%
Simplified25.0%
Applied egg-rr32.0%
if 5.49999999999999957e257 < re < 4.3e287Initial program 54.7%
sub0-neg54.7%
Simplified54.7%
Taylor expanded in re around 0 0.1%
*-commutative0.1%
associate-*r*0.1%
distribute-rgt-out28.7%
+-commutative28.7%
*-commutative28.7%
unpow228.7%
associate-*l*28.7%
Simplified28.7%
Applied egg-rr29.4%
Final simplification38.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (+ 0.5 (* re (* re -0.25)))))
(if (<= im -1.02e+42)
(* -3.0 t_0)
(if (<= im 4.9e+179) (- im) (* t_0 27.0)))))
double code(double re, double im) {
double t_0 = 0.5 + (re * (re * -0.25));
double tmp;
if (im <= -1.02e+42) {
tmp = -3.0 * t_0;
} else if (im <= 4.9e+179) {
tmp = -im;
} else {
tmp = t_0 * 27.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 = 0.5d0 + (re * (re * (-0.25d0)))
if (im <= (-1.02d+42)) then
tmp = (-3.0d0) * t_0
else if (im <= 4.9d+179) then
tmp = -im
else
tmp = t_0 * 27.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 + (re * (re * -0.25));
double tmp;
if (im <= -1.02e+42) {
tmp = -3.0 * t_0;
} else if (im <= 4.9e+179) {
tmp = -im;
} else {
tmp = t_0 * 27.0;
}
return tmp;
}
def code(re, im): t_0 = 0.5 + (re * (re * -0.25)) tmp = 0 if im <= -1.02e+42: tmp = -3.0 * t_0 elif im <= 4.9e+179: tmp = -im else: tmp = t_0 * 27.0 return tmp
function code(re, im) t_0 = Float64(0.5 + Float64(re * Float64(re * -0.25))) tmp = 0.0 if (im <= -1.02e+42) tmp = Float64(-3.0 * t_0); elseif (im <= 4.9e+179) tmp = Float64(-im); else tmp = Float64(t_0 * 27.0); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 + (re * (re * -0.25)); tmp = 0.0; if (im <= -1.02e+42) tmp = -3.0 * t_0; elseif (im <= 4.9e+179) tmp = -im; else tmp = t_0 * 27.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.02e+42], N[(-3.0 * t$95$0), $MachinePrecision], If[LessEqual[im, 4.9e+179], (-im), N[(t$95$0 * 27.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 + re \cdot \left(re \cdot -0.25\right)\\
\mathbf{if}\;im \leq -1.02 \cdot 10^{+42}:\\
\;\;\;\;-3 \cdot t_0\\
\mathbf{elif}\;im \leq 4.9 \cdot 10^{+179}:\\
\;\;\;\;-im\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot 27\\
\end{array}
\end{array}
if im < -1.01999999999999996e42Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
associate-*r*0.0%
distribute-rgt-out63.3%
+-commutative63.3%
*-commutative63.3%
unpow263.3%
associate-*l*63.3%
Simplified63.3%
Applied egg-rr25.4%
if -1.01999999999999996e42 < im < 4.8999999999999999e179Initial program 23.4%
sub0-neg23.4%
Simplified23.4%
Taylor expanded in im around 0 83.7%
mul-1-neg83.7%
*-commutative83.7%
distribute-lft-neg-in83.7%
Simplified83.7%
Taylor expanded in re around 0 46.2%
neg-mul-146.2%
+-commutative46.2%
unsub-neg46.2%
*-commutative46.2%
*-commutative46.2%
associate-*l*46.2%
unpow246.2%
Simplified46.2%
Taylor expanded in re around 0 47.2%
neg-mul-147.2%
Simplified47.2%
if 4.8999999999999999e179 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
associate-*r*0.0%
distribute-rgt-out55.3%
+-commutative55.3%
*-commutative55.3%
unpow255.3%
associate-*l*55.3%
Simplified55.3%
Applied egg-rr30.2%
Final simplification40.5%
(FPCore (re im) :precision binary64 (if (<= re 1.9e+153) (- im) (* -3.0 (+ 0.5 (* re (* re -0.25))))))
double code(double re, double im) {
double tmp;
if (re <= 1.9e+153) {
tmp = -im;
} else {
tmp = -3.0 * (0.5 + (re * (re * -0.25)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 1.9d+153) then
tmp = -im
else
tmp = (-3.0d0) * (0.5d0 + (re * (re * (-0.25d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 1.9e+153) {
tmp = -im;
} else {
tmp = -3.0 * (0.5 + (re * (re * -0.25)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.9e+153: tmp = -im else: tmp = -3.0 * (0.5 + (re * (re * -0.25))) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.9e+153) tmp = Float64(-im); else tmp = Float64(-3.0 * Float64(0.5 + Float64(re * Float64(re * -0.25)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.9e+153) tmp = -im; else tmp = -3.0 * (0.5 + (re * (re * -0.25))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.9e+153], (-im), N[(-3.0 * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.9 \cdot 10^{+153}:\\
\;\;\;\;-im\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\
\end{array}
\end{array}
if re < 1.89999999999999983e153Initial program 49.9%
sub0-neg49.9%
Simplified49.9%
Taylor expanded in im around 0 57.0%
mul-1-neg57.0%
*-commutative57.0%
distribute-lft-neg-in57.0%
Simplified57.0%
Taylor expanded in re around 0 39.1%
neg-mul-139.1%
+-commutative39.1%
unsub-neg39.1%
*-commutative39.1%
*-commutative39.1%
associate-*l*39.1%
unpow239.1%
Simplified39.1%
Taylor expanded in re around 0 35.3%
neg-mul-135.3%
Simplified35.3%
if 1.89999999999999983e153 < re Initial program 45.3%
sub0-neg45.3%
Simplified45.3%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
associate-*r*0.0%
distribute-rgt-out26.1%
+-commutative26.1%
*-commutative26.1%
unpow226.1%
associate-*l*26.1%
Simplified26.1%
Applied egg-rr27.0%
Final simplification34.6%
(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 49.5%
sub0-neg49.5%
Simplified49.5%
Taylor expanded in im around 0 57.5%
mul-1-neg57.5%
*-commutative57.5%
distribute-lft-neg-in57.5%
Simplified57.5%
Taylor expanded in re around 0 38.0%
neg-mul-138.0%
+-commutative38.0%
unsub-neg38.0%
*-commutative38.0%
*-commutative38.0%
associate-*l*38.0%
unpow238.0%
Simplified38.0%
Taylor expanded in re around 0 32.8%
neg-mul-132.8%
Simplified32.8%
Final simplification32.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 2023238
(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))))