
(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 16 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 (* (cos re) (* im -2.0))))))
double code(double re, double im) {
return 0.5 * log1p(expm1((cos(re) * (im * -2.0))));
}
public static double code(double re, double im) {
return 0.5 * Math.log1p(Math.expm1((Math.cos(re) * (im * -2.0))));
}
def code(re, im): return 0.5 * math.log1p(math.expm1((math.cos(re) * (im * -2.0))))
function code(re, im) return Float64(0.5 * log1p(expm1(Float64(cos(re) * Float64(im * -2.0))))) end
code[re_, im_] := N[(0.5 * N[Log[1 + N[(Exp[N[(N[Cos[re], $MachinePrecision] * N[(im * -2.0), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos re \cdot \left(im \cdot -2\right)\right)\right)
\end{array}
Initial program 57.6%
/-rgt-identity57.6%
exp-057.6%
associate-*l/57.6%
cos-neg57.6%
associate-*l*57.6%
associate-*r/57.6%
exp-057.6%
/-rgt-identity57.6%
*-commutative57.6%
neg-sub057.6%
cos-neg57.6%
Simplified57.6%
Taylor expanded in im around 0 49.2%
log1p-expm1-u98.5%
*-commutative98.5%
*-commutative98.5%
Applied egg-rr98.5%
(FPCore (re im) :precision binary64 (log1p (expm1 (* (cos re) (- im)))))
double code(double re, double im) {
return log1p(expm1((cos(re) * -im)));
}
public static double code(double re, double im) {
return Math.log1p(Math.expm1((Math.cos(re) * -im)));
}
def code(re, im): return math.log1p(math.expm1((math.cos(re) * -im)))
function code(re, im) return log1p(expm1(Float64(cos(re) * Float64(-im)))) end
code[re_, im_] := N[Log[1 + N[(Exp[N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{log1p}\left(\mathsf{expm1}\left(\cos re \cdot \left(-im\right)\right)\right)
\end{array}
Initial program 57.6%
/-rgt-identity57.6%
exp-057.6%
associate-*l/57.6%
cos-neg57.6%
associate-*l*57.6%
associate-*r/57.6%
exp-057.6%
/-rgt-identity57.6%
*-commutative57.6%
neg-sub057.6%
cos-neg57.6%
Simplified57.6%
Taylor expanded in im around 0 49.2%
log1p-expm1-u98.5%
associate-*r*98.5%
*-commutative98.5%
associate-*r*98.5%
metadata-eval98.5%
Applied egg-rr98.5%
Final simplification98.5%
(FPCore (re im)
:precision binary64
(if (<= im 490.0)
(* 0.5 (* (cos re) (* im (- (* -0.3333333333333333 (pow im 2.0)) 2.0))))
(if (<= im 2.6e+78)
(* 0.5 (log1p (expm1 (* im -2.0))))
(*
0.5
(* (cos re) (* im (- (* -0.0003968253968253968 (pow im 6.0)) 2.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 490.0) {
tmp = 0.5 * (cos(re) * (im * ((-0.3333333333333333 * pow(im, 2.0)) - 2.0)));
} else if (im <= 2.6e+78) {
tmp = 0.5 * log1p(expm1((im * -2.0)));
} else {
tmp = 0.5 * (cos(re) * (im * ((-0.0003968253968253968 * pow(im, 6.0)) - 2.0)));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 490.0) {
tmp = 0.5 * (Math.cos(re) * (im * ((-0.3333333333333333 * Math.pow(im, 2.0)) - 2.0)));
} else if (im <= 2.6e+78) {
tmp = 0.5 * Math.log1p(Math.expm1((im * -2.0)));
} else {
tmp = 0.5 * (Math.cos(re) * (im * ((-0.0003968253968253968 * Math.pow(im, 6.0)) - 2.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 490.0: tmp = 0.5 * (math.cos(re) * (im * ((-0.3333333333333333 * math.pow(im, 2.0)) - 2.0))) elif im <= 2.6e+78: tmp = 0.5 * math.log1p(math.expm1((im * -2.0))) else: tmp = 0.5 * (math.cos(re) * (im * ((-0.0003968253968253968 * math.pow(im, 6.0)) - 2.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 490.0) tmp = Float64(0.5 * Float64(cos(re) * Float64(im * Float64(Float64(-0.3333333333333333 * (im ^ 2.0)) - 2.0)))); elseif (im <= 2.6e+78) tmp = Float64(0.5 * log1p(expm1(Float64(im * -2.0)))); else tmp = Float64(0.5 * Float64(cos(re) * Float64(im * Float64(Float64(-0.0003968253968253968 * (im ^ 6.0)) - 2.0)))); end return tmp end
code[re_, im_] := If[LessEqual[im, 490.0], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(im * N[(N[(-0.3333333333333333 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.6e+78], N[(0.5 * N[Log[1 + N[(Exp[N[(im * -2.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(im * N[(N[(-0.0003968253968253968 * N[Power[im, 6.0], $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 490:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(im \cdot \left(-0.3333333333333333 \cdot {im}^{2} - 2\right)\right)\right)\\
\mathbf{elif}\;im \leq 2.6 \cdot 10^{+78}:\\
\;\;\;\;0.5 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(im \cdot \left(-0.0003968253968253968 \cdot {im}^{6} - 2\right)\right)\right)\\
\end{array}
\end{array}
if im < 490Initial program 38.6%
/-rgt-identity38.6%
exp-038.6%
associate-*l/38.6%
cos-neg38.6%
associate-*l*38.6%
associate-*r/38.6%
exp-038.6%
/-rgt-identity38.6%
*-commutative38.6%
neg-sub038.6%
cos-neg38.6%
Simplified38.6%
Taylor expanded in im around 0 87.5%
if 490 < im < 2.6e78Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 3.4%
log1p-expm1-u100.0%
*-commutative100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 84.6%
expm1-define84.6%
Simplified84.6%
if 2.6e78 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
Final simplification89.8%
(FPCore (re im)
:precision binary64
(if (<= im 480.0)
(* (cos re) (- im))
(if (or (<= im 7.2e+202) (not (<= im 8.2e+215)))
(* 0.5 (log1p (expm1 (* im -2.0))))
(* im (+ -1.0 (* 0.5 (pow re 2.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 480.0) {
tmp = cos(re) * -im;
} else if ((im <= 7.2e+202) || !(im <= 8.2e+215)) {
tmp = 0.5 * log1p(expm1((im * -2.0)));
} else {
tmp = im * (-1.0 + (0.5 * pow(re, 2.0)));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 480.0) {
tmp = Math.cos(re) * -im;
} else if ((im <= 7.2e+202) || !(im <= 8.2e+215)) {
tmp = 0.5 * Math.log1p(Math.expm1((im * -2.0)));
} else {
tmp = im * (-1.0 + (0.5 * Math.pow(re, 2.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 480.0: tmp = math.cos(re) * -im elif (im <= 7.2e+202) or not (im <= 8.2e+215): tmp = 0.5 * math.log1p(math.expm1((im * -2.0))) else: tmp = im * (-1.0 + (0.5 * math.pow(re, 2.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 480.0) tmp = Float64(cos(re) * Float64(-im)); elseif ((im <= 7.2e+202) || !(im <= 8.2e+215)) tmp = Float64(0.5 * log1p(expm1(Float64(im * -2.0)))); else tmp = Float64(im * Float64(-1.0 + Float64(0.5 * (re ^ 2.0)))); end return tmp end
code[re_, im_] := If[LessEqual[im, 480.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[Or[LessEqual[im, 7.2e+202], N[Not[LessEqual[im, 8.2e+215]], $MachinePrecision]], N[(0.5 * N[Log[1 + N[(Exp[N[(im * -2.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(im * N[(-1.0 + N[(0.5 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 480:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 7.2 \cdot 10^{+202} \lor \neg \left(im \leq 8.2 \cdot 10^{+215}\right):\\
\;\;\;\;0.5 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-1 + 0.5 \cdot {re}^{2}\right)\\
\end{array}
\end{array}
if im < 480Initial program 38.6%
/-rgt-identity38.6%
exp-038.6%
associate-*l/38.6%
cos-neg38.6%
associate-*l*38.6%
associate-*r/38.6%
exp-038.6%
/-rgt-identity38.6%
*-commutative38.6%
neg-sub038.6%
cos-neg38.6%
Simplified38.6%
Taylor expanded in im around 0 68.4%
Taylor expanded in im around 0 68.4%
associate-*r*68.4%
*-commutative68.4%
mul-1-neg68.4%
Simplified68.4%
if 480 < im < 7.20000000000000016e202 or 8.2000000000000007e215 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 6.1%
log1p-expm1-u100.0%
*-commutative100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 78.7%
expm1-define78.7%
Simplified78.7%
if 7.20000000000000016e202 < im < 8.2000000000000007e215Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 5.7%
Taylor expanded in re around 0 53.0%
*-commutative53.0%
*-commutative53.0%
associate-*l*53.0%
distribute-lft-out53.0%
Simplified53.0%
Final simplification71.2%
(FPCore (re im)
:precision binary64
(if (<= im 430.0)
(* 0.5 (* (cos re) (* im (- (* -0.3333333333333333 (pow im 2.0)) 2.0))))
(if (<= im 2.6e+78)
(* 0.5 (log1p (expm1 (* im -2.0))))
(* 0.5 (* (cos re) (* -0.0003968253968253968 (pow im 7.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 430.0) {
tmp = 0.5 * (cos(re) * (im * ((-0.3333333333333333 * pow(im, 2.0)) - 2.0)));
} else if (im <= 2.6e+78) {
tmp = 0.5 * log1p(expm1((im * -2.0)));
} else {
tmp = 0.5 * (cos(re) * (-0.0003968253968253968 * pow(im, 7.0)));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 430.0) {
tmp = 0.5 * (Math.cos(re) * (im * ((-0.3333333333333333 * Math.pow(im, 2.0)) - 2.0)));
} else if (im <= 2.6e+78) {
tmp = 0.5 * Math.log1p(Math.expm1((im * -2.0)));
} else {
tmp = 0.5 * (Math.cos(re) * (-0.0003968253968253968 * Math.pow(im, 7.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 430.0: tmp = 0.5 * (math.cos(re) * (im * ((-0.3333333333333333 * math.pow(im, 2.0)) - 2.0))) elif im <= 2.6e+78: tmp = 0.5 * math.log1p(math.expm1((im * -2.0))) else: tmp = 0.5 * (math.cos(re) * (-0.0003968253968253968 * math.pow(im, 7.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 430.0) tmp = Float64(0.5 * Float64(cos(re) * Float64(im * Float64(Float64(-0.3333333333333333 * (im ^ 2.0)) - 2.0)))); elseif (im <= 2.6e+78) tmp = Float64(0.5 * log1p(expm1(Float64(im * -2.0)))); else tmp = Float64(0.5 * Float64(cos(re) * Float64(-0.0003968253968253968 * (im ^ 7.0)))); end return tmp end
code[re_, im_] := If[LessEqual[im, 430.0], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(im * N[(N[(-0.3333333333333333 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.6e+78], N[(0.5 * N[Log[1 + N[(Exp[N[(im * -2.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(-0.0003968253968253968 * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 430:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(im \cdot \left(-0.3333333333333333 \cdot {im}^{2} - 2\right)\right)\right)\\
\mathbf{elif}\;im \leq 2.6 \cdot 10^{+78}:\\
\;\;\;\;0.5 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(-0.0003968253968253968 \cdot {im}^{7}\right)\right)\\
\end{array}
\end{array}
if im < 430Initial program 38.6%
/-rgt-identity38.6%
exp-038.6%
associate-*l/38.6%
cos-neg38.6%
associate-*l*38.6%
associate-*r/38.6%
exp-038.6%
/-rgt-identity38.6%
*-commutative38.6%
neg-sub038.6%
cos-neg38.6%
Simplified38.6%
Taylor expanded in im around 0 87.5%
if 430 < im < 2.6e78Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 3.4%
log1p-expm1-u100.0%
*-commutative100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 84.6%
expm1-define84.6%
Simplified84.6%
if 2.6e78 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification89.8%
(FPCore (re im)
:precision binary64
(if (<= im 450.0)
(* (cos re) (- im))
(if (<= im 2.6e+78)
(* 0.5 (log1p (expm1 (* im -2.0))))
(* 0.5 (* (cos re) (* -0.0003968253968253968 (pow im 7.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 450.0) {
tmp = cos(re) * -im;
} else if (im <= 2.6e+78) {
tmp = 0.5 * log1p(expm1((im * -2.0)));
} else {
tmp = 0.5 * (cos(re) * (-0.0003968253968253968 * pow(im, 7.0)));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 450.0) {
tmp = Math.cos(re) * -im;
} else if (im <= 2.6e+78) {
tmp = 0.5 * Math.log1p(Math.expm1((im * -2.0)));
} else {
tmp = 0.5 * (Math.cos(re) * (-0.0003968253968253968 * Math.pow(im, 7.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 450.0: tmp = math.cos(re) * -im elif im <= 2.6e+78: tmp = 0.5 * math.log1p(math.expm1((im * -2.0))) else: tmp = 0.5 * (math.cos(re) * (-0.0003968253968253968 * math.pow(im, 7.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 450.0) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 2.6e+78) tmp = Float64(0.5 * log1p(expm1(Float64(im * -2.0)))); else tmp = Float64(0.5 * Float64(cos(re) * Float64(-0.0003968253968253968 * (im ^ 7.0)))); end return tmp end
code[re_, im_] := If[LessEqual[im, 450.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 2.6e+78], N[(0.5 * N[Log[1 + N[(Exp[N[(im * -2.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(-0.0003968253968253968 * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 450:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 2.6 \cdot 10^{+78}:\\
\;\;\;\;0.5 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(-0.0003968253968253968 \cdot {im}^{7}\right)\right)\\
\end{array}
\end{array}
if im < 450Initial program 38.6%
/-rgt-identity38.6%
exp-038.6%
associate-*l/38.6%
cos-neg38.6%
associate-*l*38.6%
associate-*r/38.6%
exp-038.6%
/-rgt-identity38.6%
*-commutative38.6%
neg-sub038.6%
cos-neg38.6%
Simplified38.6%
Taylor expanded in im around 0 68.4%
Taylor expanded in im around 0 68.4%
associate-*r*68.4%
*-commutative68.4%
mul-1-neg68.4%
Simplified68.4%
if 450 < im < 2.6e78Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 3.4%
log1p-expm1-u100.0%
*-commutative100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 84.6%
expm1-define84.6%
Simplified84.6%
if 2.6e78 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification76.6%
(FPCore (re im)
:precision binary64
(if (<= im 42000.0)
(* (cos re) (- im))
(if (<= im 7.2e+24)
(* 0.5 (* im (* -0.08333333333333333 (pow re 4.0))))
(if (or (<= im 7.2e+202) (not (<= im 8.2e+215)))
(* 0.5 (* im (- (* -0.0003968253968253968 (pow im 6.0)) 2.0)))
(* im (+ -1.0 (* 0.5 (pow re 2.0))))))))
double code(double re, double im) {
double tmp;
if (im <= 42000.0) {
tmp = cos(re) * -im;
} else if (im <= 7.2e+24) {
tmp = 0.5 * (im * (-0.08333333333333333 * pow(re, 4.0)));
} else if ((im <= 7.2e+202) || !(im <= 8.2e+215)) {
tmp = 0.5 * (im * ((-0.0003968253968253968 * pow(im, 6.0)) - 2.0));
} else {
tmp = im * (-1.0 + (0.5 * 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 <= 42000.0d0) then
tmp = cos(re) * -im
else if (im <= 7.2d+24) then
tmp = 0.5d0 * (im * ((-0.08333333333333333d0) * (re ** 4.0d0)))
else if ((im <= 7.2d+202) .or. (.not. (im <= 8.2d+215))) then
tmp = 0.5d0 * (im * (((-0.0003968253968253968d0) * (im ** 6.0d0)) - 2.0d0))
else
tmp = im * ((-1.0d0) + (0.5d0 * (re ** 2.0d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 42000.0) {
tmp = Math.cos(re) * -im;
} else if (im <= 7.2e+24) {
tmp = 0.5 * (im * (-0.08333333333333333 * Math.pow(re, 4.0)));
} else if ((im <= 7.2e+202) || !(im <= 8.2e+215)) {
tmp = 0.5 * (im * ((-0.0003968253968253968 * Math.pow(im, 6.0)) - 2.0));
} else {
tmp = im * (-1.0 + (0.5 * Math.pow(re, 2.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 42000.0: tmp = math.cos(re) * -im elif im <= 7.2e+24: tmp = 0.5 * (im * (-0.08333333333333333 * math.pow(re, 4.0))) elif (im <= 7.2e+202) or not (im <= 8.2e+215): tmp = 0.5 * (im * ((-0.0003968253968253968 * math.pow(im, 6.0)) - 2.0)) else: tmp = im * (-1.0 + (0.5 * math.pow(re, 2.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 42000.0) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 7.2e+24) tmp = Float64(0.5 * Float64(im * Float64(-0.08333333333333333 * (re ^ 4.0)))); elseif ((im <= 7.2e+202) || !(im <= 8.2e+215)) tmp = Float64(0.5 * Float64(im * Float64(Float64(-0.0003968253968253968 * (im ^ 6.0)) - 2.0))); else tmp = Float64(im * Float64(-1.0 + Float64(0.5 * (re ^ 2.0)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 42000.0) tmp = cos(re) * -im; elseif (im <= 7.2e+24) tmp = 0.5 * (im * (-0.08333333333333333 * (re ^ 4.0))); elseif ((im <= 7.2e+202) || ~((im <= 8.2e+215))) tmp = 0.5 * (im * ((-0.0003968253968253968 * (im ^ 6.0)) - 2.0)); else tmp = im * (-1.0 + (0.5 * (re ^ 2.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 42000.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 7.2e+24], N[(0.5 * N[(im * N[(-0.08333333333333333 * N[Power[re, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, 7.2e+202], N[Not[LessEqual[im, 8.2e+215]], $MachinePrecision]], N[(0.5 * N[(im * N[(N[(-0.0003968253968253968 * N[Power[im, 6.0], $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(-1.0 + N[(0.5 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 42000:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 7.2 \cdot 10^{+24}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(-0.08333333333333333 \cdot {re}^{4}\right)\right)\\
\mathbf{elif}\;im \leq 7.2 \cdot 10^{+202} \lor \neg \left(im \leq 8.2 \cdot 10^{+215}\right):\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(-0.0003968253968253968 \cdot {im}^{6} - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-1 + 0.5 \cdot {re}^{2}\right)\\
\end{array}
\end{array}
if im < 42000Initial program 39.0%
/-rgt-identity39.0%
exp-039.0%
associate-*l/39.0%
cos-neg39.0%
associate-*l*39.0%
associate-*r/39.0%
exp-039.0%
/-rgt-identity39.0%
*-commutative39.0%
neg-sub039.0%
cos-neg39.0%
Simplified39.0%
Taylor expanded in im around 0 68.0%
Taylor expanded in im around 0 68.0%
associate-*r*68.0%
*-commutative68.0%
mul-1-neg68.0%
Simplified68.0%
if 42000 < im < 7.19999999999999966e24Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 3.2%
Taylor expanded in re around 0 45.5%
*-commutative45.5%
distribute-rgt-in23.3%
associate-+r+23.3%
distribute-lft-out23.3%
associate-*r*23.3%
associate-*l*23.3%
*-commutative23.3%
pow-sqr23.3%
metadata-eval23.3%
Simplified23.3%
Taylor expanded in re around inf 45.0%
associate-*r*45.0%
*-commutative45.0%
associate-*r*45.0%
Simplified45.0%
if 7.19999999999999966e24 < im < 7.20000000000000016e202 or 8.2000000000000007e215 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 89.8%
Taylor expanded in im around inf 89.8%
Taylor expanded in re around 0 71.2%
if 7.20000000000000016e202 < im < 8.2000000000000007e215Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 5.7%
Taylor expanded in re around 0 53.0%
*-commutative53.0%
*-commutative53.0%
associate-*l*53.0%
distribute-lft-out53.0%
Simplified53.0%
Final simplification67.8%
(FPCore (re im)
:precision binary64
(if (<= im 42000.0)
(* (cos re) (- im))
(if (<= im 8.6e+106)
(* 0.5 (* im (* -0.08333333333333333 (pow re 4.0))))
(if (or (<= im 7.2e+202) (not (<= im 8.2e+215)))
(* 0.5 (* -0.3333333333333333 (pow im 3.0)))
(* im (+ -1.0 (* 0.5 (pow re 2.0))))))))
double code(double re, double im) {
double tmp;
if (im <= 42000.0) {
tmp = cos(re) * -im;
} else if (im <= 8.6e+106) {
tmp = 0.5 * (im * (-0.08333333333333333 * pow(re, 4.0)));
} else if ((im <= 7.2e+202) || !(im <= 8.2e+215)) {
tmp = 0.5 * (-0.3333333333333333 * pow(im, 3.0));
} else {
tmp = im * (-1.0 + (0.5 * 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 <= 42000.0d0) then
tmp = cos(re) * -im
else if (im <= 8.6d+106) then
tmp = 0.5d0 * (im * ((-0.08333333333333333d0) * (re ** 4.0d0)))
else if ((im <= 7.2d+202) .or. (.not. (im <= 8.2d+215))) then
tmp = 0.5d0 * ((-0.3333333333333333d0) * (im ** 3.0d0))
else
tmp = im * ((-1.0d0) + (0.5d0 * (re ** 2.0d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 42000.0) {
tmp = Math.cos(re) * -im;
} else if (im <= 8.6e+106) {
tmp = 0.5 * (im * (-0.08333333333333333 * Math.pow(re, 4.0)));
} else if ((im <= 7.2e+202) || !(im <= 8.2e+215)) {
tmp = 0.5 * (-0.3333333333333333 * Math.pow(im, 3.0));
} else {
tmp = im * (-1.0 + (0.5 * Math.pow(re, 2.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 42000.0: tmp = math.cos(re) * -im elif im <= 8.6e+106: tmp = 0.5 * (im * (-0.08333333333333333 * math.pow(re, 4.0))) elif (im <= 7.2e+202) or not (im <= 8.2e+215): tmp = 0.5 * (-0.3333333333333333 * math.pow(im, 3.0)) else: tmp = im * (-1.0 + (0.5 * math.pow(re, 2.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 42000.0) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 8.6e+106) tmp = Float64(0.5 * Float64(im * Float64(-0.08333333333333333 * (re ^ 4.0)))); elseif ((im <= 7.2e+202) || !(im <= 8.2e+215)) tmp = Float64(0.5 * Float64(-0.3333333333333333 * (im ^ 3.0))); else tmp = Float64(im * Float64(-1.0 + Float64(0.5 * (re ^ 2.0)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 42000.0) tmp = cos(re) * -im; elseif (im <= 8.6e+106) tmp = 0.5 * (im * (-0.08333333333333333 * (re ^ 4.0))); elseif ((im <= 7.2e+202) || ~((im <= 8.2e+215))) tmp = 0.5 * (-0.3333333333333333 * (im ^ 3.0)); else tmp = im * (-1.0 + (0.5 * (re ^ 2.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 42000.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 8.6e+106], N[(0.5 * N[(im * N[(-0.08333333333333333 * N[Power[re, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, 7.2e+202], N[Not[LessEqual[im, 8.2e+215]], $MachinePrecision]], N[(0.5 * N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(-1.0 + N[(0.5 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 42000:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 8.6 \cdot 10^{+106}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(-0.08333333333333333 \cdot {re}^{4}\right)\right)\\
\mathbf{elif}\;im \leq 7.2 \cdot 10^{+202} \lor \neg \left(im \leq 8.2 \cdot 10^{+215}\right):\\
\;\;\;\;0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-1 + 0.5 \cdot {re}^{2}\right)\\
\end{array}
\end{array}
if im < 42000Initial program 39.0%
/-rgt-identity39.0%
exp-039.0%
associate-*l/39.0%
cos-neg39.0%
associate-*l*39.0%
associate-*r/39.0%
exp-039.0%
/-rgt-identity39.0%
*-commutative39.0%
neg-sub039.0%
cos-neg39.0%
Simplified39.0%
Taylor expanded in im around 0 68.0%
Taylor expanded in im around 0 68.0%
associate-*r*68.0%
*-commutative68.0%
mul-1-neg68.0%
Simplified68.0%
if 42000 < im < 8.5999999999999999e106Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 3.5%
Taylor expanded in re around 0 21.7%
*-commutative21.7%
distribute-rgt-in8.8%
associate-+r+8.8%
distribute-lft-out8.8%
associate-*r*8.8%
associate-*l*8.8%
*-commutative8.8%
pow-sqr8.8%
metadata-eval8.8%
Simplified8.8%
Taylor expanded in re around inf 20.8%
associate-*r*20.8%
*-commutative20.8%
associate-*r*20.8%
Simplified20.8%
if 8.5999999999999999e106 < im < 7.20000000000000016e202 or 8.2000000000000007e215 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 76.7%
Taylor expanded in im around inf 76.7%
if 7.20000000000000016e202 < im < 8.2000000000000007e215Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 5.7%
Taylor expanded in re around 0 53.0%
*-commutative53.0%
*-commutative53.0%
associate-*l*53.0%
distribute-lft-out53.0%
Simplified53.0%
Final simplification63.5%
(FPCore (re im)
:precision binary64
(if (<= im 42000.0)
(* (cos re) (- im))
(if (<= im 8.6e+106)
(* 0.5 (* im (* -0.08333333333333333 (pow re 4.0))))
(if (<= im 1.1e+202)
(* 0.5 (* im (- (* -0.3333333333333333 (pow im 2.0)) 2.0)))
(if (<= im 8.2e+215)
(* im (+ -1.0 (* 0.5 (pow re 2.0))))
(* 0.5 (* -0.3333333333333333 (pow im 3.0))))))))
double code(double re, double im) {
double tmp;
if (im <= 42000.0) {
tmp = cos(re) * -im;
} else if (im <= 8.6e+106) {
tmp = 0.5 * (im * (-0.08333333333333333 * pow(re, 4.0)));
} else if (im <= 1.1e+202) {
tmp = 0.5 * (im * ((-0.3333333333333333 * pow(im, 2.0)) - 2.0));
} else if (im <= 8.2e+215) {
tmp = im * (-1.0 + (0.5 * 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 <= 42000.0d0) then
tmp = cos(re) * -im
else if (im <= 8.6d+106) then
tmp = 0.5d0 * (im * ((-0.08333333333333333d0) * (re ** 4.0d0)))
else if (im <= 1.1d+202) then
tmp = 0.5d0 * (im * (((-0.3333333333333333d0) * (im ** 2.0d0)) - 2.0d0))
else if (im <= 8.2d+215) then
tmp = im * ((-1.0d0) + (0.5d0 * (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 <= 42000.0) {
tmp = Math.cos(re) * -im;
} else if (im <= 8.6e+106) {
tmp = 0.5 * (im * (-0.08333333333333333 * Math.pow(re, 4.0)));
} else if (im <= 1.1e+202) {
tmp = 0.5 * (im * ((-0.3333333333333333 * Math.pow(im, 2.0)) - 2.0));
} else if (im <= 8.2e+215) {
tmp = im * (-1.0 + (0.5 * 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 <= 42000.0: tmp = math.cos(re) * -im elif im <= 8.6e+106: tmp = 0.5 * (im * (-0.08333333333333333 * math.pow(re, 4.0))) elif im <= 1.1e+202: tmp = 0.5 * (im * ((-0.3333333333333333 * math.pow(im, 2.0)) - 2.0)) elif im <= 8.2e+215: tmp = im * (-1.0 + (0.5 * 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 <= 42000.0) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 8.6e+106) tmp = Float64(0.5 * Float64(im * Float64(-0.08333333333333333 * (re ^ 4.0)))); elseif (im <= 1.1e+202) tmp = Float64(0.5 * Float64(im * Float64(Float64(-0.3333333333333333 * (im ^ 2.0)) - 2.0))); elseif (im <= 8.2e+215) tmp = Float64(im * Float64(-1.0 + Float64(0.5 * (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 <= 42000.0) tmp = cos(re) * -im; elseif (im <= 8.6e+106) tmp = 0.5 * (im * (-0.08333333333333333 * (re ^ 4.0))); elseif (im <= 1.1e+202) tmp = 0.5 * (im * ((-0.3333333333333333 * (im ^ 2.0)) - 2.0)); elseif (im <= 8.2e+215) tmp = im * (-1.0 + (0.5 * (re ^ 2.0))); else tmp = 0.5 * (-0.3333333333333333 * (im ^ 3.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 42000.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 8.6e+106], N[(0.5 * N[(im * N[(-0.08333333333333333 * N[Power[re, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.1e+202], N[(0.5 * N[(im * N[(N[(-0.3333333333333333 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 8.2e+215], N[(im * N[(-1.0 + N[(0.5 * 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 42000:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 8.6 \cdot 10^{+106}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(-0.08333333333333333 \cdot {re}^{4}\right)\right)\\
\mathbf{elif}\;im \leq 1.1 \cdot 10^{+202}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(-0.3333333333333333 \cdot {im}^{2} - 2\right)\right)\\
\mathbf{elif}\;im \leq 8.2 \cdot 10^{+215}:\\
\;\;\;\;im \cdot \left(-1 + 0.5 \cdot {re}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right)\\
\end{array}
\end{array}
if im < 42000Initial program 39.0%
/-rgt-identity39.0%
exp-039.0%
associate-*l/39.0%
cos-neg39.0%
associate-*l*39.0%
associate-*r/39.0%
exp-039.0%
/-rgt-identity39.0%
*-commutative39.0%
neg-sub039.0%
cos-neg39.0%
Simplified39.0%
Taylor expanded in im around 0 68.0%
Taylor expanded in im around 0 68.0%
associate-*r*68.0%
*-commutative68.0%
mul-1-neg68.0%
Simplified68.0%
if 42000 < im < 8.5999999999999999e106Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 3.5%
Taylor expanded in re around 0 21.7%
*-commutative21.7%
distribute-rgt-in8.8%
associate-+r+8.8%
distribute-lft-out8.8%
associate-*r*8.8%
associate-*l*8.8%
*-commutative8.8%
pow-sqr8.8%
metadata-eval8.8%
Simplified8.8%
Taylor expanded in re around inf 20.8%
associate-*r*20.8%
*-commutative20.8%
associate-*r*20.8%
Simplified20.8%
if 8.5999999999999999e106 < im < 1.09999999999999989e202Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 75.0%
if 1.09999999999999989e202 < im < 8.2000000000000007e215Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 5.7%
Taylor expanded in re around 0 53.0%
*-commutative53.0%
*-commutative53.0%
associate-*l*53.0%
distribute-lft-out53.0%
Simplified53.0%
if 8.2000000000000007e215 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 78.9%
Taylor expanded in im around inf 78.9%
Final simplification63.5%
(FPCore (re im)
:precision binary64
(if (<= im 42000.0)
(* (cos re) (- im))
(if (<= im 8.6e+106)
(* 0.5 (* im (* -0.08333333333333333 (pow re 4.0))))
(if (or (<= im 7.2e+202) (not (<= im 1.25e+216)))
(* 0.5 (* -0.3333333333333333 (pow im 3.0)))
(* 0.5 (* im (fma re re -2.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 42000.0) {
tmp = cos(re) * -im;
} else if (im <= 8.6e+106) {
tmp = 0.5 * (im * (-0.08333333333333333 * pow(re, 4.0)));
} else if ((im <= 7.2e+202) || !(im <= 1.25e+216)) {
tmp = 0.5 * (-0.3333333333333333 * pow(im, 3.0));
} else {
tmp = 0.5 * (im * fma(re, re, -2.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 42000.0) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 8.6e+106) tmp = Float64(0.5 * Float64(im * Float64(-0.08333333333333333 * (re ^ 4.0)))); elseif ((im <= 7.2e+202) || !(im <= 1.25e+216)) tmp = Float64(0.5 * Float64(-0.3333333333333333 * (im ^ 3.0))); else tmp = Float64(0.5 * Float64(im * fma(re, re, -2.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 42000.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 8.6e+106], N[(0.5 * N[(im * N[(-0.08333333333333333 * N[Power[re, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, 7.2e+202], N[Not[LessEqual[im, 1.25e+216]], $MachinePrecision]], N[(0.5 * N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[(re * re + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 42000:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 8.6 \cdot 10^{+106}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(-0.08333333333333333 \cdot {re}^{4}\right)\right)\\
\mathbf{elif}\;im \leq 7.2 \cdot 10^{+202} \lor \neg \left(im \leq 1.25 \cdot 10^{+216}\right):\\
\;\;\;\;0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \mathsf{fma}\left(re, re, -2\right)\right)\\
\end{array}
\end{array}
if im < 42000Initial program 39.0%
/-rgt-identity39.0%
exp-039.0%
associate-*l/39.0%
cos-neg39.0%
associate-*l*39.0%
associate-*r/39.0%
exp-039.0%
/-rgt-identity39.0%
*-commutative39.0%
neg-sub039.0%
cos-neg39.0%
Simplified39.0%
Taylor expanded in im around 0 68.0%
Taylor expanded in im around 0 68.0%
associate-*r*68.0%
*-commutative68.0%
mul-1-neg68.0%
Simplified68.0%
if 42000 < im < 8.5999999999999999e106Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 3.5%
Taylor expanded in re around 0 21.7%
*-commutative21.7%
distribute-rgt-in8.8%
associate-+r+8.8%
distribute-lft-out8.8%
associate-*r*8.8%
associate-*l*8.8%
*-commutative8.8%
pow-sqr8.8%
metadata-eval8.8%
Simplified8.8%
Taylor expanded in re around inf 20.8%
associate-*r*20.8%
*-commutative20.8%
associate-*r*20.8%
Simplified20.8%
if 8.5999999999999999e106 < im < 7.20000000000000016e202 or 1.24999999999999995e216 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 76.7%
Taylor expanded in im around inf 76.7%
if 7.20000000000000016e202 < im < 1.24999999999999995e216Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 5.7%
log1p-expm1-u100.0%
*-commutative100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 53.0%
+-commutative53.0%
*-commutative53.0%
distribute-lft-out53.0%
unpow253.0%
fma-undefine53.0%
Simplified53.0%
Final simplification63.5%
(FPCore (re im)
:precision binary64
(if (<= im 390.0)
(* (cos re) (- im))
(if (or (<= im 9e+97) (and (not (<= im 7.2e+202)) (<= im 8.2e+215)))
(* 0.5 (* im (fma re re -2.0)))
(* 0.5 (* -0.3333333333333333 (pow im 3.0))))))
double code(double re, double im) {
double tmp;
if (im <= 390.0) {
tmp = cos(re) * -im;
} else if ((im <= 9e+97) || (!(im <= 7.2e+202) && (im <= 8.2e+215))) {
tmp = 0.5 * (im * fma(re, re, -2.0));
} else {
tmp = 0.5 * (-0.3333333333333333 * pow(im, 3.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 390.0) tmp = Float64(cos(re) * Float64(-im)); elseif ((im <= 9e+97) || (!(im <= 7.2e+202) && (im <= 8.2e+215))) tmp = Float64(0.5 * Float64(im * fma(re, re, -2.0))); else tmp = Float64(0.5 * Float64(-0.3333333333333333 * (im ^ 3.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 390.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[Or[LessEqual[im, 9e+97], And[N[Not[LessEqual[im, 7.2e+202]], $MachinePrecision], LessEqual[im, 8.2e+215]]], N[(0.5 * N[(im * N[(re * re + -2.0), $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 390:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 9 \cdot 10^{+97} \lor \neg \left(im \leq 7.2 \cdot 10^{+202}\right) \land im \leq 8.2 \cdot 10^{+215}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \mathsf{fma}\left(re, re, -2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right)\\
\end{array}
\end{array}
if im < 390Initial program 38.3%
/-rgt-identity38.3%
exp-038.3%
associate-*l/38.3%
cos-neg38.3%
associate-*l*38.3%
associate-*r/38.3%
exp-038.3%
/-rgt-identity38.3%
*-commutative38.3%
neg-sub038.3%
cos-neg38.3%
Simplified38.3%
Taylor expanded in im around 0 68.7%
Taylor expanded in im around 0 68.7%
associate-*r*68.7%
*-commutative68.7%
mul-1-neg68.7%
Simplified68.7%
if 390 < im < 8.99999999999999952e97 or 7.20000000000000016e202 < im < 8.2000000000000007e215Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 3.8%
log1p-expm1-u97.4%
*-commutative97.4%
*-commutative97.4%
Applied egg-rr97.4%
Taylor expanded in re around 0 18.8%
+-commutative18.8%
*-commutative18.8%
distribute-lft-out18.8%
unpow218.8%
fma-undefine18.8%
Simplified18.8%
if 8.99999999999999952e97 < im < 7.20000000000000016e202 or 8.2000000000000007e215 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 76.7%
Taylor expanded in im around inf 76.7%
Final simplification62.9%
(FPCore (re im)
:precision binary64
(if (<= im 2350.0)
(* (cos re) (- im))
(if (or (<= im 9e+97) (and (not (<= im 7.2e+202)) (<= im 8.2e+215)))
(* 0.5 (* im (pow re 2.0)))
(* 0.5 (* -0.3333333333333333 (pow im 3.0))))))
double code(double re, double im) {
double tmp;
if (im <= 2350.0) {
tmp = cos(re) * -im;
} else if ((im <= 9e+97) || (!(im <= 7.2e+202) && (im <= 8.2e+215))) {
tmp = 0.5 * (im * 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 <= 2350.0d0) then
tmp = cos(re) * -im
else if ((im <= 9d+97) .or. (.not. (im <= 7.2d+202)) .and. (im <= 8.2d+215)) then
tmp = 0.5d0 * (im * (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 <= 2350.0) {
tmp = Math.cos(re) * -im;
} else if ((im <= 9e+97) || (!(im <= 7.2e+202) && (im <= 8.2e+215))) {
tmp = 0.5 * (im * 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 <= 2350.0: tmp = math.cos(re) * -im elif (im <= 9e+97) or (not (im <= 7.2e+202) and (im <= 8.2e+215)): tmp = 0.5 * (im * 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 <= 2350.0) tmp = Float64(cos(re) * Float64(-im)); elseif ((im <= 9e+97) || (!(im <= 7.2e+202) && (im <= 8.2e+215))) tmp = Float64(0.5 * Float64(im * (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 <= 2350.0) tmp = cos(re) * -im; elseif ((im <= 9e+97) || (~((im <= 7.2e+202)) && (im <= 8.2e+215))) tmp = 0.5 * (im * (re ^ 2.0)); else tmp = 0.5 * (-0.3333333333333333 * (im ^ 3.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2350.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[Or[LessEqual[im, 9e+97], And[N[Not[LessEqual[im, 7.2e+202]], $MachinePrecision], LessEqual[im, 8.2e+215]]], N[(0.5 * N[(im * N[Power[re, 2.0], $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 2350:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 9 \cdot 10^{+97} \lor \neg \left(im \leq 7.2 \cdot 10^{+202}\right) \land im \leq 8.2 \cdot 10^{+215}:\\
\;\;\;\;0.5 \cdot \left(im \cdot {re}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right)\\
\end{array}
\end{array}
if im < 2350Initial program 39.0%
/-rgt-identity39.0%
exp-039.0%
associate-*l/39.0%
cos-neg39.0%
associate-*l*39.0%
associate-*r/39.0%
exp-039.0%
/-rgt-identity39.0%
*-commutative39.0%
neg-sub039.0%
cos-neg39.0%
Simplified39.0%
Taylor expanded in im around 0 68.0%
Taylor expanded in im around 0 68.0%
associate-*r*68.0%
*-commutative68.0%
mul-1-neg68.0%
Simplified68.0%
if 2350 < im < 8.99999999999999952e97 or 7.20000000000000016e202 < im < 8.2000000000000007e215Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 3.8%
log1p-expm1-u100.0%
*-commutative100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 19.6%
+-commutative19.6%
*-commutative19.6%
distribute-lft-out19.6%
unpow219.6%
fma-undefine19.6%
Simplified19.6%
Taylor expanded in re around inf 18.3%
if 8.99999999999999952e97 < im < 7.20000000000000016e202 or 8.2000000000000007e215 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 76.7%
Taylor expanded in im around inf 76.7%
Final simplification62.7%
(FPCore (re im) :precision binary64 (if (<= im 3.1e+37) (* (cos re) (- im)) (* 0.5 (* -0.3333333333333333 (pow im 3.0)))))
double code(double re, double im) {
double tmp;
if (im <= 3.1e+37) {
tmp = cos(re) * -im;
} 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 <= 3.1d+37) then
tmp = cos(re) * -im
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 <= 3.1e+37) {
tmp = Math.cos(re) * -im;
} else {
tmp = 0.5 * (-0.3333333333333333 * Math.pow(im, 3.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3.1e+37: tmp = math.cos(re) * -im else: tmp = 0.5 * (-0.3333333333333333 * math.pow(im, 3.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 3.1e+37) tmp = Float64(cos(re) * Float64(-im)); 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 <= 3.1e+37) tmp = cos(re) * -im; else tmp = 0.5 * (-0.3333333333333333 * (im ^ 3.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3.1e+37], N[(N[Cos[re], $MachinePrecision] * (-im)), $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 3.1 \cdot 10^{+37}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right)\\
\end{array}
\end{array}
if im < 3.1000000000000002e37Initial program 44.0%
/-rgt-identity44.0%
exp-044.0%
associate-*l/44.0%
cos-neg44.0%
associate-*l*44.0%
associate-*r/44.0%
exp-044.0%
/-rgt-identity44.0%
*-commutative44.0%
neg-sub044.0%
cos-neg44.0%
Simplified44.0%
Taylor expanded in im around 0 62.7%
Taylor expanded in im around 0 62.7%
associate-*r*62.7%
*-commutative62.7%
mul-1-neg62.7%
Simplified62.7%
if 3.1000000000000002e37 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 77.4%
Taylor expanded in re around 0 56.2%
Taylor expanded in im around inf 56.2%
(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 55.2%
/-rgt-identity55.2%
exp-055.2%
associate-*l/55.2%
cos-neg55.2%
associate-*l*55.2%
associate-*r/55.2%
exp-055.2%
/-rgt-identity55.2%
*-commutative55.2%
neg-sub055.2%
cos-neg55.2%
Simplified55.2%
Taylor expanded in im around 0 52.7%
add-cbrt-cube57.1%
pow357.1%
associate-*r*57.1%
*-commutative57.1%
associate-*r*57.1%
metadata-eval57.1%
Applied egg-rr57.1%
rem-cbrt-cube51.5%
add-sqr-sqrt27.0%
sqrt-unprod30.1%
mul-1-neg30.1%
mul-1-neg30.1%
sqr-neg30.1%
sqrt-unprod0.8%
add-sqr-sqrt1.9%
Applied egg-rr1.9%
Taylor expanded in re around 0 13.9%
if -1.9999999999999e-311 < (cos.f64 re) Initial program 58.4%
/-rgt-identity58.4%
exp-058.4%
associate-*l/58.4%
cos-neg58.4%
associate-*l*58.4%
associate-*r/58.4%
exp-058.4%
/-rgt-identity58.4%
*-commutative58.4%
neg-sub058.4%
cos-neg58.4%
Simplified58.4%
Taylor expanded in im around 0 47.9%
Taylor expanded in re around 0 36.3%
mul-1-neg36.3%
Simplified36.3%
(FPCore (re im) :precision binary64 (* (cos re) (- im)))
double code(double re, double im) {
return cos(re) * -im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = cos(re) * -im
end function
public static double code(double re, double im) {
return Math.cos(re) * -im;
}
def code(re, im): return math.cos(re) * -im
function code(re, im) return Float64(cos(re) * Float64(-im)) end
function tmp = code(re, im) tmp = cos(re) * -im; end
code[re_, im_] := N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision]
\begin{array}{l}
\\
\cos re \cdot \left(-im\right)
\end{array}
Initial program 57.6%
/-rgt-identity57.6%
exp-057.6%
associate-*l/57.6%
cos-neg57.6%
associate-*l*57.6%
associate-*r/57.6%
exp-057.6%
/-rgt-identity57.6%
*-commutative57.6%
neg-sub057.6%
cos-neg57.6%
Simplified57.6%
Taylor expanded in im around 0 49.2%
Taylor expanded in im around 0 48.9%
associate-*r*48.9%
*-commutative48.9%
mul-1-neg48.9%
Simplified48.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 57.6%
/-rgt-identity57.6%
exp-057.6%
associate-*l/57.6%
cos-neg57.6%
associate-*l*57.6%
associate-*r/57.6%
exp-057.6%
/-rgt-identity57.6%
*-commutative57.6%
neg-sub057.6%
cos-neg57.6%
Simplified57.6%
Taylor expanded in im around 0 49.2%
add-cbrt-cube51.0%
pow351.0%
associate-*r*51.0%
*-commutative51.0%
associate-*r*51.0%
metadata-eval51.0%
Applied egg-rr51.0%
rem-cbrt-cube48.9%
add-sqr-sqrt28.3%
sqrt-unprod26.1%
mul-1-neg26.1%
mul-1-neg26.1%
sqr-neg26.1%
sqrt-unprod0.8%
add-sqr-sqrt1.9%
Applied egg-rr1.9%
Taylor expanded in re around 0 5.0%
(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 2024103
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
:alt
(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))))