
(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 13 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))) (t_1 (* 0.5 (sin re))))
(if (or (<= t_0 -1.0) (not (<= t_0 0.04)))
(* t_0 t_1)
(*
t_1
(+
(* im -2.0)
(+
(* -0.3333333333333333 (pow im 3.0))
(* -0.016666666666666666 (pow im 5.0))))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double t_1 = 0.5 * sin(re);
double tmp;
if ((t_0 <= -1.0) || !(t_0 <= 0.04)) {
tmp = t_0 * t_1;
} else {
tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * pow(im, 3.0)) + (-0.016666666666666666 * pow(im, 5.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) :: t_1
real(8) :: tmp
t_0 = exp(-im) - exp(im)
t_1 = 0.5d0 * sin(re)
if ((t_0 <= (-1.0d0)) .or. (.not. (t_0 <= 0.04d0))) then
tmp = t_0 * t_1
else
tmp = t_1 * ((im * (-2.0d0)) + (((-0.3333333333333333d0) * (im ** 3.0d0)) + ((-0.016666666666666666d0) * (im ** 5.0d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double t_1 = 0.5 * Math.sin(re);
double tmp;
if ((t_0 <= -1.0) || !(t_0 <= 0.04)) {
tmp = t_0 * t_1;
} else {
tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * Math.pow(im, 3.0)) + (-0.016666666666666666 * Math.pow(im, 5.0))));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) t_1 = 0.5 * math.sin(re) tmp = 0 if (t_0 <= -1.0) or not (t_0 <= 0.04): tmp = t_0 * t_1 else: tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * math.pow(im, 3.0)) + (-0.016666666666666666 * math.pow(im, 5.0)))) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) t_1 = Float64(0.5 * sin(re)) tmp = 0.0 if ((t_0 <= -1.0) || !(t_0 <= 0.04)) tmp = Float64(t_0 * t_1); else tmp = Float64(t_1 * Float64(Float64(im * -2.0) + Float64(Float64(-0.3333333333333333 * (im ^ 3.0)) + Float64(-0.016666666666666666 * (im ^ 5.0))))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); t_1 = 0.5 * sin(re); tmp = 0.0; if ((t_0 <= -1.0) || ~((t_0 <= 0.04))) tmp = t_0 * t_1; else tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * (im ^ 3.0)) + (-0.016666666666666666 * (im ^ 5.0)))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -1.0], N[Not[LessEqual[t$95$0, 0.04]], $MachinePrecision]], N[(t$95$0 * t$95$1), $MachinePrecision], N[(t$95$1 * N[(N[(im * -2.0), $MachinePrecision] + N[(N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.016666666666666666 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := 0.5 \cdot \sin re\\
\mathbf{if}\;t_0 \leq -1 \lor \neg \left(t_0 \leq 0.04\right):\\
\;\;\;\;t_0 \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(im \cdot -2 + \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -1 or 0.0400000000000000008 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
if -1 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 0.0400000000000000008Initial program 37.1%
Taylor expanded in im around 0 99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (or (<= t_0 -1.0) (not (<= t_0 0.04)))
(* t_0 (* 0.5 (sin re)))
(*
(sin re)
(+
(* (pow im 5.0) -0.008333333333333333)
(- (* (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 <= -1.0) || !(t_0 <= 0.04)) {
tmp = t_0 * (0.5 * sin(re));
} else {
tmp = sin(re) * ((pow(im, 5.0) * -0.008333333333333333) + ((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 <= (-1.0d0)) .or. (.not. (t_0 <= 0.04d0))) then
tmp = t_0 * (0.5d0 * sin(re))
else
tmp = sin(re) * (((im ** 5.0d0) * (-0.008333333333333333d0)) + (((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 <= -1.0) || !(t_0 <= 0.04)) {
tmp = t_0 * (0.5 * Math.sin(re));
} else {
tmp = Math.sin(re) * ((Math.pow(im, 5.0) * -0.008333333333333333) + ((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 <= -1.0) or not (t_0 <= 0.04): tmp = t_0 * (0.5 * math.sin(re)) else: tmp = math.sin(re) * ((math.pow(im, 5.0) * -0.008333333333333333) + ((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 <= -1.0) || !(t_0 <= 0.04)) tmp = Float64(t_0 * Float64(0.5 * sin(re))); else tmp = Float64(sin(re) * Float64(Float64((im ^ 5.0) * -0.008333333333333333) + 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 <= -1.0) || ~((t_0 <= 0.04))) tmp = t_0 * (0.5 * sin(re)); else tmp = sin(re) * (((im ^ 5.0) * -0.008333333333333333) + (((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, -1.0], N[Not[LessEqual[t$95$0, 0.04]], $MachinePrecision]], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision] + N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -1 \lor \neg \left(t_0 \leq 0.04\right):\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left({im}^{5} \cdot -0.008333333333333333 + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -1 or 0.0400000000000000008 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 100.0%
if -1 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 0.0400000000000000008Initial program 37.1%
Taylor expanded in im around 0 99.8%
Taylor expanded in im around 0 99.8%
associate-+r+99.8%
neg-mul-199.8%
distribute-lft-neg-in99.8%
associate-*r*99.8%
*-commutative99.8%
distribute-rgt-in99.8%
+-commutative99.8%
sub-neg99.8%
*-commutative99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (or (<= t_0 -1.0) (not (<= t_0 2e-11)))
(* t_0 (* 0.5 (sin re)))
(- (* -0.16666666666666666 (* (sin re) (pow im 3.0))) (* im (sin re))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -1.0) || !(t_0 <= 2e-11)) {
tmp = t_0 * (0.5 * sin(re));
} else {
tmp = (-0.16666666666666666 * (sin(re) * pow(im, 3.0))) - (im * sin(re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-im) - exp(im)
if ((t_0 <= (-1.0d0)) .or. (.not. (t_0 <= 2d-11))) then
tmp = t_0 * (0.5d0 * sin(re))
else
tmp = ((-0.16666666666666666d0) * (sin(re) * (im ** 3.0d0))) - (im * sin(re))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double tmp;
if ((t_0 <= -1.0) || !(t_0 <= 2e-11)) {
tmp = t_0 * (0.5 * Math.sin(re));
} else {
tmp = (-0.16666666666666666 * (Math.sin(re) * Math.pow(im, 3.0))) - (im * Math.sin(re));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -1.0) or not (t_0 <= 2e-11): tmp = t_0 * (0.5 * math.sin(re)) else: tmp = (-0.16666666666666666 * (math.sin(re) * math.pow(im, 3.0))) - (im * math.sin(re)) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= -1.0) || !(t_0 <= 2e-11)) tmp = Float64(t_0 * Float64(0.5 * sin(re))); else tmp = Float64(Float64(-0.16666666666666666 * Float64(sin(re) * (im ^ 3.0))) - Float64(im * sin(re))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -1.0) || ~((t_0 <= 2e-11))) tmp = t_0 * (0.5 * sin(re)); else tmp = (-0.16666666666666666 * (sin(re) * (im ^ 3.0))) - (im * sin(re)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -1.0], N[Not[LessEqual[t$95$0, 2e-11]], $MachinePrecision]], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.16666666666666666 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -1 \lor \neg \left(t_0 \leq 2 \cdot 10^{-11}\right):\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\
\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right) - im \cdot \sin re\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -1 or 1.99999999999999988e-11 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 99.8%
if -1 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 1.99999999999999988e-11Initial program 36.2%
Taylor expanded in im around 0 99.8%
Final simplification99.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (or (<= t_0 -1.0) (not (<= t_0 2e-11)))
(* 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 <= -1.0) || !(t_0 <= 2e-11)) {
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 <= (-1.0d0)) .or. (.not. (t_0 <= 2d-11))) 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 <= -1.0) || !(t_0 <= 2e-11)) {
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 <= -1.0) or not (t_0 <= 2e-11): 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 <= -1.0) || !(t_0 <= 2e-11)) 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 <= -1.0) || ~((t_0 <= 2e-11))) 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, -1.0], N[Not[LessEqual[t$95$0, 2e-11]], $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 -1 \lor \neg \left(t_0 \leq 2 \cdot 10^{-11}\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)) < -1 or 1.99999999999999988e-11 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 99.8%
if -1 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 1.99999999999999988e-11Initial program 36.2%
Taylor expanded in im around 0 99.8%
+-commutative99.8%
mul-1-neg99.8%
unsub-neg99.8%
associate-*r*99.8%
distribute-rgt-out--99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))) (t_1 (* 0.5 (sin re))))
(if (<= t_0 -1.0)
(* t_0 t_1)
(*
t_1
(+
(* im -2.0)
(+
(* -0.3333333333333333 (pow im 3.0))
(+
(* -0.016666666666666666 (pow im 5.0))
(* -0.0003968253968253968 (pow im 7.0)))))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double t_1 = 0.5 * sin(re);
double tmp;
if (t_0 <= -1.0) {
tmp = t_0 * t_1;
} else {
tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * pow(im, 3.0)) + ((-0.016666666666666666 * pow(im, 5.0)) + (-0.0003968253968253968 * pow(im, 7.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) :: t_1
real(8) :: tmp
t_0 = exp(-im) - exp(im)
t_1 = 0.5d0 * sin(re)
if (t_0 <= (-1.0d0)) then
tmp = t_0 * t_1
else
tmp = t_1 * ((im * (-2.0d0)) + (((-0.3333333333333333d0) * (im ** 3.0d0)) + (((-0.016666666666666666d0) * (im ** 5.0d0)) + ((-0.0003968253968253968d0) * (im ** 7.0d0)))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double t_1 = 0.5 * Math.sin(re);
double tmp;
if (t_0 <= -1.0) {
tmp = t_0 * t_1;
} else {
tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * Math.pow(im, 3.0)) + ((-0.016666666666666666 * Math.pow(im, 5.0)) + (-0.0003968253968253968 * Math.pow(im, 7.0)))));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) t_1 = 0.5 * math.sin(re) tmp = 0 if t_0 <= -1.0: tmp = t_0 * t_1 else: tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * math.pow(im, 3.0)) + ((-0.016666666666666666 * math.pow(im, 5.0)) + (-0.0003968253968253968 * math.pow(im, 7.0))))) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) t_1 = Float64(0.5 * sin(re)) tmp = 0.0 if (t_0 <= -1.0) tmp = Float64(t_0 * t_1); else tmp = Float64(t_1 * Float64(Float64(im * -2.0) + Float64(Float64(-0.3333333333333333 * (im ^ 3.0)) + Float64(Float64(-0.016666666666666666 * (im ^ 5.0)) + Float64(-0.0003968253968253968 * (im ^ 7.0)))))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); t_1 = 0.5 * sin(re); tmp = 0.0; if (t_0 <= -1.0) tmp = t_0 * t_1; else tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * (im ^ 3.0)) + ((-0.016666666666666666 * (im ^ 5.0)) + (-0.0003968253968253968 * (im ^ 7.0))))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1.0], N[(t$95$0 * t$95$1), $MachinePrecision], N[(t$95$1 * N[(N[(im * -2.0), $MachinePrecision] + N[(N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-0.016666666666666666 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision] + N[(-0.0003968253968253968 * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := 0.5 \cdot \sin re\\
\mathbf{if}\;t_0 \leq -1:\\
\;\;\;\;t_0 \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(im \cdot -2 + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -1Initial program 99.9%
if -1 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 59.3%
Taylor expanded in im around 0 98.9%
Final simplification99.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (<= t_0 -1.0)
(* t_0 (* 0.5 (sin re)))
(*
(sin re)
(+
(+
(* (pow im 5.0) -0.008333333333333333)
(* (pow im 7.0) -0.0001984126984126984))
(- (* (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 <= -1.0) {
tmp = t_0 * (0.5 * sin(re));
} else {
tmp = sin(re) * (((pow(im, 5.0) * -0.008333333333333333) + (pow(im, 7.0) * -0.0001984126984126984)) + ((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 <= (-1.0d0)) then
tmp = t_0 * (0.5d0 * sin(re))
else
tmp = sin(re) * ((((im ** 5.0d0) * (-0.008333333333333333d0)) + ((im ** 7.0d0) * (-0.0001984126984126984d0))) + (((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 <= -1.0) {
tmp = t_0 * (0.5 * Math.sin(re));
} else {
tmp = Math.sin(re) * (((Math.pow(im, 5.0) * -0.008333333333333333) + (Math.pow(im, 7.0) * -0.0001984126984126984)) + ((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 <= -1.0: tmp = t_0 * (0.5 * math.sin(re)) else: tmp = math.sin(re) * (((math.pow(im, 5.0) * -0.008333333333333333) + (math.pow(im, 7.0) * -0.0001984126984126984)) + ((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 <= -1.0) tmp = Float64(t_0 * Float64(0.5 * sin(re))); else tmp = Float64(sin(re) * Float64(Float64(Float64((im ^ 5.0) * -0.008333333333333333) + Float64((im ^ 7.0) * -0.0001984126984126984)) + 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 <= -1.0) tmp = t_0 * (0.5 * sin(re)); else tmp = sin(re) * ((((im ^ 5.0) * -0.008333333333333333) + ((im ^ 7.0) * -0.0001984126984126984)) + (((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[LessEqual[t$95$0, -1.0], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision] + N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -1:\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 + {im}^{7} \cdot -0.0001984126984126984\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -1Initial program 99.9%
if -1 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 59.3%
Taylor expanded in im around 0 98.9%
Taylor expanded in im around 0 98.9%
associate-+r+98.9%
neg-mul-198.9%
distribute-lft-neg-in98.9%
associate-*r*98.9%
*-commutative98.9%
distribute-rgt-in98.8%
+-commutative98.8%
sub-neg98.8%
+-commutative98.8%
associate-*r*98.8%
associate-*r*98.8%
distribute-rgt-out98.8%
Simplified98.9%
Final simplification99.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.0001984126984126984 (* (sin re) (pow im 7.0)))))
(if (<= im -1.45e+57)
t_0
(if (<= im 0.00105)
(log1p (expm1 (* (- im) (sin re))))
(if (<= im 1.1e+44) (* (- (exp (- im)) (exp im)) (* 0.5 re)) t_0)))))
double code(double re, double im) {
double t_0 = -0.0001984126984126984 * (sin(re) * pow(im, 7.0));
double tmp;
if (im <= -1.45e+57) {
tmp = t_0;
} else if (im <= 0.00105) {
tmp = log1p(expm1((-im * sin(re))));
} else if (im <= 1.1e+44) {
tmp = (exp(-im) - exp(im)) * (0.5 * re);
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = -0.0001984126984126984 * (Math.sin(re) * Math.pow(im, 7.0));
double tmp;
if (im <= -1.45e+57) {
tmp = t_0;
} else if (im <= 0.00105) {
tmp = Math.log1p(Math.expm1((-im * Math.sin(re))));
} else if (im <= 1.1e+44) {
tmp = (Math.exp(-im) - Math.exp(im)) * (0.5 * re);
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = -0.0001984126984126984 * (math.sin(re) * math.pow(im, 7.0)) tmp = 0 if im <= -1.45e+57: tmp = t_0 elif im <= 0.00105: tmp = math.log1p(math.expm1((-im * math.sin(re)))) elif im <= 1.1e+44: tmp = (math.exp(-im) - math.exp(im)) * (0.5 * re) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(-0.0001984126984126984 * Float64(sin(re) * (im ^ 7.0))) tmp = 0.0 if (im <= -1.45e+57) tmp = t_0; elseif (im <= 0.00105) tmp = log1p(expm1(Float64(Float64(-im) * sin(re)))); elseif (im <= 1.1e+44) tmp = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 * re)); else tmp = t_0; end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(-0.0001984126984126984 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.45e+57], t$95$0, If[LessEqual[im, 0.00105], N[Log[1 + N[(Exp[N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 1.1e+44], N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\
\mathbf{if}\;im \leq -1.45 \cdot 10^{+57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.00105:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\left(-im\right) \cdot \sin re\right)\right)\\
\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -1.4500000000000001e57 or 1.09999999999999998e44 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
if -1.4500000000000001e57 < im < 0.00104999999999999994Initial program 41.0%
Taylor expanded in im around 0 92.9%
associate-*r*92.9%
neg-mul-192.9%
Simplified92.9%
log1p-expm1-u98.8%
*-commutative98.8%
Applied egg-rr98.8%
if 0.00104999999999999994 < im < 1.09999999999999998e44Initial program 99.7%
Taylor expanded in re around 0 84.6%
associate-*r*84.6%
*-commutative84.6%
Simplified84.6%
Final simplification98.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.0001984126984126984 (* (sin re) (pow im 7.0)))))
(if (<= im -5.7)
t_0
(if (<= im 0.0225)
(* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
(if (<= im 1.1e+44) (* (- (exp (- im)) (exp im)) (* 0.5 re)) t_0)))))
double code(double re, double im) {
double t_0 = -0.0001984126984126984 * (sin(re) * pow(im, 7.0));
double tmp;
if (im <= -5.7) {
tmp = t_0;
} else if (im <= 0.0225) {
tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 1.1e+44) {
tmp = (exp(-im) - exp(im)) * (0.5 * 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.0001984126984126984d0) * (sin(re) * (im ** 7.0d0))
if (im <= (-5.7d0)) then
tmp = t_0
else if (im <= 0.0225d0) then
tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else if (im <= 1.1d+44) then
tmp = (exp(-im) - exp(im)) * (0.5d0 * re)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = -0.0001984126984126984 * (Math.sin(re) * Math.pow(im, 7.0));
double tmp;
if (im <= -5.7) {
tmp = t_0;
} else if (im <= 0.0225) {
tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else if (im <= 1.1e+44) {
tmp = (Math.exp(-im) - Math.exp(im)) * (0.5 * re);
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = -0.0001984126984126984 * (math.sin(re) * math.pow(im, 7.0)) tmp = 0 if im <= -5.7: tmp = t_0 elif im <= 0.0225: tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) elif im <= 1.1e+44: tmp = (math.exp(-im) - math.exp(im)) * (0.5 * re) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(-0.0001984126984126984 * Float64(sin(re) * (im ^ 7.0))) tmp = 0.0 if (im <= -5.7) tmp = t_0; elseif (im <= 0.0225) tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); elseif (im <= 1.1e+44) tmp = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 * re)); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = -0.0001984126984126984 * (sin(re) * (im ^ 7.0)); tmp = 0.0; if (im <= -5.7) tmp = t_0; elseif (im <= 0.0225) tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im); elseif (im <= 1.1e+44) tmp = (exp(-im) - exp(im)) * (0.5 * re); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(-0.0001984126984126984 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.7], t$95$0, If[LessEqual[im, 0.0225], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.1e+44], N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\
\mathbf{if}\;im \leq -5.7:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 0.0225:\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -5.70000000000000018 or 1.09999999999999998e44 < im Initial program 100.0%
Taylor expanded in im around 0 98.3%
Taylor expanded in im around inf 98.3%
if -5.70000000000000018 < im < 0.022499999999999999Initial program 37.1%
Taylor expanded in im around 0 99.4%
+-commutative99.4%
mul-1-neg99.4%
unsub-neg99.4%
associate-*r*99.4%
distribute-rgt-out--99.4%
*-commutative99.4%
Simplified99.4%
if 0.022499999999999999 < im < 1.09999999999999998e44Initial program 99.7%
Taylor expanded in re around 0 84.6%
associate-*r*84.6%
*-commutative84.6%
Simplified84.6%
Final simplification97.8%
(FPCore (re im) :precision binary64 (if (or (<= im -5.7) (not (<= im 5.6))) (* -0.0001984126984126984 (* (sin re) (pow im 7.0))) (* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))))
double code(double re, double im) {
double tmp;
if ((im <= -5.7) || !(im <= 5.6)) {
tmp = -0.0001984126984126984 * (sin(re) * pow(im, 7.0));
} 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 <= (-5.7d0)) .or. (.not. (im <= 5.6d0))) then
tmp = (-0.0001984126984126984d0) * (sin(re) * (im ** 7.0d0))
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 <= -5.7) || !(im <= 5.6)) {
tmp = -0.0001984126984126984 * (Math.sin(re) * Math.pow(im, 7.0));
} else {
tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -5.7) or not (im <= 5.6): tmp = -0.0001984126984126984 * (math.sin(re) * math.pow(im, 7.0)) else: tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) return tmp
function code(re, im) tmp = 0.0 if ((im <= -5.7) || !(im <= 5.6)) tmp = Float64(-0.0001984126984126984 * Float64(sin(re) * (im ^ 7.0))); 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 <= -5.7) || ~((im <= 5.6))) tmp = -0.0001984126984126984 * (sin(re) * (im ^ 7.0)); else tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -5.7], N[Not[LessEqual[im, 5.6]], $MachinePrecision]], N[(-0.0001984126984126984 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 7.0], $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}
\mathbf{if}\;im \leq -5.7 \lor \neg \left(im \leq 5.6\right):\\
\;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if im < -5.70000000000000018 or 5.5999999999999996 < im Initial program 100.0%
Taylor expanded in im around 0 85.8%
Taylor expanded in im around inf 85.7%
if -5.70000000000000018 < im < 5.5999999999999996Initial program 37.7%
Taylor expanded in im around 0 98.9%
+-commutative98.9%
mul-1-neg98.9%
unsub-neg98.9%
associate-*r*98.9%
distribute-rgt-out--98.9%
*-commutative98.9%
Simplified98.9%
Final simplification92.1%
(FPCore (re im) :precision binary64 (if (or (<= im -4.2) (not (<= im 4.2))) (* -0.0001984126984126984 (* (sin re) (pow im 7.0))) (* (- im) (sin re))))
double code(double re, double im) {
double tmp;
if ((im <= -4.2) || !(im <= 4.2)) {
tmp = -0.0001984126984126984 * (sin(re) * pow(im, 7.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 <= (-4.2d0)) .or. (.not. (im <= 4.2d0))) then
tmp = (-0.0001984126984126984d0) * (sin(re) * (im ** 7.0d0))
else
tmp = -im * sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -4.2) || !(im <= 4.2)) {
tmp = -0.0001984126984126984 * (Math.sin(re) * Math.pow(im, 7.0));
} else {
tmp = -im * Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -4.2) or not (im <= 4.2): tmp = -0.0001984126984126984 * (math.sin(re) * math.pow(im, 7.0)) else: tmp = -im * math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -4.2) || !(im <= 4.2)) tmp = Float64(-0.0001984126984126984 * Float64(sin(re) * (im ^ 7.0))); else tmp = Float64(Float64(-im) * sin(re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -4.2) || ~((im <= 4.2))) tmp = -0.0001984126984126984 * (sin(re) * (im ^ 7.0)); else tmp = -im * sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -4.2], N[Not[LessEqual[im, 4.2]], $MachinePrecision]], N[(-0.0001984126984126984 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.2 \lor \neg \left(im \leq 4.2\right):\\
\;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\end{array}
\end{array}
if im < -4.20000000000000018 or 4.20000000000000018 < im Initial program 100.0%
Taylor expanded in im around 0 85.8%
Taylor expanded in im around inf 85.7%
if -4.20000000000000018 < im < 4.20000000000000018Initial program 37.7%
Taylor expanded in im around 0 98.1%
associate-*r*98.1%
neg-mul-198.1%
Simplified98.1%
Final simplification91.7%
(FPCore (re im) :precision binary64 (if (or (<= im -1.3e+46) (not (<= im 30500000000.0))) (* -0.0001984126984126984 (* re (pow im 7.0))) (* (- im) (sin re))))
double code(double re, double im) {
double tmp;
if ((im <= -1.3e+46) || !(im <= 30500000000.0)) {
tmp = -0.0001984126984126984 * (re * pow(im, 7.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 <= (-1.3d+46)) .or. (.not. (im <= 30500000000.0d0))) then
tmp = (-0.0001984126984126984d0) * (re * (im ** 7.0d0))
else
tmp = -im * sin(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -1.3e+46) || !(im <= 30500000000.0)) {
tmp = -0.0001984126984126984 * (re * Math.pow(im, 7.0));
} else {
tmp = -im * Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -1.3e+46) or not (im <= 30500000000.0): tmp = -0.0001984126984126984 * (re * math.pow(im, 7.0)) else: tmp = -im * math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -1.3e+46) || !(im <= 30500000000.0)) tmp = Float64(-0.0001984126984126984 * Float64(re * (im ^ 7.0))); else tmp = Float64(Float64(-im) * sin(re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -1.3e+46) || ~((im <= 30500000000.0))) tmp = -0.0001984126984126984 * (re * (im ^ 7.0)); else tmp = -im * sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -1.3e+46], N[Not[LessEqual[im, 30500000000.0]], $MachinePrecision]], N[(-0.0001984126984126984 * N[(re * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.3 \cdot 10^{+46} \lor \neg \left(im \leq 30500000000\right):\\
\;\;\;\;-0.0001984126984126984 \cdot \left(re \cdot {im}^{7}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\end{array}
\end{array}
if im < -1.30000000000000007e46 or 3.05e10 < im Initial program 100.0%
Taylor expanded in im around 0 91.4%
Taylor expanded in im around 0 91.4%
associate-+r+91.4%
neg-mul-191.4%
distribute-lft-neg-in91.4%
associate-*r*91.4%
*-commutative91.4%
distribute-rgt-in91.4%
+-commutative91.4%
sub-neg91.4%
+-commutative91.4%
associate-*r*91.4%
associate-*r*91.4%
distribute-rgt-out91.4%
Simplified91.4%
Taylor expanded in im around inf 91.4%
associate-*r*91.4%
*-commutative91.4%
associate-*l*91.4%
Simplified91.4%
Taylor expanded in re around 0 76.5%
if -1.30000000000000007e46 < im < 3.05e10Initial program 42.3%
Taylor expanded in im around 0 91.2%
associate-*r*91.2%
neg-mul-191.2%
Simplified91.2%
Final simplification84.2%
(FPCore (re im) :precision binary64 (if (or (<= im -1.82e+177) (not (<= im 340000000000.0))) (* (- im) re) (* (- im) (sin re))))
double code(double re, double im) {
double tmp;
if ((im <= -1.82e+177) || !(im <= 340000000000.0)) {
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 <= (-1.82d+177)) .or. (.not. (im <= 340000000000.0d0))) 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 <= -1.82e+177) || !(im <= 340000000000.0)) {
tmp = -im * re;
} else {
tmp = -im * Math.sin(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -1.82e+177) or not (im <= 340000000000.0): tmp = -im * re else: tmp = -im * math.sin(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -1.82e+177) || !(im <= 340000000000.0)) 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 <= -1.82e+177) || ~((im <= 340000000000.0))) tmp = -im * re; else tmp = -im * sin(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -1.82e+177], N[Not[LessEqual[im, 340000000000.0]], $MachinePrecision]], N[((-im) * re), $MachinePrecision], N[((-im) * N[Sin[re], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.82 \cdot 10^{+177} \lor \neg \left(im \leq 340000000000\right):\\
\;\;\;\;\left(-im\right) \cdot re\\
\mathbf{else}:\\
\;\;\;\;\left(-im\right) \cdot \sin re\\
\end{array}
\end{array}
if im < -1.82e177 or 3.4e11 < im Initial program 100.0%
Taylor expanded in im around 0 4.7%
associate-*r*4.7%
neg-mul-14.7%
Simplified4.7%
Taylor expanded in re around 0 15.7%
associate-*r*15.7%
neg-mul-115.7%
Simplified15.7%
if -1.82e177 < im < 3.4e11Initial program 54.2%
Taylor expanded in im around 0 73.0%
associate-*r*73.0%
neg-mul-173.0%
Simplified73.0%
Final simplification53.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 69.8%
Taylor expanded in im around 0 49.8%
associate-*r*49.8%
neg-mul-149.8%
Simplified49.8%
Taylor expanded in re around 0 32.9%
associate-*r*32.9%
neg-mul-132.9%
Simplified32.9%
Final simplification32.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 2023293
(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))))