
(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 14 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 -0.2) (not (<= t_0 2e-6)))
(* 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 <= -0.2) || !(t_0 <= 2e-6)) {
tmp = t_0 * (0.5 * sin(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) :: t_0
real(8) :: tmp
t_0 = exp(-im) - exp(im)
if ((t_0 <= (-0.2d0)) .or. (.not. (t_0 <= 2d-6))) then
tmp = t_0 * (0.5d0 * sin(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 t_0 = Math.exp(-im) - Math.exp(im);
double tmp;
if ((t_0 <= -0.2) || !(t_0 <= 2e-6)) {
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 <= -0.2) or not (t_0 <= 2e-6): 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 <= -0.2) || !(t_0 <= 2e-6)) 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 <= -0.2) || ~((t_0 <= 2e-6))) 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, -0.2], N[Not[LessEqual[t$95$0, 2e-6]], $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 -0.2 \lor \neg \left(t_0 \leq 2 \cdot 10^{-6}\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)) < -0.20000000000000001 or 1.99999999999999991e-6 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
if -0.20000000000000001 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 1.99999999999999991e-6Initial program 28.2%
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 -5e+103)
(and (not (<= im -1000.0)) (or (<= im 0.205) (not (<= im 5.5e+102)))))
(* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
(* (- (exp (- im)) (exp im)) (* 0.5 re))))
double code(double re, double im) {
double tmp;
if ((im <= -5e+103) || (!(im <= -1000.0) && ((im <= 0.205) || !(im <= 5.5e+102)))) {
tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else {
tmp = (exp(-im) - exp(im)) * (0.5 * re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-5d+103)) .or. (.not. (im <= (-1000.0d0))) .and. (im <= 0.205d0) .or. (.not. (im <= 5.5d+102))) then
tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else
tmp = (exp(-im) - exp(im)) * (0.5d0 * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -5e+103) || (!(im <= -1000.0) && ((im <= 0.205) || !(im <= 5.5e+102)))) {
tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else {
tmp = (Math.exp(-im) - Math.exp(im)) * (0.5 * re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -5e+103) or (not (im <= -1000.0) and ((im <= 0.205) or not (im <= 5.5e+102))): tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) else: tmp = (math.exp(-im) - math.exp(im)) * (0.5 * re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -5e+103) || (!(im <= -1000.0) && ((im <= 0.205) || !(im <= 5.5e+102)))) tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); else tmp = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -5e+103) || (~((im <= -1000.0)) && ((im <= 0.205) || ~((im <= 5.5e+102))))) tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im); else tmp = (exp(-im) - exp(im)) * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -5e+103], And[N[Not[LessEqual[im, -1000.0]], $MachinePrecision], Or[LessEqual[im, 0.205], N[Not[LessEqual[im, 5.5e+102]], $MachinePrecision]]]], N[(N[Sin[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 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -5 \cdot 10^{+103} \lor \neg \left(im \leq -1000\right) \land \left(im \leq 0.205 \lor \neg \left(im \leq 5.5 \cdot 10^{+102}\right)\right):\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < -5e103 or -1e3 < im < 0.204999999999999988 or 5.49999999999999981e102 < im Initial program 55.4%
Taylor expanded in im around 0 99.2%
+-commutative99.2%
mul-1-neg99.2%
unsub-neg99.2%
associate-*r*99.2%
distribute-rgt-out--99.2%
*-commutative99.2%
Simplified99.2%
if -5e103 < im < -1e3 or 0.204999999999999988 < im < 5.49999999999999981e102Initial program 100.0%
Taylor expanded in re around 0 85.5%
associate-*r*85.5%
*-commutative85.5%
Simplified85.5%
Final simplification96.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))))
(if (<= im -5e+103)
t_0
(if (<= im -68000000000000.0)
(* re (sqrt (* 0.027777777777777776 (pow im 6.0))))
(if (or (<= im 5.4e+20) (not (<= im 5.5e+102)))
t_0
(* im (- (* -0.16666666666666666 (pow re 3.0)) re)))))))
double code(double re, double im) {
double t_0 = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
double tmp;
if (im <= -5e+103) {
tmp = t_0;
} else if (im <= -68000000000000.0) {
tmp = re * sqrt((0.027777777777777776 * pow(im, 6.0)));
} else if ((im <= 5.4e+20) || !(im <= 5.5e+102)) {
tmp = t_0;
} else {
tmp = im * ((-0.16666666666666666 * pow(re, 3.0)) - 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 = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
if (im <= (-5d+103)) then
tmp = t_0
else if (im <= (-68000000000000.0d0)) then
tmp = re * sqrt((0.027777777777777776d0 * (im ** 6.0d0)))
else if ((im <= 5.4d+20) .or. (.not. (im <= 5.5d+102))) then
tmp = t_0
else
tmp = im * (((-0.16666666666666666d0) * (re ** 3.0d0)) - re)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
double tmp;
if (im <= -5e+103) {
tmp = t_0;
} else if (im <= -68000000000000.0) {
tmp = re * Math.sqrt((0.027777777777777776 * Math.pow(im, 6.0)));
} else if ((im <= 5.4e+20) || !(im <= 5.5e+102)) {
tmp = t_0;
} else {
tmp = im * ((-0.16666666666666666 * Math.pow(re, 3.0)) - re);
}
return tmp;
}
def code(re, im): t_0 = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) tmp = 0 if im <= -5e+103: tmp = t_0 elif im <= -68000000000000.0: tmp = re * math.sqrt((0.027777777777777776 * math.pow(im, 6.0))) elif (im <= 5.4e+20) or not (im <= 5.5e+102): tmp = t_0 else: tmp = im * ((-0.16666666666666666 * math.pow(re, 3.0)) - re) return tmp
function code(re, im) t_0 = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)) tmp = 0.0 if (im <= -5e+103) tmp = t_0; elseif (im <= -68000000000000.0) tmp = Float64(re * sqrt(Float64(0.027777777777777776 * (im ^ 6.0)))); elseif ((im <= 5.4e+20) || !(im <= 5.5e+102)) tmp = t_0; else tmp = Float64(im * Float64(Float64(-0.16666666666666666 * (re ^ 3.0)) - re)); end return tmp end
function tmp_2 = code(re, im) t_0 = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im); tmp = 0.0; if (im <= -5e+103) tmp = t_0; elseif (im <= -68000000000000.0) tmp = re * sqrt((0.027777777777777776 * (im ^ 6.0))); elseif ((im <= 5.4e+20) || ~((im <= 5.5e+102))) tmp = t_0; else tmp = im * ((-0.16666666666666666 * (re ^ 3.0)) - re); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5e+103], t$95$0, If[LessEqual[im, -68000000000000.0], N[(re * N[Sqrt[N[(0.027777777777777776 * N[Power[im, 6.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, 5.4e+20], N[Not[LessEqual[im, 5.5e+102]], $MachinePrecision]], t$95$0, N[(im * N[(N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{if}\;im \leq -5 \cdot 10^{+103}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq -68000000000000:\\
\;\;\;\;re \cdot \sqrt{0.027777777777777776 \cdot {im}^{6}}\\
\mathbf{elif}\;im \leq 5.4 \cdot 10^{+20} \lor \neg \left(im \leq 5.5 \cdot 10^{+102}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-0.16666666666666666 \cdot {re}^{3} - re\right)\\
\end{array}
\end{array}
if im < -5e103 or -6.8e13 < im < 5.4e20 or 5.49999999999999981e102 < im Initial program 57.1%
Taylor expanded in im around 0 95.5%
+-commutative95.5%
mul-1-neg95.5%
unsub-neg95.5%
associate-*r*95.5%
distribute-rgt-out--95.5%
*-commutative95.5%
Simplified95.5%
if -5e103 < im < -6.8e13Initial program 100.0%
Taylor expanded in im around 0 9.4%
+-commutative9.4%
mul-1-neg9.4%
unsub-neg9.4%
associate-*r*9.4%
distribute-rgt-out--9.4%
*-commutative9.4%
Simplified9.4%
Taylor expanded in re around 0 38.8%
Taylor expanded in im around inf 38.8%
associate-*r*38.8%
*-commutative38.8%
Simplified38.8%
add-sqr-sqrt38.8%
sqrt-unprod69.0%
swap-sqr69.0%
metadata-eval69.0%
pow-prod-up69.0%
metadata-eval69.0%
Applied egg-rr69.0%
if 5.4e20 < im < 5.49999999999999981e102Initial program 100.0%
Taylor expanded in im around 0 3.3%
associate-*r*3.3%
neg-mul-13.3%
Simplified3.3%
Taylor expanded in re around 0 1.8%
+-commutative1.8%
mul-1-neg1.8%
unsub-neg1.8%
*-commutative1.8%
associate-*r*1.8%
*-commutative1.8%
distribute-rgt-out--5.8%
Simplified5.8%
add-log-exp28.4%
*-un-lft-identity28.4%
log-prod28.4%
metadata-eval28.4%
add-log-exp5.8%
add-sqr-sqrt1.4%
sqrt-unprod21.1%
swap-sqr21.1%
metadata-eval21.1%
metadata-eval21.1%
swap-sqr21.1%
*-commutative21.1%
*-commutative21.1%
sqrt-unprod12.9%
add-sqr-sqrt33.7%
*-commutative33.7%
Applied egg-rr33.7%
+-lft-identity33.7%
Simplified33.7%
Final simplification87.2%
(FPCore (re im)
:precision binary64
(if (<= im -3300.0)
(* re (- (sqrt (* 0.027777777777777776 (pow im 6.0))) im))
(if (<= im 3.3e+15)
(* im (- (sin re)))
(* re (- (* (pow im 3.0) -0.16666666666666666) im)))))
double code(double re, double im) {
double tmp;
if (im <= -3300.0) {
tmp = re * (sqrt((0.027777777777777776 * pow(im, 6.0))) - im);
} else if (im <= 3.3e+15) {
tmp = im * -sin(re);
} else {
tmp = 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 <= (-3300.0d0)) then
tmp = re * (sqrt((0.027777777777777776d0 * (im ** 6.0d0))) - im)
else if (im <= 3.3d+15) then
tmp = im * -sin(re)
else
tmp = 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 <= -3300.0) {
tmp = re * (Math.sqrt((0.027777777777777776 * Math.pow(im, 6.0))) - im);
} else if (im <= 3.3e+15) {
tmp = im * -Math.sin(re);
} else {
tmp = re * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -3300.0: tmp = re * (math.sqrt((0.027777777777777776 * math.pow(im, 6.0))) - im) elif im <= 3.3e+15: tmp = im * -math.sin(re) else: tmp = re * ((math.pow(im, 3.0) * -0.16666666666666666) - im) return tmp
function code(re, im) tmp = 0.0 if (im <= -3300.0) tmp = Float64(re * Float64(sqrt(Float64(0.027777777777777776 * (im ^ 6.0))) - im)); elseif (im <= 3.3e+15) tmp = Float64(im * Float64(-sin(re))); else tmp = Float64(re * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -3300.0) tmp = re * (sqrt((0.027777777777777776 * (im ^ 6.0))) - im); elseif (im <= 3.3e+15) tmp = im * -sin(re); else tmp = re * (((im ^ 3.0) * -0.16666666666666666) - im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -3300.0], N[(re * N[(N[Sqrt[N[(0.027777777777777776 * N[Power[im, 6.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.3e+15], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], N[(re * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -3300:\\
\;\;\;\;re \cdot \left(\sqrt{0.027777777777777776 \cdot {im}^{6}} - im\right)\\
\mathbf{elif}\;im \leq 3.3 \cdot 10^{+15}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if im < -3300Initial program 100.0%
Taylor expanded in im around 0 64.1%
+-commutative64.1%
mul-1-neg64.1%
unsub-neg64.1%
associate-*r*64.1%
distribute-rgt-out--64.1%
*-commutative64.1%
Simplified64.1%
Taylor expanded in re around 0 58.3%
add-sqr-sqrt58.3%
sqrt-unprod69.2%
swap-sqr69.2%
metadata-eval69.2%
pow-prod-up69.2%
metadata-eval69.2%
Applied egg-rr69.2%
if -3300 < im < 3.3e15Initial program 31.5%
Taylor expanded in im around 0 95.5%
associate-*r*95.5%
neg-mul-195.5%
Simplified95.5%
if 3.3e15 < im Initial program 100.0%
Taylor expanded in im around 0 59.8%
+-commutative59.8%
mul-1-neg59.8%
unsub-neg59.8%
associate-*r*59.8%
distribute-rgt-out--59.8%
*-commutative59.8%
Simplified59.8%
Taylor expanded in re around 0 52.8%
Final simplification78.6%
(FPCore (re im)
:precision binary64
(if (<= im -145000.0)
(* re (sqrt (* 0.027777777777777776 (pow im 6.0))))
(if (<= im 1.6e+16)
(* im (- (sin re)))
(* re (- (* (pow im 3.0) -0.16666666666666666) im)))))
double code(double re, double im) {
double tmp;
if (im <= -145000.0) {
tmp = re * sqrt((0.027777777777777776 * pow(im, 6.0)));
} else if (im <= 1.6e+16) {
tmp = im * -sin(re);
} else {
tmp = 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 <= (-145000.0d0)) then
tmp = re * sqrt((0.027777777777777776d0 * (im ** 6.0d0)))
else if (im <= 1.6d+16) then
tmp = im * -sin(re)
else
tmp = 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 <= -145000.0) {
tmp = re * Math.sqrt((0.027777777777777776 * Math.pow(im, 6.0)));
} else if (im <= 1.6e+16) {
tmp = im * -Math.sin(re);
} else {
tmp = re * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -145000.0: tmp = re * math.sqrt((0.027777777777777776 * math.pow(im, 6.0))) elif im <= 1.6e+16: tmp = im * -math.sin(re) else: tmp = re * ((math.pow(im, 3.0) * -0.16666666666666666) - im) return tmp
function code(re, im) tmp = 0.0 if (im <= -145000.0) tmp = Float64(re * sqrt(Float64(0.027777777777777776 * (im ^ 6.0)))); elseif (im <= 1.6e+16) tmp = Float64(im * Float64(-sin(re))); else tmp = Float64(re * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -145000.0) tmp = re * sqrt((0.027777777777777776 * (im ^ 6.0))); elseif (im <= 1.6e+16) tmp = im * -sin(re); else tmp = re * (((im ^ 3.0) * -0.16666666666666666) - im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -145000.0], N[(re * N[Sqrt[N[(0.027777777777777776 * N[Power[im, 6.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.6e+16], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], N[(re * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -145000:\\
\;\;\;\;re \cdot \sqrt{0.027777777777777776 \cdot {im}^{6}}\\
\mathbf{elif}\;im \leq 1.6 \cdot 10^{+16}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if im < -145000Initial program 100.0%
Taylor expanded in im around 0 64.1%
+-commutative64.1%
mul-1-neg64.1%
unsub-neg64.1%
associate-*r*64.1%
distribute-rgt-out--64.1%
*-commutative64.1%
Simplified64.1%
Taylor expanded in re around 0 58.3%
Taylor expanded in im around inf 58.3%
associate-*r*58.3%
*-commutative58.3%
Simplified58.3%
add-sqr-sqrt58.3%
sqrt-unprod69.2%
swap-sqr69.2%
metadata-eval69.2%
pow-prod-up69.2%
metadata-eval69.2%
Applied egg-rr69.2%
if -145000 < im < 1.6e16Initial program 31.5%
Taylor expanded in im around 0 95.5%
associate-*r*95.5%
neg-mul-195.5%
Simplified95.5%
if 1.6e16 < im Initial program 100.0%
Taylor expanded in im around 0 59.8%
+-commutative59.8%
mul-1-neg59.8%
unsub-neg59.8%
associate-*r*59.8%
distribute-rgt-out--59.8%
*-commutative59.8%
Simplified59.8%
Taylor expanded in re around 0 52.8%
Final simplification78.6%
(FPCore (re im) :precision binary64 (if (or (<= im -3000.0) (not (<= im 6e+14))) (* re (- (* (pow im 3.0) -0.16666666666666666) im)) (* im (- (sin re)))))
double code(double re, double im) {
double tmp;
if ((im <= -3000.0) || !(im <= 6e+14)) {
tmp = re * ((pow(im, 3.0) * -0.16666666666666666) - im);
} 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 <= (-3000.0d0)) .or. (.not. (im <= 6d+14))) then
tmp = re * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else
tmp = im * -sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -3000.0) || !(im <= 6e+14)) {
tmp = re * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else {
tmp = im * -Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -3000.0) or not (im <= 6e+14): tmp = re * ((math.pow(im, 3.0) * -0.16666666666666666) - im) else: tmp = im * -math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -3000.0) || !(im <= 6e+14)) tmp = Float64(re * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); else tmp = Float64(im * Float64(-sin(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -3000.0) || ~((im <= 6e+14))) tmp = re * (((im ^ 3.0) * -0.16666666666666666) - im); else tmp = im * -sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -3000.0], N[Not[LessEqual[im, 6e+14]], $MachinePrecision]], N[(re * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -3000 \lor \neg \left(im \leq 6 \cdot 10^{+14}\right):\\
\;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\end{array}
\end{array}
if im < -3e3 or 6e14 < im Initial program 100.0%
Taylor expanded in im around 0 61.9%
+-commutative61.9%
mul-1-neg61.9%
unsub-neg61.9%
associate-*r*61.9%
distribute-rgt-out--61.9%
*-commutative61.9%
Simplified61.9%
Taylor expanded in re around 0 55.5%
if -3e3 < im < 6e14Initial program 31.5%
Taylor expanded in im around 0 95.5%
associate-*r*95.5%
neg-mul-195.5%
Simplified95.5%
Final simplification76.0%
(FPCore (re im) :precision binary64 (if (or (<= im -90000.0) (not (<= im 7e+14))) (* -0.16666666666666666 (* re (pow im 3.0))) (* im (- (sin re)))))
double code(double re, double im) {
double tmp;
if ((im <= -90000.0) || !(im <= 7e+14)) {
tmp = -0.16666666666666666 * (re * pow(im, 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 <= (-90000.0d0)) .or. (.not. (im <= 7d+14))) then
tmp = (-0.16666666666666666d0) * (re * (im ** 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 <= -90000.0) || !(im <= 7e+14)) {
tmp = -0.16666666666666666 * (re * Math.pow(im, 3.0));
} else {
tmp = im * -Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -90000.0) or not (im <= 7e+14): tmp = -0.16666666666666666 * (re * math.pow(im, 3.0)) else: tmp = im * -math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -90000.0) || !(im <= 7e+14)) tmp = Float64(-0.16666666666666666 * Float64(re * (im ^ 3.0))); else tmp = Float64(im * Float64(-sin(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -90000.0) || ~((im <= 7e+14))) tmp = -0.16666666666666666 * (re * (im ^ 3.0)); else tmp = im * -sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -90000.0], N[Not[LessEqual[im, 7e+14]], $MachinePrecision]], N[(-0.16666666666666666 * N[(re * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -90000 \lor \neg \left(im \leq 7 \cdot 10^{+14}\right):\\
\;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\end{array}
\end{array}
if im < -9e4 or 7e14 < im Initial program 100.0%
Taylor expanded in im around 0 61.9%
+-commutative61.9%
mul-1-neg61.9%
unsub-neg61.9%
associate-*r*61.9%
distribute-rgt-out--61.9%
*-commutative61.9%
Simplified61.9%
Taylor expanded in re around 0 55.5%
Taylor expanded in im around inf 55.5%
if -9e4 < im < 7e14Initial program 31.5%
Taylor expanded in im around 0 95.5%
associate-*r*95.5%
neg-mul-195.5%
Simplified95.5%
Final simplification76.0%
(FPCore (re im) :precision binary64 (if (<= im -1.2e+14) (* (* 0.5 re) (* im -2.0)) (if (<= im 6.5e+15) (* im (- (sin re))) (* im (- re)))))
double code(double re, double im) {
double tmp;
if (im <= -1.2e+14) {
tmp = (0.5 * re) * (im * -2.0);
} else if (im <= 6.5e+15) {
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 <= (-1.2d+14)) then
tmp = (0.5d0 * re) * (im * (-2.0d0))
else if (im <= 6.5d+15) 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 <= -1.2e+14) {
tmp = (0.5 * re) * (im * -2.0);
} else if (im <= 6.5e+15) {
tmp = im * -Math.sin(re);
} else {
tmp = im * -re;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -1.2e+14: tmp = (0.5 * re) * (im * -2.0) elif im <= 6.5e+15: tmp = im * -math.sin(re) else: tmp = im * -re return tmp
function code(re, im) tmp = 0.0 if (im <= -1.2e+14) tmp = Float64(Float64(0.5 * re) * Float64(im * -2.0)); elseif (im <= 6.5e+15) 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 <= -1.2e+14) tmp = (0.5 * re) * (im * -2.0); elseif (im <= 6.5e+15) tmp = im * -sin(re); else tmp = im * -re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -1.2e+14], N[(N[(0.5 * re), $MachinePrecision] * N[(im * -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.5e+15], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], N[(im * (-re)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.2 \cdot 10^{+14}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im \cdot -2\right)\\
\mathbf{elif}\;im \leq 6.5 \cdot 10^{+15}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-re\right)\\
\end{array}
\end{array}
if im < -1.2e14Initial program 100.0%
Taylor expanded in re around 0 79.7%
associate-*r*79.7%
*-commutative79.7%
Simplified79.7%
Taylor expanded in im around 0 11.8%
if -1.2e14 < im < 6.5e15Initial program 32.6%
Taylor expanded in im around 0 94.1%
associate-*r*94.1%
neg-mul-194.1%
Simplified94.1%
if 6.5e15 < im Initial program 100.0%
Taylor expanded in im around 0 4.2%
associate-*r*4.2%
neg-mul-14.2%
Simplified4.2%
Taylor expanded in re around 0 12.0%
associate-*r*12.0%
neg-mul-112.0%
Simplified12.0%
Final simplification54.6%
(FPCore (re im) :precision binary64 (* (* 0.5 re) (* im -2.0)))
double code(double re, double im) {
return (0.5 * re) * (im * -2.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * re) * (im * (-2.0d0))
end function
public static double code(double re, double im) {
return (0.5 * re) * (im * -2.0);
}
def code(re, im): return (0.5 * re) * (im * -2.0)
function code(re, im) return Float64(Float64(0.5 * re) * Float64(im * -2.0)) end
function tmp = code(re, im) tmp = (0.5 * re) * (im * -2.0); end
code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * N[(im * -2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot re\right) \cdot \left(im \cdot -2\right)
\end{array}
Initial program 65.0%
Taylor expanded in re around 0 52.4%
associate-*r*52.4%
*-commutative52.4%
Simplified52.4%
Taylor expanded in im around 0 32.8%
Final simplification32.8%
(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 65.0%
Taylor expanded in im around 0 51.0%
associate-*r*51.0%
neg-mul-151.0%
Simplified51.0%
Taylor expanded in re around 0 32.4%
associate-*r*32.4%
neg-mul-132.4%
Simplified32.4%
Final simplification32.4%
(FPCore (re im) :precision binary64 -512.0)
double code(double re, double im) {
return -512.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -512.0d0
end function
public static double code(double re, double im) {
return -512.0;
}
def code(re, im): return -512.0
function code(re, im) return -512.0 end
function tmp = code(re, im) tmp = -512.0; end
code[re_, im_] := -512.0
\begin{array}{l}
\\
-512
\end{array}
Initial program 65.0%
Taylor expanded in im around 0 51.0%
associate-*r*51.0%
neg-mul-151.0%
Simplified51.0%
Applied egg-rr2.7%
Final simplification2.7%
(FPCore (re im) :precision binary64 -0.16666666666666666)
double code(double re, double im) {
return -0.16666666666666666;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -0.16666666666666666d0
end function
public static double code(double re, double im) {
return -0.16666666666666666;
}
def code(re, im): return -0.16666666666666666
function code(re, im) return -0.16666666666666666 end
function tmp = code(re, im) tmp = -0.16666666666666666; end
code[re_, im_] := -0.16666666666666666
\begin{array}{l}
\\
-0.16666666666666666
\end{array}
Initial program 65.0%
Taylor expanded in im around 0 51.0%
associate-*r*51.0%
neg-mul-151.0%
Simplified51.0%
Applied egg-rr2.7%
Final simplification2.7%
(FPCore (re im) :precision binary64 -9.92290301275212e-8)
double code(double re, double im) {
return -9.92290301275212e-8;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -9.92290301275212d-8
end function
public static double code(double re, double im) {
return -9.92290301275212e-8;
}
def code(re, im): return -9.92290301275212e-8
function code(re, im) return -9.92290301275212e-8 end
function tmp = code(re, im) tmp = -9.92290301275212e-8; end
code[re_, im_] := -9.92290301275212e-8
\begin{array}{l}
\\
-9.92290301275212 \cdot 10^{-8}
\end{array}
Initial program 65.0%
Taylor expanded in im around 0 51.0%
associate-*r*51.0%
neg-mul-151.0%
Simplified51.0%
Applied egg-rr2.7%
Final simplification2.7%
(FPCore (re im) :precision binary64 0.0)
double code(double re, double im) {
return 0.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.0d0
end function
public static double code(double re, double im) {
return 0.0;
}
def code(re, im): return 0.0
function code(re, im) return 0.0 end
function tmp = code(re, im) tmp = 0.0; end
code[re_, im_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 65.0%
Taylor expanded in im around 0 51.0%
associate-*r*51.0%
neg-mul-151.0%
Simplified51.0%
Applied egg-rr13.5%
Final simplification13.5%
(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 2023271
(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))))