
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(-im) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp(-im) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(-im) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(-im) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp(-im) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(-im) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-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 5e-14)))
(* t_0 (* 0.5 (sin re)))
(* (sin 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 <= 5e-14)) {
tmp = t_0 * (0.5 * sin(re));
} else {
tmp = sin(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 <= 5e-14)) {
tmp = t_0 * (0.5 * Math.sin(re));
} else {
tmp = Math.sin(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 <= 5e-14): tmp = t_0 * (0.5 * math.sin(re)) else: tmp = math.sin(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 <= 5e-14)) tmp = Float64(t_0 * Float64(0.5 * sin(re))); else tmp = Float64(sin(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 <= 5e-14))) tmp = t_0 * (0.5 * sin(re)); else tmp = sin(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, 5e-14]], $MachinePrecision]], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[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 5 \cdot 10^{-14}\right):\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -inf.0 or 5.0000000000000002e-14 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
if -inf.0 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 5.0000000000000002e-14Initial program 28.4%
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
(let* ((t_0 (* 0.5 (* (- (exp (- im)) (exp im)) re)))
(t_1 (* -0.16666666666666666 (* (sin re) (pow im 3.0)))))
(if (<= im -2.7e+101)
t_1
(if (<= im -0.066)
t_0
(if (<= im 0.00095)
(* im (- (sin re)))
(if (<= im 5.5e+102) t_0 t_1))))))
double code(double re, double im) {
double t_0 = 0.5 * ((exp(-im) - exp(im)) * re);
double t_1 = -0.16666666666666666 * (sin(re) * pow(im, 3.0));
double tmp;
if (im <= -2.7e+101) {
tmp = t_1;
} else if (im <= -0.066) {
tmp = t_0;
} else if (im <= 0.00095) {
tmp = im * -sin(re);
} else if (im <= 5.5e+102) {
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)) * re)
t_1 = (-0.16666666666666666d0) * (sin(re) * (im ** 3.0d0))
if (im <= (-2.7d+101)) then
tmp = t_1
else if (im <= (-0.066d0)) then
tmp = t_0
else if (im <= 0.00095d0) then
tmp = im * -sin(re)
else if (im <= 5.5d+102) 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)) * re);
double t_1 = -0.16666666666666666 * (Math.sin(re) * Math.pow(im, 3.0));
double tmp;
if (im <= -2.7e+101) {
tmp = t_1;
} else if (im <= -0.066) {
tmp = t_0;
} else if (im <= 0.00095) {
tmp = im * -Math.sin(re);
} else if (im <= 5.5e+102) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * ((math.exp(-im) - math.exp(im)) * re) t_1 = -0.16666666666666666 * (math.sin(re) * math.pow(im, 3.0)) tmp = 0 if im <= -2.7e+101: tmp = t_1 elif im <= -0.066: tmp = t_0 elif im <= 0.00095: tmp = im * -math.sin(re) elif im <= 5.5e+102: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(Float64(exp(Float64(-im)) - exp(im)) * re)) t_1 = Float64(-0.16666666666666666 * Float64(sin(re) * (im ^ 3.0))) tmp = 0.0 if (im <= -2.7e+101) tmp = t_1; elseif (im <= -0.066) tmp = t_0; elseif (im <= 0.00095) tmp = Float64(im * Float64(-sin(re))); elseif (im <= 5.5e+102) 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)) * re); t_1 = -0.16666666666666666 * (sin(re) * (im ^ 3.0)); tmp = 0.0; if (im <= -2.7e+101) tmp = t_1; elseif (im <= -0.066) tmp = t_0; elseif (im <= 0.00095) tmp = im * -sin(re); elseif (im <= 5.5e+102) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.16666666666666666 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.7e+101], t$95$1, If[LessEqual[im, -0.066], t$95$0, If[LessEqual[im, 0.00095], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 5.5e+102], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\
t_1 := -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\
\mathbf{if}\;im \leq -2.7 \cdot 10^{+101}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.066:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.00095:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{elif}\;im \leq 5.5 \cdot 10^{+102}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -2.70000000000000006e101 or 5.49999999999999981e102 < im Initial program 100.0%
Taylor expanded in im around 0 99.0%
mul-1-neg99.0%
unsub-neg99.0%
*-commutative99.0%
associate-*l*99.0%
distribute-lft-out--99.0%
Simplified99.0%
Taylor expanded in im around inf 99.0%
if -2.70000000000000006e101 < im < -0.066000000000000003 or 9.49999999999999998e-4 < im < 5.49999999999999981e102Initial program 100.0%
Taylor expanded in re around 0 75.9%
if -0.066000000000000003 < im < 9.49999999999999998e-4Initial program 28.4%
Taylor expanded in im around 0 99.7%
mul-1-neg99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Final simplification94.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (* (- (exp (- im)) (exp im)) re)))
(t_1 (* -0.16666666666666666 (* (sin re) (pow im 3.0)))))
(if (<= im -2.7e+101)
t_1
(if (<= im -0.085)
t_0
(if (<= im 0.105)
(* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
(if (<= im 5.5e+102) t_0 t_1))))))
double code(double re, double im) {
double t_0 = 0.5 * ((exp(-im) - exp(im)) * re);
double t_1 = -0.16666666666666666 * (sin(re) * pow(im, 3.0));
double tmp;
if (im <= -2.7e+101) {
tmp = t_1;
} else if (im <= -0.085) {
tmp = t_0;
} else if (im <= 0.105) {
tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 5.5e+102) {
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)) * re)
t_1 = (-0.16666666666666666d0) * (sin(re) * (im ** 3.0d0))
if (im <= (-2.7d+101)) then
tmp = t_1
else if (im <= (-0.085d0)) then
tmp = t_0
else if (im <= 0.105d0) then
tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else if (im <= 5.5d+102) 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)) * re);
double t_1 = -0.16666666666666666 * (Math.sin(re) * Math.pow(im, 3.0));
double tmp;
if (im <= -2.7e+101) {
tmp = t_1;
} else if (im <= -0.085) {
tmp = t_0;
} else if (im <= 0.105) {
tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 5.5e+102) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * ((math.exp(-im) - math.exp(im)) * re) t_1 = -0.16666666666666666 * (math.sin(re) * math.pow(im, 3.0)) tmp = 0 if im <= -2.7e+101: tmp = t_1 elif im <= -0.085: tmp = t_0 elif im <= 0.105: tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) elif im <= 5.5e+102: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(Float64(exp(Float64(-im)) - exp(im)) * re)) t_1 = Float64(-0.16666666666666666 * Float64(sin(re) * (im ^ 3.0))) tmp = 0.0 if (im <= -2.7e+101) tmp = t_1; elseif (im <= -0.085) tmp = t_0; elseif (im <= 0.105) tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); elseif (im <= 5.5e+102) 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)) * re); t_1 = -0.16666666666666666 * (sin(re) * (im ^ 3.0)); tmp = 0.0; if (im <= -2.7e+101) tmp = t_1; elseif (im <= -0.085) tmp = t_0; elseif (im <= 0.105) tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im); elseif (im <= 5.5e+102) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.16666666666666666 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.7e+101], t$95$1, If[LessEqual[im, -0.085], t$95$0, If[LessEqual[im, 0.105], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5.5e+102], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\
t_1 := -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\
\mathbf{if}\;im \leq -2.7 \cdot 10^{+101}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.085:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.105:\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{elif}\;im \leq 5.5 \cdot 10^{+102}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -2.70000000000000006e101 or 5.49999999999999981e102 < im Initial program 100.0%
Taylor expanded in im around 0 99.0%
mul-1-neg99.0%
unsub-neg99.0%
*-commutative99.0%
associate-*l*99.0%
distribute-lft-out--99.0%
Simplified99.0%
Taylor expanded in im around inf 99.0%
if -2.70000000000000006e101 < im < -0.0850000000000000061 or 0.104999999999999996 < im < 5.49999999999999981e102Initial program 100.0%
Taylor expanded in re around 0 75.9%
if -0.0850000000000000061 < im < 0.104999999999999996Initial program 28.4%
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 simplification94.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (log (/ 1.0 (+ 1.0 (expm1 (* im re))))))
(t_1 (* -0.16666666666666666 (* (sin re) (pow im 3.0)))))
(if (<= im -1.15e+99)
t_1
(if (<= im -620.0)
t_0
(if (<= im 680.0) (* im (- (sin re))) (if (<= im 5.5e+102) t_0 t_1))))))
double code(double re, double im) {
double t_0 = log((1.0 / (1.0 + expm1((im * re)))));
double t_1 = -0.16666666666666666 * (sin(re) * pow(im, 3.0));
double tmp;
if (im <= -1.15e+99) {
tmp = t_1;
} else if (im <= -620.0) {
tmp = t_0;
} else if (im <= 680.0) {
tmp = im * -sin(re);
} else if (im <= 5.5e+102) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = Math.log((1.0 / (1.0 + Math.expm1((im * re)))));
double t_1 = -0.16666666666666666 * (Math.sin(re) * Math.pow(im, 3.0));
double tmp;
if (im <= -1.15e+99) {
tmp = t_1;
} else if (im <= -620.0) {
tmp = t_0;
} else if (im <= 680.0) {
tmp = im * -Math.sin(re);
} else if (im <= 5.5e+102) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = math.log((1.0 / (1.0 + math.expm1((im * re))))) t_1 = -0.16666666666666666 * (math.sin(re) * math.pow(im, 3.0)) tmp = 0 if im <= -1.15e+99: tmp = t_1 elif im <= -620.0: tmp = t_0 elif im <= 680.0: tmp = im * -math.sin(re) elif im <= 5.5e+102: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = log(Float64(1.0 / Float64(1.0 + expm1(Float64(im * re))))) t_1 = Float64(-0.16666666666666666 * Float64(sin(re) * (im ^ 3.0))) tmp = 0.0 if (im <= -1.15e+99) tmp = t_1; elseif (im <= -620.0) tmp = t_0; elseif (im <= 680.0) tmp = Float64(im * Float64(-sin(re))); elseif (im <= 5.5e+102) tmp = t_0; else tmp = t_1; end return tmp end
code[re_, im_] := Block[{t$95$0 = N[Log[N[(1.0 / N[(1.0 + N[(Exp[N[(im * re), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(-0.16666666666666666 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.15e+99], t$95$1, If[LessEqual[im, -620.0], t$95$0, If[LessEqual[im, 680.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 5.5e+102], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\frac{1}{1 + \mathsf{expm1}\left(im \cdot re\right)}\right)\\
t_1 := -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\
\mathbf{if}\;im \leq -1.15 \cdot 10^{+99}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -620:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 680:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{elif}\;im \leq 5.5 \cdot 10^{+102}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -1.1500000000000001e99 or 5.49999999999999981e102 < im Initial program 100.0%
Taylor expanded in im around 0 97.9%
mul-1-neg97.9%
unsub-neg97.9%
*-commutative97.9%
associate-*l*97.9%
distribute-lft-out--97.9%
Simplified97.9%
Taylor expanded in im around inf 97.9%
if -1.1500000000000001e99 < im < -620 or 680 < im < 5.49999999999999981e102Initial program 100.0%
Taylor expanded in im around 0 3.0%
mul-1-neg3.0%
*-commutative3.0%
distribute-rgt-neg-in3.0%
Simplified3.0%
distribute-rgt-neg-out3.0%
add-sqr-sqrt1.4%
sqrt-unprod1.8%
sqr-neg1.8%
sqrt-unprod0.4%
add-sqr-sqrt0.7%
log1p-expm1-u0.4%
log1p-udef0.6%
neg-log0.6%
add-sqr-sqrt0.3%
sqrt-unprod27.0%
sqr-neg27.0%
sqrt-unprod26.8%
add-sqr-sqrt61.1%
Applied egg-rr61.1%
Taylor expanded in re around 0 36.5%
if -620 < im < 680Initial program 28.4%
Taylor expanded in im around 0 99.7%
mul-1-neg99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Final simplification86.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (log (* 0.5 (* (* re re) (* im im)))))
(t_1 (* -0.16666666666666666 (* (sin re) (pow im 3.0)))))
(if (<= im -2.75e+107)
t_1
(if (<= im -36000.0)
t_0
(if (<= im 2e+41) (* im (- (sin re))) (if (<= im 4.4e+101) t_0 t_1))))))
double code(double re, double im) {
double t_0 = log((0.5 * ((re * re) * (im * im))));
double t_1 = -0.16666666666666666 * (sin(re) * pow(im, 3.0));
double tmp;
if (im <= -2.75e+107) {
tmp = t_1;
} else if (im <= -36000.0) {
tmp = t_0;
} else if (im <= 2e+41) {
tmp = im * -sin(re);
} else if (im <= 4.4e+101) {
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 = log((0.5d0 * ((re * re) * (im * im))))
t_1 = (-0.16666666666666666d0) * (sin(re) * (im ** 3.0d0))
if (im <= (-2.75d+107)) then
tmp = t_1
else if (im <= (-36000.0d0)) then
tmp = t_0
else if (im <= 2d+41) then
tmp = im * -sin(re)
else if (im <= 4.4d+101) 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.log((0.5 * ((re * re) * (im * im))));
double t_1 = -0.16666666666666666 * (Math.sin(re) * Math.pow(im, 3.0));
double tmp;
if (im <= -2.75e+107) {
tmp = t_1;
} else if (im <= -36000.0) {
tmp = t_0;
} else if (im <= 2e+41) {
tmp = im * -Math.sin(re);
} else if (im <= 4.4e+101) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = math.log((0.5 * ((re * re) * (im * im)))) t_1 = -0.16666666666666666 * (math.sin(re) * math.pow(im, 3.0)) tmp = 0 if im <= -2.75e+107: tmp = t_1 elif im <= -36000.0: tmp = t_0 elif im <= 2e+41: tmp = im * -math.sin(re) elif im <= 4.4e+101: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = log(Float64(0.5 * Float64(Float64(re * re) * Float64(im * im)))) t_1 = Float64(-0.16666666666666666 * Float64(sin(re) * (im ^ 3.0))) tmp = 0.0 if (im <= -2.75e+107) tmp = t_1; elseif (im <= -36000.0) tmp = t_0; elseif (im <= 2e+41) tmp = Float64(im * Float64(-sin(re))); elseif (im <= 4.4e+101) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = log((0.5 * ((re * re) * (im * im)))); t_1 = -0.16666666666666666 * (sin(re) * (im ^ 3.0)); tmp = 0.0; if (im <= -2.75e+107) tmp = t_1; elseif (im <= -36000.0) tmp = t_0; elseif (im <= 2e+41) tmp = im * -sin(re); elseif (im <= 4.4e+101) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[Log[N[(0.5 * N[(N[(re * re), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(-0.16666666666666666 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.75e+107], t$95$1, If[LessEqual[im, -36000.0], t$95$0, If[LessEqual[im, 2e+41], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 4.4e+101], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)\right)\\
t_1 := -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\
\mathbf{if}\;im \leq -2.75 \cdot 10^{+107}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -36000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 2 \cdot 10^{+41}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{elif}\;im \leq 4.4 \cdot 10^{+101}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -2.7500000000000002e107 or 4.4000000000000001e101 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
if -2.7500000000000002e107 < im < -36000 or 2.00000000000000001e41 < im < 4.4000000000000001e101Initial program 100.0%
Taylor expanded in im around 0 3.1%
mul-1-neg3.1%
*-commutative3.1%
distribute-rgt-neg-in3.1%
Simplified3.1%
distribute-rgt-neg-out3.1%
add-sqr-sqrt1.3%
sqrt-unprod1.7%
sqr-neg1.7%
sqrt-unprod0.4%
add-sqr-sqrt0.7%
log1p-expm1-u0.4%
log1p-udef0.6%
neg-log0.6%
add-sqr-sqrt0.3%
sqrt-unprod24.6%
sqr-neg24.6%
sqrt-unprod24.3%
add-sqr-sqrt59.4%
Applied egg-rr59.4%
Taylor expanded in re around 0 20.5%
associate-+r+20.5%
mul-1-neg20.5%
unsub-neg20.5%
+-commutative20.5%
mul-1-neg20.5%
unsub-neg20.5%
*-commutative20.5%
distribute-rgt-out20.5%
unpow220.5%
metadata-eval20.5%
unpow220.5%
Simplified20.5%
Taylor expanded in re around inf 37.4%
*-commutative37.4%
unpow237.4%
unpow237.4%
Simplified37.4%
if -36000 < im < 2.00000000000000001e41Initial program 34.1%
Taylor expanded in im around 0 92.1%
mul-1-neg92.1%
*-commutative92.1%
distribute-rgt-neg-in92.1%
Simplified92.1%
Final simplification84.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (- (* 0.16666666666666666 (pow re 3.0)) re))))
(if (<= im -36000.0)
t_0
(if (<= im 37000000.0)
(* im (- (sin re)))
(if (<= im 1.9e+189) t_0 (* im (- re)))))))
double code(double re, double im) {
double t_0 = im * ((0.16666666666666666 * pow(re, 3.0)) - re);
double tmp;
if (im <= -36000.0) {
tmp = t_0;
} else if (im <= 37000000.0) {
tmp = im * -sin(re);
} else if (im <= 1.9e+189) {
tmp = t_0;
} else {
tmp = im * -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 * ((0.16666666666666666d0 * (re ** 3.0d0)) - re)
if (im <= (-36000.0d0)) then
tmp = t_0
else if (im <= 37000000.0d0) then
tmp = im * -sin(re)
else if (im <= 1.9d+189) then
tmp = t_0
else
tmp = im * -re
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * ((0.16666666666666666 * Math.pow(re, 3.0)) - re);
double tmp;
if (im <= -36000.0) {
tmp = t_0;
} else if (im <= 37000000.0) {
tmp = im * -Math.sin(re);
} else if (im <= 1.9e+189) {
tmp = t_0;
} else {
tmp = im * -re;
}
return tmp;
}
def code(re, im): t_0 = im * ((0.16666666666666666 * math.pow(re, 3.0)) - re) tmp = 0 if im <= -36000.0: tmp = t_0 elif im <= 37000000.0: tmp = im * -math.sin(re) elif im <= 1.9e+189: tmp = t_0 else: tmp = im * -re return tmp
function code(re, im) t_0 = Float64(im * Float64(Float64(0.16666666666666666 * (re ^ 3.0)) - re)) tmp = 0.0 if (im <= -36000.0) tmp = t_0; elseif (im <= 37000000.0) tmp = Float64(im * Float64(-sin(re))); elseif (im <= 1.9e+189) tmp = t_0; else tmp = Float64(im * Float64(-re)); end return tmp end
function tmp_2 = code(re, im) t_0 = im * ((0.16666666666666666 * (re ^ 3.0)) - re); tmp = 0.0; if (im <= -36000.0) tmp = t_0; elseif (im <= 37000000.0) tmp = im * -sin(re); elseif (im <= 1.9e+189) tmp = t_0; else tmp = im * -re; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(N[(0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -36000.0], t$95$0, If[LessEqual[im, 37000000.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.9e+189], t$95$0, N[(im * (-re)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\
\mathbf{if}\;im \leq -36000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 37000000:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{elif}\;im \leq 1.9 \cdot 10^{+189}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-re\right)\\
\end{array}
\end{array}
if im < -36000 or 3.7e7 < im < 1.8999999999999999e189Initial program 100.0%
Taylor expanded in im around 0 3.8%
mul-1-neg3.8%
*-commutative3.8%
distribute-rgt-neg-in3.8%
Simplified3.8%
Taylor expanded in re around 0 14.3%
+-commutative14.3%
mul-1-neg14.3%
unsub-neg14.3%
associate-*r*14.3%
distribute-rgt-out--22.4%
Simplified22.4%
if -36000 < im < 3.7e7Initial program 29.7%
Taylor expanded in im around 0 98.1%
mul-1-neg98.1%
*-commutative98.1%
distribute-rgt-neg-in98.1%
Simplified98.1%
if 1.8999999999999999e189 < im Initial program 100.0%
Taylor expanded in im around 0 5.5%
mul-1-neg5.5%
*-commutative5.5%
distribute-rgt-neg-in5.5%
Simplified5.5%
Taylor expanded in re around 0 38.0%
mul-1-neg38.0%
distribute-rgt-neg-in38.0%
Simplified38.0%
Final simplification59.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (- (* (pow im 3.0) -0.16666666666666666) im))))
(if (<= im -2.05e+102)
t_0
(if (<= im -36000.0)
(* im (- (* 0.16666666666666666 (pow re 3.0)) re))
(if (<= im 4.2e-7) (* im (- (sin re))) t_0)))))
double code(double re, double im) {
double t_0 = re * ((pow(im, 3.0) * -0.16666666666666666) - im);
double tmp;
if (im <= -2.05e+102) {
tmp = t_0;
} else if (im <= -36000.0) {
tmp = im * ((0.16666666666666666 * pow(re, 3.0)) - re);
} else if (im <= 4.2e-7) {
tmp = im * -sin(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 = re * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
if (im <= (-2.05d+102)) then
tmp = t_0
else if (im <= (-36000.0d0)) then
tmp = im * ((0.16666666666666666d0 * (re ** 3.0d0)) - re)
else if (im <= 4.2d-7) then
tmp = im * -sin(re)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = re * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
double tmp;
if (im <= -2.05e+102) {
tmp = t_0;
} else if (im <= -36000.0) {
tmp = im * ((0.16666666666666666 * Math.pow(re, 3.0)) - re);
} else if (im <= 4.2e-7) {
tmp = im * -Math.sin(re);
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = re * ((math.pow(im, 3.0) * -0.16666666666666666) - im) tmp = 0 if im <= -2.05e+102: tmp = t_0 elif im <= -36000.0: tmp = im * ((0.16666666666666666 * math.pow(re, 3.0)) - re) elif im <= 4.2e-7: tmp = im * -math.sin(re) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(re * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)) tmp = 0.0 if (im <= -2.05e+102) tmp = t_0; elseif (im <= -36000.0) tmp = Float64(im * Float64(Float64(0.16666666666666666 * (re ^ 3.0)) - re)); elseif (im <= 4.2e-7) tmp = Float64(im * Float64(-sin(re))); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = re * (((im ^ 3.0) * -0.16666666666666666) - im); tmp = 0.0; if (im <= -2.05e+102) tmp = t_0; elseif (im <= -36000.0) tmp = im * ((0.16666666666666666 * (re ^ 3.0)) - re); elseif (im <= 4.2e-7) tmp = im * -sin(re); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.05e+102], t$95$0, If[LessEqual[im, -36000.0], N[(im * N[(N[(0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.2e-7], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{if}\;im \leq -2.05 \cdot 10^{+102}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -36000:\\
\;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\
\mathbf{elif}\;im \leq 4.2 \cdot 10^{-7}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -2.05e102 or 4.2e-7 < im Initial program 99.7%
Taylor expanded in im around 0 80.3%
mul-1-neg80.3%
unsub-neg80.3%
*-commutative80.3%
associate-*l*80.3%
distribute-lft-out--80.3%
Simplified80.3%
Taylor expanded in re around 0 65.9%
if -2.05e102 < im < -36000Initial program 100.0%
Taylor expanded in im around 0 3.1%
mul-1-neg3.1%
*-commutative3.1%
distribute-rgt-neg-in3.1%
Simplified3.1%
Taylor expanded in re around 0 20.3%
+-commutative20.3%
mul-1-neg20.3%
unsub-neg20.3%
associate-*r*20.3%
distribute-rgt-out--23.4%
Simplified23.4%
if -36000 < im < 4.2e-7Initial program 28.7%
Taylor expanded in im around 0 99.0%
mul-1-neg99.0%
*-commutative99.0%
distribute-rgt-neg-in99.0%
Simplified99.0%
Final simplification75.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (- (* (pow im 3.0) -0.16666666666666666) im))))
(if (<= im -1.22e+77)
t_0
(if (<= im -36000.0)
(log (* 0.5 (* (* re re) (* im im))))
(if (<= im 4.2e-7) (* im (- (sin re))) t_0)))))
double code(double re, double im) {
double t_0 = re * ((pow(im, 3.0) * -0.16666666666666666) - im);
double tmp;
if (im <= -1.22e+77) {
tmp = t_0;
} else if (im <= -36000.0) {
tmp = log((0.5 * ((re * re) * (im * im))));
} else if (im <= 4.2e-7) {
tmp = im * -sin(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 = re * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
if (im <= (-1.22d+77)) then
tmp = t_0
else if (im <= (-36000.0d0)) then
tmp = log((0.5d0 * ((re * re) * (im * im))))
else if (im <= 4.2d-7) then
tmp = im * -sin(re)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = re * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
double tmp;
if (im <= -1.22e+77) {
tmp = t_0;
} else if (im <= -36000.0) {
tmp = Math.log((0.5 * ((re * re) * (im * im))));
} else if (im <= 4.2e-7) {
tmp = im * -Math.sin(re);
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = re * ((math.pow(im, 3.0) * -0.16666666666666666) - im) tmp = 0 if im <= -1.22e+77: tmp = t_0 elif im <= -36000.0: tmp = math.log((0.5 * ((re * re) * (im * im)))) elif im <= 4.2e-7: tmp = im * -math.sin(re) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(re * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)) tmp = 0.0 if (im <= -1.22e+77) tmp = t_0; elseif (im <= -36000.0) tmp = log(Float64(0.5 * Float64(Float64(re * re) * Float64(im * im)))); elseif (im <= 4.2e-7) tmp = Float64(im * Float64(-sin(re))); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = re * (((im ^ 3.0) * -0.16666666666666666) - im); tmp = 0.0; if (im <= -1.22e+77) tmp = t_0; elseif (im <= -36000.0) tmp = log((0.5 * ((re * re) * (im * im)))); elseif (im <= 4.2e-7) tmp = im * -sin(re); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.22e+77], t$95$0, If[LessEqual[im, -36000.0], N[Log[N[(0.5 * N[(N[(re * re), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 4.2e-7], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{if}\;im \leq -1.22 \cdot 10^{+77}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -36000:\\
\;\;\;\;\log \left(0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)\right)\\
\mathbf{elif}\;im \leq 4.2 \cdot 10^{-7}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.22000000000000012e77 or 4.2e-7 < im Initial program 99.7%
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 62.9%
if -1.22000000000000012e77 < im < -36000Initial program 100.0%
Taylor expanded in im around 0 3.0%
mul-1-neg3.0%
*-commutative3.0%
distribute-rgt-neg-in3.0%
Simplified3.0%
distribute-rgt-neg-out3.0%
add-sqr-sqrt1.3%
sqrt-unprod1.8%
sqr-neg1.8%
sqrt-unprod0.4%
add-sqr-sqrt0.7%
log1p-expm1-u0.4%
log1p-udef0.6%
neg-log0.6%
add-sqr-sqrt0.3%
sqrt-unprod28.7%
sqr-neg28.7%
sqrt-unprod28.3%
add-sqr-sqrt60.7%
Applied egg-rr60.7%
Taylor expanded in re around 0 21.0%
associate-+r+21.0%
mul-1-neg21.0%
unsub-neg21.0%
+-commutative21.0%
mul-1-neg21.0%
unsub-neg21.0%
*-commutative21.0%
distribute-rgt-out21.0%
unpow221.0%
metadata-eval21.0%
unpow221.0%
Simplified21.0%
Taylor expanded in re around inf 40.5%
*-commutative40.5%
unpow240.5%
unpow240.5%
Simplified40.5%
if -36000 < im < 4.2e-7Initial program 28.7%
Taylor expanded in im around 0 99.0%
mul-1-neg99.0%
*-commutative99.0%
distribute-rgt-neg-in99.0%
Simplified99.0%
Final simplification77.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.16666666666666666 (* im (pow re 3.0)))))
(if (<= im -36000.0)
t_0
(if (<= im 15800000000000.0)
(* im (- (sin re)))
(if (<= im 2.1e+190) t_0 (* im (- re)))))))
double code(double re, double im) {
double t_0 = 0.16666666666666666 * (im * pow(re, 3.0));
double tmp;
if (im <= -36000.0) {
tmp = t_0;
} else if (im <= 15800000000000.0) {
tmp = im * -sin(re);
} else if (im <= 2.1e+190) {
tmp = t_0;
} else {
tmp = im * -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 = 0.16666666666666666d0 * (im * (re ** 3.0d0))
if (im <= (-36000.0d0)) then
tmp = t_0
else if (im <= 15800000000000.0d0) then
tmp = im * -sin(re)
else if (im <= 2.1d+190) then
tmp = t_0
else
tmp = im * -re
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.16666666666666666 * (im * Math.pow(re, 3.0));
double tmp;
if (im <= -36000.0) {
tmp = t_0;
} else if (im <= 15800000000000.0) {
tmp = im * -Math.sin(re);
} else if (im <= 2.1e+190) {
tmp = t_0;
} else {
tmp = im * -re;
}
return tmp;
}
def code(re, im): t_0 = 0.16666666666666666 * (im * math.pow(re, 3.0)) tmp = 0 if im <= -36000.0: tmp = t_0 elif im <= 15800000000000.0: tmp = im * -math.sin(re) elif im <= 2.1e+190: tmp = t_0 else: tmp = im * -re return tmp
function code(re, im) t_0 = Float64(0.16666666666666666 * Float64(im * (re ^ 3.0))) tmp = 0.0 if (im <= -36000.0) tmp = t_0; elseif (im <= 15800000000000.0) tmp = Float64(im * Float64(-sin(re))); elseif (im <= 2.1e+190) tmp = t_0; else tmp = Float64(im * Float64(-re)); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.16666666666666666 * (im * (re ^ 3.0)); tmp = 0.0; if (im <= -36000.0) tmp = t_0; elseif (im <= 15800000000000.0) tmp = im * -sin(re); elseif (im <= 2.1e+190) tmp = t_0; else tmp = im * -re; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.16666666666666666 * N[(im * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -36000.0], t$95$0, If[LessEqual[im, 15800000000000.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 2.1e+190], t$95$0, N[(im * (-re)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\
\mathbf{if}\;im \leq -36000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 15800000000000:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{elif}\;im \leq 2.1 \cdot 10^{+190}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-re\right)\\
\end{array}
\end{array}
if im < -36000 or 1.58e13 < im < 2.1000000000000001e190Initial program 100.0%
Taylor expanded in im around 0 3.8%
mul-1-neg3.8%
*-commutative3.8%
distribute-rgt-neg-in3.8%
Simplified3.8%
Taylor expanded in re around 0 14.6%
Taylor expanded in re around inf 21.8%
if -36000 < im < 1.58e13Initial program 30.8%
Taylor expanded in im around 0 96.5%
mul-1-neg96.5%
*-commutative96.5%
distribute-rgt-neg-in96.5%
Simplified96.5%
if 2.1000000000000001e190 < im Initial program 100.0%
Taylor expanded in im around 0 5.5%
mul-1-neg5.5%
*-commutative5.5%
distribute-rgt-neg-in5.5%
Simplified5.5%
Taylor expanded in re around 0 38.0%
mul-1-neg38.0%
distribute-rgt-neg-in38.0%
Simplified38.0%
Final simplification58.7%
(FPCore (re im) :precision binary64 (if (<= im 6.2e+26) (* im (- (sin re))) (* im (- re))))
double code(double re, double im) {
double tmp;
if (im <= 6.2e+26) {
tmp = im * -sin(re);
} else {
tmp = im * -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.2d+26) then
tmp = im * -sin(re)
else
tmp = im * -re
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 6.2e+26) {
tmp = im * -Math.sin(re);
} else {
tmp = im * -re;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 6.2e+26: tmp = im * -math.sin(re) else: tmp = im * -re return tmp
function code(re, im) tmp = 0.0 if (im <= 6.2e+26) tmp = Float64(im * Float64(-sin(re))); else tmp = Float64(im * Float64(-re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 6.2e+26) tmp = im * -sin(re); else tmp = im * -re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 6.2e+26], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], N[(im * (-re)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 6.2 \cdot 10^{+26}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-re\right)\\
\end{array}
\end{array}
if im < 6.1999999999999999e26Initial program 56.8%
Taylor expanded in im around 0 61.6%
mul-1-neg61.6%
*-commutative61.6%
distribute-rgt-neg-in61.6%
Simplified61.6%
if 6.1999999999999999e26 < im Initial program 100.0%
Taylor expanded in im around 0 4.4%
mul-1-neg4.4%
*-commutative4.4%
distribute-rgt-neg-in4.4%
Simplified4.4%
Taylor expanded in re around 0 24.7%
mul-1-neg24.7%
distribute-rgt-neg-in24.7%
Simplified24.7%
Final simplification52.7%
(FPCore (re im) :precision binary64 (* im (- re)))
double code(double re, double im) {
return im * -re;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * -re
end function
public static double code(double re, double im) {
return im * -re;
}
def code(re, im): return im * -re
function code(re, im) return Float64(im * Float64(-re)) end
function tmp = code(re, im) tmp = im * -re; end
code[re_, im_] := N[(im * (-re)), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(-re\right)
\end{array}
Initial program 67.3%
Taylor expanded in im around 0 47.8%
mul-1-neg47.8%
*-commutative47.8%
distribute-rgt-neg-in47.8%
Simplified47.8%
Taylor expanded in re around 0 34.7%
mul-1-neg34.7%
distribute-rgt-neg-in34.7%
Simplified34.7%
Final simplification34.7%
(FPCore (re im)
:precision binary64
(if (< (fabs im) 1.0)
(-
(*
(sin re)
(+
(+ im (* (* (* 0.16666666666666666 im) im) im))
(* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))))
double code(double re, double im) {
double tmp;
if (fabs(im) < 1.0) {
tmp = -(sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * sin(re)) * (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 (abs(im) < 1.0d0) then
tmp = -(sin(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
else
tmp = (0.5d0 * sin(re)) * (exp(-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.sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if math.fabs(im) < 1.0: tmp = -(math.sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))) else: tmp = (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (abs(im) < 1.0) tmp = Float64(-Float64(sin(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 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (abs(im) < 1.0) tmp = -(sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))); else tmp = (0.5 * sin(re)) * (exp(-im) - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Sin[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[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\sin 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 \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\
\end{array}
\end{array}
herbie shell --seed 2023257
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:precision binary64
:herbie-target
(if (< (fabs im) 1.0) (- (* (sin re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))