
(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 10 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 25.9%
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 (* (- (exp (- im)) (exp im)) (* 0.5 re)))
(t_1 (* -0.16666666666666666 (* (sin re) (pow im 3.0)))))
(if (<= im -1.25e+173)
t_1
(if (<= im -220.0)
t_0
(if (<= im 0.031)
(* (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 = (exp(-im) - exp(im)) * (0.5 * re);
double t_1 = -0.16666666666666666 * (sin(re) * pow(im, 3.0));
double tmp;
if (im <= -1.25e+173) {
tmp = t_1;
} else if (im <= -220.0) {
tmp = t_0;
} else if (im <= 0.031) {
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 = (exp(-im) - exp(im)) * (0.5d0 * re)
t_1 = (-0.16666666666666666d0) * (sin(re) * (im ** 3.0d0))
if (im <= (-1.25d+173)) then
tmp = t_1
else if (im <= (-220.0d0)) then
tmp = t_0
else if (im <= 0.031d0) 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 = (Math.exp(-im) - Math.exp(im)) * (0.5 * re);
double t_1 = -0.16666666666666666 * (Math.sin(re) * Math.pow(im, 3.0));
double tmp;
if (im <= -1.25e+173) {
tmp = t_1;
} else if (im <= -220.0) {
tmp = t_0;
} else if (im <= 0.031) {
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 = (math.exp(-im) - math.exp(im)) * (0.5 * re) t_1 = -0.16666666666666666 * (math.sin(re) * math.pow(im, 3.0)) tmp = 0 if im <= -1.25e+173: tmp = t_1 elif im <= -220.0: tmp = t_0 elif im <= 0.031: 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(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 * re)) t_1 = Float64(-0.16666666666666666 * Float64(sin(re) * (im ^ 3.0))) tmp = 0.0 if (im <= -1.25e+173) tmp = t_1; elseif (im <= -220.0) tmp = t_0; elseif (im <= 0.031) 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 = (exp(-im) - exp(im)) * (0.5 * re); t_1 = -0.16666666666666666 * (sin(re) * (im ^ 3.0)); tmp = 0.0; if (im <= -1.25e+173) tmp = t_1; elseif (im <= -220.0) tmp = t_0; elseif (im <= 0.031) 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[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * 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, -1.25e+173], t$95$1, If[LessEqual[im, -220.0], t$95$0, If[LessEqual[im, 0.031], 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 := \left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
t_1 := -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\
\mathbf{if}\;im \leq -1.25 \cdot 10^{+173}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -220:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.031:\\
\;\;\;\;\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 < -1.25000000000000009e173 or 5.49999999999999981e102 < 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 -1.25000000000000009e173 < im < -220 or 0.031 < im < 5.49999999999999981e102Initial program 100.0%
Taylor expanded in re around 0 77.2%
if -220 < im < 0.031Initial program 26.5%
Taylor expanded in im around 0 99.1%
mul-1-neg99.1%
unsub-neg99.1%
*-commutative99.1%
associate-*l*99.1%
distribute-lft-out--99.1%
Simplified99.1%
Final simplification94.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (- (* 0.16666666666666666 (pow re 3.0)) re)))
(t_1 (* -0.16666666666666666 (* (sin re) (pow im 3.0)))))
(if (<= im -2.2e+98)
t_1
(if (<= im -190000000000.0)
t_0
(if (<= im 17500000000000.0)
(* (- im) (sin re))
(if (<= im 4.3e+102) t_0 t_1))))))
double code(double re, double im) {
double t_0 = im * ((0.16666666666666666 * pow(re, 3.0)) - re);
double t_1 = -0.16666666666666666 * (sin(re) * pow(im, 3.0));
double tmp;
if (im <= -2.2e+98) {
tmp = t_1;
} else if (im <= -190000000000.0) {
tmp = t_0;
} else if (im <= 17500000000000.0) {
tmp = -im * sin(re);
} else if (im <= 4.3e+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 = im * ((0.16666666666666666d0 * (re ** 3.0d0)) - re)
t_1 = (-0.16666666666666666d0) * (sin(re) * (im ** 3.0d0))
if (im <= (-2.2d+98)) then
tmp = t_1
else if (im <= (-190000000000.0d0)) then
tmp = t_0
else if (im <= 17500000000000.0d0) then
tmp = -im * sin(re)
else if (im <= 4.3d+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 = im * ((0.16666666666666666 * Math.pow(re, 3.0)) - re);
double t_1 = -0.16666666666666666 * (Math.sin(re) * Math.pow(im, 3.0));
double tmp;
if (im <= -2.2e+98) {
tmp = t_1;
} else if (im <= -190000000000.0) {
tmp = t_0;
} else if (im <= 17500000000000.0) {
tmp = -im * Math.sin(re);
} else if (im <= 4.3e+102) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = im * ((0.16666666666666666 * math.pow(re, 3.0)) - re) t_1 = -0.16666666666666666 * (math.sin(re) * math.pow(im, 3.0)) tmp = 0 if im <= -2.2e+98: tmp = t_1 elif im <= -190000000000.0: tmp = t_0 elif im <= 17500000000000.0: tmp = -im * math.sin(re) elif im <= 4.3e+102: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(im * Float64(Float64(0.16666666666666666 * (re ^ 3.0)) - re)) t_1 = Float64(-0.16666666666666666 * Float64(sin(re) * (im ^ 3.0))) tmp = 0.0 if (im <= -2.2e+98) tmp = t_1; elseif (im <= -190000000000.0) tmp = t_0; elseif (im <= 17500000000000.0) tmp = Float64(Float64(-im) * sin(re)); elseif (im <= 4.3e+102) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = im * ((0.16666666666666666 * (re ^ 3.0)) - re); t_1 = -0.16666666666666666 * (sin(re) * (im ^ 3.0)); tmp = 0.0; if (im <= -2.2e+98) tmp = t_1; elseif (im <= -190000000000.0) tmp = t_0; elseif (im <= 17500000000000.0) tmp = -im * sin(re); elseif (im <= 4.3e+102) tmp = t_0; else tmp = t_1; 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]}, Block[{t$95$1 = N[(-0.16666666666666666 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.2e+98], t$95$1, If[LessEqual[im, -190000000000.0], t$95$0, If[LessEqual[im, 17500000000000.0], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.3e+102], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\
t_1 := -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\
\mathbf{if}\;im \leq -2.2 \cdot 10^{+98}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -190000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 17500000000000:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\mathbf{elif}\;im \leq 4.3 \cdot 10^{+102}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -2.20000000000000009e98 or 4.3000000000000001e102 < im Initial program 100.0%
Taylor expanded in im around 0 95.5%
mul-1-neg95.5%
unsub-neg95.5%
*-commutative95.5%
associate-*l*95.5%
distribute-lft-out--95.5%
Simplified95.5%
Taylor expanded in im around inf 95.5%
if -2.20000000000000009e98 < im < -1.9e11 or 1.75e13 < im < 4.3000000000000001e102Initial program 100.0%
Taylor expanded in im around 0 3.2%
mul-1-neg3.2%
*-commutative3.2%
distribute-lft-neg-in3.2%
Simplified3.2%
Taylor expanded in re around 0 36.8%
+-commutative36.8%
mul-1-neg36.8%
unsub-neg36.8%
associate-*r*36.8%
distribute-rgt-out--40.1%
Simplified40.1%
if -1.9e11 < im < 1.75e13Initial program 29.6%
Taylor expanded in im around 0 94.4%
mul-1-neg94.4%
*-commutative94.4%
distribute-lft-neg-in94.4%
Simplified94.4%
Final simplification88.2%
(FPCore (re im) :precision binary64 (* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im)))
double code(double re, double im) {
return sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
end function
public static double code(double re, double im) {
return Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
}
def code(re, im): return math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
function code(re, im) return Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)) end
function tmp = code(re, im) tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im); end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)
\end{array}
Initial program 61.5%
Taylor expanded in im around 0 84.2%
mul-1-neg84.2%
unsub-neg84.2%
*-commutative84.2%
associate-*l*84.2%
distribute-lft-out--84.2%
Simplified84.2%
Final simplification84.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.16666666666666666 (* re (pow im 3.0)))))
(if (<= im -210.0)
t_0
(if (<= im 27000000000000.0)
(* (- im) (sin re))
(if (<= im 8.5e+91)
(* im (- (* 0.16666666666666666 (pow re 3.0)) re))
t_0)))))
double code(double re, double im) {
double t_0 = -0.16666666666666666 * (re * pow(im, 3.0));
double tmp;
if (im <= -210.0) {
tmp = t_0;
} else if (im <= 27000000000000.0) {
tmp = -im * sin(re);
} else if (im <= 8.5e+91) {
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 = (-0.16666666666666666d0) * (re * (im ** 3.0d0))
if (im <= (-210.0d0)) then
tmp = t_0
else if (im <= 27000000000000.0d0) then
tmp = -im * sin(re)
else if (im <= 8.5d+91) 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 = -0.16666666666666666 * (re * Math.pow(im, 3.0));
double tmp;
if (im <= -210.0) {
tmp = t_0;
} else if (im <= 27000000000000.0) {
tmp = -im * Math.sin(re);
} else if (im <= 8.5e+91) {
tmp = im * ((0.16666666666666666 * Math.pow(re, 3.0)) - re);
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = -0.16666666666666666 * (re * math.pow(im, 3.0)) tmp = 0 if im <= -210.0: tmp = t_0 elif im <= 27000000000000.0: tmp = -im * math.sin(re) elif im <= 8.5e+91: tmp = im * ((0.16666666666666666 * math.pow(re, 3.0)) - re) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(-0.16666666666666666 * Float64(re * (im ^ 3.0))) tmp = 0.0 if (im <= -210.0) tmp = t_0; elseif (im <= 27000000000000.0) tmp = Float64(Float64(-im) * sin(re)); elseif (im <= 8.5e+91) 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 = -0.16666666666666666 * (re * (im ^ 3.0)); tmp = 0.0; if (im <= -210.0) tmp = t_0; elseif (im <= 27000000000000.0) tmp = -im * sin(re); elseif (im <= 8.5e+91) 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[(-0.16666666666666666 * N[(re * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -210.0], t$95$0, If[LessEqual[im, 27000000000000.0], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 8.5e+91], 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 := -0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\
\mathbf{if}\;im \leq -210:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 27000000000000:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\mathbf{elif}\;im \leq 8.5 \cdot 10^{+91}:\\
\;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -210 or 8.4999999999999995e91 < im Initial program 100.0%
Taylor expanded in re around 0 74.3%
Taylor expanded in im around 0 62.6%
+-commutative62.6%
fma-def62.6%
Simplified62.6%
Taylor expanded in im around inf 62.6%
if -210 < im < 2.7e13Initial program 27.6%
Taylor expanded in im around 0 97.1%
mul-1-neg97.1%
*-commutative97.1%
distribute-lft-neg-in97.1%
Simplified97.1%
if 2.7e13 < im < 8.4999999999999995e91Initial program 100.0%
Taylor expanded in im around 0 3.2%
mul-1-neg3.2%
*-commutative3.2%
distribute-lft-neg-in3.2%
Simplified3.2%
Taylor expanded in re around 0 35.1%
+-commutative35.1%
mul-1-neg35.1%
unsub-neg35.1%
associate-*r*35.1%
distribute-rgt-out--41.8%
Simplified41.8%
Final simplification79.7%
(FPCore (re im)
:precision binary64
(if (<= im -210.0)
(* -0.16666666666666666 (* re (pow im 3.0)))
(if (<= im 17500000000000.0)
(* (- im) (sin re))
(if (<= im 4e+94)
(* im (- (* 0.16666666666666666 (pow re 3.0)) re))
(* re (- (* (pow im 3.0) -0.16666666666666666) im))))))
double code(double re, double im) {
double tmp;
if (im <= -210.0) {
tmp = -0.16666666666666666 * (re * pow(im, 3.0));
} else if (im <= 17500000000000.0) {
tmp = -im * sin(re);
} else if (im <= 4e+94) {
tmp = im * ((0.16666666666666666 * pow(re, 3.0)) - 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 <= (-210.0d0)) then
tmp = (-0.16666666666666666d0) * (re * (im ** 3.0d0))
else if (im <= 17500000000000.0d0) then
tmp = -im * sin(re)
else if (im <= 4d+94) then
tmp = im * ((0.16666666666666666d0 * (re ** 3.0d0)) - 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 <= -210.0) {
tmp = -0.16666666666666666 * (re * Math.pow(im, 3.0));
} else if (im <= 17500000000000.0) {
tmp = -im * Math.sin(re);
} else if (im <= 4e+94) {
tmp = im * ((0.16666666666666666 * Math.pow(re, 3.0)) - re);
} else {
tmp = re * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -210.0: tmp = -0.16666666666666666 * (re * math.pow(im, 3.0)) elif im <= 17500000000000.0: tmp = -im * math.sin(re) elif im <= 4e+94: tmp = im * ((0.16666666666666666 * math.pow(re, 3.0)) - re) else: tmp = re * ((math.pow(im, 3.0) * -0.16666666666666666) - im) return tmp
function code(re, im) tmp = 0.0 if (im <= -210.0) tmp = Float64(-0.16666666666666666 * Float64(re * (im ^ 3.0))); elseif (im <= 17500000000000.0) tmp = Float64(Float64(-im) * sin(re)); elseif (im <= 4e+94) tmp = Float64(im * Float64(Float64(0.16666666666666666 * (re ^ 3.0)) - 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 <= -210.0) tmp = -0.16666666666666666 * (re * (im ^ 3.0)); elseif (im <= 17500000000000.0) tmp = -im * sin(re); elseif (im <= 4e+94) tmp = im * ((0.16666666666666666 * (re ^ 3.0)) - re); else tmp = re * (((im ^ 3.0) * -0.16666666666666666) - im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -210.0], N[(-0.16666666666666666 * N[(re * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 17500000000000.0], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4e+94], N[(im * N[(N[(0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] - 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 -210:\\
\;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\
\mathbf{elif}\;im \leq 17500000000000:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\mathbf{elif}\;im \leq 4 \cdot 10^{+94}:\\
\;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if im < -210Initial program 100.0%
Taylor expanded in re around 0 73.1%
Taylor expanded in im around 0 55.0%
+-commutative55.0%
fma-def55.0%
Simplified55.0%
Taylor expanded in im around inf 55.0%
if -210 < im < 1.75e13Initial program 27.6%
Taylor expanded in im around 0 97.1%
mul-1-neg97.1%
*-commutative97.1%
distribute-lft-neg-in97.1%
Simplified97.1%
if 1.75e13 < im < 4.0000000000000001e94Initial program 100.0%
Taylor expanded in im around 0 3.2%
mul-1-neg3.2%
*-commutative3.2%
distribute-lft-neg-in3.2%
Simplified3.2%
Taylor expanded in re around 0 35.1%
+-commutative35.1%
mul-1-neg35.1%
unsub-neg35.1%
associate-*r*35.1%
distribute-rgt-out--41.8%
Simplified41.8%
if 4.0000000000000001e94 < im Initial program 100.0%
Taylor expanded in im around 0 97.8%
mul-1-neg97.8%
unsub-neg97.8%
*-commutative97.8%
associate-*l*97.8%
distribute-lft-out--97.8%
Simplified97.8%
Taylor expanded in re around 0 74.0%
Final simplification79.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.16666666666666666 (* re (pow im 3.0)))))
(if (<= im -210.0)
t_0
(if (<= im 17500000000000.0)
(* (- im) (sin re))
(if (<= im 7.5e+90) (* 0.16666666666666666 (* im (pow re 3.0))) t_0)))))
double code(double re, double im) {
double t_0 = -0.16666666666666666 * (re * pow(im, 3.0));
double tmp;
if (im <= -210.0) {
tmp = t_0;
} else if (im <= 17500000000000.0) {
tmp = -im * sin(re);
} else if (im <= 7.5e+90) {
tmp = 0.16666666666666666 * (im * pow(re, 3.0));
} 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 = (-0.16666666666666666d0) * (re * (im ** 3.0d0))
if (im <= (-210.0d0)) then
tmp = t_0
else if (im <= 17500000000000.0d0) then
tmp = -im * sin(re)
else if (im <= 7.5d+90) then
tmp = 0.16666666666666666d0 * (im * (re ** 3.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = -0.16666666666666666 * (re * Math.pow(im, 3.0));
double tmp;
if (im <= -210.0) {
tmp = t_0;
} else if (im <= 17500000000000.0) {
tmp = -im * Math.sin(re);
} else if (im <= 7.5e+90) {
tmp = 0.16666666666666666 * (im * Math.pow(re, 3.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = -0.16666666666666666 * (re * math.pow(im, 3.0)) tmp = 0 if im <= -210.0: tmp = t_0 elif im <= 17500000000000.0: tmp = -im * math.sin(re) elif im <= 7.5e+90: tmp = 0.16666666666666666 * (im * math.pow(re, 3.0)) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(-0.16666666666666666 * Float64(re * (im ^ 3.0))) tmp = 0.0 if (im <= -210.0) tmp = t_0; elseif (im <= 17500000000000.0) tmp = Float64(Float64(-im) * sin(re)); elseif (im <= 7.5e+90) tmp = Float64(0.16666666666666666 * Float64(im * (re ^ 3.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = -0.16666666666666666 * (re * (im ^ 3.0)); tmp = 0.0; if (im <= -210.0) tmp = t_0; elseif (im <= 17500000000000.0) tmp = -im * sin(re); elseif (im <= 7.5e+90) tmp = 0.16666666666666666 * (im * (re ^ 3.0)); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(-0.16666666666666666 * N[(re * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -210.0], t$95$0, If[LessEqual[im, 17500000000000.0], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 7.5e+90], N[(0.16666666666666666 * N[(im * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\
\mathbf{if}\;im \leq -210:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 17500000000000:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\mathbf{elif}\;im \leq 7.5 \cdot 10^{+90}:\\
\;\;\;\;0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -210 or 7.50000000000000014e90 < im Initial program 100.0%
Taylor expanded in re around 0 74.3%
Taylor expanded in im around 0 62.6%
+-commutative62.6%
fma-def62.6%
Simplified62.6%
Taylor expanded in im around inf 62.6%
if -210 < im < 1.75e13Initial program 27.6%
Taylor expanded in im around 0 97.1%
mul-1-neg97.1%
*-commutative97.1%
distribute-lft-neg-in97.1%
Simplified97.1%
if 1.75e13 < im < 7.50000000000000014e90Initial program 100.0%
Taylor expanded in im around 0 3.2%
mul-1-neg3.2%
*-commutative3.2%
distribute-lft-neg-in3.2%
Simplified3.2%
Taylor expanded in re around 0 35.1%
Taylor expanded in re around inf 40.7%
Final simplification79.6%
(FPCore (re im) :precision binary64 (if (or (<= im -190.0) (not (<= im 3e+65))) (* -0.16666666666666666 (* re (pow im 3.0))) (* (- im) (sin re))))
double code(double re, double im) {
double tmp;
if ((im <= -190.0) || !(im <= 3e+65)) {
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 <= (-190.0d0)) .or. (.not. (im <= 3d+65))) 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 <= -190.0) || !(im <= 3e+65)) {
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 <= -190.0) or not (im <= 3e+65): 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 <= -190.0) || !(im <= 3e+65)) tmp = Float64(-0.16666666666666666 * Float64(re * (im ^ 3.0))); else tmp = Float64(Float64(-im) * sin(re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -190.0) || ~((im <= 3e+65))) tmp = -0.16666666666666666 * (re * (im ^ 3.0)); else tmp = -im * sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -190.0], N[Not[LessEqual[im, 3e+65]], $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 -190 \lor \neg \left(im \leq 3 \cdot 10^{+65}\right):\\
\;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\end{array}
\end{array}
if im < -190 or 3.0000000000000002e65 < im Initial program 100.0%
Taylor expanded in re around 0 75.1%
Taylor expanded in im around 0 58.9%
+-commutative58.9%
fma-def58.9%
Simplified58.9%
Taylor expanded in im around inf 58.9%
if -190 < im < 3.0000000000000002e65Initial program 31.6%
Taylor expanded in im around 0 91.9%
mul-1-neg91.9%
*-commutative91.9%
distribute-lft-neg-in91.9%
Simplified91.9%
Final simplification77.5%
(FPCore (re im) :precision binary64 (if (or (<= im -210.0) (not (<= im 1.1e+112))) (* (- im) re) (* (- im) (sin re))))
double code(double re, double im) {
double tmp;
if ((im <= -210.0) || !(im <= 1.1e+112)) {
tmp = -im * 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 <= (-210.0d0)) .or. (.not. (im <= 1.1d+112))) then
tmp = -im * re
else
tmp = -im * sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -210.0) || !(im <= 1.1e+112)) {
tmp = -im * re;
} else {
tmp = -im * Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -210.0) or not (im <= 1.1e+112): tmp = -im * re else: tmp = -im * math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -210.0) || !(im <= 1.1e+112)) tmp = Float64(Float64(-im) * re); else tmp = Float64(Float64(-im) * sin(re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -210.0) || ~((im <= 1.1e+112))) tmp = -im * re; else tmp = -im * sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -210.0], N[Not[LessEqual[im, 1.1e+112]], $MachinePrecision]], N[((-im) * re), $MachinePrecision], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -210 \lor \neg \left(im \leq 1.1 \cdot 10^{+112}\right):\\
\;\;\;\;\left(-im\right) \cdot re\\
\mathbf{else}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\end{array}
\end{array}
if im < -210 or 1.1e112 < im Initial program 100.0%
Taylor expanded in im around 0 4.5%
mul-1-neg4.5%
*-commutative4.5%
distribute-lft-neg-in4.5%
Simplified4.5%
Taylor expanded in re around 0 14.9%
if -210 < im < 1.1e112Initial program 37.3%
Taylor expanded in im around 0 84.6%
mul-1-neg84.6%
*-commutative84.6%
distribute-lft-neg-in84.6%
Simplified84.6%
Final simplification57.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(Float64(-im) * re) end
function tmp = code(re, im) tmp = -im * re; end
code[re_, im_] := N[((-im) * re), $MachinePrecision]
\begin{array}{l}
\\
\left(-im\right) \cdot re
\end{array}
Initial program 61.5%
Taylor expanded in im around 0 53.6%
mul-1-neg53.6%
*-commutative53.6%
distribute-lft-neg-in53.6%
Simplified53.6%
Taylor expanded in re around 0 29.2%
Final simplification29.2%
(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 2023201
(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))))