
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (or (<= t_0 -400.0) (not (<= t_0 0.2)))
(* (* (cos re) 0.5) t_0)
(*
(cos re)
(+
(+
(* (pow im 7.0) -0.0001984126984126984)
(* (pow im 5.0) -0.008333333333333333))
(- (* (pow im 3.0) -0.16666666666666666) im))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -400.0) || !(t_0 <= 0.2)) {
tmp = (cos(re) * 0.5) * t_0;
} else {
tmp = cos(re) * (((pow(im, 7.0) * -0.0001984126984126984) + (pow(im, 5.0) * -0.008333333333333333)) + ((pow(im, 3.0) * -0.16666666666666666) - im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-im) - exp(im)
if ((t_0 <= (-400.0d0)) .or. (.not. (t_0 <= 0.2d0))) then
tmp = (cos(re) * 0.5d0) * t_0
else
tmp = cos(re) * ((((im ** 7.0d0) * (-0.0001984126984126984d0)) + ((im ** 5.0d0) * (-0.008333333333333333d0))) + (((im ** 3.0d0) * (-0.16666666666666666d0)) - im))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double tmp;
if ((t_0 <= -400.0) || !(t_0 <= 0.2)) {
tmp = (Math.cos(re) * 0.5) * t_0;
} else {
tmp = Math.cos(re) * (((Math.pow(im, 7.0) * -0.0001984126984126984) + (Math.pow(im, 5.0) * -0.008333333333333333)) + ((Math.pow(im, 3.0) * -0.16666666666666666) - im));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -400.0) or not (t_0 <= 0.2): tmp = (math.cos(re) * 0.5) * t_0 else: tmp = math.cos(re) * (((math.pow(im, 7.0) * -0.0001984126984126984) + (math.pow(im, 5.0) * -0.008333333333333333)) + ((math.pow(im, 3.0) * -0.16666666666666666) - im)) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= -400.0) || !(t_0 <= 0.2)) tmp = Float64(Float64(cos(re) * 0.5) * t_0); else tmp = Float64(cos(re) * Float64(Float64(Float64((im ^ 7.0) * -0.0001984126984126984) + Float64((im ^ 5.0) * -0.008333333333333333)) + Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -400.0) || ~((t_0 <= 0.2))) tmp = (cos(re) * 0.5) * t_0; else tmp = cos(re) * ((((im ^ 7.0) * -0.0001984126984126984) + ((im ^ 5.0) * -0.008333333333333333)) + (((im ^ 3.0) * -0.16666666666666666) - im)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -400.0], N[Not[LessEqual[t$95$0, 0.2]], $MachinePrecision]], N[(N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -400 \lor \neg \left(t_0 \leq 0.2\right):\\
\;\;\;\;\left(\cos re \cdot 0.5\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(\left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -400 or 0.20000000000000001 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
if -400 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 0.20000000000000001Initial program 9.5%
sub0-neg9.5%
Simplified9.5%
Taylor expanded in im around 0 99.7%
associate-+r+99.7%
+-commutative99.7%
mul-1-neg99.7%
*-commutative99.7%
distribute-lft-neg-in99.7%
*-commutative99.7%
associate-*r*99.7%
distribute-rgt-out99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
associate-*l*99.7%
distribute-lft-out99.7%
Simplified99.7%
Final simplification99.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))) (t_1 (* (cos re) 0.5)))
(if (or (<= t_0 -400.0) (not (<= t_0 0.02)))
(* t_1 t_0)
(*
t_1
(+
(* im -2.0)
(+
(* (pow im 5.0) -0.016666666666666666)
(* (pow im 3.0) -0.3333333333333333)))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double t_1 = cos(re) * 0.5;
double tmp;
if ((t_0 <= -400.0) || !(t_0 <= 0.02)) {
tmp = t_1 * t_0;
} else {
tmp = t_1 * ((im * -2.0) + ((pow(im, 5.0) * -0.016666666666666666) + (pow(im, 3.0) * -0.3333333333333333)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(-im) - exp(im)
t_1 = cos(re) * 0.5d0
if ((t_0 <= (-400.0d0)) .or. (.not. (t_0 <= 0.02d0))) then
tmp = t_1 * t_0
else
tmp = t_1 * ((im * (-2.0d0)) + (((im ** 5.0d0) * (-0.016666666666666666d0)) + ((im ** 3.0d0) * (-0.3333333333333333d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double t_1 = Math.cos(re) * 0.5;
double tmp;
if ((t_0 <= -400.0) || !(t_0 <= 0.02)) {
tmp = t_1 * t_0;
} else {
tmp = t_1 * ((im * -2.0) + ((Math.pow(im, 5.0) * -0.016666666666666666) + (Math.pow(im, 3.0) * -0.3333333333333333)));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) t_1 = math.cos(re) * 0.5 tmp = 0 if (t_0 <= -400.0) or not (t_0 <= 0.02): tmp = t_1 * t_0 else: tmp = t_1 * ((im * -2.0) + ((math.pow(im, 5.0) * -0.016666666666666666) + (math.pow(im, 3.0) * -0.3333333333333333))) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) t_1 = Float64(cos(re) * 0.5) tmp = 0.0 if ((t_0 <= -400.0) || !(t_0 <= 0.02)) tmp = Float64(t_1 * t_0); else tmp = Float64(t_1 * Float64(Float64(im * -2.0) + Float64(Float64((im ^ 5.0) * -0.016666666666666666) + Float64((im ^ 3.0) * -0.3333333333333333)))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); t_1 = cos(re) * 0.5; tmp = 0.0; if ((t_0 <= -400.0) || ~((t_0 <= 0.02))) tmp = t_1 * t_0; else tmp = t_1 * ((im * -2.0) + (((im ^ 5.0) * -0.016666666666666666) + ((im ^ 3.0) * -0.3333333333333333))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -400.0], N[Not[LessEqual[t$95$0, 0.02]], $MachinePrecision]], N[(t$95$1 * t$95$0), $MachinePrecision], N[(t$95$1 * N[(N[(im * -2.0), $MachinePrecision] + N[(N[(N[Power[im, 5.0], $MachinePrecision] * -0.016666666666666666), $MachinePrecision] + N[(N[Power[im, 3.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := \cos re \cdot 0.5\\
\mathbf{if}\;t_0 \leq -400 \lor \neg \left(t_0 \leq 0.02\right):\\
\;\;\;\;t_1 \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(im \cdot -2 + \left({im}^{5} \cdot -0.016666666666666666 + {im}^{3} \cdot -0.3333333333333333\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -400 or 0.0200000000000000004 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 99.9%
sub0-neg99.9%
Simplified99.9%
if -400 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 0.0200000000000000004Initial program 8.8%
sub0-neg8.8%
Simplified8.8%
Taylor expanded in im around 0 99.7%
Final simplification99.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (or (<= t_0 -400.0) (not (<= t_0 0.001)))
(* (* (cos re) 0.5) t_0)
(* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im)))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -400.0) || !(t_0 <= 0.001)) {
tmp = (cos(re) * 0.5) * t_0;
} else {
tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-im) - exp(im)
if ((t_0 <= (-400.0d0)) .or. (.not. (t_0 <= 0.001d0))) then
tmp = (cos(re) * 0.5d0) * t_0
else
tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double tmp;
if ((t_0 <= -400.0) || !(t_0 <= 0.001)) {
tmp = (Math.cos(re) * 0.5) * t_0;
} else {
tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -400.0) or not (t_0 <= 0.001): tmp = (math.cos(re) * 0.5) * t_0 else: tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= -400.0) || !(t_0 <= 0.001)) tmp = Float64(Float64(cos(re) * 0.5) * t_0); else tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -400.0) || ~((t_0 <= 0.001))) tmp = (cos(re) * 0.5) * t_0; else tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -400.0], N[Not[LessEqual[t$95$0, 0.001]], $MachinePrecision]], N[(N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -400 \lor \neg \left(t_0 \leq 0.001\right):\\
\;\;\;\;\left(\cos re \cdot 0.5\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -400 or 1e-3 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 99.9%
sub0-neg99.9%
Simplified99.9%
if -400 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1e-3Initial program 8.2%
sub0-neg8.2%
Simplified8.2%
Taylor expanded in im around 0 99.7%
mul-1-neg99.7%
unsub-neg99.7%
*-commutative99.7%
associate-*l*99.7%
distribute-lft-out--99.7%
Simplified99.7%
Final simplification99.8%
(FPCore (re im)
:precision binary64
(*
(cos re)
(+
(- (log (exp (* (pow im 3.0) -0.16666666666666666))) im)
(+
(* (pow im 7.0) -0.0001984126984126984)
(* (pow im 5.0) -0.008333333333333333)))))
double code(double re, double im) {
return cos(re) * ((log(exp((pow(im, 3.0) * -0.16666666666666666))) - im) + ((pow(im, 7.0) * -0.0001984126984126984) + (pow(im, 5.0) * -0.008333333333333333)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = cos(re) * ((log(exp(((im ** 3.0d0) * (-0.16666666666666666d0)))) - im) + (((im ** 7.0d0) * (-0.0001984126984126984d0)) + ((im ** 5.0d0) * (-0.008333333333333333d0))))
end function
public static double code(double re, double im) {
return Math.cos(re) * ((Math.log(Math.exp((Math.pow(im, 3.0) * -0.16666666666666666))) - im) + ((Math.pow(im, 7.0) * -0.0001984126984126984) + (Math.pow(im, 5.0) * -0.008333333333333333)));
}
def code(re, im): return math.cos(re) * ((math.log(math.exp((math.pow(im, 3.0) * -0.16666666666666666))) - im) + ((math.pow(im, 7.0) * -0.0001984126984126984) + (math.pow(im, 5.0) * -0.008333333333333333)))
function code(re, im) return Float64(cos(re) * Float64(Float64(log(exp(Float64((im ^ 3.0) * -0.16666666666666666))) - im) + Float64(Float64((im ^ 7.0) * -0.0001984126984126984) + Float64((im ^ 5.0) * -0.008333333333333333)))) end
function tmp = code(re, im) tmp = cos(re) * ((log(exp(((im ^ 3.0) * -0.16666666666666666))) - im) + (((im ^ 7.0) * -0.0001984126984126984) + ((im ^ 5.0) * -0.008333333333333333))); end
code[re_, im_] := N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Log[N[Exp[N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] - im), $MachinePrecision] + N[(N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos re \cdot \left(\left(\log \left(e^{{im}^{3} \cdot -0.16666666666666666}\right) - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\right)
\end{array}
Initial program 51.2%
sub0-neg51.2%
Simplified51.2%
Taylor expanded in im around 0 95.4%
associate-+r+95.4%
+-commutative95.4%
mul-1-neg95.4%
*-commutative95.4%
distribute-lft-neg-in95.4%
*-commutative95.4%
associate-*r*95.4%
distribute-rgt-out95.4%
*-commutative95.4%
associate-*l*95.4%
*-commutative95.4%
associate-*l*95.4%
distribute-lft-out95.4%
Simplified95.4%
log1p-expm1-u99.1%
log1p-udef98.9%
Applied egg-rr98.9%
add-exp-log98.9%
log1p-def98.9%
log1p-expm1-u99.0%
Applied egg-rr99.0%
Final simplification99.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
(t_1 (- (* (pow im 3.0) -0.16666666666666666) im))
(t_2 (* t_1 (+ (* -0.5 (* re re)) 1.0))))
(if (<= im -1e+108)
t_2
(if (<= im -0.015)
t_0
(if (<= im 0.00066)
(* (cos re) (- im))
(if (<= im 1e+105) t_0 (if (<= im 5e+172) t_2 t_1)))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(-im) - exp(im));
double t_1 = (pow(im, 3.0) * -0.16666666666666666) - im;
double t_2 = t_1 * ((-0.5 * (re * re)) + 1.0);
double tmp;
if (im <= -1e+108) {
tmp = t_2;
} else if (im <= -0.015) {
tmp = t_0;
} else if (im <= 0.00066) {
tmp = cos(re) * -im;
} else if (im <= 1e+105) {
tmp = t_0;
} else if (im <= 5e+172) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 0.5d0 * (exp(-im) - exp(im))
t_1 = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
t_2 = t_1 * (((-0.5d0) * (re * re)) + 1.0d0)
if (im <= (-1d+108)) then
tmp = t_2
else if (im <= (-0.015d0)) then
tmp = t_0
else if (im <= 0.00066d0) then
tmp = cos(re) * -im
else if (im <= 1d+105) then
tmp = t_0
else if (im <= 5d+172) then
tmp = t_2
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
double t_1 = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
double t_2 = t_1 * ((-0.5 * (re * re)) + 1.0);
double tmp;
if (im <= -1e+108) {
tmp = t_2;
} else if (im <= -0.015) {
tmp = t_0;
} else if (im <= 0.00066) {
tmp = Math.cos(re) * -im;
} else if (im <= 1e+105) {
tmp = t_0;
} else if (im <= 5e+172) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.exp(-im) - math.exp(im)) t_1 = (math.pow(im, 3.0) * -0.16666666666666666) - im t_2 = t_1 * ((-0.5 * (re * re)) + 1.0) tmp = 0 if im <= -1e+108: tmp = t_2 elif im <= -0.015: tmp = t_0 elif im <= 0.00066: tmp = math.cos(re) * -im elif im <= 1e+105: tmp = t_0 elif im <= 5e+172: tmp = t_2 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))) t_1 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) t_2 = Float64(t_1 * Float64(Float64(-0.5 * Float64(re * re)) + 1.0)) tmp = 0.0 if (im <= -1e+108) tmp = t_2; elseif (im <= -0.015) tmp = t_0; elseif (im <= 0.00066) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 1e+105) tmp = t_0; elseif (im <= 5e+172) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (exp(-im) - exp(im)); t_1 = ((im ^ 3.0) * -0.16666666666666666) - im; t_2 = t_1 * ((-0.5 * (re * re)) + 1.0); tmp = 0.0; if (im <= -1e+108) tmp = t_2; elseif (im <= -0.015) tmp = t_0; elseif (im <= 0.00066) tmp = cos(re) * -im; elseif (im <= 1e+105) tmp = t_0; elseif (im <= 5e+172) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1e+108], t$95$2, If[LessEqual[im, -0.015], t$95$0, If[LessEqual[im, 0.00066], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 1e+105], t$95$0, If[LessEqual[im, 5e+172], t$95$2, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := {im}^{3} \cdot -0.16666666666666666 - im\\
t_2 := t_1 \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\
\mathbf{if}\;im \leq -1 \cdot 10^{+108}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq -0.015:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.00066:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 10^{+105}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 5 \cdot 10^{+172}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -1e108 or 9.9999999999999994e104 < im < 5.0000000000000001e172Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in re around 0 0.0%
associate--l+0.0%
associate-*r*0.0%
distribute-lft1-in87.3%
unpow287.3%
Simplified87.3%
if -1e108 < im < -0.014999999999999999 or 6.6e-4 < im < 9.9999999999999994e104Initial program 99.8%
sub0-neg99.8%
Simplified99.8%
Taylor expanded in re around 0 81.7%
if -0.014999999999999999 < im < 6.6e-4Initial program 8.8%
sub0-neg8.8%
Simplified8.8%
Taylor expanded in im around 0 98.9%
mul-1-neg98.9%
*-commutative98.9%
distribute-lft-neg-in98.9%
Simplified98.9%
if 5.0000000000000001e172 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in re around 0 89.3%
Final simplification92.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (pow im 7.0) (* (cos re) -0.0001984126984126984))))
(if (<= im -1.1e+44)
t_0
(if (<= im -0.0285)
(* 0.5 (- (exp (- im)) (exp im)))
(if (<= im 5.5)
(* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))
t_0)))))
double code(double re, double im) {
double t_0 = pow(im, 7.0) * (cos(re) * -0.0001984126984126984);
double tmp;
if (im <= -1.1e+44) {
tmp = t_0;
} else if (im <= -0.0285) {
tmp = 0.5 * (exp(-im) - exp(im));
} else if (im <= 5.5) {
tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = (im ** 7.0d0) * (cos(re) * (-0.0001984126984126984d0))
if (im <= (-1.1d+44)) then
tmp = t_0
else if (im <= (-0.0285d0)) then
tmp = 0.5d0 * (exp(-im) - exp(im))
else if (im <= 5.5d0) then
tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.pow(im, 7.0) * (Math.cos(re) * -0.0001984126984126984);
double tmp;
if (im <= -1.1e+44) {
tmp = t_0;
} else if (im <= -0.0285) {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
} else if (im <= 5.5) {
tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = math.pow(im, 7.0) * (math.cos(re) * -0.0001984126984126984) tmp = 0 if im <= -1.1e+44: tmp = t_0 elif im <= -0.0285: tmp = 0.5 * (math.exp(-im) - math.exp(im)) elif im <= 5.5: tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64((im ^ 7.0) * Float64(cos(re) * -0.0001984126984126984)) tmp = 0.0 if (im <= -1.1e+44) tmp = t_0; elseif (im <= -0.0285) tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); elseif (im <= 5.5) tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = (im ^ 7.0) * (cos(re) * -0.0001984126984126984); tmp = 0.0; if (im <= -1.1e+44) tmp = t_0; elseif (im <= -0.0285) tmp = 0.5 * (exp(-im) - exp(im)); elseif (im <= 5.5) tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 7.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.1e+44], t$95$0, If[LessEqual[im, -0.0285], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5.5], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -1.1 \cdot 10^{+44}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -0.0285:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{elif}\;im \leq 5.5:\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.09999999999999998e44 or 5.5 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 95.0%
associate-+r+95.0%
+-commutative95.0%
mul-1-neg95.0%
*-commutative95.0%
distribute-lft-neg-in95.0%
*-commutative95.0%
associate-*r*95.0%
distribute-rgt-out95.0%
*-commutative95.0%
associate-*l*95.0%
*-commutative95.0%
associate-*l*95.0%
distribute-lft-out95.0%
Simplified95.0%
Taylor expanded in im around inf 95.0%
associate-*r*95.0%
*-commutative95.0%
Simplified95.0%
if -1.09999999999999998e44 < im < -0.028500000000000001Initial program 99.1%
sub0-neg99.1%
Simplified99.1%
Taylor expanded in re around 0 76.5%
if -0.028500000000000001 < im < 5.5Initial program 8.8%
sub0-neg8.8%
Simplified8.8%
Taylor expanded in im around 0 99.5%
mul-1-neg99.5%
unsub-neg99.5%
*-commutative99.5%
associate-*l*99.5%
distribute-lft-out--99.5%
Simplified99.5%
Final simplification96.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (pow im 7.0) (* (cos re) -0.0001984126984126984))))
(if (<= im -1.1e+44)
t_0
(if (<= im -0.01)
(* 0.5 (- (exp (- im)) (exp im)))
(if (<= im 4.1) (* (cos re) (- im)) t_0)))))
double code(double re, double im) {
double t_0 = pow(im, 7.0) * (cos(re) * -0.0001984126984126984);
double tmp;
if (im <= -1.1e+44) {
tmp = t_0;
} else if (im <= -0.01) {
tmp = 0.5 * (exp(-im) - exp(im));
} else if (im <= 4.1) {
tmp = cos(re) * -im;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = (im ** 7.0d0) * (cos(re) * (-0.0001984126984126984d0))
if (im <= (-1.1d+44)) then
tmp = t_0
else if (im <= (-0.01d0)) then
tmp = 0.5d0 * (exp(-im) - exp(im))
else if (im <= 4.1d0) then
tmp = cos(re) * -im
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.pow(im, 7.0) * (Math.cos(re) * -0.0001984126984126984);
double tmp;
if (im <= -1.1e+44) {
tmp = t_0;
} else if (im <= -0.01) {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
} else if (im <= 4.1) {
tmp = Math.cos(re) * -im;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = math.pow(im, 7.0) * (math.cos(re) * -0.0001984126984126984) tmp = 0 if im <= -1.1e+44: tmp = t_0 elif im <= -0.01: tmp = 0.5 * (math.exp(-im) - math.exp(im)) elif im <= 4.1: tmp = math.cos(re) * -im else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64((im ^ 7.0) * Float64(cos(re) * -0.0001984126984126984)) tmp = 0.0 if (im <= -1.1e+44) tmp = t_0; elseif (im <= -0.01) tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); elseif (im <= 4.1) tmp = Float64(cos(re) * Float64(-im)); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = (im ^ 7.0) * (cos(re) * -0.0001984126984126984); tmp = 0.0; if (im <= -1.1e+44) tmp = t_0; elseif (im <= -0.01) tmp = 0.5 * (exp(-im) - exp(im)); elseif (im <= 4.1) tmp = cos(re) * -im; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 7.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.1e+44], t$95$0, If[LessEqual[im, -0.01], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.1], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -1.1 \cdot 10^{+44}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -0.01:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{elif}\;im \leq 4.1:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.09999999999999998e44 or 4.0999999999999996 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 95.0%
associate-+r+95.0%
+-commutative95.0%
mul-1-neg95.0%
*-commutative95.0%
distribute-lft-neg-in95.0%
*-commutative95.0%
associate-*r*95.0%
distribute-rgt-out95.0%
*-commutative95.0%
associate-*l*95.0%
*-commutative95.0%
associate-*l*95.0%
distribute-lft-out95.0%
Simplified95.0%
Taylor expanded in im around inf 95.0%
associate-*r*95.0%
*-commutative95.0%
Simplified95.0%
if -1.09999999999999998e44 < im < -0.0100000000000000002Initial program 99.1%
sub0-neg99.1%
Simplified99.1%
Taylor expanded in re around 0 76.5%
if -0.0100000000000000002 < im < 4.0999999999999996Initial program 8.8%
sub0-neg8.8%
Simplified8.8%
Taylor expanded in im around 0 98.9%
mul-1-neg98.9%
*-commutative98.9%
distribute-lft-neg-in98.9%
Simplified98.9%
Final simplification96.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (pow im 7.0) -0.0001984126984126984))
(t_1 (- (* (pow im 3.0) -0.16666666666666666) im))
(t_2 (* t_1 (+ (* -0.5 (* re re)) 1.0))))
(if (<= im -5e+110)
t_2
(if (<= im -4.5)
t_0
(if (<= im 5.8)
(* (cos re) (- im))
(if (<= im 5e+102) t_0 (if (<= im 2e+175) t_2 t_1)))))))
double code(double re, double im) {
double t_0 = pow(im, 7.0) * -0.0001984126984126984;
double t_1 = (pow(im, 3.0) * -0.16666666666666666) - im;
double t_2 = t_1 * ((-0.5 * (re * re)) + 1.0);
double tmp;
if (im <= -5e+110) {
tmp = t_2;
} else if (im <= -4.5) {
tmp = t_0;
} else if (im <= 5.8) {
tmp = cos(re) * -im;
} else if (im <= 5e+102) {
tmp = t_0;
} else if (im <= 2e+175) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (im ** 7.0d0) * (-0.0001984126984126984d0)
t_1 = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
t_2 = t_1 * (((-0.5d0) * (re * re)) + 1.0d0)
if (im <= (-5d+110)) then
tmp = t_2
else if (im <= (-4.5d0)) then
tmp = t_0
else if (im <= 5.8d0) then
tmp = cos(re) * -im
else if (im <= 5d+102) then
tmp = t_0
else if (im <= 2d+175) then
tmp = t_2
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.pow(im, 7.0) * -0.0001984126984126984;
double t_1 = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
double t_2 = t_1 * ((-0.5 * (re * re)) + 1.0);
double tmp;
if (im <= -5e+110) {
tmp = t_2;
} else if (im <= -4.5) {
tmp = t_0;
} else if (im <= 5.8) {
tmp = Math.cos(re) * -im;
} else if (im <= 5e+102) {
tmp = t_0;
} else if (im <= 2e+175) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = math.pow(im, 7.0) * -0.0001984126984126984 t_1 = (math.pow(im, 3.0) * -0.16666666666666666) - im t_2 = t_1 * ((-0.5 * (re * re)) + 1.0) tmp = 0 if im <= -5e+110: tmp = t_2 elif im <= -4.5: tmp = t_0 elif im <= 5.8: tmp = math.cos(re) * -im elif im <= 5e+102: tmp = t_0 elif im <= 2e+175: tmp = t_2 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64((im ^ 7.0) * -0.0001984126984126984) t_1 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) t_2 = Float64(t_1 * Float64(Float64(-0.5 * Float64(re * re)) + 1.0)) tmp = 0.0 if (im <= -5e+110) tmp = t_2; elseif (im <= -4.5) tmp = t_0; elseif (im <= 5.8) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 5e+102) tmp = t_0; elseif (im <= 2e+175) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = (im ^ 7.0) * -0.0001984126984126984; t_1 = ((im ^ 3.0) * -0.16666666666666666) - im; t_2 = t_1 * ((-0.5 * (re * re)) + 1.0); tmp = 0.0; if (im <= -5e+110) tmp = t_2; elseif (im <= -4.5) tmp = t_0; elseif (im <= 5.8) tmp = cos(re) * -im; elseif (im <= 5e+102) tmp = t_0; elseif (im <= 2e+175) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5e+110], t$95$2, If[LessEqual[im, -4.5], t$95$0, If[LessEqual[im, 5.8], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 5e+102], t$95$0, If[LessEqual[im, 2e+175], t$95$2, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{7} \cdot -0.0001984126984126984\\
t_1 := {im}^{3} \cdot -0.16666666666666666 - im\\
t_2 := t_1 \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\
\mathbf{if}\;im \leq -5 \cdot 10^{+110}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq -4.5:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 5.8:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 5 \cdot 10^{+102}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 2 \cdot 10^{+175}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -4.99999999999999978e110 or 5e102 < im < 1.9999999999999999e175Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in re around 0 0.0%
associate--l+0.0%
associate-*r*0.0%
distribute-lft1-in87.3%
unpow287.3%
Simplified87.3%
if -4.99999999999999978e110 < im < -4.5 or 5.79999999999999982 < im < 5e102Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 67.6%
associate-+r+67.6%
+-commutative67.6%
mul-1-neg67.6%
*-commutative67.6%
distribute-lft-neg-in67.6%
*-commutative67.6%
associate-*r*67.6%
distribute-rgt-out67.6%
*-commutative67.6%
associate-*l*67.6%
*-commutative67.6%
associate-*l*67.6%
distribute-lft-out67.6%
Simplified67.6%
Taylor expanded in im around inf 67.4%
associate-*r*67.4%
*-commutative67.4%
Simplified67.4%
Taylor expanded in re around 0 58.5%
if -4.5 < im < 5.79999999999999982Initial program 10.1%
sub0-neg10.1%
Simplified10.1%
Taylor expanded in im around 0 97.9%
mul-1-neg97.9%
*-commutative97.9%
distribute-lft-neg-in97.9%
Simplified97.9%
if 1.9999999999999999e175 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in re around 0 89.3%
Final simplification89.4%
(FPCore (re im) :precision binary64 (if (or (<= im -7.2) (not (<= im 5.5))) (* (pow im 7.0) -0.0001984126984126984) (* (cos re) (- im))))
double code(double re, double im) {
double tmp;
if ((im <= -7.2) || !(im <= 5.5)) {
tmp = pow(im, 7.0) * -0.0001984126984126984;
} else {
tmp = cos(re) * -im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-7.2d0)) .or. (.not. (im <= 5.5d0))) then
tmp = (im ** 7.0d0) * (-0.0001984126984126984d0)
else
tmp = cos(re) * -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -7.2) || !(im <= 5.5)) {
tmp = Math.pow(im, 7.0) * -0.0001984126984126984;
} else {
tmp = Math.cos(re) * -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -7.2) or not (im <= 5.5): tmp = math.pow(im, 7.0) * -0.0001984126984126984 else: tmp = math.cos(re) * -im return tmp
function code(re, im) tmp = 0.0 if ((im <= -7.2) || !(im <= 5.5)) tmp = Float64((im ^ 7.0) * -0.0001984126984126984); else tmp = Float64(cos(re) * Float64(-im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -7.2) || ~((im <= 5.5))) tmp = (im ^ 7.0) * -0.0001984126984126984; else tmp = cos(re) * -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -7.2], N[Not[LessEqual[im, 5.5]], $MachinePrecision]], N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -7.2 \lor \neg \left(im \leq 5.5\right):\\
\;\;\;\;{im}^{7} \cdot -0.0001984126984126984\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\end{array}
\end{array}
if im < -7.20000000000000018 or 5.5 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 90.6%
associate-+r+90.6%
+-commutative90.6%
mul-1-neg90.6%
*-commutative90.6%
distribute-lft-neg-in90.6%
*-commutative90.6%
associate-*r*90.6%
distribute-rgt-out90.6%
*-commutative90.6%
associate-*l*90.6%
*-commutative90.6%
associate-*l*90.6%
distribute-lft-out90.6%
Simplified90.6%
Taylor expanded in im around inf 90.5%
associate-*r*90.5%
*-commutative90.5%
Simplified90.5%
Taylor expanded in re around 0 70.0%
if -7.20000000000000018 < im < 5.5Initial program 10.1%
sub0-neg10.1%
Simplified10.1%
Taylor expanded in im around 0 97.9%
mul-1-neg97.9%
*-commutative97.9%
distribute-lft-neg-in97.9%
Simplified97.9%
Final simplification85.1%
(FPCore (re im) :precision binary64 (if (<= im -1.75e+43) (- (* (* re im) (* re 0.5)) im) (if (<= im 660.0) (* (cos re) (- im)) (+ 13.5 (* (* re re) -6.75)))))
double code(double re, double im) {
double tmp;
if (im <= -1.75e+43) {
tmp = ((re * im) * (re * 0.5)) - im;
} else if (im <= 660.0) {
tmp = cos(re) * -im;
} else {
tmp = 13.5 + ((re * re) * -6.75);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-1.75d+43)) then
tmp = ((re * im) * (re * 0.5d0)) - im
else if (im <= 660.0d0) then
tmp = cos(re) * -im
else
tmp = 13.5d0 + ((re * re) * (-6.75d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -1.75e+43) {
tmp = ((re * im) * (re * 0.5)) - im;
} else if (im <= 660.0) {
tmp = Math.cos(re) * -im;
} else {
tmp = 13.5 + ((re * re) * -6.75);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -1.75e+43: tmp = ((re * im) * (re * 0.5)) - im elif im <= 660.0: tmp = math.cos(re) * -im else: tmp = 13.5 + ((re * re) * -6.75) return tmp
function code(re, im) tmp = 0.0 if (im <= -1.75e+43) tmp = Float64(Float64(Float64(re * im) * Float64(re * 0.5)) - im); elseif (im <= 660.0) tmp = Float64(cos(re) * Float64(-im)); else tmp = Float64(13.5 + Float64(Float64(re * re) * -6.75)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -1.75e+43) tmp = ((re * im) * (re * 0.5)) - im; elseif (im <= 660.0) tmp = cos(re) * -im; else tmp = 13.5 + ((re * re) * -6.75); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -1.75e+43], N[(N[(N[(re * im), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 660.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(13.5 + N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.75 \cdot 10^{+43}:\\
\;\;\;\;\left(re \cdot im\right) \cdot \left(re \cdot 0.5\right) - im\\
\mathbf{elif}\;im \leq 660:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{else}:\\
\;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\
\end{array}
\end{array}
if im < -1.7500000000000001e43Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 5.4%
mul-1-neg5.4%
*-commutative5.4%
distribute-lft-neg-in5.4%
Simplified5.4%
Taylor expanded in re around 0 27.7%
mul-1-neg27.7%
+-commutative27.7%
unsub-neg27.7%
*-commutative27.7%
associate-*l*27.7%
unpow227.7%
Simplified27.7%
Taylor expanded in re around 0 27.7%
*-commutative27.7%
associate-*r*27.7%
unpow227.7%
associate-*l*27.7%
*-commutative27.7%
associate-*r*27.7%
associate-*l*27.7%
*-commutative27.7%
Simplified27.7%
if -1.7500000000000001e43 < im < 660Initial program 14.4%
sub0-neg14.4%
Simplified14.4%
Taylor expanded in im around 0 93.5%
mul-1-neg93.5%
*-commutative93.5%
distribute-lft-neg-in93.5%
Simplified93.5%
if 660 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Applied egg-rr0.6%
Taylor expanded in re around 0 16.6%
*-commutative16.6%
unpow216.6%
Simplified16.6%
Final simplification62.8%
(FPCore (re im) :precision binary64 (if (or (<= im -8.6e+42) (not (<= im 680.0))) (+ 13.5 (* (* re re) -6.75)) (- im)))
double code(double re, double im) {
double tmp;
if ((im <= -8.6e+42) || !(im <= 680.0)) {
tmp = 13.5 + ((re * re) * -6.75);
} else {
tmp = -im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-8.6d+42)) .or. (.not. (im <= 680.0d0))) then
tmp = 13.5d0 + ((re * re) * (-6.75d0))
else
tmp = -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -8.6e+42) || !(im <= 680.0)) {
tmp = 13.5 + ((re * re) * -6.75);
} else {
tmp = -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -8.6e+42) or not (im <= 680.0): tmp = 13.5 + ((re * re) * -6.75) else: tmp = -im return tmp
function code(re, im) tmp = 0.0 if ((im <= -8.6e+42) || !(im <= 680.0)) tmp = Float64(13.5 + Float64(Float64(re * re) * -6.75)); else tmp = Float64(-im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -8.6e+42) || ~((im <= 680.0))) tmp = 13.5 + ((re * re) * -6.75); else tmp = -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -8.6e+42], N[Not[LessEqual[im, 680.0]], $MachinePrecision]], N[(13.5 + N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision]), $MachinePrecision], (-im)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -8.6 \cdot 10^{+42} \lor \neg \left(im \leq 680\right):\\
\;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\
\mathbf{else}:\\
\;\;\;\;-im\\
\end{array}
\end{array}
if im < -8.5999999999999996e42 or 680 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Applied egg-rr1.8%
Taylor expanded in re around 0 16.3%
*-commutative16.3%
unpow216.3%
Simplified16.3%
if -8.5999999999999996e42 < im < 680Initial program 14.4%
sub0-neg14.4%
Simplified14.4%
Taylor expanded in im around 0 93.5%
mul-1-neg93.5%
*-commutative93.5%
distribute-lft-neg-in93.5%
Simplified93.5%
Taylor expanded in re around 0 54.7%
mul-1-neg54.7%
Simplified54.7%
Final simplification38.2%
(FPCore (re im) :precision binary64 (if (<= re 1.5e+191) (- (* (* re im) (* re 0.5)) im) (+ 13.5 (* (* re re) -6.75))))
double code(double re, double im) {
double tmp;
if (re <= 1.5e+191) {
tmp = ((re * im) * (re * 0.5)) - im;
} else {
tmp = 13.5 + ((re * re) * -6.75);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 1.5d+191) then
tmp = ((re * im) * (re * 0.5d0)) - im
else
tmp = 13.5d0 + ((re * re) * (-6.75d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 1.5e+191) {
tmp = ((re * im) * (re * 0.5)) - im;
} else {
tmp = 13.5 + ((re * re) * -6.75);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.5e+191: tmp = ((re * im) * (re * 0.5)) - im else: tmp = 13.5 + ((re * re) * -6.75) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.5e+191) tmp = Float64(Float64(Float64(re * im) * Float64(re * 0.5)) - im); else tmp = Float64(13.5 + Float64(Float64(re * re) * -6.75)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.5e+191) tmp = ((re * im) * (re * 0.5)) - im; else tmp = 13.5 + ((re * re) * -6.75); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.5e+191], N[(N[(N[(re * im), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], N[(13.5 + N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.5 \cdot 10^{+191}:\\
\;\;\;\;\left(re \cdot im\right) \cdot \left(re \cdot 0.5\right) - im\\
\mathbf{else}:\\
\;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\
\end{array}
\end{array}
if re < 1.4999999999999999e191Initial program 51.0%
sub0-neg51.0%
Simplified51.0%
Taylor expanded in im around 0 55.9%
mul-1-neg55.9%
*-commutative55.9%
distribute-lft-neg-in55.9%
Simplified55.9%
Taylor expanded in re around 0 40.9%
mul-1-neg40.9%
+-commutative40.9%
unsub-neg40.9%
*-commutative40.9%
associate-*l*40.9%
unpow240.9%
Simplified40.9%
Taylor expanded in re around 0 40.9%
*-commutative40.9%
associate-*r*40.9%
unpow240.9%
associate-*l*40.9%
*-commutative40.9%
associate-*r*40.9%
associate-*l*40.9%
*-commutative40.9%
Simplified40.9%
if 1.4999999999999999e191 < re Initial program 52.4%
sub0-neg52.4%
Simplified52.4%
Applied egg-rr3.8%
Taylor expanded in re around 0 28.0%
*-commutative28.0%
unpow228.0%
Simplified28.0%
Final simplification39.6%
(FPCore (re im) :precision binary64 (- im))
double code(double re, double im) {
return -im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -im
end function
public static double code(double re, double im) {
return -im;
}
def code(re, im): return -im
function code(re, im) return Float64(-im) end
function tmp = code(re, im) tmp = -im; end
code[re_, im_] := (-im)
\begin{array}{l}
\\
-im
\end{array}
Initial program 51.2%
sub0-neg51.2%
Simplified51.2%
Taylor expanded in im around 0 55.7%
mul-1-neg55.7%
*-commutative55.7%
distribute-lft-neg-in55.7%
Simplified55.7%
Taylor expanded in re around 0 33.1%
mul-1-neg33.1%
Simplified33.1%
Final simplification33.1%
(FPCore (re im) :precision binary64 13.5)
double code(double re, double im) {
return 13.5;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 13.5d0
end function
public static double code(double re, double im) {
return 13.5;
}
def code(re, im): return 13.5
function code(re, im) return 13.5 end
function tmp = code(re, im) tmp = 13.5; end
code[re_, im_] := 13.5
\begin{array}{l}
\\
13.5
\end{array}
Initial program 51.2%
sub0-neg51.2%
Simplified51.2%
Applied egg-rr3.1%
Taylor expanded in re around 0 3.0%
Final simplification3.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 2023182
(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))))