
(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 12 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-5)))
(* 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-5)) {
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-5)) {
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-5): 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-5)) 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-5))) 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-5]], $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^{-5}\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.00000000000000024e-5 < (-.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.00000000000000024e-5Initial program 25.1%
Taylor expanded in im around 0 99.9%
mul-1-neg99.9%
unsub-neg99.9%
*-commutative99.9%
associate-*l*99.9%
distribute-lft-out--99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(if (<= im -8.2e+97)
(* -0.16666666666666666 (* (sin re) (pow im 3.0)))
(if (or (<= im -2.3e+15) (and (not (<= im 0.155)) (<= im 3.5e+94)))
(* 0.5 (* (- (exp (- im)) (exp im)) re))
(* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im)))))
double code(double re, double im) {
double tmp;
if (im <= -8.2e+97) {
tmp = -0.16666666666666666 * (sin(re) * pow(im, 3.0));
} else if ((im <= -2.3e+15) || (!(im <= 0.155) && (im <= 3.5e+94))) {
tmp = 0.5 * ((exp(-im) - exp(im)) * re);
} else {
tmp = sin(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) :: tmp
if (im <= (-8.2d+97)) then
tmp = (-0.16666666666666666d0) * (sin(re) * (im ** 3.0d0))
else if ((im <= (-2.3d+15)) .or. (.not. (im <= 0.155d0)) .and. (im <= 3.5d+94)) then
tmp = 0.5d0 * ((exp(-im) - exp(im)) * re)
else
tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -8.2e+97) {
tmp = -0.16666666666666666 * (Math.sin(re) * Math.pow(im, 3.0));
} else if ((im <= -2.3e+15) || (!(im <= 0.155) && (im <= 3.5e+94))) {
tmp = 0.5 * ((Math.exp(-im) - Math.exp(im)) * re);
} else {
tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -8.2e+97: tmp = -0.16666666666666666 * (math.sin(re) * math.pow(im, 3.0)) elif (im <= -2.3e+15) or (not (im <= 0.155) and (im <= 3.5e+94)): tmp = 0.5 * ((math.exp(-im) - math.exp(im)) * re) else: tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) return tmp
function code(re, im) tmp = 0.0 if (im <= -8.2e+97) tmp = Float64(-0.16666666666666666 * Float64(sin(re) * (im ^ 3.0))); elseif ((im <= -2.3e+15) || (!(im <= 0.155) && (im <= 3.5e+94))) tmp = Float64(0.5 * Float64(Float64(exp(Float64(-im)) - exp(im)) * re)); else tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -8.2e+97) tmp = -0.16666666666666666 * (sin(re) * (im ^ 3.0)); elseif ((im <= -2.3e+15) || (~((im <= 0.155)) && (im <= 3.5e+94))) tmp = 0.5 * ((exp(-im) - exp(im)) * re); else tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -8.2e+97], N[(-0.16666666666666666 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, -2.3e+15], And[N[Not[LessEqual[im, 0.155]], $MachinePrecision], LessEqual[im, 3.5e+94]]], N[(0.5 * N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * re), $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}
\mathbf{if}\;im \leq -8.2 \cdot 10^{+97}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\
\mathbf{elif}\;im \leq -2.3 \cdot 10^{+15} \lor \neg \left(im \leq 0.155\right) \land im \leq 3.5 \cdot 10^{+94}:\\
\;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if im < -8.19999999999999977e97Initial 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 -8.19999999999999977e97 < im < -2.3e15 or 0.154999999999999999 < im < 3.4999999999999997e94Initial program 100.0%
Taylor expanded in re around 0 75.9%
if -2.3e15 < im < 0.154999999999999999 or 3.4999999999999997e94 < im Initial program 45.8%
Taylor expanded in im around 0 97.6%
mul-1-neg97.6%
unsub-neg97.6%
*-commutative97.6%
associate-*l*97.6%
distribute-lft-out--97.6%
Simplified97.6%
Final simplification93.1%
(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 -8.2e+97)
t_1
(if (<= im -1.7e-5)
t_0
(if (<= im 0.00027)
(* im (- (sin re)))
(if (<= im 3.5e+94) 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 <= -8.2e+97) {
tmp = t_1;
} else if (im <= -1.7e-5) {
tmp = t_0;
} else if (im <= 0.00027) {
tmp = im * -sin(re);
} else if (im <= 3.5e+94) {
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 <= (-8.2d+97)) then
tmp = t_1
else if (im <= (-1.7d-5)) then
tmp = t_0
else if (im <= 0.00027d0) then
tmp = im * -sin(re)
else if (im <= 3.5d+94) 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 <= -8.2e+97) {
tmp = t_1;
} else if (im <= -1.7e-5) {
tmp = t_0;
} else if (im <= 0.00027) {
tmp = im * -Math.sin(re);
} else if (im <= 3.5e+94) {
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 <= -8.2e+97: tmp = t_1 elif im <= -1.7e-5: tmp = t_0 elif im <= 0.00027: tmp = im * -math.sin(re) elif im <= 3.5e+94: 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 <= -8.2e+97) tmp = t_1; elseif (im <= -1.7e-5) tmp = t_0; elseif (im <= 0.00027) tmp = Float64(im * Float64(-sin(re))); elseif (im <= 3.5e+94) 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 <= -8.2e+97) tmp = t_1; elseif (im <= -1.7e-5) tmp = t_0; elseif (im <= 0.00027) tmp = im * -sin(re); elseif (im <= 3.5e+94) 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, -8.2e+97], t$95$1, If[LessEqual[im, -1.7e-5], t$95$0, If[LessEqual[im, 0.00027], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 3.5e+94], 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 -8.2 \cdot 10^{+97}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -1.7 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.00027:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{elif}\;im \leq 3.5 \cdot 10^{+94}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -8.19999999999999977e97 or 3.4999999999999997e94 < im Initial program 100.0%
Taylor expanded in im around 0 95.8%
mul-1-neg95.8%
unsub-neg95.8%
*-commutative95.8%
associate-*l*95.8%
distribute-lft-out--95.8%
Simplified95.8%
Taylor expanded in im around inf 95.8%
if -8.19999999999999977e97 < im < -1.7e-5 or 2.70000000000000003e-4 < im < 3.4999999999999997e94Initial program 99.6%
Taylor expanded in re around 0 74.6%
if -1.7e-5 < im < 2.70000000000000003e-4Initial program 24.6%
Taylor expanded in im around 0 99.8%
mul-1-neg99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Final simplification93.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.16666666666666666 (* (sin re) (pow im 3.0)))))
(if (<= im -7.2e+102)
t_0
(if (<= im -680.0)
(log1p (expm1 (* im re)))
(if (<= im 310000000000.0)
(* im (- (sin re)))
(if (<= im 5.7e+102)
(log (- (- 1.0 (* im re)) (* (* (* im im) -0.5) (* re re))))
t_0))))))
double code(double re, double im) {
double t_0 = -0.16666666666666666 * (sin(re) * pow(im, 3.0));
double tmp;
if (im <= -7.2e+102) {
tmp = t_0;
} else if (im <= -680.0) {
tmp = log1p(expm1((im * re)));
} else if (im <= 310000000000.0) {
tmp = im * -sin(re);
} else if (im <= 5.7e+102) {
tmp = log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * re))));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = -0.16666666666666666 * (Math.sin(re) * Math.pow(im, 3.0));
double tmp;
if (im <= -7.2e+102) {
tmp = t_0;
} else if (im <= -680.0) {
tmp = Math.log1p(Math.expm1((im * re)));
} else if (im <= 310000000000.0) {
tmp = im * -Math.sin(re);
} else if (im <= 5.7e+102) {
tmp = Math.log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * re))));
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = -0.16666666666666666 * (math.sin(re) * math.pow(im, 3.0)) tmp = 0 if im <= -7.2e+102: tmp = t_0 elif im <= -680.0: tmp = math.log1p(math.expm1((im * re))) elif im <= 310000000000.0: tmp = im * -math.sin(re) elif im <= 5.7e+102: tmp = math.log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * re)))) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(-0.16666666666666666 * Float64(sin(re) * (im ^ 3.0))) tmp = 0.0 if (im <= -7.2e+102) tmp = t_0; elseif (im <= -680.0) tmp = log1p(expm1(Float64(im * re))); elseif (im <= 310000000000.0) tmp = Float64(im * Float64(-sin(re))); elseif (im <= 5.7e+102) tmp = log(Float64(Float64(1.0 - Float64(im * re)) - Float64(Float64(Float64(im * im) * -0.5) * Float64(re * re)))); else tmp = t_0; end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(-0.16666666666666666 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7.2e+102], t$95$0, If[LessEqual[im, -680.0], N[Log[1 + N[(Exp[N[(im * re), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 310000000000.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 5.7e+102], N[Log[N[(N[(1.0 - N[(im * re), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\
\mathbf{if}\;im \leq -7.2 \cdot 10^{+102}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -680:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot re\right)\right)\\
\mathbf{elif}\;im \leq 310000000000:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{elif}\;im \leq 5.7 \cdot 10^{+102}:\\
\;\;\;\;\log \left(\left(1 - im \cdot re\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -7.2000000000000003e102 or 5.6999999999999999e102 < 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 -7.2000000000000003e102 < im < -680Initial 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.7%
sqr-neg1.7%
sqrt-unprod0.4%
add-sqr-sqrt0.8%
log1p-expm1-u0.5%
log1p-udef0.8%
neg-log0.8%
add-sqr-sqrt0.4%
sqrt-unprod23.0%
sqr-neg23.0%
sqrt-unprod22.6%
add-sqr-sqrt49.0%
Applied egg-rr49.0%
Taylor expanded in re around 0 19.3%
add-sqr-sqrt11.9%
sqrt-unprod23.0%
neg-log23.0%
log1p-udef23.0%
log1p-expm1-u23.0%
neg-log23.0%
log1p-udef23.0%
log1p-expm1-u16.0%
sqr-neg16.0%
sqrt-unprod4.6%
add-sqr-sqrt6.2%
log1p-expm1-u30.1%
Applied egg-rr30.1%
if -680 < im < 3.1e11Initial program 27.0%
Taylor expanded in im around 0 97.1%
mul-1-neg97.1%
*-commutative97.1%
distribute-rgt-neg-in97.1%
Simplified97.1%
if 3.1e11 < im < 5.6999999999999999e102Initial program 100.0%
Taylor expanded in im around 0 3.3%
mul-1-neg3.3%
*-commutative3.3%
distribute-rgt-neg-in3.3%
Simplified3.3%
distribute-rgt-neg-out3.3%
add-sqr-sqrt0.9%
sqrt-unprod1.2%
sqr-neg1.2%
sqrt-unprod0.4%
add-sqr-sqrt0.6%
log1p-expm1-u0.3%
log1p-udef0.4%
neg-log0.4%
add-sqr-sqrt0.2%
sqrt-unprod10.5%
sqr-neg10.5%
sqrt-unprod10.4%
add-sqr-sqrt70.5%
Applied egg-rr70.5%
Taylor expanded in re around 0 41.0%
associate-+r+41.0%
mul-1-neg41.0%
unsub-neg41.0%
+-commutative41.0%
mul-1-neg41.0%
unsub-neg41.0%
*-commutative41.0%
distribute-rgt-out41.0%
unpow241.0%
metadata-eval41.0%
unpow241.0%
Simplified41.0%
Final simplification84.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (- (* (pow im 3.0) -0.16666666666666666) im))))
(if (<= im -5.2e+109)
t_0
(if (<= im -610.0)
(log1p (expm1 (* im re)))
(if (<= im 1000000000000.0)
(* im (- (sin re)))
(if (<= im 6.6e+108)
(log (- (- 1.0 (* im re)) (* (* (* im im) -0.5) (* re re))))
t_0))))))
double code(double re, double im) {
double t_0 = re * ((pow(im, 3.0) * -0.16666666666666666) - im);
double tmp;
if (im <= -5.2e+109) {
tmp = t_0;
} else if (im <= -610.0) {
tmp = log1p(expm1((im * re)));
} else if (im <= 1000000000000.0) {
tmp = im * -sin(re);
} else if (im <= 6.6e+108) {
tmp = log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * re))));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = re * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
double tmp;
if (im <= -5.2e+109) {
tmp = t_0;
} else if (im <= -610.0) {
tmp = Math.log1p(Math.expm1((im * re)));
} else if (im <= 1000000000000.0) {
tmp = im * -Math.sin(re);
} else if (im <= 6.6e+108) {
tmp = Math.log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * 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 <= -5.2e+109: tmp = t_0 elif im <= -610.0: tmp = math.log1p(math.expm1((im * re))) elif im <= 1000000000000.0: tmp = im * -math.sin(re) elif im <= 6.6e+108: tmp = math.log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * 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 <= -5.2e+109) tmp = t_0; elseif (im <= -610.0) tmp = log1p(expm1(Float64(im * re))); elseif (im <= 1000000000000.0) tmp = Float64(im * Float64(-sin(re))); elseif (im <= 6.6e+108) tmp = log(Float64(Float64(1.0 - Float64(im * re)) - Float64(Float64(Float64(im * im) * -0.5) * Float64(re * re)))); else tmp = t_0; end return 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, -5.2e+109], t$95$0, If[LessEqual[im, -610.0], N[Log[1 + N[(Exp[N[(im * re), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 1000000000000.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 6.6e+108], N[Log[N[(N[(1.0 - N[(im * re), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $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 -5.2 \cdot 10^{+109}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -610:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot re\right)\right)\\
\mathbf{elif}\;im \leq 1000000000000:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{elif}\;im \leq 6.6 \cdot 10^{+108}:\\
\;\;\;\;\log \left(\left(1 - im \cdot re\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -5.1999999999999997e109 or 6.60000000000000038e108 < 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 re around 0 80.3%
if -5.1999999999999997e109 < im < -610Initial 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.5%
log1p-udef0.8%
neg-log0.8%
add-sqr-sqrt0.4%
sqrt-unprod24.9%
sqr-neg24.9%
sqrt-unprod24.5%
add-sqr-sqrt52.5%
Applied egg-rr52.5%
Taylor expanded in re around 0 21.4%
add-sqr-sqrt14.5%
sqrt-unprod24.9%
neg-log24.9%
log1p-udef24.9%
log1p-expm1-u24.9%
neg-log24.9%
log1p-udef24.9%
log1p-expm1-u18.3%
sqr-neg18.3%
sqrt-unprod4.2%
add-sqr-sqrt5.9%
log1p-expm1-u31.5%
Applied egg-rr31.5%
if -610 < im < 1e12Initial program 27.0%
Taylor expanded in im around 0 97.1%
mul-1-neg97.1%
*-commutative97.1%
distribute-rgt-neg-in97.1%
Simplified97.1%
if 1e12 < im < 6.60000000000000038e108Initial program 100.0%
Taylor expanded in im around 0 3.3%
mul-1-neg3.3%
*-commutative3.3%
distribute-rgt-neg-in3.3%
Simplified3.3%
distribute-rgt-neg-out3.3%
add-sqr-sqrt0.8%
sqrt-unprod1.2%
sqr-neg1.2%
sqrt-unprod0.4%
add-sqr-sqrt0.6%
log1p-expm1-u0.3%
log1p-udef0.4%
neg-log0.4%
add-sqr-sqrt0.1%
sqrt-unprod9.6%
sqr-neg9.6%
sqrt-unprod9.5%
add-sqr-sqrt70.2%
Applied egg-rr70.2%
Taylor expanded in re around 0 43.4%
associate-+r+43.4%
mul-1-neg43.4%
unsub-neg43.4%
+-commutative43.4%
mul-1-neg43.4%
unsub-neg43.4%
*-commutative43.4%
distribute-rgt-out43.4%
unpow243.4%
metadata-eval43.4%
unpow243.4%
Simplified43.4%
Final simplification77.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (- (* (pow im 3.0) -0.16666666666666666) im))))
(if (<= im -1.6e-5)
t_0
(if (<= im 9000000000.0)
(* im (- (sin re)))
(if (<= im 6.6e+108)
(log (- (- 1.0 (* im re)) (* (* (* im im) -0.5) (* re 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.6e-5) {
tmp = t_0;
} else if (im <= 9000000000.0) {
tmp = im * -sin(re);
} else if (im <= 6.6e+108) {
tmp = log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * 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.6d-5)) then
tmp = t_0
else if (im <= 9000000000.0d0) then
tmp = im * -sin(re)
else if (im <= 6.6d+108) then
tmp = log(((1.0d0 - (im * re)) - (((im * im) * (-0.5d0)) * (re * 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.6e-5) {
tmp = t_0;
} else if (im <= 9000000000.0) {
tmp = im * -Math.sin(re);
} else if (im <= 6.6e+108) {
tmp = Math.log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * 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.6e-5: tmp = t_0 elif im <= 9000000000.0: tmp = im * -math.sin(re) elif im <= 6.6e+108: tmp = math.log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * 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.6e-5) tmp = t_0; elseif (im <= 9000000000.0) tmp = Float64(im * Float64(-sin(re))); elseif (im <= 6.6e+108) tmp = log(Float64(Float64(1.0 - Float64(im * re)) - Float64(Float64(Float64(im * im) * -0.5) * Float64(re * 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.6e-5) tmp = t_0; elseif (im <= 9000000000.0) tmp = im * -sin(re); elseif (im <= 6.6e+108) tmp = log(((1.0 - (im * re)) - (((im * im) * -0.5) * (re * 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.6e-5], t$95$0, If[LessEqual[im, 9000000000.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 6.6e+108], N[Log[N[(N[(1.0 - N[(im * re), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $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.6 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 9000000000:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{elif}\;im \leq 6.6 \cdot 10^{+108}:\\
\;\;\;\;\log \left(\left(1 - im \cdot re\right) - \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.59999999999999993e-5 or 6.60000000000000038e108 < im Initial program 99.8%
Taylor expanded in im around 0 76.5%
mul-1-neg76.5%
unsub-neg76.5%
*-commutative76.5%
associate-*l*76.5%
distribute-lft-out--76.5%
Simplified76.5%
Taylor expanded in re around 0 62.8%
if -1.59999999999999993e-5 < im < 9e9Initial program 26.5%
Taylor expanded in im around 0 97.4%
mul-1-neg97.4%
*-commutative97.4%
distribute-rgt-neg-in97.4%
Simplified97.4%
if 9e9 < im < 6.60000000000000038e108Initial program 100.0%
Taylor expanded in im around 0 3.3%
mul-1-neg3.3%
*-commutative3.3%
distribute-rgt-neg-in3.3%
Simplified3.3%
distribute-rgt-neg-out3.3%
add-sqr-sqrt0.8%
sqrt-unprod1.2%
sqr-neg1.2%
sqrt-unprod0.4%
add-sqr-sqrt0.6%
log1p-expm1-u0.3%
log1p-udef0.4%
neg-log0.4%
add-sqr-sqrt0.1%
sqrt-unprod9.6%
sqr-neg9.6%
sqrt-unprod9.5%
add-sqr-sqrt70.2%
Applied egg-rr70.2%
Taylor expanded in re around 0 43.4%
associate-+r+43.4%
mul-1-neg43.4%
unsub-neg43.4%
+-commutative43.4%
mul-1-neg43.4%
unsub-neg43.4%
*-commutative43.4%
distribute-rgt-out43.4%
unpow243.4%
metadata-eval43.4%
unpow243.4%
Simplified43.4%
Final simplification76.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (- (* (pow im 3.0) -0.16666666666666666) im))))
(if (<= im -1.7e-5)
t_0
(if (<= im 510000000.0)
(* im (- (sin re)))
(if (<= im 6.6e+108)
(* im (- (* 0.16666666666666666 (pow re 3.0)) 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.7e-5) {
tmp = t_0;
} else if (im <= 510000000.0) {
tmp = im * -sin(re);
} else if (im <= 6.6e+108) {
tmp = im * ((0.16666666666666666 * pow(re, 3.0)) - 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.7d-5)) then
tmp = t_0
else if (im <= 510000000.0d0) then
tmp = im * -sin(re)
else if (im <= 6.6d+108) then
tmp = im * ((0.16666666666666666d0 * (re ** 3.0d0)) - 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.7e-5) {
tmp = t_0;
} else if (im <= 510000000.0) {
tmp = im * -Math.sin(re);
} else if (im <= 6.6e+108) {
tmp = im * ((0.16666666666666666 * Math.pow(re, 3.0)) - 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.7e-5: tmp = t_0 elif im <= 510000000.0: tmp = im * -math.sin(re) elif im <= 6.6e+108: tmp = im * ((0.16666666666666666 * math.pow(re, 3.0)) - 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.7e-5) tmp = t_0; elseif (im <= 510000000.0) tmp = Float64(im * Float64(-sin(re))); elseif (im <= 6.6e+108) tmp = Float64(im * Float64(Float64(0.16666666666666666 * (re ^ 3.0)) - 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.7e-5) tmp = t_0; elseif (im <= 510000000.0) tmp = im * -sin(re); elseif (im <= 6.6e+108) tmp = im * ((0.16666666666666666 * (re ^ 3.0)) - 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.7e-5], t$95$0, If[LessEqual[im, 510000000.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 6.6e+108], N[(im * N[(N[(0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] - 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.7 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 510000000:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{elif}\;im \leq 6.6 \cdot 10^{+108}:\\
\;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.7e-5 or 6.60000000000000038e108 < im Initial program 99.8%
Taylor expanded in im around 0 76.5%
mul-1-neg76.5%
unsub-neg76.5%
*-commutative76.5%
associate-*l*76.5%
distribute-lft-out--76.5%
Simplified76.5%
Taylor expanded in re around 0 62.8%
if -1.7e-5 < im < 5.1e8Initial program 25.9%
Taylor expanded in im around 0 98.2%
mul-1-neg98.2%
*-commutative98.2%
distribute-rgt-neg-in98.2%
Simplified98.2%
if 5.1e8 < im < 6.60000000000000038e108Initial program 100.0%
Taylor expanded in im around 0 3.3%
mul-1-neg3.3%
*-commutative3.3%
distribute-rgt-neg-in3.3%
Simplified3.3%
Taylor expanded in re around 0 25.2%
+-commutative25.2%
mul-1-neg25.2%
unsub-neg25.2%
associate-*r*25.2%
distribute-rgt-out--31.1%
Simplified31.1%
Final simplification74.6%
(FPCore (re im) :precision binary64 (if (or (<= im -620.0) (not (<= im 510000000.0))) (* im (- (* 0.16666666666666666 (pow re 3.0)) re)) (* im (- (sin re)))))
double code(double re, double im) {
double tmp;
if ((im <= -620.0) || !(im <= 510000000.0)) {
tmp = im * ((0.16666666666666666 * pow(re, 3.0)) - re);
} else {
tmp = im * -sin(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-620.0d0)) .or. (.not. (im <= 510000000.0d0))) then
tmp = im * ((0.16666666666666666d0 * (re ** 3.0d0)) - re)
else
tmp = im * -sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -620.0) || !(im <= 510000000.0)) {
tmp = im * ((0.16666666666666666 * Math.pow(re, 3.0)) - re);
} else {
tmp = im * -Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -620.0) or not (im <= 510000000.0): tmp = im * ((0.16666666666666666 * math.pow(re, 3.0)) - re) else: tmp = im * -math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -620.0) || !(im <= 510000000.0)) tmp = Float64(im * Float64(Float64(0.16666666666666666 * (re ^ 3.0)) - re)); else tmp = Float64(im * Float64(-sin(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -620.0) || ~((im <= 510000000.0))) tmp = im * ((0.16666666666666666 * (re ^ 3.0)) - re); else tmp = im * -sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -620.0], N[Not[LessEqual[im, 510000000.0]], $MachinePrecision]], N[(im * N[(N[(0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -620 \lor \neg \left(im \leq 510000000\right):\\
\;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\end{array}
\end{array}
if im < -620 or 5.1e8 < im Initial program 100.0%
Taylor expanded in im around 0 4.1%
mul-1-neg4.1%
*-commutative4.1%
distribute-rgt-neg-in4.1%
Simplified4.1%
Taylor expanded in re around 0 14.3%
+-commutative14.3%
mul-1-neg14.3%
unsub-neg14.3%
associate-*r*14.3%
distribute-rgt-out--25.1%
Simplified25.1%
if -620 < im < 5.1e8Initial program 26.4%
Taylor expanded in im around 0 97.9%
mul-1-neg97.9%
*-commutative97.9%
distribute-rgt-neg-in97.9%
Simplified97.9%
Final simplification58.4%
(FPCore (re im) :precision binary64 (if (or (<= im -650.0) (not (<= im 9000000000.0))) (* 0.16666666666666666 (* im (pow re 3.0))) (* im (- (sin re)))))
double code(double re, double im) {
double tmp;
if ((im <= -650.0) || !(im <= 9000000000.0)) {
tmp = 0.16666666666666666 * (im * pow(re, 3.0));
} else {
tmp = im * -sin(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-650.0d0)) .or. (.not. (im <= 9000000000.0d0))) then
tmp = 0.16666666666666666d0 * (im * (re ** 3.0d0))
else
tmp = im * -sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -650.0) || !(im <= 9000000000.0)) {
tmp = 0.16666666666666666 * (im * Math.pow(re, 3.0));
} else {
tmp = im * -Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -650.0) or not (im <= 9000000000.0): tmp = 0.16666666666666666 * (im * math.pow(re, 3.0)) else: tmp = im * -math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -650.0) || !(im <= 9000000000.0)) tmp = Float64(0.16666666666666666 * Float64(im * (re ^ 3.0))); else tmp = Float64(im * Float64(-sin(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -650.0) || ~((im <= 9000000000.0))) tmp = 0.16666666666666666 * (im * (re ^ 3.0)); else tmp = im * -sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -650.0], N[Not[LessEqual[im, 9000000000.0]], $MachinePrecision]], N[(0.16666666666666666 * N[(im * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -650 \lor \neg \left(im \leq 9000000000\right):\\
\;\;\;\;0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\end{array}
\end{array}
if im < -650 or 9e9 < im Initial program 100.0%
Taylor expanded in im around 0 4.1%
mul-1-neg4.1%
*-commutative4.1%
distribute-rgt-neg-in4.1%
Simplified4.1%
Taylor expanded in re around 0 14.4%
Taylor expanded in re around inf 24.1%
if -650 < im < 9e9Initial program 27.0%
Taylor expanded in im around 0 97.1%
mul-1-neg97.1%
*-commutative97.1%
distribute-rgt-neg-in97.1%
Simplified97.1%
Final simplification57.8%
(FPCore (re im) :precision binary64 (if (<= im -9.8e+30) (* im (- re)) (if (<= im 7.4e+40) (* im (- (sin re))) (* im re))))
double code(double re, double im) {
double tmp;
if (im <= -9.8e+30) {
tmp = im * -re;
} else if (im <= 7.4e+40) {
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 <= (-9.8d+30)) then
tmp = im * -re
else if (im <= 7.4d+40) 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 <= -9.8e+30) {
tmp = im * -re;
} else if (im <= 7.4e+40) {
tmp = im * -Math.sin(re);
} else {
tmp = im * re;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -9.8e+30: tmp = im * -re elif im <= 7.4e+40: tmp = im * -math.sin(re) else: tmp = im * re return tmp
function code(re, im) tmp = 0.0 if (im <= -9.8e+30) tmp = Float64(im * Float64(-re)); elseif (im <= 7.4e+40) tmp = Float64(im * Float64(-sin(re))); else tmp = Float64(im * re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -9.8e+30) tmp = im * -re; elseif (im <= 7.4e+40) tmp = im * -sin(re); else tmp = im * re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -9.8e+30], N[(im * (-re)), $MachinePrecision], If[LessEqual[im, 7.4e+40], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], N[(im * re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -9.8 \cdot 10^{+30}:\\
\;\;\;\;im \cdot \left(-re\right)\\
\mathbf{elif}\;im \leq 7.4 \cdot 10^{+40}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot re\\
\end{array}
\end{array}
if im < -9.79999999999999969e30Initial program 100.0%
Taylor expanded in im around 0 4.2%
mul-1-neg4.2%
*-commutative4.2%
distribute-rgt-neg-in4.2%
Simplified4.2%
Taylor expanded in re around 0 13.6%
mul-1-neg13.6%
distribute-rgt-neg-in13.6%
Simplified13.6%
if -9.79999999999999969e30 < im < 7.4e40Initial program 34.7%
Taylor expanded in im around 0 87.1%
mul-1-neg87.1%
*-commutative87.1%
distribute-rgt-neg-in87.1%
Simplified87.1%
if 7.4e40 < 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%
distribute-rgt-neg-out4.4%
add-sqr-sqrt1.7%
sqrt-unprod1.9%
sqr-neg1.9%
sqrt-unprod0.2%
add-sqr-sqrt0.5%
log1p-expm1-u0.1%
log1p-udef0.2%
neg-log0.2%
add-sqr-sqrt0.1%
sqrt-unprod25.0%
sqr-neg25.0%
sqrt-unprod29.7%
add-sqr-sqrt83.9%
Applied egg-rr83.9%
Taylor expanded in re around 0 54.4%
add-sqr-sqrt33.0%
sqrt-unprod54.3%
neg-log54.3%
log1p-udef54.3%
log1p-expm1-u54.3%
neg-log54.3%
log1p-udef54.3%
log1p-expm1-u38.6%
sqr-neg38.6%
sqrt-unprod9.3%
add-sqr-sqrt16.0%
*-commutative16.0%
Applied egg-rr16.0%
Final simplification52.1%
(FPCore (re im) :precision binary64 (if (<= re -2.8e+167) (* im re) (* im (- re))))
double code(double re, double im) {
double tmp;
if (re <= -2.8e+167) {
tmp = im * 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 (re <= (-2.8d+167)) then
tmp = im * re
else
tmp = im * -re
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -2.8e+167) {
tmp = im * re;
} else {
tmp = im * -re;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -2.8e+167: tmp = im * re else: tmp = im * -re return tmp
function code(re, im) tmp = 0.0 if (re <= -2.8e+167) tmp = Float64(im * re); else tmp = Float64(im * Float64(-re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -2.8e+167) tmp = im * re; else tmp = im * -re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -2.8e+167], N[(im * re), $MachinePrecision], N[(im * (-re)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -2.8 \cdot 10^{+167}:\\
\;\;\;\;im \cdot re\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-re\right)\\
\end{array}
\end{array}
if re < -2.7999999999999999e167Initial program 50.1%
Taylor expanded in im around 0 56.7%
mul-1-neg56.7%
*-commutative56.7%
distribute-rgt-neg-in56.7%
Simplified56.7%
distribute-rgt-neg-out56.7%
add-sqr-sqrt34.7%
sqrt-unprod36.0%
sqr-neg36.0%
sqrt-unprod1.1%
add-sqr-sqrt2.4%
log1p-expm1-u2.2%
log1p-udef3.0%
neg-log3.0%
add-sqr-sqrt1.4%
sqrt-unprod35.0%
sqr-neg35.0%
sqrt-unprod33.6%
add-sqr-sqrt50.1%
Applied egg-rr50.1%
Taylor expanded in re around 0 17.1%
add-sqr-sqrt13.7%
sqrt-unprod32.1%
neg-log32.1%
log1p-udef32.1%
log1p-expm1-u32.1%
neg-log32.1%
log1p-udef31.3%
log1p-expm1-u31.5%
sqr-neg31.5%
sqrt-unprod13.4%
add-sqr-sqrt26.5%
*-commutative26.5%
Applied egg-rr26.5%
if -2.7999999999999999e167 < re Initial program 68.7%
Taylor expanded in im around 0 45.6%
mul-1-neg45.6%
*-commutative45.6%
distribute-rgt-neg-in45.6%
Simplified45.6%
Taylor expanded in re around 0 28.9%
mul-1-neg28.9%
distribute-rgt-neg-in28.9%
Simplified28.9%
Final simplification28.6%
(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 * re) end
function tmp = code(re, im) tmp = im * re; end
code[re_, im_] := N[(im * re), $MachinePrecision]
\begin{array}{l}
\\
im \cdot re
\end{array}
Initial program 66.3%
Taylor expanded in im around 0 47.0%
mul-1-neg47.0%
*-commutative47.0%
distribute-rgt-neg-in47.0%
Simplified47.0%
distribute-rgt-neg-out47.0%
add-sqr-sqrt27.1%
sqrt-unprod30.5%
sqr-neg30.5%
sqrt-unprod3.6%
add-sqr-sqrt9.4%
log1p-expm1-u9.2%
log1p-udef9.9%
neg-log9.9%
add-sqr-sqrt3.8%
sqrt-unprod25.8%
sqr-neg25.8%
sqrt-unprod24.3%
add-sqr-sqrt51.3%
Applied egg-rr51.3%
Taylor expanded in re around 0 35.8%
add-sqr-sqrt25.9%
sqrt-unprod35.0%
neg-log35.0%
log1p-udef35.0%
log1p-expm1-u35.0%
neg-log35.0%
log1p-udef35.4%
log1p-expm1-u27.6%
sqr-neg27.6%
sqrt-unprod12.3%
add-sqr-sqrt15.9%
*-commutative15.9%
Applied egg-rr15.9%
Final simplification15.9%
(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 2023195
(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))))