
(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 15 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 (- INFINITY)) (not (<= t_0 1e-6)))
(* (* 0.5 (cos re)) t_0)
(* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im)))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 1e-6)) {
tmp = (0.5 * cos(re)) * t_0;
} else {
tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 1e-6)) {
tmp = (0.5 * Math.cos(re)) * t_0;
} else {
tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 1e-6): tmp = (0.5 * math.cos(re)) * t_0 else: tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 1e-6)) tmp = Float64(Float64(0.5 * cos(re)) * t_0); else tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 1e-6))) tmp = (0.5 * cos(re)) * t_0; else tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 1e-6]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 10^{-6}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -inf.0 or 9.99999999999999955e-7 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
if -inf.0 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 9.99999999999999955e-7Initial program 8.1%
sub0-neg8.1%
Simplified8.1%
Taylor expanded in im around 0 99.8%
mul-1-neg99.8%
unsub-neg99.8%
*-commutative99.8%
associate-*l*99.8%
distribute-lft-out--99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(if (or (<= im -8e+91)
(not (or (<= im -0.3) (and (not (<= im 14000.0)) (<= im 1.08e+98)))))
(* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))
(* 0.5 (- (exp (- im)) (exp im)))))
double code(double re, double im) {
double tmp;
if ((im <= -8e+91) || !((im <= -0.3) || (!(im <= 14000.0) && (im <= 1.08e+98)))) {
tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else {
tmp = 0.5 * (exp(-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 ((im <= (-8d+91)) .or. (.not. (im <= (-0.3d0)) .or. (.not. (im <= 14000.0d0)) .and. (im <= 1.08d+98))) then
tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else
tmp = 0.5d0 * (exp(-im) - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -8e+91) || !((im <= -0.3) || (!(im <= 14000.0) && (im <= 1.08e+98)))) {
tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -8e+91) or not ((im <= -0.3) or (not (im <= 14000.0) and (im <= 1.08e+98))): tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) else: tmp = 0.5 * (math.exp(-im) - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if ((im <= -8e+91) || !((im <= -0.3) || (!(im <= 14000.0) && (im <= 1.08e+98)))) tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); else tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -8e+91) || ~(((im <= -0.3) || (~((im <= 14000.0)) && (im <= 1.08e+98))))) tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im); else tmp = 0.5 * (exp(-im) - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -8e+91], N[Not[Or[LessEqual[im, -0.3], And[N[Not[LessEqual[im, 14000.0]], $MachinePrecision], LessEqual[im, 1.08e+98]]]], $MachinePrecision]], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -8 \cdot 10^{+91} \lor \neg \left(im \leq -0.3 \lor \neg \left(im \leq 14000\right) \land im \leq 1.08 \cdot 10^{+98}\right):\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\end{array}
\end{array}
if im < -8.00000000000000064e91 or -0.299999999999999989 < im < 14000 or 1.07999999999999997e98 < im Initial program 44.7%
sub0-neg44.7%
Simplified44.7%
Taylor expanded in im around 0 98.2%
mul-1-neg98.2%
unsub-neg98.2%
*-commutative98.2%
associate-*l*98.2%
distribute-lft-out--98.2%
Simplified98.2%
if -8.00000000000000064e91 < im < -0.299999999999999989 or 14000 < im < 1.07999999999999997e98Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 88.6%
Final simplification96.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
(t_1 (/ (* (cos re) (- 9.0 (* im im))) (+ im -3.0))))
(if (<= im -6.1e+168)
t_1
(if (<= im -0.0005)
t_0
(if (<= im 14000.0)
(* (cos re) (- im))
(if (<= im 1.15e+140) t_0 t_1))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(-im) - exp(im));
double t_1 = (cos(re) * (9.0 - (im * im))) / (im + -3.0);
double tmp;
if (im <= -6.1e+168) {
tmp = t_1;
} else if (im <= -0.0005) {
tmp = t_0;
} else if (im <= 14000.0) {
tmp = cos(re) * -im;
} else if (im <= 1.15e+140) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * (exp(-im) - exp(im))
t_1 = (cos(re) * (9.0d0 - (im * im))) / (im + (-3.0d0))
if (im <= (-6.1d+168)) then
tmp = t_1
else if (im <= (-0.0005d0)) then
tmp = t_0
else if (im <= 14000.0d0) then
tmp = cos(re) * -im
else if (im <= 1.15d+140) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
double t_1 = (Math.cos(re) * (9.0 - (im * im))) / (im + -3.0);
double tmp;
if (im <= -6.1e+168) {
tmp = t_1;
} else if (im <= -0.0005) {
tmp = t_0;
} else if (im <= 14000.0) {
tmp = Math.cos(re) * -im;
} else if (im <= 1.15e+140) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.exp(-im) - math.exp(im)) t_1 = (math.cos(re) * (9.0 - (im * im))) / (im + -3.0) tmp = 0 if im <= -6.1e+168: tmp = t_1 elif im <= -0.0005: tmp = t_0 elif im <= 14000.0: tmp = math.cos(re) * -im elif im <= 1.15e+140: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))) t_1 = Float64(Float64(cos(re) * Float64(9.0 - Float64(im * im))) / Float64(im + -3.0)) tmp = 0.0 if (im <= -6.1e+168) tmp = t_1; elseif (im <= -0.0005) tmp = t_0; elseif (im <= 14000.0) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 1.15e+140) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (exp(-im) - exp(im)); t_1 = (cos(re) * (9.0 - (im * im))) / (im + -3.0); tmp = 0.0; if (im <= -6.1e+168) tmp = t_1; elseif (im <= -0.0005) tmp = t_0; elseif (im <= 14000.0) tmp = cos(re) * -im; elseif (im <= 1.15e+140) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[re], $MachinePrecision] * N[(9.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -6.1e+168], t$95$1, If[LessEqual[im, -0.0005], t$95$0, If[LessEqual[im, 14000.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 1.15e+140], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\
\mathbf{if}\;im \leq -6.1 \cdot 10^{+168}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.0005:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 14000:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 1.15 \cdot 10^{+140}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -6.1000000000000002e168 or 1.14999999999999995e140 < 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%
Applied egg-rr7.4%
*-commutative7.4%
flip--98.5%
associate-*l/98.5%
metadata-eval98.5%
+-commutative98.5%
Applied egg-rr98.5%
if -6.1000000000000002e168 < im < -5.0000000000000001e-4 or 14000 < im < 1.14999999999999995e140Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 83.1%
if -5.0000000000000001e-4 < im < 14000Initial program 8.8%
sub0-neg8.8%
Simplified8.8%
Taylor expanded in im around 0 99.0%
mul-1-neg99.0%
*-commutative99.0%
distribute-lft-neg-in99.0%
Simplified99.0%
Final simplification95.2%
(FPCore (re im)
:precision binary64
(let* ((t_0
(*
(- (* (pow im 3.0) -0.16666666666666666) im)
(+ (* -0.5 (* re re)) 1.0)))
(t_1 (/ (* (cos re) (- 9.0 (* im im))) (+ im -3.0))))
(if (<= im -2.1e+153)
t_1
(if (<= im -3.1e-7)
t_0
(if (<= im 0.0005)
(* (cos re) (- im))
(if (<= im 1.32e+154) t_0 t_1))))))
double code(double re, double im) {
double t_0 = ((pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
double t_1 = (cos(re) * (9.0 - (im * im))) / (im + -3.0);
double tmp;
if (im <= -2.1e+153) {
tmp = t_1;
} else if (im <= -3.1e-7) {
tmp = t_0;
} else if (im <= 0.0005) {
tmp = cos(re) * -im;
} else if (im <= 1.32e+154) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((im ** 3.0d0) * (-0.16666666666666666d0)) - im) * (((-0.5d0) * (re * re)) + 1.0d0)
t_1 = (cos(re) * (9.0d0 - (im * im))) / (im + (-3.0d0))
if (im <= (-2.1d+153)) then
tmp = t_1
else if (im <= (-3.1d-7)) then
tmp = t_0
else if (im <= 0.0005d0) then
tmp = cos(re) * -im
else if (im <= 1.32d+154) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = ((Math.pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
double t_1 = (Math.cos(re) * (9.0 - (im * im))) / (im + -3.0);
double tmp;
if (im <= -2.1e+153) {
tmp = t_1;
} else if (im <= -3.1e-7) {
tmp = t_0;
} else if (im <= 0.0005) {
tmp = Math.cos(re) * -im;
} else if (im <= 1.32e+154) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = ((math.pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0) t_1 = (math.cos(re) * (9.0 - (im * im))) / (im + -3.0) tmp = 0 if im <= -2.1e+153: tmp = t_1 elif im <= -3.1e-7: tmp = t_0 elif im <= 0.0005: tmp = math.cos(re) * -im elif im <= 1.32e+154: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) * Float64(Float64(-0.5 * Float64(re * re)) + 1.0)) t_1 = Float64(Float64(cos(re) * Float64(9.0 - Float64(im * im))) / Float64(im + -3.0)) tmp = 0.0 if (im <= -2.1e+153) tmp = t_1; elseif (im <= -3.1e-7) tmp = t_0; elseif (im <= 0.0005) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 1.32e+154) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = (((im ^ 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0); t_1 = (cos(re) * (9.0 - (im * im))) / (im + -3.0); tmp = 0.0; if (im <= -2.1e+153) tmp = t_1; elseif (im <= -3.1e-7) tmp = t_0; elseif (im <= 0.0005) tmp = cos(re) * -im; elseif (im <= 1.32e+154) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision] * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[re], $MachinePrecision] * N[(9.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.1e+153], t$95$1, If[LessEqual[im, -3.1e-7], t$95$0, If[LessEqual[im, 0.0005], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 1.32e+154], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\
t_1 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+153}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -3.1 \cdot 10^{-7}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.0005:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -2.10000000000000017e153 or 1.31999999999999998e154 < 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%
Applied egg-rr7.2%
*-commutative7.2%
flip--98.6%
associate-*l/98.6%
metadata-eval98.6%
+-commutative98.6%
Applied egg-rr98.6%
if -2.10000000000000017e153 < im < -3.1e-7 or 5.0000000000000001e-4 < im < 1.31999999999999998e154Initial program 99.5%
sub0-neg99.5%
Simplified99.5%
Taylor expanded in im around 0 34.0%
mul-1-neg34.0%
unsub-neg34.0%
*-commutative34.0%
associate-*l*34.0%
distribute-lft-out--34.0%
Simplified34.0%
Taylor expanded in re around 0 14.4%
associate--l+14.4%
associate-*r*14.4%
distribute-lft1-in35.8%
unpow235.8%
Simplified35.8%
if -3.1e-7 < im < 5.0000000000000001e-4Initial program 7.6%
sub0-neg7.6%
Simplified7.6%
Taylor expanded in im around 0 99.8%
mul-1-neg99.8%
*-commutative99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Final simplification85.5%
(FPCore (re im)
:precision binary64
(let* ((t_0
(* (pow im 3.0) (* -0.16666666666666666 (+ (* -0.5 (* re re)) 1.0))))
(t_1 (/ (* (cos re) (- 9.0 (* im im))) (+ im -3.0))))
(if (<= im -2.1e+153)
t_1
(if (<= im -5.8e+34)
t_0
(if (<= im 720.0)
(* (cos re) (- im))
(if (<= im 1.32e+154) t_0 t_1))))))
double code(double re, double im) {
double t_0 = pow(im, 3.0) * (-0.16666666666666666 * ((-0.5 * (re * re)) + 1.0));
double t_1 = (cos(re) * (9.0 - (im * im))) / (im + -3.0);
double tmp;
if (im <= -2.1e+153) {
tmp = t_1;
} else if (im <= -5.8e+34) {
tmp = t_0;
} else if (im <= 720.0) {
tmp = cos(re) * -im;
} else if (im <= 1.32e+154) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (im ** 3.0d0) * ((-0.16666666666666666d0) * (((-0.5d0) * (re * re)) + 1.0d0))
t_1 = (cos(re) * (9.0d0 - (im * im))) / (im + (-3.0d0))
if (im <= (-2.1d+153)) then
tmp = t_1
else if (im <= (-5.8d+34)) then
tmp = t_0
else if (im <= 720.0d0) then
tmp = cos(re) * -im
else if (im <= 1.32d+154) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.pow(im, 3.0) * (-0.16666666666666666 * ((-0.5 * (re * re)) + 1.0));
double t_1 = (Math.cos(re) * (9.0 - (im * im))) / (im + -3.0);
double tmp;
if (im <= -2.1e+153) {
tmp = t_1;
} else if (im <= -5.8e+34) {
tmp = t_0;
} else if (im <= 720.0) {
tmp = Math.cos(re) * -im;
} else if (im <= 1.32e+154) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = math.pow(im, 3.0) * (-0.16666666666666666 * ((-0.5 * (re * re)) + 1.0)) t_1 = (math.cos(re) * (9.0 - (im * im))) / (im + -3.0) tmp = 0 if im <= -2.1e+153: tmp = t_1 elif im <= -5.8e+34: tmp = t_0 elif im <= 720.0: tmp = math.cos(re) * -im elif im <= 1.32e+154: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64((im ^ 3.0) * Float64(-0.16666666666666666 * Float64(Float64(-0.5 * Float64(re * re)) + 1.0))) t_1 = Float64(Float64(cos(re) * Float64(9.0 - Float64(im * im))) / Float64(im + -3.0)) tmp = 0.0 if (im <= -2.1e+153) tmp = t_1; elseif (im <= -5.8e+34) tmp = t_0; elseif (im <= 720.0) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 1.32e+154) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = (im ^ 3.0) * (-0.16666666666666666 * ((-0.5 * (re * re)) + 1.0)); t_1 = (cos(re) * (9.0 - (im * im))) / (im + -3.0); tmp = 0.0; if (im <= -2.1e+153) tmp = t_1; elseif (im <= -5.8e+34) tmp = t_0; elseif (im <= 720.0) tmp = cos(re) * -im; elseif (im <= 1.32e+154) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * N[(-0.16666666666666666 * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[re], $MachinePrecision] * N[(9.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.1e+153], t$95$1, If[LessEqual[im, -5.8e+34], t$95$0, If[LessEqual[im, 720.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 1.32e+154], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{3} \cdot \left(-0.16666666666666666 \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\right)\\
t_1 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+153}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -5.8 \cdot 10^{+34}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 720:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -2.10000000000000017e153 or 1.31999999999999998e154 < 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%
Applied egg-rr7.2%
*-commutative7.2%
flip--98.6%
associate-*l/98.6%
metadata-eval98.6%
+-commutative98.6%
Applied egg-rr98.6%
if -2.10000000000000017e153 < im < -5.8000000000000003e34 or 720 < im < 1.31999999999999998e154Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 35.7%
mul-1-neg35.7%
unsub-neg35.7%
*-commutative35.7%
associate-*l*35.7%
distribute-lft-out--35.7%
Simplified35.7%
Taylor expanded in re around 0 13.9%
associate--l+13.9%
associate-*r*13.9%
distribute-lft1-in37.9%
unpow237.9%
Simplified37.9%
Taylor expanded in im around inf 37.9%
associate-*r*37.9%
unpow237.9%
Simplified37.9%
if -5.8000000000000003e34 < im < 720Initial program 11.4%
sub0-neg11.4%
Simplified11.4%
Taylor expanded in im around 0 96.2%
mul-1-neg96.2%
*-commutative96.2%
distribute-lft-neg-in96.2%
Simplified96.2%
Final simplification85.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (/ (* (cos re) (- 9.0 (* im im))) (+ im -3.0))))
(if (<= im -7e+168)
t_0
(if (<= im -3.1e-7)
(- (* (pow im 3.0) -0.16666666666666666) im)
(if (<= im 1.8) (* (cos re) (- im)) t_0)))))
double code(double re, double im) {
double t_0 = (cos(re) * (9.0 - (im * im))) / (im + -3.0);
double tmp;
if (im <= -7e+168) {
tmp = t_0;
} else if (im <= -3.1e-7) {
tmp = (pow(im, 3.0) * -0.16666666666666666) - im;
} else if (im <= 1.8) {
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 = (cos(re) * (9.0d0 - (im * im))) / (im + (-3.0d0))
if (im <= (-7d+168)) then
tmp = t_0
else if (im <= (-3.1d-7)) then
tmp = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
else if (im <= 1.8d0) 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.cos(re) * (9.0 - (im * im))) / (im + -3.0);
double tmp;
if (im <= -7e+168) {
tmp = t_0;
} else if (im <= -3.1e-7) {
tmp = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
} else if (im <= 1.8) {
tmp = Math.cos(re) * -im;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = (math.cos(re) * (9.0 - (im * im))) / (im + -3.0) tmp = 0 if im <= -7e+168: tmp = t_0 elif im <= -3.1e-7: tmp = (math.pow(im, 3.0) * -0.16666666666666666) - im elif im <= 1.8: tmp = math.cos(re) * -im else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(Float64(cos(re) * Float64(9.0 - Float64(im * im))) / Float64(im + -3.0)) tmp = 0.0 if (im <= -7e+168) tmp = t_0; elseif (im <= -3.1e-7) tmp = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im); elseif (im <= 1.8) tmp = Float64(cos(re) * Float64(-im)); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = (cos(re) * (9.0 - (im * im))) / (im + -3.0); tmp = 0.0; if (im <= -7e+168) tmp = t_0; elseif (im <= -3.1e-7) tmp = ((im ^ 3.0) * -0.16666666666666666) - im; elseif (im <= 1.8) tmp = cos(re) * -im; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Cos[re], $MachinePrecision] * N[(9.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7e+168], t$95$0, If[LessEqual[im, -3.1e-7], N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 1.8], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\
\mathbf{if}\;im \leq -7 \cdot 10^{+168}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -3.1 \cdot 10^{-7}:\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{elif}\;im \leq 1.8:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -7.0000000000000004e168 or 1.80000000000000004 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 78.2%
mul-1-neg78.2%
unsub-neg78.2%
*-commutative78.2%
associate-*l*78.2%
distribute-lft-out--78.2%
Simplified78.2%
Applied egg-rr6.4%
*-commutative6.4%
flip--72.3%
associate-*l/72.3%
metadata-eval72.3%
+-commutative72.3%
Applied egg-rr72.3%
if -7.0000000000000004e168 < im < -3.1e-7Initial program 99.3%
sub0-neg99.3%
Simplified99.3%
Taylor expanded in im around 0 51.3%
mul-1-neg51.3%
unsub-neg51.3%
*-commutative51.3%
associate-*l*51.3%
distribute-lft-out--51.3%
Simplified51.3%
Taylor expanded in re around 0 42.6%
if -3.1e-7 < im < 1.80000000000000004Initial program 7.6%
sub0-neg7.6%
Simplified7.6%
Taylor expanded in im around 0 99.8%
mul-1-neg99.8%
*-commutative99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Final simplification82.2%
(FPCore (re im) :precision binary64 (if (or (<= im -3.1e-7) (not (<= im 6.2e+14))) (- (* (pow im 3.0) -0.16666666666666666) im) (* (cos re) (- im))))
double code(double re, double im) {
double tmp;
if ((im <= -3.1e-7) || !(im <= 6.2e+14)) {
tmp = (pow(im, 3.0) * -0.16666666666666666) - im;
} else {
tmp = cos(re) * -im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-3.1d-7)) .or. (.not. (im <= 6.2d+14))) then
tmp = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
else
tmp = cos(re) * -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -3.1e-7) || !(im <= 6.2e+14)) {
tmp = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
} else {
tmp = Math.cos(re) * -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -3.1e-7) or not (im <= 6.2e+14): tmp = (math.pow(im, 3.0) * -0.16666666666666666) - im else: tmp = math.cos(re) * -im return tmp
function code(re, im) tmp = 0.0 if ((im <= -3.1e-7) || !(im <= 6.2e+14)) tmp = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im); else tmp = Float64(cos(re) * Float64(-im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -3.1e-7) || ~((im <= 6.2e+14))) tmp = ((im ^ 3.0) * -0.16666666666666666) - im; else tmp = cos(re) * -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -3.1e-7], N[Not[LessEqual[im, 6.2e+14]], $MachinePrecision]], N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.1 \cdot 10^{-7} \lor \neg \left(im \leq 6.2 \cdot 10^{+14}\right):\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\end{array}
\end{array}
if im < -3.1e-7 or 6.2e14 < im Initial program 99.8%
sub0-neg99.8%
Simplified99.8%
Taylor expanded in im around 0 70.7%
mul-1-neg70.7%
unsub-neg70.7%
*-commutative70.7%
associate-*l*70.7%
distribute-lft-out--70.7%
Simplified70.7%
Taylor expanded in re around 0 55.7%
if -3.1e-7 < im < 6.2e14Initial program 8.3%
sub0-neg8.3%
Simplified8.3%
Taylor expanded in im around 0 99.0%
mul-1-neg99.0%
*-commutative99.0%
distribute-lft-neg-in99.0%
Simplified99.0%
Final simplification78.2%
(FPCore (re im) :precision binary64 (if (or (<= im -2.6) (not (<= im 1e-7))) (* (pow im 3.0) -0.16666666666666666) (- im)))
double code(double re, double im) {
double tmp;
if ((im <= -2.6) || !(im <= 1e-7)) {
tmp = pow(im, 3.0) * -0.16666666666666666;
} else {
tmp = -im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-2.6d0)) .or. (.not. (im <= 1d-7))) then
tmp = (im ** 3.0d0) * (-0.16666666666666666d0)
else
tmp = -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -2.6) || !(im <= 1e-7)) {
tmp = Math.pow(im, 3.0) * -0.16666666666666666;
} else {
tmp = -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -2.6) or not (im <= 1e-7): tmp = math.pow(im, 3.0) * -0.16666666666666666 else: tmp = -im return tmp
function code(re, im) tmp = 0.0 if ((im <= -2.6) || !(im <= 1e-7)) tmp = Float64((im ^ 3.0) * -0.16666666666666666); else tmp = Float64(-im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -2.6) || ~((im <= 1e-7))) tmp = (im ^ 3.0) * -0.16666666666666666; else tmp = -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -2.6], N[Not[LessEqual[im, 1e-7]], $MachinePrecision]], N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision], (-im)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.6 \lor \neg \left(im \leq 10^{-7}\right):\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666\\
\mathbf{else}:\\
\;\;\;\;-im\\
\end{array}
\end{array}
if im < -2.60000000000000009 or 9.9999999999999995e-8 < im Initial program 99.7%
sub0-neg99.7%
Simplified99.7%
Taylor expanded in im around 0 70.2%
mul-1-neg70.2%
unsub-neg70.2%
*-commutative70.2%
associate-*l*70.2%
distribute-lft-out--70.2%
Simplified70.2%
Taylor expanded in re around 0 54.5%
Taylor expanded in im around inf 54.5%
if -2.60000000000000009 < im < 9.9999999999999995e-8Initial program 7.6%
sub0-neg7.6%
Simplified7.6%
Taylor expanded in im around 0 99.8%
mul-1-neg99.8%
unsub-neg99.8%
*-commutative99.8%
associate-*l*99.8%
distribute-lft-out--99.8%
Simplified99.8%
Taylor expanded in re around 0 59.8%
Taylor expanded in im around 0 59.7%
neg-mul-159.7%
Simplified59.7%
Final simplification57.2%
(FPCore (re im) :precision binary64 (if (or (<= im -3.7e+46) (not (<= im 1.55e+14))) (* (pow im 3.0) -0.16666666666666666) (* (cos re) (- im))))
double code(double re, double im) {
double tmp;
if ((im <= -3.7e+46) || !(im <= 1.55e+14)) {
tmp = pow(im, 3.0) * -0.16666666666666666;
} else {
tmp = cos(re) * -im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-3.7d+46)) .or. (.not. (im <= 1.55d+14))) then
tmp = (im ** 3.0d0) * (-0.16666666666666666d0)
else
tmp = cos(re) * -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -3.7e+46) || !(im <= 1.55e+14)) {
tmp = Math.pow(im, 3.0) * -0.16666666666666666;
} else {
tmp = Math.cos(re) * -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -3.7e+46) or not (im <= 1.55e+14): tmp = math.pow(im, 3.0) * -0.16666666666666666 else: tmp = math.cos(re) * -im return tmp
function code(re, im) tmp = 0.0 if ((im <= -3.7e+46) || !(im <= 1.55e+14)) tmp = Float64((im ^ 3.0) * -0.16666666666666666); else tmp = Float64(cos(re) * Float64(-im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -3.7e+46) || ~((im <= 1.55e+14))) tmp = (im ^ 3.0) * -0.16666666666666666; else tmp = cos(re) * -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -3.7e+46], N[Not[LessEqual[im, 1.55e+14]], $MachinePrecision]], N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.7 \cdot 10^{+46} \lor \neg \left(im \leq 1.55 \cdot 10^{+14}\right):\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\end{array}
\end{array}
if im < -3.6999999999999999e46 or 1.55e14 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 75.8%
mul-1-neg75.8%
unsub-neg75.8%
*-commutative75.8%
associate-*l*75.8%
distribute-lft-out--75.8%
Simplified75.8%
Taylor expanded in re around 0 59.5%
Taylor expanded in im around inf 59.5%
if -3.6999999999999999e46 < im < 1.55e14Initial program 14.5%
sub0-neg14.5%
Simplified14.5%
Taylor expanded in im around 0 92.9%
mul-1-neg92.9%
*-commutative92.9%
distribute-lft-neg-in92.9%
Simplified92.9%
Final simplification78.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* re re) 0.75)))
(if (<= re 1.05e+92)
(- (* (* re re) (* im 0.5)) im)
(if (<= re 4e+145)
(/ (- 2.25 (* t_0 t_0)) (- -1.5 t_0))
(* 27.0 (+ 0.5 (* re (* re -0.25))))))))
double code(double re, double im) {
double t_0 = (re * re) * 0.75;
double tmp;
if (re <= 1.05e+92) {
tmp = ((re * re) * (im * 0.5)) - im;
} else if (re <= 4e+145) {
tmp = (2.25 - (t_0 * t_0)) / (-1.5 - t_0);
} else {
tmp = 27.0 * (0.5 + (re * (re * -0.25)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = (re * re) * 0.75d0
if (re <= 1.05d+92) then
tmp = ((re * re) * (im * 0.5d0)) - im
else if (re <= 4d+145) then
tmp = (2.25d0 - (t_0 * t_0)) / ((-1.5d0) - t_0)
else
tmp = 27.0d0 * (0.5d0 + (re * (re * (-0.25d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (re * re) * 0.75;
double tmp;
if (re <= 1.05e+92) {
tmp = ((re * re) * (im * 0.5)) - im;
} else if (re <= 4e+145) {
tmp = (2.25 - (t_0 * t_0)) / (-1.5 - t_0);
} else {
tmp = 27.0 * (0.5 + (re * (re * -0.25)));
}
return tmp;
}
def code(re, im): t_0 = (re * re) * 0.75 tmp = 0 if re <= 1.05e+92: tmp = ((re * re) * (im * 0.5)) - im elif re <= 4e+145: tmp = (2.25 - (t_0 * t_0)) / (-1.5 - t_0) else: tmp = 27.0 * (0.5 + (re * (re * -0.25))) return tmp
function code(re, im) t_0 = Float64(Float64(re * re) * 0.75) tmp = 0.0 if (re <= 1.05e+92) tmp = Float64(Float64(Float64(re * re) * Float64(im * 0.5)) - im); elseif (re <= 4e+145) tmp = Float64(Float64(2.25 - Float64(t_0 * t_0)) / Float64(-1.5 - t_0)); else tmp = Float64(27.0 * Float64(0.5 + Float64(re * Float64(re * -0.25)))); end return tmp end
function tmp_2 = code(re, im) t_0 = (re * re) * 0.75; tmp = 0.0; if (re <= 1.05e+92) tmp = ((re * re) * (im * 0.5)) - im; elseif (re <= 4e+145) tmp = (2.25 - (t_0 * t_0)) / (-1.5 - t_0); else tmp = 27.0 * (0.5 + (re * (re * -0.25))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision]}, If[LessEqual[re, 1.05e+92], N[(N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[re, 4e+145], N[(N[(2.25 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(-1.5 - t$95$0), $MachinePrecision]), $MachinePrecision], N[(27.0 * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(re \cdot re\right) \cdot 0.75\\
\mathbf{if}\;re \leq 1.05 \cdot 10^{+92}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\
\mathbf{elif}\;re \leq 4 \cdot 10^{+145}:\\
\;\;\;\;\frac{2.25 - t_0 \cdot t_0}{-1.5 - t_0}\\
\mathbf{else}:\\
\;\;\;\;27 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\
\end{array}
\end{array}
if re < 1.04999999999999993e92Initial program 51.2%
sub0-neg51.2%
Simplified51.2%
Taylor expanded in im around 0 55.5%
mul-1-neg55.5%
*-commutative55.5%
distribute-lft-neg-in55.5%
Simplified55.5%
Taylor expanded in re around 0 40.5%
neg-mul-140.5%
+-commutative40.5%
unsub-neg40.5%
*-commutative40.5%
associate-*l*40.5%
unpow240.5%
Simplified40.5%
if 1.04999999999999993e92 < re < 4e145Initial program 73.5%
sub0-neg73.5%
Simplified73.5%
Taylor expanded in re around 0 1.1%
*-commutative1.1%
associate-*r*1.1%
distribute-rgt-out34.5%
+-commutative34.5%
*-commutative34.5%
unpow234.5%
associate-*l*34.5%
Simplified34.5%
Applied egg-rr3.5%
distribute-lft-in3.5%
flip-+42.5%
metadata-eval42.5%
metadata-eval42.5%
metadata-eval42.5%
*-commutative42.5%
*-commutative42.5%
associate-*r*42.5%
associate-*l*42.5%
metadata-eval42.5%
associate-*r*42.5%
associate-*l*42.5%
metadata-eval42.5%
metadata-eval42.5%
*-commutative42.5%
associate-*r*42.5%
associate-*l*42.5%
metadata-eval42.5%
Applied egg-rr42.5%
if 4e145 < re Initial program 51.0%
sub0-neg51.0%
Simplified51.0%
Taylor expanded in re around 0 0.2%
*-commutative0.2%
associate-*r*0.2%
distribute-rgt-out17.4%
+-commutative17.4%
*-commutative17.4%
unpow217.4%
associate-*l*17.4%
Simplified17.4%
Applied egg-rr29.2%
Final simplification39.3%
(FPCore (re im) :precision binary64 (if (<= re 1.7e+144) (- im) (* 27.0 (+ 0.5 (* re (* re -0.25))))))
double code(double re, double im) {
double tmp;
if (re <= 1.7e+144) {
tmp = -im;
} else {
tmp = 27.0 * (0.5 + (re * (re * -0.25)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 1.7d+144) then
tmp = -im
else
tmp = 27.0d0 * (0.5d0 + (re * (re * (-0.25d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 1.7e+144) {
tmp = -im;
} else {
tmp = 27.0 * (0.5 + (re * (re * -0.25)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.7e+144: tmp = -im else: tmp = 27.0 * (0.5 + (re * (re * -0.25))) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.7e+144) tmp = Float64(-im); else tmp = Float64(27.0 * Float64(0.5 + Float64(re * Float64(re * -0.25)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.7e+144) tmp = -im; else tmp = 27.0 * (0.5 + (re * (re * -0.25))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.7e+144], (-im), N[(27.0 * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.7 \cdot 10^{+144}:\\
\;\;\;\;-im\\
\mathbf{else}:\\
\;\;\;\;27 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\
\end{array}
\end{array}
if re < 1.7e144Initial program 52.4%
sub0-neg52.4%
Simplified52.4%
Taylor expanded in im around 0 85.3%
mul-1-neg85.3%
unsub-neg85.3%
*-commutative85.3%
associate-*l*85.3%
distribute-lft-out--85.3%
Simplified85.3%
Taylor expanded in re around 0 60.5%
Taylor expanded in im around 0 36.1%
neg-mul-136.1%
Simplified36.1%
if 1.7e144 < re Initial program 51.0%
sub0-neg51.0%
Simplified51.0%
Taylor expanded in re around 0 0.2%
*-commutative0.2%
associate-*r*0.2%
distribute-rgt-out17.4%
+-commutative17.4%
*-commutative17.4%
unpow217.4%
associate-*l*17.4%
Simplified17.4%
Applied egg-rr29.2%
Final simplification35.3%
(FPCore (re im) :precision binary64 (if (<= re 1.05e+197) (- (* (* re re) (* im 0.5)) im) (* 27.0 (+ 0.5 (* re (* re -0.25))))))
double code(double re, double im) {
double tmp;
if (re <= 1.05e+197) {
tmp = ((re * re) * (im * 0.5)) - im;
} else {
tmp = 27.0 * (0.5 + (re * (re * -0.25)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 1.05d+197) then
tmp = ((re * re) * (im * 0.5d0)) - im
else
tmp = 27.0d0 * (0.5d0 + (re * (re * (-0.25d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 1.05e+197) {
tmp = ((re * re) * (im * 0.5)) - im;
} else {
tmp = 27.0 * (0.5 + (re * (re * -0.25)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.05e+197: tmp = ((re * re) * (im * 0.5)) - im else: tmp = 27.0 * (0.5 + (re * (re * -0.25))) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.05e+197) tmp = Float64(Float64(Float64(re * re) * Float64(im * 0.5)) - im); else tmp = Float64(27.0 * Float64(0.5 + Float64(re * Float64(re * -0.25)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.05e+197) tmp = ((re * re) * (im * 0.5)) - im; else tmp = 27.0 * (0.5 + (re * (re * -0.25))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.05e+197], N[(N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], N[(27.0 * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.05 \cdot 10^{+197}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\
\mathbf{else}:\\
\;\;\;\;27 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\
\end{array}
\end{array}
if re < 1.05000000000000003e197Initial program 52.2%
sub0-neg52.2%
Simplified52.2%
Taylor expanded in im around 0 54.6%
mul-1-neg54.6%
*-commutative54.6%
distribute-lft-neg-in54.6%
Simplified54.6%
Taylor expanded in re around 0 39.2%
neg-mul-139.2%
+-commutative39.2%
unsub-neg39.2%
*-commutative39.2%
associate-*l*39.2%
unpow239.2%
Simplified39.2%
if 1.05000000000000003e197 < re Initial program 52.4%
sub0-neg52.4%
Simplified52.4%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
associate-*r*0.0%
distribute-rgt-out11.1%
+-commutative11.1%
*-commutative11.1%
unpow211.1%
associate-*l*11.1%
Simplified11.1%
Applied egg-rr39.7%
Final simplification39.2%
(FPCore (re im) :precision binary64 (if (<= re 2.2e+168) (- im) (* (* re re) 0.75)))
double code(double re, double im) {
double tmp;
if (re <= 2.2e+168) {
tmp = -im;
} else {
tmp = (re * re) * 0.75;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 2.2d+168) then
tmp = -im
else
tmp = (re * re) * 0.75d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 2.2e+168) {
tmp = -im;
} else {
tmp = (re * re) * 0.75;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 2.2e+168: tmp = -im else: tmp = (re * re) * 0.75 return tmp
function code(re, im) tmp = 0.0 if (re <= 2.2e+168) tmp = Float64(-im); else tmp = Float64(Float64(re * re) * 0.75); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 2.2e+168) tmp = -im; else tmp = (re * re) * 0.75; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 2.2e+168], (-im), N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 2.2 \cdot 10^{+168}:\\
\;\;\;\;-im\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot 0.75\\
\end{array}
\end{array}
if re < 2.2000000000000002e168Initial program 52.4%
sub0-neg52.4%
Simplified52.4%
Taylor expanded in im around 0 85.5%
mul-1-neg85.5%
unsub-neg85.5%
*-commutative85.5%
associate-*l*85.5%
distribute-lft-out--85.5%
Simplified85.5%
Taylor expanded in re around 0 60.4%
Taylor expanded in im around 0 35.6%
neg-mul-135.6%
Simplified35.6%
if 2.2000000000000002e168 < re Initial program 50.8%
sub0-neg50.8%
Simplified50.8%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
associate-*r*0.0%
distribute-rgt-out20.0%
+-commutative20.0%
*-commutative20.0%
unpow220.0%
associate-*l*20.0%
Simplified20.0%
Applied egg-rr16.9%
Taylor expanded in re around inf 16.9%
unpow216.9%
Simplified16.9%
Final simplification33.7%
(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 52.2%
sub0-neg52.2%
Simplified52.2%
Taylor expanded in im around 0 85.4%
mul-1-neg85.4%
unsub-neg85.4%
*-commutative85.4%
associate-*l*85.4%
distribute-lft-out--85.4%
Simplified85.4%
Taylor expanded in re around 0 57.2%
Taylor expanded in im around 0 33.0%
neg-mul-133.0%
Simplified33.0%
Final simplification33.0%
(FPCore (re im) :precision binary64 -1.5)
double code(double re, double im) {
return -1.5;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -1.5d0
end function
public static double code(double re, double im) {
return -1.5;
}
def code(re, im): return -1.5
function code(re, im) return -1.5 end
function tmp = code(re, im) tmp = -1.5; end
code[re_, im_] := -1.5
\begin{array}{l}
\\
-1.5
\end{array}
Initial program 52.2%
sub0-neg52.2%
Simplified52.2%
Taylor expanded in re around 0 2.8%
*-commutative2.8%
associate-*r*2.8%
distribute-rgt-out36.7%
+-commutative36.7%
*-commutative36.7%
unpow236.7%
associate-*l*36.7%
Simplified36.7%
Applied egg-rr6.4%
Taylor expanded in re around 0 2.7%
Final simplification2.7%
(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 2023188
(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))))