
(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 13 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 (* 0.5 (log1p (expm1 (* -2.0 (* im (cos re)))))))
double code(double re, double im) {
return 0.5 * log1p(expm1((-2.0 * (im * cos(re)))));
}
public static double code(double re, double im) {
return 0.5 * Math.log1p(Math.expm1((-2.0 * (im * Math.cos(re)))));
}
def code(re, im): return 0.5 * math.log1p(math.expm1((-2.0 * (im * math.cos(re)))))
function code(re, im) return Float64(0.5 * log1p(expm1(Float64(-2.0 * Float64(im * cos(re)))))) end
code[re_, im_] := N[(0.5 * N[Log[1 + N[(Exp[N[(-2.0 * N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(-2 \cdot \left(im \cdot \cos re\right)\right)\right)
\end{array}
Initial program 51.7%
cos-neg51.7%
sub-neg51.7%
neg-sub051.7%
remove-double-neg51.7%
remove-double-neg51.7%
sub0-neg51.7%
distribute-neg-in51.7%
+-commutative51.7%
sub-neg51.7%
associate-*l*51.7%
sub-neg51.7%
+-commutative51.7%
distribute-neg-in51.7%
Simplified51.7%
Taylor expanded in im around 0 55.3%
log1p-expm1-u98.9%
associate-*l*98.9%
Applied egg-rr98.9%
Final simplification98.9%
(FPCore (re im)
:precision binary64
(if (<= im 1.6)
(* 0.5 (* (cos re) (* -2.0 im)))
(if (<= im 1.2e+61)
(* 0.5 (log1p (expm1 (* -2.0 im))))
(* 0.5 (* (* (cos re) -0.016666666666666666) (pow im 5.0))))))
double code(double re, double im) {
double tmp;
if (im <= 1.6) {
tmp = 0.5 * (cos(re) * (-2.0 * im));
} else if (im <= 1.2e+61) {
tmp = 0.5 * log1p(expm1((-2.0 * im)));
} else {
tmp = 0.5 * ((cos(re) * -0.016666666666666666) * pow(im, 5.0));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 1.6) {
tmp = 0.5 * (Math.cos(re) * (-2.0 * im));
} else if (im <= 1.2e+61) {
tmp = 0.5 * Math.log1p(Math.expm1((-2.0 * im)));
} else {
tmp = 0.5 * ((Math.cos(re) * -0.016666666666666666) * Math.pow(im, 5.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.6: tmp = 0.5 * (math.cos(re) * (-2.0 * im)) elif im <= 1.2e+61: tmp = 0.5 * math.log1p(math.expm1((-2.0 * im))) else: tmp = 0.5 * ((math.cos(re) * -0.016666666666666666) * math.pow(im, 5.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.6) tmp = Float64(0.5 * Float64(cos(re) * Float64(-2.0 * im))); elseif (im <= 1.2e+61) tmp = Float64(0.5 * log1p(expm1(Float64(-2.0 * im)))); else tmp = Float64(0.5 * Float64(Float64(cos(re) * -0.016666666666666666) * (im ^ 5.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 1.6], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(-2.0 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.2e+61], N[(0.5 * N[Log[1 + N[(Exp[N[(-2.0 * im), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(N[Cos[re], $MachinePrecision] * -0.016666666666666666), $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.6:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(-2 \cdot im\right)\right)\\
\mathbf{elif}\;im \leq 1.2 \cdot 10^{+61}:\\
\;\;\;\;0.5 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(-2 \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(\cos re \cdot -0.016666666666666666\right) \cdot {im}^{5}\right)\\
\end{array}
\end{array}
if im < 1.6000000000000001Initial program 36.6%
cos-neg36.6%
sub-neg36.6%
neg-sub036.6%
remove-double-neg36.6%
remove-double-neg36.6%
sub0-neg36.6%
distribute-neg-in36.6%
+-commutative36.6%
sub-neg36.6%
associate-*l*36.6%
sub-neg36.6%
+-commutative36.6%
distribute-neg-in36.6%
Simplified36.6%
Taylor expanded in im around 0 70.4%
if 1.6000000000000001 < im < 1.1999999999999999e61Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 3.3%
log1p-expm1-u100.0%
associate-*l*100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 75.0%
if 1.1999999999999999e61 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 98.2%
Taylor expanded in im around inf 98.2%
associate-*r*98.2%
*-commutative98.2%
associate-*r*98.2%
Simplified98.2%
Final simplification75.9%
(FPCore (re im)
:precision binary64
(if (<= im 0.115)
(* 0.5 (* (cos re) (* -2.0 im)))
(if (<= im 1.2e+61)
(* 0.5 (- (exp (- im)) (exp im)))
(* 0.5 (* (* (cos re) -0.016666666666666666) (pow im 5.0))))))
double code(double re, double im) {
double tmp;
if (im <= 0.115) {
tmp = 0.5 * (cos(re) * (-2.0 * im));
} else if (im <= 1.2e+61) {
tmp = 0.5 * (exp(-im) - exp(im));
} else {
tmp = 0.5 * ((cos(re) * -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) :: tmp
if (im <= 0.115d0) then
tmp = 0.5d0 * (cos(re) * ((-2.0d0) * im))
else if (im <= 1.2d+61) then
tmp = 0.5d0 * (exp(-im) - exp(im))
else
tmp = 0.5d0 * ((cos(re) * (-0.016666666666666666d0)) * (im ** 5.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.115) {
tmp = 0.5 * (Math.cos(re) * (-2.0 * im));
} else if (im <= 1.2e+61) {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
} else {
tmp = 0.5 * ((Math.cos(re) * -0.016666666666666666) * Math.pow(im, 5.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.115: tmp = 0.5 * (math.cos(re) * (-2.0 * im)) elif im <= 1.2e+61: tmp = 0.5 * (math.exp(-im) - math.exp(im)) else: tmp = 0.5 * ((math.cos(re) * -0.016666666666666666) * math.pow(im, 5.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.115) tmp = Float64(0.5 * Float64(cos(re) * Float64(-2.0 * im))); elseif (im <= 1.2e+61) tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); else tmp = Float64(0.5 * Float64(Float64(cos(re) * -0.016666666666666666) * (im ^ 5.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.115) tmp = 0.5 * (cos(re) * (-2.0 * im)); elseif (im <= 1.2e+61) tmp = 0.5 * (exp(-im) - exp(im)); else tmp = 0.5 * ((cos(re) * -0.016666666666666666) * (im ^ 5.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.115], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(-2.0 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.2e+61], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(N[Cos[re], $MachinePrecision] * -0.016666666666666666), $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.115:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(-2 \cdot im\right)\right)\\
\mathbf{elif}\;im \leq 1.2 \cdot 10^{+61}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(\cos re \cdot -0.016666666666666666\right) \cdot {im}^{5}\right)\\
\end{array}
\end{array}
if im < 0.115000000000000005Initial program 36.6%
cos-neg36.6%
sub-neg36.6%
neg-sub036.6%
remove-double-neg36.6%
remove-double-neg36.6%
sub0-neg36.6%
distribute-neg-in36.6%
+-commutative36.6%
sub-neg36.6%
associate-*l*36.6%
sub-neg36.6%
+-commutative36.6%
distribute-neg-in36.6%
Simplified36.6%
Taylor expanded in im around 0 70.4%
if 0.115000000000000005 < im < 1.1999999999999999e61Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in re around 0 75.0%
if 1.1999999999999999e61 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 98.2%
Taylor expanded in im around inf 98.2%
associate-*r*98.2%
*-commutative98.2%
associate-*r*98.2%
Simplified98.2%
Final simplification75.9%
(FPCore (re im)
:precision binary64
(if (<= im 0.06)
(* 0.5 (* (cos re) (+ (* -2.0 im) (* -0.3333333333333333 (pow im 3.0)))))
(if (<= im 1.2e+61)
(* 0.5 (- (exp (- im)) (exp im)))
(* 0.5 (* (* (cos re) -0.016666666666666666) (pow im 5.0))))))
double code(double re, double im) {
double tmp;
if (im <= 0.06) {
tmp = 0.5 * (cos(re) * ((-2.0 * im) + (-0.3333333333333333 * pow(im, 3.0))));
} else if (im <= 1.2e+61) {
tmp = 0.5 * (exp(-im) - exp(im));
} else {
tmp = 0.5 * ((cos(re) * -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) :: tmp
if (im <= 0.06d0) then
tmp = 0.5d0 * (cos(re) * (((-2.0d0) * im) + ((-0.3333333333333333d0) * (im ** 3.0d0))))
else if (im <= 1.2d+61) then
tmp = 0.5d0 * (exp(-im) - exp(im))
else
tmp = 0.5d0 * ((cos(re) * (-0.016666666666666666d0)) * (im ** 5.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.06) {
tmp = 0.5 * (Math.cos(re) * ((-2.0 * im) + (-0.3333333333333333 * Math.pow(im, 3.0))));
} else if (im <= 1.2e+61) {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
} else {
tmp = 0.5 * ((Math.cos(re) * -0.016666666666666666) * Math.pow(im, 5.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.06: tmp = 0.5 * (math.cos(re) * ((-2.0 * im) + (-0.3333333333333333 * math.pow(im, 3.0)))) elif im <= 1.2e+61: tmp = 0.5 * (math.exp(-im) - math.exp(im)) else: tmp = 0.5 * ((math.cos(re) * -0.016666666666666666) * math.pow(im, 5.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.06) tmp = Float64(0.5 * Float64(cos(re) * Float64(Float64(-2.0 * im) + Float64(-0.3333333333333333 * (im ^ 3.0))))); elseif (im <= 1.2e+61) tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); else tmp = Float64(0.5 * Float64(Float64(cos(re) * -0.016666666666666666) * (im ^ 5.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.06) tmp = 0.5 * (cos(re) * ((-2.0 * im) + (-0.3333333333333333 * (im ^ 3.0)))); elseif (im <= 1.2e+61) tmp = 0.5 * (exp(-im) - exp(im)); else tmp = 0.5 * ((cos(re) * -0.016666666666666666) * (im ^ 5.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.06], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(N[(-2.0 * im), $MachinePrecision] + N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.2e+61], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(N[Cos[re], $MachinePrecision] * -0.016666666666666666), $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.06:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(-2 \cdot im + -0.3333333333333333 \cdot {im}^{3}\right)\right)\\
\mathbf{elif}\;im \leq 1.2 \cdot 10^{+61}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(\cos re \cdot -0.016666666666666666\right) \cdot {im}^{5}\right)\\
\end{array}
\end{array}
if im < 0.059999999999999998Initial program 36.6%
cos-neg36.6%
sub-neg36.6%
neg-sub036.6%
remove-double-neg36.6%
remove-double-neg36.6%
sub0-neg36.6%
distribute-neg-in36.6%
+-commutative36.6%
sub-neg36.6%
associate-*l*36.6%
sub-neg36.6%
+-commutative36.6%
distribute-neg-in36.6%
Simplified36.6%
Taylor expanded in im around 0 90.3%
if 0.059999999999999998 < im < 1.1999999999999999e61Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in re around 0 75.0%
if 1.1999999999999999e61 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 98.2%
Taylor expanded in im around inf 98.2%
associate-*r*98.2%
*-commutative98.2%
associate-*r*98.2%
Simplified98.2%
Final simplification91.1%
(FPCore (re im)
:precision binary64
(if (<= im 70000.0)
(* 0.5 (* (cos re) (* -2.0 im)))
(if (<= im 5.2e+69)
(log1p (expm1 im))
(* 0.5 (+ (* -2.0 im) (* -0.3333333333333333 (pow im 3.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 70000.0) {
tmp = 0.5 * (cos(re) * (-2.0 * im));
} else if (im <= 5.2e+69) {
tmp = log1p(expm1(im));
} else {
tmp = 0.5 * ((-2.0 * im) + (-0.3333333333333333 * pow(im, 3.0)));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 70000.0) {
tmp = 0.5 * (Math.cos(re) * (-2.0 * im));
} else if (im <= 5.2e+69) {
tmp = Math.log1p(Math.expm1(im));
} else {
tmp = 0.5 * ((-2.0 * im) + (-0.3333333333333333 * Math.pow(im, 3.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 70000.0: tmp = 0.5 * (math.cos(re) * (-2.0 * im)) elif im <= 5.2e+69: tmp = math.log1p(math.expm1(im)) else: tmp = 0.5 * ((-2.0 * im) + (-0.3333333333333333 * math.pow(im, 3.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 70000.0) tmp = Float64(0.5 * Float64(cos(re) * Float64(-2.0 * im))); elseif (im <= 5.2e+69) tmp = log1p(expm1(im)); else tmp = Float64(0.5 * Float64(Float64(-2.0 * im) + Float64(-0.3333333333333333 * (im ^ 3.0)))); end return tmp end
code[re_, im_] := If[LessEqual[im, 70000.0], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(-2.0 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5.2e+69], N[Log[1 + N[(Exp[im] - 1), $MachinePrecision]], $MachinePrecision], N[(0.5 * N[(N[(-2.0 * im), $MachinePrecision] + N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 70000:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(-2 \cdot im\right)\right)\\
\mathbf{elif}\;im \leq 5.2 \cdot 10^{+69}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(-2 \cdot im + -0.3333333333333333 \cdot {im}^{3}\right)\\
\end{array}
\end{array}
if im < 7e4Initial program 37.2%
cos-neg37.2%
sub-neg37.2%
neg-sub037.2%
remove-double-neg37.2%
remove-double-neg37.2%
sub0-neg37.2%
distribute-neg-in37.2%
+-commutative37.2%
sub-neg37.2%
associate-*l*37.2%
sub-neg37.2%
+-commutative37.2%
distribute-neg-in37.2%
Simplified37.2%
Taylor expanded in im around 0 69.7%
if 7e4 < im < 5.2000000000000004e69Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 3.4%
log1p-expm1-u100.0%
associate-*l*100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 2.2%
add-sqr-sqrt0.0%
sqrt-unprod1.7%
associate-*r*1.7%
associate-*r*1.7%
swap-sqr1.7%
metadata-eval1.7%
metadata-eval1.7%
metadata-eval1.7%
*-un-lft-identity1.7%
sqrt-unprod1.7%
add-sqr-sqrt1.7%
log1p-expm1-u41.7%
Applied egg-rr41.7%
if 5.2000000000000004e69 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 88.5%
Taylor expanded in re around 0 67.2%
Final simplification67.9%
(FPCore (re im) :precision binary64 (if (<= (cos re) -0.01) (* 0.5 (* im (pow re 2.0))) (- im)))
double code(double re, double im) {
double tmp;
if (cos(re) <= -0.01) {
tmp = 0.5 * (im * pow(re, 2.0));
} 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 (cos(re) <= (-0.01d0)) then
tmp = 0.5d0 * (im * (re ** 2.0d0))
else
tmp = -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.cos(re) <= -0.01) {
tmp = 0.5 * (im * Math.pow(re, 2.0));
} else {
tmp = -im;
}
return tmp;
}
def code(re, im): tmp = 0 if math.cos(re) <= -0.01: tmp = 0.5 * (im * math.pow(re, 2.0)) else: tmp = -im return tmp
function code(re, im) tmp = 0.0 if (cos(re) <= -0.01) tmp = Float64(0.5 * Float64(im * (re ^ 2.0))); else tmp = Float64(-im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (cos(re) <= -0.01) tmp = 0.5 * (im * (re ^ 2.0)); else tmp = -im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Cos[re], $MachinePrecision], -0.01], N[(0.5 * N[(im * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-im)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos re \leq -0.01:\\
\;\;\;\;0.5 \cdot \left(im \cdot {re}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;-im\\
\end{array}
\end{array}
if (cos.f64 re) < -0.0100000000000000002Initial program 45.7%
cos-neg45.7%
sub-neg45.7%
neg-sub045.7%
remove-double-neg45.7%
remove-double-neg45.7%
sub0-neg45.7%
distribute-neg-in45.7%
+-commutative45.7%
sub-neg45.7%
associate-*l*45.7%
sub-neg45.7%
+-commutative45.7%
distribute-neg-in45.7%
Simplified45.7%
Taylor expanded in im around 0 61.6%
Taylor expanded in re around 0 30.9%
+-commutative30.9%
*-commutative30.9%
distribute-lft-out32.5%
Simplified32.5%
Taylor expanded in re around inf 32.5%
if -0.0100000000000000002 < (cos.f64 re) Initial program 53.6%
cos-neg53.6%
sub-neg53.6%
neg-sub053.6%
remove-double-neg53.6%
remove-double-neg53.6%
sub0-neg53.6%
distribute-neg-in53.6%
+-commutative53.6%
sub-neg53.6%
associate-*l*53.6%
sub-neg53.6%
+-commutative53.6%
distribute-neg-in53.6%
Simplified53.6%
Taylor expanded in im around 0 53.3%
log1p-expm1-u98.9%
associate-*l*98.9%
Applied egg-rr98.9%
Taylor expanded in re around 0 41.0%
Taylor expanded in im around 0 41.0%
neg-mul-141.0%
Simplified41.0%
Final simplification38.9%
(FPCore (re im) :precision binary64 (if (<= im 1.6) (* 0.5 (* (cos re) (* -2.0 im))) (* 0.5 (log1p (expm1 (* -2.0 im))))))
double code(double re, double im) {
double tmp;
if (im <= 1.6) {
tmp = 0.5 * (cos(re) * (-2.0 * im));
} else {
tmp = 0.5 * log1p(expm1((-2.0 * im)));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 1.6) {
tmp = 0.5 * (Math.cos(re) * (-2.0 * im));
} else {
tmp = 0.5 * Math.log1p(Math.expm1((-2.0 * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.6: tmp = 0.5 * (math.cos(re) * (-2.0 * im)) else: tmp = 0.5 * math.log1p(math.expm1((-2.0 * im))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.6) tmp = Float64(0.5 * Float64(cos(re) * Float64(-2.0 * im))); else tmp = Float64(0.5 * log1p(expm1(Float64(-2.0 * im)))); end return tmp end
code[re_, im_] := If[LessEqual[im, 1.6], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(-2.0 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Log[1 + N[(Exp[N[(-2.0 * im), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.6:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(-2 \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(-2 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 1.6000000000000001Initial program 36.6%
cos-neg36.6%
sub-neg36.6%
neg-sub036.6%
remove-double-neg36.6%
remove-double-neg36.6%
sub0-neg36.6%
distribute-neg-in36.6%
+-commutative36.6%
sub-neg36.6%
associate-*l*36.6%
sub-neg36.6%
+-commutative36.6%
distribute-neg-in36.6%
Simplified36.6%
Taylor expanded in im around 0 70.4%
if 1.6000000000000001 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 6.9%
log1p-expm1-u100.0%
associate-*l*100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 75.4%
Final simplification71.6%
(FPCore (re im)
:precision binary64
(if (<= im 2.7e+16)
(* 0.5 (* (cos re) (* -2.0 im)))
(if (<= im 4.8e+69)
(* 0.5 (* im (+ -2.0 (pow re 2.0))))
(* 0.5 (+ (* -2.0 im) (* -0.3333333333333333 (pow im 3.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 2.7e+16) {
tmp = 0.5 * (cos(re) * (-2.0 * im));
} else if (im <= 4.8e+69) {
tmp = 0.5 * (im * (-2.0 + pow(re, 2.0)));
} else {
tmp = 0.5 * ((-2.0 * im) + (-0.3333333333333333 * pow(im, 3.0)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.7d+16) then
tmp = 0.5d0 * (cos(re) * ((-2.0d0) * im))
else if (im <= 4.8d+69) then
tmp = 0.5d0 * (im * ((-2.0d0) + (re ** 2.0d0)))
else
tmp = 0.5d0 * (((-2.0d0) * im) + ((-0.3333333333333333d0) * (im ** 3.0d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.7e+16) {
tmp = 0.5 * (Math.cos(re) * (-2.0 * im));
} else if (im <= 4.8e+69) {
tmp = 0.5 * (im * (-2.0 + Math.pow(re, 2.0)));
} else {
tmp = 0.5 * ((-2.0 * im) + (-0.3333333333333333 * Math.pow(im, 3.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.7e+16: tmp = 0.5 * (math.cos(re) * (-2.0 * im)) elif im <= 4.8e+69: tmp = 0.5 * (im * (-2.0 + math.pow(re, 2.0))) else: tmp = 0.5 * ((-2.0 * im) + (-0.3333333333333333 * math.pow(im, 3.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.7e+16) tmp = Float64(0.5 * Float64(cos(re) * Float64(-2.0 * im))); elseif (im <= 4.8e+69) tmp = Float64(0.5 * Float64(im * Float64(-2.0 + (re ^ 2.0)))); else tmp = Float64(0.5 * Float64(Float64(-2.0 * im) + Float64(-0.3333333333333333 * (im ^ 3.0)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.7e+16) tmp = 0.5 * (cos(re) * (-2.0 * im)); elseif (im <= 4.8e+69) tmp = 0.5 * (im * (-2.0 + (re ^ 2.0))); else tmp = 0.5 * ((-2.0 * im) + (-0.3333333333333333 * (im ^ 3.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.7e+16], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(-2.0 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.8e+69], N[(0.5 * N[(im * N[(-2.0 + N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(-2.0 * im), $MachinePrecision] + N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.7 \cdot 10^{+16}:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(-2 \cdot im\right)\right)\\
\mathbf{elif}\;im \leq 4.8 \cdot 10^{+69}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(-2 + {re}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(-2 \cdot im + -0.3333333333333333 \cdot {im}^{3}\right)\\
\end{array}
\end{array}
if im < 2.7e16Initial program 38.2%
cos-neg38.2%
sub-neg38.2%
neg-sub038.2%
remove-double-neg38.2%
remove-double-neg38.2%
sub0-neg38.2%
distribute-neg-in38.2%
+-commutative38.2%
sub-neg38.2%
associate-*l*38.2%
sub-neg38.2%
+-commutative38.2%
distribute-neg-in38.2%
Simplified38.2%
Taylor expanded in im around 0 68.7%
if 2.7e16 < im < 4.8000000000000003e69Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 3.5%
Taylor expanded in re around 0 35.6%
+-commutative35.6%
*-commutative35.6%
distribute-lft-out35.6%
Simplified35.6%
if 4.8000000000000003e69 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 88.5%
Taylor expanded in re around 0 67.2%
Final simplification67.2%
(FPCore (re im)
:precision binary64
(if (<= im 2.9e+16)
(* 0.5 (* (cos re) (* -2.0 im)))
(if (<= im 5e+69)
(* 0.5 (* im (+ -2.0 (pow re 2.0))))
(* 0.5 (* -0.3333333333333333 (pow im 3.0))))))
double code(double re, double im) {
double tmp;
if (im <= 2.9e+16) {
tmp = 0.5 * (cos(re) * (-2.0 * im));
} else if (im <= 5e+69) {
tmp = 0.5 * (im * (-2.0 + pow(re, 2.0)));
} else {
tmp = 0.5 * (-0.3333333333333333 * pow(im, 3.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.9d+16) then
tmp = 0.5d0 * (cos(re) * ((-2.0d0) * im))
else if (im <= 5d+69) then
tmp = 0.5d0 * (im * ((-2.0d0) + (re ** 2.0d0)))
else
tmp = 0.5d0 * ((-0.3333333333333333d0) * (im ** 3.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.9e+16) {
tmp = 0.5 * (Math.cos(re) * (-2.0 * im));
} else if (im <= 5e+69) {
tmp = 0.5 * (im * (-2.0 + Math.pow(re, 2.0)));
} else {
tmp = 0.5 * (-0.3333333333333333 * Math.pow(im, 3.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.9e+16: tmp = 0.5 * (math.cos(re) * (-2.0 * im)) elif im <= 5e+69: tmp = 0.5 * (im * (-2.0 + math.pow(re, 2.0))) else: tmp = 0.5 * (-0.3333333333333333 * math.pow(im, 3.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.9e+16) tmp = Float64(0.5 * Float64(cos(re) * Float64(-2.0 * im))); elseif (im <= 5e+69) tmp = Float64(0.5 * Float64(im * Float64(-2.0 + (re ^ 2.0)))); else tmp = Float64(0.5 * Float64(-0.3333333333333333 * (im ^ 3.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.9e+16) tmp = 0.5 * (cos(re) * (-2.0 * im)); elseif (im <= 5e+69) tmp = 0.5 * (im * (-2.0 + (re ^ 2.0))); else tmp = 0.5 * (-0.3333333333333333 * (im ^ 3.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.9e+16], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(-2.0 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5e+69], N[(0.5 * N[(im * N[(-2.0 + N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.9 \cdot 10^{+16}:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(-2 \cdot im\right)\right)\\
\mathbf{elif}\;im \leq 5 \cdot 10^{+69}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(-2 + {re}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right)\\
\end{array}
\end{array}
if im < 2.9e16Initial program 38.2%
cos-neg38.2%
sub-neg38.2%
neg-sub038.2%
remove-double-neg38.2%
remove-double-neg38.2%
sub0-neg38.2%
distribute-neg-in38.2%
+-commutative38.2%
sub-neg38.2%
associate-*l*38.2%
sub-neg38.2%
+-commutative38.2%
distribute-neg-in38.2%
Simplified38.2%
Taylor expanded in im around 0 68.7%
if 2.9e16 < im < 5.00000000000000036e69Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 3.5%
Taylor expanded in re around 0 35.6%
+-commutative35.6%
*-commutative35.6%
distribute-lft-out35.6%
Simplified35.6%
if 5.00000000000000036e69 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in re around 0 78.7%
Taylor expanded in im around 0 67.2%
Taylor expanded in im around inf 67.2%
Final simplification67.2%
(FPCore (re im) :precision binary64 (if (<= im 2.65e+16) (* 0.5 (* (cos re) (* -2.0 im))) (* 0.5 (* im (+ -2.0 (pow re 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 2.65e+16) {
tmp = 0.5 * (cos(re) * (-2.0 * im));
} else {
tmp = 0.5 * (im * (-2.0 + pow(re, 2.0)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.65d+16) then
tmp = 0.5d0 * (cos(re) * ((-2.0d0) * im))
else
tmp = 0.5d0 * (im * ((-2.0d0) + (re ** 2.0d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.65e+16) {
tmp = 0.5 * (Math.cos(re) * (-2.0 * im));
} else {
tmp = 0.5 * (im * (-2.0 + Math.pow(re, 2.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.65e+16: tmp = 0.5 * (math.cos(re) * (-2.0 * im)) else: tmp = 0.5 * (im * (-2.0 + math.pow(re, 2.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.65e+16) tmp = Float64(0.5 * Float64(cos(re) * Float64(-2.0 * im))); else tmp = Float64(0.5 * Float64(im * Float64(-2.0 + (re ^ 2.0)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.65e+16) tmp = 0.5 * (cos(re) * (-2.0 * im)); else tmp = 0.5 * (im * (-2.0 + (re ^ 2.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.65e+16], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(-2.0 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[(-2.0 + N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.65 \cdot 10^{+16}:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(-2 \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(-2 + {re}^{2}\right)\right)\\
\end{array}
\end{array}
if im < 2.65e16Initial program 38.2%
cos-neg38.2%
sub-neg38.2%
neg-sub038.2%
remove-double-neg38.2%
remove-double-neg38.2%
sub0-neg38.2%
distribute-neg-in38.2%
+-commutative38.2%
sub-neg38.2%
associate-*l*38.2%
sub-neg38.2%
+-commutative38.2%
distribute-neg-in38.2%
Simplified38.2%
Taylor expanded in im around 0 68.7%
if 2.65e16 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 7.3%
Taylor expanded in re around 0 19.7%
+-commutative19.7%
*-commutative19.7%
distribute-lft-out21.5%
Simplified21.5%
Final simplification58.4%
(FPCore (re im) :precision binary64 (if (<= im 1e+17) (* 0.5 (* (cos re) (* -2.0 im))) (* 0.5 (* im (pow re 2.0)))))
double code(double re, double im) {
double tmp;
if (im <= 1e+17) {
tmp = 0.5 * (cos(re) * (-2.0 * im));
} else {
tmp = 0.5 * (im * pow(re, 2.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1d+17) then
tmp = 0.5d0 * (cos(re) * ((-2.0d0) * im))
else
tmp = 0.5d0 * (im * (re ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1e+17) {
tmp = 0.5 * (Math.cos(re) * (-2.0 * im));
} else {
tmp = 0.5 * (im * Math.pow(re, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1e+17: tmp = 0.5 * (math.cos(re) * (-2.0 * im)) else: tmp = 0.5 * (im * math.pow(re, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1e+17) tmp = Float64(0.5 * Float64(cos(re) * Float64(-2.0 * im))); else tmp = Float64(0.5 * Float64(im * (re ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1e+17) tmp = 0.5 * (cos(re) * (-2.0 * im)); else tmp = 0.5 * (im * (re ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1e+17], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(-2.0 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 10^{+17}:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(-2 \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot {re}^{2}\right)\\
\end{array}
\end{array}
if im < 1e17Initial program 38.2%
cos-neg38.2%
sub-neg38.2%
neg-sub038.2%
remove-double-neg38.2%
remove-double-neg38.2%
sub0-neg38.2%
distribute-neg-in38.2%
+-commutative38.2%
sub-neg38.2%
associate-*l*38.2%
sub-neg38.2%
+-commutative38.2%
distribute-neg-in38.2%
Simplified38.2%
Taylor expanded in im around 0 68.7%
if 1e17 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 7.3%
Taylor expanded in re around 0 19.7%
+-commutative19.7%
*-commutative19.7%
distribute-lft-out21.5%
Simplified21.5%
Taylor expanded in re around inf 19.1%
Final simplification57.8%
(FPCore (re im) :precision binary64 (if (<= (cos re) -2e-311) im (- im)))
double code(double re, double im) {
double tmp;
if (cos(re) <= -2e-311) {
tmp = im;
} 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 (cos(re) <= (-2d-311)) then
tmp = im
else
tmp = -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.cos(re) <= -2e-311) {
tmp = im;
} else {
tmp = -im;
}
return tmp;
}
def code(re, im): tmp = 0 if math.cos(re) <= -2e-311: tmp = im else: tmp = -im return tmp
function code(re, im) tmp = 0.0 if (cos(re) <= -2e-311) tmp = im; else tmp = Float64(-im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (cos(re) <= -2e-311) tmp = im; else tmp = -im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Cos[re], $MachinePrecision], -2e-311], im, (-im)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos re \leq -2 \cdot 10^{-311}:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;-im\\
\end{array}
\end{array}
if (cos.f64 re) < -1.9999999999999e-311Initial program 45.7%
cos-neg45.7%
sub-neg45.7%
neg-sub045.7%
remove-double-neg45.7%
remove-double-neg45.7%
sub0-neg45.7%
distribute-neg-in45.7%
+-commutative45.7%
sub-neg45.7%
associate-*l*45.7%
sub-neg45.7%
+-commutative45.7%
distribute-neg-in45.7%
Simplified45.7%
Taylor expanded in im around 0 61.6%
log1p-expm1-u98.8%
associate-*l*98.8%
Applied egg-rr98.8%
Taylor expanded in re around 0 2.1%
add-sqr-sqrt0.9%
sqrt-unprod19.3%
associate-*r*19.3%
associate-*r*19.3%
swap-sqr19.3%
metadata-eval19.3%
metadata-eval19.3%
metadata-eval19.3%
*-un-lft-identity19.3%
sqrt-unprod8.3%
add-sqr-sqrt15.4%
pow115.4%
Applied egg-rr15.4%
unpow115.4%
Simplified15.4%
if -1.9999999999999e-311 < (cos.f64 re) Initial program 53.6%
cos-neg53.6%
sub-neg53.6%
neg-sub053.6%
remove-double-neg53.6%
remove-double-neg53.6%
sub0-neg53.6%
distribute-neg-in53.6%
+-commutative53.6%
sub-neg53.6%
associate-*l*53.6%
sub-neg53.6%
+-commutative53.6%
distribute-neg-in53.6%
Simplified53.6%
Taylor expanded in im around 0 53.3%
log1p-expm1-u98.9%
associate-*l*98.9%
Applied egg-rr98.9%
Taylor expanded in re around 0 41.0%
Taylor expanded in im around 0 41.0%
neg-mul-141.0%
Simplified41.0%
Final simplification34.9%
(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 im end
function tmp = code(re, im) tmp = im; end
code[re_, im_] := im
\begin{array}{l}
\\
im
\end{array}
Initial program 51.7%
cos-neg51.7%
sub-neg51.7%
neg-sub051.7%
remove-double-neg51.7%
remove-double-neg51.7%
sub0-neg51.7%
distribute-neg-in51.7%
+-commutative51.7%
sub-neg51.7%
associate-*l*51.7%
sub-neg51.7%
+-commutative51.7%
distribute-neg-in51.7%
Simplified51.7%
Taylor expanded in im around 0 55.3%
log1p-expm1-u98.9%
associate-*l*98.9%
Applied egg-rr98.9%
Taylor expanded in re around 0 31.7%
add-sqr-sqrt12.9%
sqrt-unprod22.7%
associate-*r*22.7%
associate-*r*22.7%
swap-sqr22.7%
metadata-eval22.7%
metadata-eval22.7%
metadata-eval22.7%
*-un-lft-identity22.7%
sqrt-unprod2.8%
add-sqr-sqrt5.2%
pow15.2%
Applied egg-rr5.2%
unpow15.2%
Simplified5.2%
Final simplification5.2%
(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 2024039
(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))))