
(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 -5.0) (not (<= t_0 2e-12)))
(* (* 0.5 (cos re)) t_0)
(-
(*
(cos re)
(+
(* (pow im 3.0) -0.16666666666666666)
(* (pow im 5.0) -0.008333333333333333)))
(* im (cos re))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -5.0) || !(t_0 <= 2e-12)) {
tmp = (0.5 * cos(re)) * t_0;
} else {
tmp = (cos(re) * ((pow(im, 3.0) * -0.16666666666666666) + (pow(im, 5.0) * -0.008333333333333333))) - (im * cos(re));
}
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 <= (-5.0d0)) .or. (.not. (t_0 <= 2d-12))) then
tmp = (0.5d0 * cos(re)) * t_0
else
tmp = (cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) + ((im ** 5.0d0) * (-0.008333333333333333d0)))) - (im * cos(re))
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 <= -5.0) || !(t_0 <= 2e-12)) {
tmp = (0.5 * Math.cos(re)) * t_0;
} else {
tmp = (Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) + (Math.pow(im, 5.0) * -0.008333333333333333))) - (im * Math.cos(re));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -5.0) or not (t_0 <= 2e-12): tmp = (0.5 * math.cos(re)) * t_0 else: tmp = (math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) + (math.pow(im, 5.0) * -0.008333333333333333))) - (im * math.cos(re)) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= -5.0) || !(t_0 <= 2e-12)) tmp = Float64(Float64(0.5 * cos(re)) * t_0); else tmp = Float64(Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) + Float64((im ^ 5.0) * -0.008333333333333333))) - Float64(im * cos(re))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -5.0) || ~((t_0 <= 2e-12))) tmp = (0.5 * cos(re)) * t_0; else tmp = (cos(re) * (((im ^ 3.0) * -0.16666666666666666) + ((im ^ 5.0) * -0.008333333333333333))) - (im * cos(re)); 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, -5.0], N[Not[LessEqual[t$95$0, 2e-12]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -5 \lor \neg \left(t_0 \leq 2 \cdot 10^{-12}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 + {im}^{5} \cdot -0.008333333333333333\right) - im \cdot \cos re\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -5 or 1.99999999999999996e-12 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
if -5 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1.99999999999999996e-12Initial program 9.3%
neg-sub09.3%
Simplified9.3%
Taylor expanded in im around 0 99.9%
+-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
+-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
+-commutative99.9%
*-commutative99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))) (t_1 (* 0.5 (cos re))))
(if (or (<= t_0 -5.0) (not (<= t_0 2e-12)))
(* t_1 t_0)
(*
t_1
(+
(* im -2.0)
(+
(* (pow im 3.0) -0.3333333333333333)
(* (pow im 5.0) -0.016666666666666666)))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double t_1 = 0.5 * cos(re);
double tmp;
if ((t_0 <= -5.0) || !(t_0 <= 2e-12)) {
tmp = t_1 * t_0;
} else {
tmp = t_1 * ((im * -2.0) + ((pow(im, 3.0) * -0.3333333333333333) + (pow(im, 5.0) * -0.016666666666666666)));
}
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 = 0.5d0 * cos(re)
if ((t_0 <= (-5.0d0)) .or. (.not. (t_0 <= 2d-12))) then
tmp = t_1 * t_0
else
tmp = t_1 * ((im * (-2.0d0)) + (((im ** 3.0d0) * (-0.3333333333333333d0)) + ((im ** 5.0d0) * (-0.016666666666666666d0))))
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 = 0.5 * Math.cos(re);
double tmp;
if ((t_0 <= -5.0) || !(t_0 <= 2e-12)) {
tmp = t_1 * t_0;
} else {
tmp = t_1 * ((im * -2.0) + ((Math.pow(im, 3.0) * -0.3333333333333333) + (Math.pow(im, 5.0) * -0.016666666666666666)));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) t_1 = 0.5 * math.cos(re) tmp = 0 if (t_0 <= -5.0) or not (t_0 <= 2e-12): tmp = t_1 * t_0 else: tmp = t_1 * ((im * -2.0) + ((math.pow(im, 3.0) * -0.3333333333333333) + (math.pow(im, 5.0) * -0.016666666666666666))) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) t_1 = Float64(0.5 * cos(re)) tmp = 0.0 if ((t_0 <= -5.0) || !(t_0 <= 2e-12)) tmp = Float64(t_1 * t_0); else tmp = Float64(t_1 * Float64(Float64(im * -2.0) + Float64(Float64((im ^ 3.0) * -0.3333333333333333) + Float64((im ^ 5.0) * -0.016666666666666666)))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); t_1 = 0.5 * cos(re); tmp = 0.0; if ((t_0 <= -5.0) || ~((t_0 <= 2e-12))) tmp = t_1 * t_0; else tmp = t_1 * ((im * -2.0) + (((im ^ 3.0) * -0.3333333333333333) + ((im ^ 5.0) * -0.016666666666666666))); 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[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5.0], N[Not[LessEqual[t$95$0, 2e-12]], $MachinePrecision]], N[(t$95$1 * t$95$0), $MachinePrecision], N[(t$95$1 * N[(N[(im * -2.0), $MachinePrecision] + N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := 0.5 \cdot \cos re\\
\mathbf{if}\;t_0 \leq -5 \lor \neg \left(t_0 \leq 2 \cdot 10^{-12}\right):\\
\;\;\;\;t_1 \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(im \cdot -2 + \left({im}^{3} \cdot -0.3333333333333333 + {im}^{5} \cdot -0.016666666666666666\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -5 or 1.99999999999999996e-12 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
if -5 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1.99999999999999996e-12Initial program 9.3%
neg-sub09.3%
Simplified9.3%
Taylor expanded in im around 0 99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (or (<= t_0 -0.002) (not (<= t_0 2e-12)))
(* (* 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 <= -0.002) || !(t_0 <= 2e-12)) {
tmp = (0.5 * cos(re)) * t_0;
} else {
tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-im) - exp(im)
if ((t_0 <= (-0.002d0)) .or. (.not. (t_0 <= 2d-12))) then
tmp = (0.5d0 * cos(re)) * t_0
else
tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double tmp;
if ((t_0 <= -0.002) || !(t_0 <= 2e-12)) {
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 <= -0.002) or not (t_0 <= 2e-12): 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 <= -0.002) || !(t_0 <= 2e-12)) 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 <= -0.002) || ~((t_0 <= 2e-12))) 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, -0.002], N[Not[LessEqual[t$95$0, 2e-12]], $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 -0.002 \lor \neg \left(t_0 \leq 2 \cdot 10^{-12}\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)) < -2e-3 or 1.99999999999999996e-12 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
if -2e-3 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1.99999999999999996e-12Initial program 8.7%
neg-sub08.7%
Simplified8.7%
Taylor expanded in im around 0 99.9%
+-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
associate-*r*99.9%
distribute-rgt-out--99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(if (or (<= im -7.5e+94)
(not (or (<= im -130.0) (and (not (<= im 2.0)) (<= im 5.6e+102)))))
(* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))
(* (- (exp (- im)) (exp im)) (+ 0.5 (* -0.25 (* re re))))))
double code(double re, double im) {
double tmp;
if ((im <= -7.5e+94) || !((im <= -130.0) || (!(im <= 2.0) && (im <= 5.6e+102)))) {
tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else {
tmp = (exp(-im) - exp(im)) * (0.5 + (-0.25 * (re * re)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-7.5d+94)) .or. (.not. (im <= (-130.0d0)) .or. (.not. (im <= 2.0d0)) .and. (im <= 5.6d+102))) then
tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else
tmp = (exp(-im) - exp(im)) * (0.5d0 + ((-0.25d0) * (re * re)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -7.5e+94) || !((im <= -130.0) || (!(im <= 2.0) && (im <= 5.6e+102)))) {
tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else {
tmp = (Math.exp(-im) - Math.exp(im)) * (0.5 + (-0.25 * (re * re)));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -7.5e+94) or not ((im <= -130.0) or (not (im <= 2.0) and (im <= 5.6e+102))): tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) else: tmp = (math.exp(-im) - math.exp(im)) * (0.5 + (-0.25 * (re * re))) return tmp
function code(re, im) tmp = 0.0 if ((im <= -7.5e+94) || !((im <= -130.0) || (!(im <= 2.0) && (im <= 5.6e+102)))) tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); else tmp = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 + Float64(-0.25 * Float64(re * re)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -7.5e+94) || ~(((im <= -130.0) || (~((im <= 2.0)) && (im <= 5.6e+102))))) tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im); else tmp = (exp(-im) - exp(im)) * (0.5 + (-0.25 * (re * re))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -7.5e+94], N[Not[Or[LessEqual[im, -130.0], And[N[Not[LessEqual[im, 2.0]], $MachinePrecision], LessEqual[im, 5.6e+102]]]], $MachinePrecision]], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -7.5 \cdot 10^{+94} \lor \neg \left(im \leq -130 \lor \neg \left(im \leq 2\right) \land im \leq 5.6 \cdot 10^{+102}\right):\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if im < -7.49999999999999978e94 or -130 < im < 2 or 5.60000000000000037e102 < im Initial program 46.3%
neg-sub046.3%
Simplified46.3%
Taylor expanded in im around 0 98.3%
+-commutative98.3%
mul-1-neg98.3%
unsub-neg98.3%
associate-*r*98.3%
distribute-rgt-out--98.3%
*-commutative98.3%
Simplified98.3%
if -7.49999999999999978e94 < im < -130 or 2 < im < 5.60000000000000037e102Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 3.0%
+-commutative3.0%
associate-*r*3.0%
distribute-rgt-out84.8%
unpow284.8%
Simplified84.8%
Final simplification96.6%
(FPCore (re im)
:precision binary64
(if (or (<= im -5.5e+102)
(not (or (<= im -0.072) (and (not (<= im 2.0)) (<= im 5.6e+102)))))
(* (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 <= -5.5e+102) || !((im <= -0.072) || (!(im <= 2.0) && (im <= 5.6e+102)))) {
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 <= (-5.5d+102)) .or. (.not. (im <= (-0.072d0)) .or. (.not. (im <= 2.0d0)) .and. (im <= 5.6d+102))) 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 <= -5.5e+102) || !((im <= -0.072) || (!(im <= 2.0) && (im <= 5.6e+102)))) {
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 <= -5.5e+102) or not ((im <= -0.072) or (not (im <= 2.0) and (im <= 5.6e+102))): 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 <= -5.5e+102) || !((im <= -0.072) || (!(im <= 2.0) && (im <= 5.6e+102)))) 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 <= -5.5e+102) || ~(((im <= -0.072) || (~((im <= 2.0)) && (im <= 5.6e+102))))) 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, -5.5e+102], N[Not[Or[LessEqual[im, -0.072], And[N[Not[LessEqual[im, 2.0]], $MachinePrecision], LessEqual[im, 5.6e+102]]]], $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 -5.5 \cdot 10^{+102} \lor \neg \left(im \leq -0.072 \lor \neg \left(im \leq 2\right) \land im \leq 5.6 \cdot 10^{+102}\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 < -5.49999999999999981e102 or -0.0719999999999999946 < im < 2 or 5.60000000000000037e102 < im Initial program 45.6%
neg-sub045.6%
Simplified45.6%
Taylor expanded in im around 0 99.5%
+-commutative99.5%
mul-1-neg99.5%
unsub-neg99.5%
associate-*r*99.5%
distribute-rgt-out--99.5%
*-commutative99.5%
Simplified99.5%
if -5.49999999999999981e102 < im < -0.0719999999999999946 or 2 < im < 5.60000000000000037e102Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 70.0%
Final simplification95.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im)))
(if (<= im -3e+234)
t_0
(if (<= im -2.1e+70)
(* t_0 (+ 1.0 (* re (* re -0.5))))
(if (or (<= im -0.00105) (not (<= im 2.0)))
(* 0.5 (- (exp (- im)) (exp im)))
(* im (- (cos re))))))))
double code(double re, double im) {
double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
double tmp;
if (im <= -3e+234) {
tmp = t_0;
} else if (im <= -2.1e+70) {
tmp = t_0 * (1.0 + (re * (re * -0.5)));
} else if ((im <= -0.00105) || !(im <= 2.0)) {
tmp = 0.5 * (exp(-im) - exp(im));
} else {
tmp = im * -cos(re);
}
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 ** 3.0d0) * (-0.16666666666666666d0)) - im
if (im <= (-3d+234)) then
tmp = t_0
else if (im <= (-2.1d+70)) then
tmp = t_0 * (1.0d0 + (re * (re * (-0.5d0))))
else if ((im <= (-0.00105d0)) .or. (.not. (im <= 2.0d0))) then
tmp = 0.5d0 * (exp(-im) - exp(im))
else
tmp = im * -cos(re)
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;
double tmp;
if (im <= -3e+234) {
tmp = t_0;
} else if (im <= -2.1e+70) {
tmp = t_0 * (1.0 + (re * (re * -0.5)));
} else if ((im <= -0.00105) || !(im <= 2.0)) {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
} else {
tmp = im * -Math.cos(re);
}
return tmp;
}
def code(re, im): t_0 = (math.pow(im, 3.0) * -0.16666666666666666) - im tmp = 0 if im <= -3e+234: tmp = t_0 elif im <= -2.1e+70: tmp = t_0 * (1.0 + (re * (re * -0.5))) elif (im <= -0.00105) or not (im <= 2.0): tmp = 0.5 * (math.exp(-im) - math.exp(im)) else: tmp = im * -math.cos(re) return tmp
function code(re, im) t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) tmp = 0.0 if (im <= -3e+234) tmp = t_0; elseif (im <= -2.1e+70) tmp = Float64(t_0 * Float64(1.0 + Float64(re * Float64(re * -0.5)))); elseif ((im <= -0.00105) || !(im <= 2.0)) tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); else tmp = Float64(im * Float64(-cos(re))); end return tmp end
function tmp_2 = code(re, im) t_0 = ((im ^ 3.0) * -0.16666666666666666) - im; tmp = 0.0; if (im <= -3e+234) tmp = t_0; elseif (im <= -2.1e+70) tmp = t_0 * (1.0 + (re * (re * -0.5))); elseif ((im <= -0.00105) || ~((im <= 2.0))) tmp = 0.5 * (exp(-im) - exp(im)); else tmp = im * -cos(re); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, If[LessEqual[im, -3e+234], t$95$0, If[LessEqual[im, -2.1e+70], N[(t$95$0 * N[(1.0 + N[(re * N[(re * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, -0.00105], N[Not[LessEqual[im, 2.0]], $MachinePrecision]], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{if}\;im \leq -3 \cdot 10^{+234}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -2.1 \cdot 10^{+70}:\\
\;\;\;\;t_0 \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\
\mathbf{elif}\;im \leq -0.00105 \lor \neg \left(im \leq 2\right):\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\end{array}
\end{array}
if im < -2.9999999999999999e234Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in re around 0 90.0%
if -2.9999999999999999e234 < im < -2.10000000000000008e70Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 83.6%
+-commutative83.6%
mul-1-neg83.6%
unsub-neg83.6%
associate-*r*83.6%
distribute-rgt-out--83.6%
*-commutative83.6%
Simplified83.6%
Taylor expanded in re around 0 9.0%
associate--l+9.0%
associate-*r*9.0%
distribute-lft1-in76.6%
*-commutative76.6%
+-commutative76.6%
unpow276.6%
associate-*r*76.6%
*-commutative76.6%
Simplified76.6%
if -2.10000000000000008e70 < im < -0.00104999999999999994 or 2 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 72.7%
if -0.00104999999999999994 < im < 2Initial program 10.0%
neg-sub010.0%
Simplified10.0%
Taylor expanded in im around 0 98.5%
associate-*r*98.5%
neg-mul-198.5%
Simplified98.5%
Final simplification88.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im)))
(if (<= im -7.8e+233)
t_0
(if (or (<= im -49000000.0) (not (<= im 6.5)))
(* t_0 (+ 1.0 (* re (* re -0.5))))
(* im (- (cos re)))))))
double code(double re, double im) {
double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
double tmp;
if (im <= -7.8e+233) {
tmp = t_0;
} else if ((im <= -49000000.0) || !(im <= 6.5)) {
tmp = t_0 * (1.0 + (re * (re * -0.5)));
} else {
tmp = im * -cos(re);
}
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 ** 3.0d0) * (-0.16666666666666666d0)) - im
if (im <= (-7.8d+233)) then
tmp = t_0
else if ((im <= (-49000000.0d0)) .or. (.not. (im <= 6.5d0))) then
tmp = t_0 * (1.0d0 + (re * (re * (-0.5d0))))
else
tmp = im * -cos(re)
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;
double tmp;
if (im <= -7.8e+233) {
tmp = t_0;
} else if ((im <= -49000000.0) || !(im <= 6.5)) {
tmp = t_0 * (1.0 + (re * (re * -0.5)));
} else {
tmp = im * -Math.cos(re);
}
return tmp;
}
def code(re, im): t_0 = (math.pow(im, 3.0) * -0.16666666666666666) - im tmp = 0 if im <= -7.8e+233: tmp = t_0 elif (im <= -49000000.0) or not (im <= 6.5): tmp = t_0 * (1.0 + (re * (re * -0.5))) else: tmp = im * -math.cos(re) return tmp
function code(re, im) t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) tmp = 0.0 if (im <= -7.8e+233) tmp = t_0; elseif ((im <= -49000000.0) || !(im <= 6.5)) tmp = Float64(t_0 * Float64(1.0 + Float64(re * Float64(re * -0.5)))); else tmp = Float64(im * Float64(-cos(re))); end return tmp end
function tmp_2 = code(re, im) t_0 = ((im ^ 3.0) * -0.16666666666666666) - im; tmp = 0.0; if (im <= -7.8e+233) tmp = t_0; elseif ((im <= -49000000.0) || ~((im <= 6.5))) tmp = t_0 * (1.0 + (re * (re * -0.5))); else tmp = im * -cos(re); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, If[LessEqual[im, -7.8e+233], t$95$0, If[Or[LessEqual[im, -49000000.0], N[Not[LessEqual[im, 6.5]], $MachinePrecision]], N[(t$95$0 * N[(1.0 + N[(re * N[(re * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{if}\;im \leq -7.8 \cdot 10^{+233}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -49000000 \lor \neg \left(im \leq 6.5\right):\\
\;\;\;\;t_0 \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\end{array}
\end{array}
if im < -7.7999999999999998e233Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in re around 0 90.0%
if -7.7999999999999998e233 < im < -4.9e7 or 6.5 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 70.2%
+-commutative70.2%
mul-1-neg70.2%
unsub-neg70.2%
associate-*r*70.2%
distribute-rgt-out--70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in re around 0 10.2%
associate--l+10.2%
associate-*r*10.2%
distribute-lft1-in60.2%
*-commutative60.2%
+-commutative60.2%
unpow260.2%
associate-*r*60.2%
*-commutative60.2%
Simplified60.2%
if -4.9e7 < im < 6.5Initial program 13.3%
neg-sub013.3%
Simplified13.3%
Taylor expanded in im around 0 95.1%
associate-*r*95.1%
neg-mul-195.1%
Simplified95.1%
Final simplification81.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im)))
(if (<= im -2.75e+122)
t_0
(if (<= im -6.8e+16)
(* re (* t_0 (* re -0.5)))
(if (<= im 2.35e+53) (* im (- (cos re))) t_0)))))
double code(double re, double im) {
double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
double tmp;
if (im <= -2.75e+122) {
tmp = t_0;
} else if (im <= -6.8e+16) {
tmp = re * (t_0 * (re * -0.5));
} else if (im <= 2.35e+53) {
tmp = im * -cos(re);
} 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 ** 3.0d0) * (-0.16666666666666666d0)) - im
if (im <= (-2.75d+122)) then
tmp = t_0
else if (im <= (-6.8d+16)) then
tmp = re * (t_0 * (re * (-0.5d0)))
else if (im <= 2.35d+53) then
tmp = im * -cos(re)
else
tmp = t_0
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;
double tmp;
if (im <= -2.75e+122) {
tmp = t_0;
} else if (im <= -6.8e+16) {
tmp = re * (t_0 * (re * -0.5));
} else if (im <= 2.35e+53) {
tmp = im * -Math.cos(re);
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = (math.pow(im, 3.0) * -0.16666666666666666) - im tmp = 0 if im <= -2.75e+122: tmp = t_0 elif im <= -6.8e+16: tmp = re * (t_0 * (re * -0.5)) elif im <= 2.35e+53: tmp = im * -math.cos(re) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) tmp = 0.0 if (im <= -2.75e+122) tmp = t_0; elseif (im <= -6.8e+16) tmp = Float64(re * Float64(t_0 * Float64(re * -0.5))); elseif (im <= 2.35e+53) tmp = Float64(im * Float64(-cos(re))); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = ((im ^ 3.0) * -0.16666666666666666) - im; tmp = 0.0; if (im <= -2.75e+122) tmp = t_0; elseif (im <= -6.8e+16) tmp = re * (t_0 * (re * -0.5)); elseif (im <= 2.35e+53) tmp = im * -cos(re); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, If[LessEqual[im, -2.75e+122], t$95$0, If[LessEqual[im, -6.8e+16], N[(re * N[(t$95$0 * N[(re * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.35e+53], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{if}\;im \leq -2.75 \cdot 10^{+122}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -6.8 \cdot 10^{+16}:\\
\;\;\;\;re \cdot \left(t_0 \cdot \left(re \cdot -0.5\right)\right)\\
\mathbf{elif}\;im \leq 2.35 \cdot 10^{+53}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -2.7499999999999999e122 or 2.34999999999999988e53 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 91.9%
+-commutative91.9%
mul-1-neg91.9%
unsub-neg91.9%
associate-*r*91.9%
distribute-rgt-out--91.9%
*-commutative91.9%
Simplified91.9%
Taylor expanded in re around 0 69.0%
if -2.7499999999999999e122 < im < -6.8e16Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 21.3%
+-commutative21.3%
mul-1-neg21.3%
unsub-neg21.3%
associate-*r*21.3%
distribute-rgt-out--21.3%
*-commutative21.3%
Simplified21.3%
Taylor expanded in re around 0 29.3%
associate--l+29.3%
associate-*r*29.3%
distribute-lft1-in46.0%
*-commutative46.0%
+-commutative46.0%
unpow246.0%
associate-*r*46.0%
*-commutative46.0%
Simplified46.0%
Taylor expanded in re around inf 39.3%
associate-*r*39.3%
*-commutative39.3%
unpow239.3%
associate-*r*39.3%
*-commutative39.3%
associate-*l*39.3%
*-commutative39.3%
Simplified39.3%
if -6.8e16 < im < 2.34999999999999988e53Initial program 18.0%
neg-sub018.0%
Simplified18.0%
Taylor expanded in im around 0 90.1%
associate-*r*90.1%
neg-mul-190.1%
Simplified90.1%
Final simplification79.0%
(FPCore (re im) :precision binary64 (if (or (<= im -6.5e+86) (not (<= im 1.7e+53))) (- (* (pow im 3.0) -0.16666666666666666) im) (* im (- (cos re)))))
double code(double re, double im) {
double tmp;
if ((im <= -6.5e+86) || !(im <= 1.7e+53)) {
tmp = (pow(im, 3.0) * -0.16666666666666666) - im;
} else {
tmp = im * -cos(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-6.5d+86)) .or. (.not. (im <= 1.7d+53))) then
tmp = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
else
tmp = im * -cos(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -6.5e+86) || !(im <= 1.7e+53)) {
tmp = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
} else {
tmp = im * -Math.cos(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -6.5e+86) or not (im <= 1.7e+53): tmp = (math.pow(im, 3.0) * -0.16666666666666666) - im else: tmp = im * -math.cos(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -6.5e+86) || !(im <= 1.7e+53)) tmp = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im); else tmp = Float64(im * Float64(-cos(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -6.5e+86) || ~((im <= 1.7e+53))) tmp = ((im ^ 3.0) * -0.16666666666666666) - im; else tmp = im * -cos(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -6.5e+86], N[Not[LessEqual[im, 1.7e+53]], $MachinePrecision]], N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -6.5 \cdot 10^{+86} \lor \neg \left(im \leq 1.7 \cdot 10^{+53}\right):\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\end{array}
\end{array}
if im < -6.49999999999999996e86 or 1.69999999999999999e53 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 90.4%
+-commutative90.4%
mul-1-neg90.4%
unsub-neg90.4%
associate-*r*90.4%
distribute-rgt-out--90.4%
*-commutative90.4%
Simplified90.4%
Taylor expanded in re around 0 66.7%
if -6.49999999999999996e86 < im < 1.69999999999999999e53Initial program 24.7%
neg-sub024.7%
Simplified24.7%
Taylor expanded in im around 0 83.0%
associate-*r*83.0%
neg-mul-183.0%
Simplified83.0%
Final simplification76.8%
(FPCore (re im) :precision binary64 (if (or (<= im -8.5e+16) (not (<= im 6.5))) (- (* im (* 0.5 (* re re))) im) (* im (- (cos re)))))
double code(double re, double im) {
double tmp;
if ((im <= -8.5e+16) || !(im <= 6.5)) {
tmp = (im * (0.5 * (re * re))) - im;
} else {
tmp = im * -cos(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-8.5d+16)) .or. (.not. (im <= 6.5d0))) then
tmp = (im * (0.5d0 * (re * re))) - im
else
tmp = im * -cos(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -8.5e+16) || !(im <= 6.5)) {
tmp = (im * (0.5 * (re * re))) - im;
} else {
tmp = im * -Math.cos(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -8.5e+16) or not (im <= 6.5): tmp = (im * (0.5 * (re * re))) - im else: tmp = im * -math.cos(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -8.5e+16) || !(im <= 6.5)) tmp = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im); else tmp = Float64(im * Float64(-cos(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -8.5e+16) || ~((im <= 6.5))) tmp = (im * (0.5 * (re * re))) - im; else tmp = im * -cos(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -8.5e+16], N[Not[LessEqual[im, 6.5]], $MachinePrecision]], N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -8.5 \cdot 10^{+16} \lor \neg \left(im \leq 6.5\right):\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\end{array}
\end{array}
if im < -8.5e16 or 6.5 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 5.8%
associate-*r*5.8%
neg-mul-15.8%
Simplified5.8%
Taylor expanded in re around 0 26.3%
neg-mul-126.3%
+-commutative26.3%
unsub-neg26.3%
associate-*r*26.3%
*-commutative26.3%
associate-*l*26.3%
*-commutative26.3%
unpow226.3%
Simplified26.3%
if -8.5e16 < im < 6.5Initial program 14.5%
neg-sub014.5%
Simplified14.5%
Taylor expanded in im around 0 93.8%
associate-*r*93.8%
neg-mul-193.8%
Simplified93.8%
Final simplification63.2%
(FPCore (re im) :precision binary64 (if (<= re 3.9e+158) (- (* im (* 0.5 (* re re))) im) (* (* re re) 0.75)))
double code(double re, double im) {
double tmp;
if (re <= 3.9e+158) {
tmp = (im * (0.5 * (re * re))) - 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 <= 3.9d+158) then
tmp = (im * (0.5d0 * (re * re))) - 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 <= 3.9e+158) {
tmp = (im * (0.5 * (re * re))) - im;
} else {
tmp = (re * re) * 0.75;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 3.9e+158: tmp = (im * (0.5 * (re * re))) - im else: tmp = (re * re) * 0.75 return tmp
function code(re, im) tmp = 0.0 if (re <= 3.9e+158) tmp = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im); else tmp = Float64(Float64(re * re) * 0.75); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 3.9e+158) tmp = (im * (0.5 * (re * re))) - im; else tmp = (re * re) * 0.75; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 3.9e+158], N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.9 \cdot 10^{+158}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot 0.75\\
\end{array}
\end{array}
if re < 3.9e158Initial program 53.5%
neg-sub053.5%
Simplified53.5%
Taylor expanded in im around 0 53.5%
associate-*r*53.5%
neg-mul-153.5%
Simplified53.5%
Taylor expanded in re around 0 39.0%
neg-mul-139.0%
+-commutative39.0%
unsub-neg39.0%
associate-*r*39.0%
*-commutative39.0%
associate-*l*39.0%
*-commutative39.0%
unpow239.0%
Simplified39.0%
if 3.9e158 < re Initial program 51.7%
neg-sub051.7%
Simplified51.7%
Taylor expanded in re around 0 0.1%
+-commutative0.1%
associate-*r*0.1%
distribute-rgt-out24.4%
unpow224.4%
Simplified24.4%
Applied egg-rr34.2%
Taylor expanded in re around inf 34.2%
*-commutative34.2%
unpow234.2%
Simplified34.2%
Final simplification38.4%
(FPCore (re im) :precision binary64 (if (<= re 1.35e+161) (- im) (* (* re re) 0.75)))
double code(double re, double im) {
double tmp;
if (re <= 1.35e+161) {
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 <= 1.35d+161) 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 <= 1.35e+161) {
tmp = -im;
} else {
tmp = (re * re) * 0.75;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.35e+161: tmp = -im else: tmp = (re * re) * 0.75 return tmp
function code(re, im) tmp = 0.0 if (re <= 1.35e+161) 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 <= 1.35e+161) tmp = -im; else tmp = (re * re) * 0.75; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.35e+161], (-im), N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.35 \cdot 10^{+161}:\\
\;\;\;\;-im\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot 0.75\\
\end{array}
\end{array}
if re < 1.3499999999999999e161Initial program 53.4%
neg-sub053.4%
Simplified53.4%
Taylor expanded in im around 0 53.7%
associate-*r*53.7%
neg-mul-153.7%
Simplified53.7%
Taylor expanded in re around 0 33.3%
neg-mul-133.3%
Simplified33.3%
if 1.3499999999999999e161 < re Initial program 51.9%
neg-sub051.9%
Simplified51.9%
Taylor expanded in re around 0 0.1%
+-commutative0.1%
associate-*r*0.1%
distribute-rgt-out25.9%
unpow225.9%
Simplified25.9%
Applied egg-rr36.3%
Taylor expanded in re around inf 36.3%
*-commutative36.3%
unpow236.3%
Simplified36.3%
Final simplification33.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 53.2%
neg-sub053.2%
Simplified53.2%
Taylor expanded in im around 0 53.9%
associate-*r*53.9%
neg-mul-153.9%
Simplified53.9%
Taylor expanded in re around 0 30.2%
neg-mul-130.2%
Simplified30.2%
Final simplification30.2%
(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 53.2%
neg-sub053.2%
Simplified53.2%
Taylor expanded in re around 0 3.4%
+-commutative3.4%
associate-*r*3.4%
distribute-rgt-out37.8%
unpow237.8%
Simplified37.8%
Applied egg-rr10.4%
Taylor expanded in re around 0 3.1%
Final simplification3.1%
(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 2023279
(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))))