
(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 9 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}
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
:precision binary64
(let* ((t_0 (- (exp (- im_m)) (exp im_m))) (t_1 (* 0.5 (sin re))))
(*
im_s
(if (<= t_0 -4.0)
(* t_0 t_1)
(*
t_1
(+
(* im_m -2.0)
(+
(* -0.3333333333333333 (pow im_m 3.0))
(* -0.016666666666666666 (pow im_m 5.0)))))))))im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
double t_0 = exp(-im_m) - exp(im_m);
double t_1 = 0.5 * sin(re);
double tmp;
if (t_0 <= -4.0) {
tmp = t_0 * t_1;
} else {
tmp = t_1 * ((im_m * -2.0) + ((-0.3333333333333333 * pow(im_m, 3.0)) + (-0.016666666666666666 * pow(im_m, 5.0))));
}
return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
real(8), intent (in) :: im_s
real(8), intent (in) :: re
real(8), intent (in) :: im_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(-im_m) - exp(im_m)
t_1 = 0.5d0 * sin(re)
if (t_0 <= (-4.0d0)) then
tmp = t_0 * t_1
else
tmp = t_1 * ((im_m * (-2.0d0)) + (((-0.3333333333333333d0) * (im_m ** 3.0d0)) + ((-0.016666666666666666d0) * (im_m ** 5.0d0))))
end if
code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
double t_0 = Math.exp(-im_m) - Math.exp(im_m);
double t_1 = 0.5 * Math.sin(re);
double tmp;
if (t_0 <= -4.0) {
tmp = t_0 * t_1;
} else {
tmp = t_1 * ((im_m * -2.0) + ((-0.3333333333333333 * Math.pow(im_m, 3.0)) + (-0.016666666666666666 * Math.pow(im_m, 5.0))));
}
return im_s * tmp;
}
im_m = math.fabs(im) im_s = math.copysign(1.0, im) def code(im_s, re, im_m): t_0 = math.exp(-im_m) - math.exp(im_m) t_1 = 0.5 * math.sin(re) tmp = 0 if t_0 <= -4.0: tmp = t_0 * t_1 else: tmp = t_1 * ((im_m * -2.0) + ((-0.3333333333333333 * math.pow(im_m, 3.0)) + (-0.016666666666666666 * math.pow(im_m, 5.0)))) return im_s * tmp
im_m = abs(im) im_s = copysign(1.0, im) function code(im_s, re, im_m) t_0 = Float64(exp(Float64(-im_m)) - exp(im_m)) t_1 = Float64(0.5 * sin(re)) tmp = 0.0 if (t_0 <= -4.0) tmp = Float64(t_0 * t_1); else tmp = Float64(t_1 * Float64(Float64(im_m * -2.0) + Float64(Float64(-0.3333333333333333 * (im_m ^ 3.0)) + Float64(-0.016666666666666666 * (im_m ^ 5.0))))); end return Float64(im_s * tmp) end
im_m = abs(im); im_s = sign(im) * abs(1.0); function tmp_2 = code(im_s, re, im_m) t_0 = exp(-im_m) - exp(im_m); t_1 = 0.5 * sin(re); tmp = 0.0; if (t_0 <= -4.0) tmp = t_0 * t_1; else tmp = t_1 * ((im_m * -2.0) + ((-0.3333333333333333 * (im_m ^ 3.0)) + (-0.016666666666666666 * (im_m ^ 5.0)))); end tmp_2 = im_s * tmp; end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[t$95$0, -4.0], N[(t$95$0 * t$95$1), $MachinePrecision], N[(t$95$1 * N[(N[(im$95$m * -2.0), $MachinePrecision] + N[(N[(-0.3333333333333333 * N[Power[im$95$m, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.016666666666666666 * N[Power[im$95$m, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)
\\
\begin{array}{l}
t_0 := e^{-im\_m} - e^{im\_m}\\
t_1 := 0.5 \cdot \sin re\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -4:\\
\;\;\;\;t\_0 \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(im\_m \cdot -2 + \left(-0.3333333333333333 \cdot {im\_m}^{3} + -0.016666666666666666 \cdot {im\_m}^{5}\right)\right)\\
\end{array}
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -4Initial program 100.0%
if -4 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 52.0%
Taylor expanded in im around 0 93.3%
Final simplification94.9%
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
:precision binary64
(let* ((t_0 (- (exp (- im_m)) (exp im_m))))
(*
im_s
(if (<= t_0 -0.01)
(* t_0 (* 0.5 (sin re)))
(* (sin re) (- (* (pow im_m 3.0) -0.16666666666666666) im_m))))))im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
double t_0 = exp(-im_m) - exp(im_m);
double tmp;
if (t_0 <= -0.01) {
tmp = t_0 * (0.5 * sin(re));
} else {
tmp = sin(re) * ((pow(im_m, 3.0) * -0.16666666666666666) - im_m);
}
return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
real(8), intent (in) :: im_s
real(8), intent (in) :: re
real(8), intent (in) :: im_m
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-im_m) - exp(im_m)
if (t_0 <= (-0.01d0)) then
tmp = t_0 * (0.5d0 * sin(re))
else
tmp = sin(re) * (((im_m ** 3.0d0) * (-0.16666666666666666d0)) - im_m)
end if
code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
double t_0 = Math.exp(-im_m) - Math.exp(im_m);
double tmp;
if (t_0 <= -0.01) {
tmp = t_0 * (0.5 * Math.sin(re));
} else {
tmp = Math.sin(re) * ((Math.pow(im_m, 3.0) * -0.16666666666666666) - im_m);
}
return im_s * tmp;
}
im_m = math.fabs(im) im_s = math.copysign(1.0, im) def code(im_s, re, im_m): t_0 = math.exp(-im_m) - math.exp(im_m) tmp = 0 if t_0 <= -0.01: tmp = t_0 * (0.5 * math.sin(re)) else: tmp = math.sin(re) * ((math.pow(im_m, 3.0) * -0.16666666666666666) - im_m) return im_s * tmp
im_m = abs(im) im_s = copysign(1.0, im) function code(im_s, re, im_m) t_0 = Float64(exp(Float64(-im_m)) - exp(im_m)) tmp = 0.0 if (t_0 <= -0.01) tmp = Float64(t_0 * Float64(0.5 * sin(re))); else tmp = Float64(sin(re) * Float64(Float64((im_m ^ 3.0) * -0.16666666666666666) - im_m)); end return Float64(im_s * tmp) end
im_m = abs(im); im_s = sign(im) * abs(1.0); function tmp_2 = code(im_s, re, im_m) t_0 = exp(-im_m) - exp(im_m); tmp = 0.0; if (t_0 <= -0.01) tmp = t_0 * (0.5 * sin(re)); else tmp = sin(re) * (((im_m ^ 3.0) * -0.16666666666666666) - im_m); end tmp_2 = im_s * tmp; end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[t$95$0, -0.01], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)
\\
\begin{array}{l}
t_0 := e^{-im\_m} - e^{im\_m}\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -0.01:\\
\;\;\;\;t\_0 \cdot \left(0.5 \cdot \sin re\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\
\end{array}
\end{array}
\end{array}
if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -0.0100000000000000002Initial program 100.0%
if -0.0100000000000000002 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) Initial program 52.0%
Taylor expanded in im around 0 93.3%
Taylor expanded in im around 0 90.1%
+-commutative90.1%
mul-1-neg90.1%
*-commutative90.1%
*-commutative90.1%
*-commutative90.1%
associate-*r*90.1%
sub-neg90.1%
distribute-lft-out--90.1%
Simplified90.1%
Final simplification92.5%
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
:precision binary64
(*
im_s
(if (<= im_m 0.085)
(* (sin re) (- (* (pow im_m 3.0) -0.16666666666666666) im_m))
(if (<= im_m 8.4e+59)
(* (- (exp (- im_m)) (exp im_m)) (* 0.5 re))
(* -0.008333333333333333 (* (sin re) (pow im_m 5.0)))))))im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
double tmp;
if (im_m <= 0.085) {
tmp = sin(re) * ((pow(im_m, 3.0) * -0.16666666666666666) - im_m);
} else if (im_m <= 8.4e+59) {
tmp = (exp(-im_m) - exp(im_m)) * (0.5 * re);
} else {
tmp = -0.008333333333333333 * (sin(re) * pow(im_m, 5.0));
}
return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
real(8), intent (in) :: im_s
real(8), intent (in) :: re
real(8), intent (in) :: im_m
real(8) :: tmp
if (im_m <= 0.085d0) then
tmp = sin(re) * (((im_m ** 3.0d0) * (-0.16666666666666666d0)) - im_m)
else if (im_m <= 8.4d+59) then
tmp = (exp(-im_m) - exp(im_m)) * (0.5d0 * re)
else
tmp = (-0.008333333333333333d0) * (sin(re) * (im_m ** 5.0d0))
end if
code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
double tmp;
if (im_m <= 0.085) {
tmp = Math.sin(re) * ((Math.pow(im_m, 3.0) * -0.16666666666666666) - im_m);
} else if (im_m <= 8.4e+59) {
tmp = (Math.exp(-im_m) - Math.exp(im_m)) * (0.5 * re);
} else {
tmp = -0.008333333333333333 * (Math.sin(re) * Math.pow(im_m, 5.0));
}
return im_s * tmp;
}
im_m = math.fabs(im) im_s = math.copysign(1.0, im) def code(im_s, re, im_m): tmp = 0 if im_m <= 0.085: tmp = math.sin(re) * ((math.pow(im_m, 3.0) * -0.16666666666666666) - im_m) elif im_m <= 8.4e+59: tmp = (math.exp(-im_m) - math.exp(im_m)) * (0.5 * re) else: tmp = -0.008333333333333333 * (math.sin(re) * math.pow(im_m, 5.0)) return im_s * tmp
im_m = abs(im) im_s = copysign(1.0, im) function code(im_s, re, im_m) tmp = 0.0 if (im_m <= 0.085) tmp = Float64(sin(re) * Float64(Float64((im_m ^ 3.0) * -0.16666666666666666) - im_m)); elseif (im_m <= 8.4e+59) tmp = Float64(Float64(exp(Float64(-im_m)) - exp(im_m)) * Float64(0.5 * re)); else tmp = Float64(-0.008333333333333333 * Float64(sin(re) * (im_m ^ 5.0))); end return Float64(im_s * tmp) end
im_m = abs(im); im_s = sign(im) * abs(1.0); function tmp_2 = code(im_s, re, im_m) tmp = 0.0; if (im_m <= 0.085) tmp = sin(re) * (((im_m ^ 3.0) * -0.16666666666666666) - im_m); elseif (im_m <= 8.4e+59) tmp = (exp(-im_m) - exp(im_m)) * (0.5 * re); else tmp = -0.008333333333333333 * (sin(re) * (im_m ^ 5.0)); end tmp_2 = im_s * tmp; end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 0.085], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 8.4e+59], N[(N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * N[Power[im$95$m, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)
\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 0.085:\\
\;\;\;\;\sin re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\
\mathbf{elif}\;im\_m \leq 8.4 \cdot 10^{+59}:\\
\;\;\;\;\left(e^{-im\_m} - e^{im\_m}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im\_m}^{5}\right)\\
\end{array}
\end{array}
if im < 0.0850000000000000061Initial program 52.0%
Taylor expanded in im around 0 93.3%
Taylor expanded in im around 0 90.1%
+-commutative90.1%
mul-1-neg90.1%
*-commutative90.1%
*-commutative90.1%
*-commutative90.1%
associate-*r*90.1%
sub-neg90.1%
distribute-lft-out--90.1%
Simplified90.1%
if 0.0850000000000000061 < im < 8.39999999999999936e59Initial program 100.0%
Taylor expanded in re around 0 83.3%
associate-*r*83.3%
*-commutative83.3%
Simplified83.3%
if 8.39999999999999936e59 < im Initial program 100.0%
Taylor expanded in im around 0 98.2%
Taylor expanded in im around inf 98.2%
Final simplification91.4%
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
:precision binary64
(*
im_s
(if (<= im_m 2.7e+25)
(* (- im_m) (sin re))
(if (<= im_m 1.35e+61)
(- (* im_m (* (pow re 3.0) 0.16666666666666666)) (* im_m re))
(* -0.008333333333333333 (* (sin re) (pow im_m 5.0)))))))im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
double tmp;
if (im_m <= 2.7e+25) {
tmp = -im_m * sin(re);
} else if (im_m <= 1.35e+61) {
tmp = (im_m * (pow(re, 3.0) * 0.16666666666666666)) - (im_m * re);
} else {
tmp = -0.008333333333333333 * (sin(re) * pow(im_m, 5.0));
}
return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
real(8), intent (in) :: im_s
real(8), intent (in) :: re
real(8), intent (in) :: im_m
real(8) :: tmp
if (im_m <= 2.7d+25) then
tmp = -im_m * sin(re)
else if (im_m <= 1.35d+61) then
tmp = (im_m * ((re ** 3.0d0) * 0.16666666666666666d0)) - (im_m * re)
else
tmp = (-0.008333333333333333d0) * (sin(re) * (im_m ** 5.0d0))
end if
code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
double tmp;
if (im_m <= 2.7e+25) {
tmp = -im_m * Math.sin(re);
} else if (im_m <= 1.35e+61) {
tmp = (im_m * (Math.pow(re, 3.0) * 0.16666666666666666)) - (im_m * re);
} else {
tmp = -0.008333333333333333 * (Math.sin(re) * Math.pow(im_m, 5.0));
}
return im_s * tmp;
}
im_m = math.fabs(im) im_s = math.copysign(1.0, im) def code(im_s, re, im_m): tmp = 0 if im_m <= 2.7e+25: tmp = -im_m * math.sin(re) elif im_m <= 1.35e+61: tmp = (im_m * (math.pow(re, 3.0) * 0.16666666666666666)) - (im_m * re) else: tmp = -0.008333333333333333 * (math.sin(re) * math.pow(im_m, 5.0)) return im_s * tmp
im_m = abs(im) im_s = copysign(1.0, im) function code(im_s, re, im_m) tmp = 0.0 if (im_m <= 2.7e+25) tmp = Float64(Float64(-im_m) * sin(re)); elseif (im_m <= 1.35e+61) tmp = Float64(Float64(im_m * Float64((re ^ 3.0) * 0.16666666666666666)) - Float64(im_m * re)); else tmp = Float64(-0.008333333333333333 * Float64(sin(re) * (im_m ^ 5.0))); end return Float64(im_s * tmp) end
im_m = abs(im); im_s = sign(im) * abs(1.0); function tmp_2 = code(im_s, re, im_m) tmp = 0.0; if (im_m <= 2.7e+25) tmp = -im_m * sin(re); elseif (im_m <= 1.35e+61) tmp = (im_m * ((re ^ 3.0) * 0.16666666666666666)) - (im_m * re); else tmp = -0.008333333333333333 * (sin(re) * (im_m ^ 5.0)); end tmp_2 = im_s * tmp; end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 2.7e+25], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 1.35e+61], N[(N[(im$95$m * N[(N[Power[re, 3.0], $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] - N[(im$95$m * re), $MachinePrecision]), $MachinePrecision], N[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * N[Power[im$95$m, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)
\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 2.7 \cdot 10^{+25}:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\
\mathbf{elif}\;im\_m \leq 1.35 \cdot 10^{+61}:\\
\;\;\;\;im\_m \cdot \left({re}^{3} \cdot 0.16666666666666666\right) - im\_m \cdot re\\
\mathbf{else}:\\
\;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im\_m}^{5}\right)\\
\end{array}
\end{array}
if im < 2.7e25Initial program 53.4%
Taylor expanded in im around 0 68.1%
associate-*r*68.1%
neg-mul-168.1%
Simplified68.1%
if 2.7e25 < im < 1.3500000000000001e61Initial program 100.0%
Taylor expanded in im around 0 2.9%
associate-*r*2.9%
neg-mul-12.9%
Simplified2.9%
Taylor expanded in re around 0 44.2%
+-commutative44.2%
mul-1-neg44.2%
unsub-neg44.2%
*-commutative44.2%
associate-*l*44.2%
*-commutative44.2%
Simplified44.2%
if 1.3500000000000001e61 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
Final simplification73.4%
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
:precision binary64
(*
im_s
(if (<= im_m 2.4e+25)
(* (- im_m) (sin re))
(if (<= im_m 4.4e+61)
(* re (sqrt (* (pow im_m 10.0) 6.944444444444444e-5)))
(* -0.008333333333333333 (* (sin re) (pow im_m 5.0)))))))im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
double tmp;
if (im_m <= 2.4e+25) {
tmp = -im_m * sin(re);
} else if (im_m <= 4.4e+61) {
tmp = re * sqrt((pow(im_m, 10.0) * 6.944444444444444e-5));
} else {
tmp = -0.008333333333333333 * (sin(re) * pow(im_m, 5.0));
}
return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
real(8), intent (in) :: im_s
real(8), intent (in) :: re
real(8), intent (in) :: im_m
real(8) :: tmp
if (im_m <= 2.4d+25) then
tmp = -im_m * sin(re)
else if (im_m <= 4.4d+61) then
tmp = re * sqrt(((im_m ** 10.0d0) * 6.944444444444444d-5))
else
tmp = (-0.008333333333333333d0) * (sin(re) * (im_m ** 5.0d0))
end if
code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
double tmp;
if (im_m <= 2.4e+25) {
tmp = -im_m * Math.sin(re);
} else if (im_m <= 4.4e+61) {
tmp = re * Math.sqrt((Math.pow(im_m, 10.0) * 6.944444444444444e-5));
} else {
tmp = -0.008333333333333333 * (Math.sin(re) * Math.pow(im_m, 5.0));
}
return im_s * tmp;
}
im_m = math.fabs(im) im_s = math.copysign(1.0, im) def code(im_s, re, im_m): tmp = 0 if im_m <= 2.4e+25: tmp = -im_m * math.sin(re) elif im_m <= 4.4e+61: tmp = re * math.sqrt((math.pow(im_m, 10.0) * 6.944444444444444e-5)) else: tmp = -0.008333333333333333 * (math.sin(re) * math.pow(im_m, 5.0)) return im_s * tmp
im_m = abs(im) im_s = copysign(1.0, im) function code(im_s, re, im_m) tmp = 0.0 if (im_m <= 2.4e+25) tmp = Float64(Float64(-im_m) * sin(re)); elseif (im_m <= 4.4e+61) tmp = Float64(re * sqrt(Float64((im_m ^ 10.0) * 6.944444444444444e-5))); else tmp = Float64(-0.008333333333333333 * Float64(sin(re) * (im_m ^ 5.0))); end return Float64(im_s * tmp) end
im_m = abs(im); im_s = sign(im) * abs(1.0); function tmp_2 = code(im_s, re, im_m) tmp = 0.0; if (im_m <= 2.4e+25) tmp = -im_m * sin(re); elseif (im_m <= 4.4e+61) tmp = re * sqrt(((im_m ^ 10.0) * 6.944444444444444e-5)); else tmp = -0.008333333333333333 * (sin(re) * (im_m ^ 5.0)); end tmp_2 = im_s * tmp; end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 2.4e+25], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 4.4e+61], N[(re * N[Sqrt[N[(N[Power[im$95$m, 10.0], $MachinePrecision] * 6.944444444444444e-5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * N[Power[im$95$m, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)
\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 2.4 \cdot 10^{+25}:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\
\mathbf{elif}\;im\_m \leq 4.4 \cdot 10^{+61}:\\
\;\;\;\;re \cdot \sqrt{{im\_m}^{10} \cdot 6.944444444444444 \cdot 10^{-5}}\\
\mathbf{else}:\\
\;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im\_m}^{5}\right)\\
\end{array}
\end{array}
if im < 2.39999999999999996e25Initial program 53.4%
Taylor expanded in im around 0 68.1%
associate-*r*68.1%
neg-mul-168.1%
Simplified68.1%
if 2.39999999999999996e25 < im < 4.4000000000000001e61Initial program 100.0%
Taylor expanded in im around 0 5.5%
Taylor expanded in im around inf 5.5%
*-commutative5.5%
associate-*l*5.5%
Simplified5.5%
Taylor expanded in re around 0 2.0%
*-commutative2.0%
*-commutative2.0%
associate-*l*2.0%
Simplified2.0%
add-sqr-sqrt0.0%
sqrt-unprod42.9%
swap-sqr42.9%
pow-prod-up42.9%
metadata-eval42.9%
metadata-eval42.9%
Applied egg-rr42.9%
if 4.4000000000000001e61 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
Final simplification73.4%
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
:precision binary64
(*
im_s
(if (<= im_m 2.9e+25)
(* (sin re) (- (* (pow im_m 3.0) -0.16666666666666666) im_m))
(if (<= im_m 4.4e+61)
(* re (sqrt (* (pow im_m 10.0) 6.944444444444444e-5)))
(* -0.008333333333333333 (* (sin re) (pow im_m 5.0)))))))im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
double tmp;
if (im_m <= 2.9e+25) {
tmp = sin(re) * ((pow(im_m, 3.0) * -0.16666666666666666) - im_m);
} else if (im_m <= 4.4e+61) {
tmp = re * sqrt((pow(im_m, 10.0) * 6.944444444444444e-5));
} else {
tmp = -0.008333333333333333 * (sin(re) * pow(im_m, 5.0));
}
return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
real(8), intent (in) :: im_s
real(8), intent (in) :: re
real(8), intent (in) :: im_m
real(8) :: tmp
if (im_m <= 2.9d+25) then
tmp = sin(re) * (((im_m ** 3.0d0) * (-0.16666666666666666d0)) - im_m)
else if (im_m <= 4.4d+61) then
tmp = re * sqrt(((im_m ** 10.0d0) * 6.944444444444444d-5))
else
tmp = (-0.008333333333333333d0) * (sin(re) * (im_m ** 5.0d0))
end if
code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
double tmp;
if (im_m <= 2.9e+25) {
tmp = Math.sin(re) * ((Math.pow(im_m, 3.0) * -0.16666666666666666) - im_m);
} else if (im_m <= 4.4e+61) {
tmp = re * Math.sqrt((Math.pow(im_m, 10.0) * 6.944444444444444e-5));
} else {
tmp = -0.008333333333333333 * (Math.sin(re) * Math.pow(im_m, 5.0));
}
return im_s * tmp;
}
im_m = math.fabs(im) im_s = math.copysign(1.0, im) def code(im_s, re, im_m): tmp = 0 if im_m <= 2.9e+25: tmp = math.sin(re) * ((math.pow(im_m, 3.0) * -0.16666666666666666) - im_m) elif im_m <= 4.4e+61: tmp = re * math.sqrt((math.pow(im_m, 10.0) * 6.944444444444444e-5)) else: tmp = -0.008333333333333333 * (math.sin(re) * math.pow(im_m, 5.0)) return im_s * tmp
im_m = abs(im) im_s = copysign(1.0, im) function code(im_s, re, im_m) tmp = 0.0 if (im_m <= 2.9e+25) tmp = Float64(sin(re) * Float64(Float64((im_m ^ 3.0) * -0.16666666666666666) - im_m)); elseif (im_m <= 4.4e+61) tmp = Float64(re * sqrt(Float64((im_m ^ 10.0) * 6.944444444444444e-5))); else tmp = Float64(-0.008333333333333333 * Float64(sin(re) * (im_m ^ 5.0))); end return Float64(im_s * tmp) end
im_m = abs(im); im_s = sign(im) * abs(1.0); function tmp_2 = code(im_s, re, im_m) tmp = 0.0; if (im_m <= 2.9e+25) tmp = sin(re) * (((im_m ^ 3.0) * -0.16666666666666666) - im_m); elseif (im_m <= 4.4e+61) tmp = re * sqrt(((im_m ^ 10.0) * 6.944444444444444e-5)); else tmp = -0.008333333333333333 * (sin(re) * (im_m ^ 5.0)); end tmp_2 = im_s * tmp; end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 2.9e+25], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 4.4e+61], N[(re * N[Sqrt[N[(N[Power[im$95$m, 10.0], $MachinePrecision] * 6.944444444444444e-5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * N[Power[im$95$m, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)
\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 2.9 \cdot 10^{+25}:\\
\;\;\;\;\sin re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\
\mathbf{elif}\;im\_m \leq 4.4 \cdot 10^{+61}:\\
\;\;\;\;re \cdot \sqrt{{im\_m}^{10} \cdot 6.944444444444444 \cdot 10^{-5}}\\
\mathbf{else}:\\
\;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im\_m}^{5}\right)\\
\end{array}
\end{array}
if im < 2.8999999999999999e25Initial program 53.4%
Taylor expanded in im around 0 90.6%
Taylor expanded in im around 0 87.5%
+-commutative87.5%
mul-1-neg87.5%
*-commutative87.5%
*-commutative87.5%
*-commutative87.5%
associate-*r*87.5%
sub-neg87.5%
distribute-lft-out--87.5%
Simplified87.5%
if 2.8999999999999999e25 < im < 4.4000000000000001e61Initial program 100.0%
Taylor expanded in im around 0 5.5%
Taylor expanded in im around inf 5.5%
*-commutative5.5%
associate-*l*5.5%
Simplified5.5%
Taylor expanded in re around 0 2.0%
*-commutative2.0%
*-commutative2.0%
associate-*l*2.0%
Simplified2.0%
add-sqr-sqrt0.0%
sqrt-unprod42.9%
swap-sqr42.9%
pow-prod-up42.9%
metadata-eval42.9%
metadata-eval42.9%
Applied egg-rr42.9%
if 4.4000000000000001e61 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
Final simplification88.6%
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
:precision binary64
(*
im_s
(if (<= im_m 1500.0)
(* (- im_m) (sin re))
(* -0.008333333333333333 (* re (pow im_m 5.0))))))im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
double tmp;
if (im_m <= 1500.0) {
tmp = -im_m * sin(re);
} else {
tmp = -0.008333333333333333 * (re * pow(im_m, 5.0));
}
return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
real(8), intent (in) :: im_s
real(8), intent (in) :: re
real(8), intent (in) :: im_m
real(8) :: tmp
if (im_m <= 1500.0d0) then
tmp = -im_m * sin(re)
else
tmp = (-0.008333333333333333d0) * (re * (im_m ** 5.0d0))
end if
code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
double tmp;
if (im_m <= 1500.0) {
tmp = -im_m * Math.sin(re);
} else {
tmp = -0.008333333333333333 * (re * Math.pow(im_m, 5.0));
}
return im_s * tmp;
}
im_m = math.fabs(im) im_s = math.copysign(1.0, im) def code(im_s, re, im_m): tmp = 0 if im_m <= 1500.0: tmp = -im_m * math.sin(re) else: tmp = -0.008333333333333333 * (re * math.pow(im_m, 5.0)) return im_s * tmp
im_m = abs(im) im_s = copysign(1.0, im) function code(im_s, re, im_m) tmp = 0.0 if (im_m <= 1500.0) tmp = Float64(Float64(-im_m) * sin(re)); else tmp = Float64(-0.008333333333333333 * Float64(re * (im_m ^ 5.0))); end return Float64(im_s * tmp) end
im_m = abs(im); im_s = sign(im) * abs(1.0); function tmp_2 = code(im_s, re, im_m) tmp = 0.0; if (im_m <= 1500.0) tmp = -im_m * sin(re); else tmp = -0.008333333333333333 * (re * (im_m ^ 5.0)); end tmp_2 = im_s * tmp; end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 1500.0], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], N[(-0.008333333333333333 * N[(re * N[Power[im$95$m, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)
\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 1500:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\
\mathbf{else}:\\
\;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im\_m}^{5}\right)\\
\end{array}
\end{array}
if im < 1500Initial program 52.0%
Taylor expanded in im around 0 70.1%
associate-*r*70.1%
neg-mul-170.1%
Simplified70.1%
if 1500 < im Initial program 100.0%
Taylor expanded in im around 0 79.6%
Taylor expanded in im around inf 79.6%
*-commutative79.6%
associate-*l*79.6%
Simplified79.6%
Taylor expanded in re around 0 72.6%
Final simplification70.7%
im_m = (fabs.f64 im) im_s = (copysign.f64 1 im) (FPCore (im_s re im_m) :precision binary64 (* im_s (if (<= im_m 3500000000.0) (* (- im_m) (sin re)) (* (- im_m) re))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
double tmp;
if (im_m <= 3500000000.0) {
tmp = -im_m * sin(re);
} else {
tmp = -im_m * re;
}
return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
real(8), intent (in) :: im_s
real(8), intent (in) :: re
real(8), intent (in) :: im_m
real(8) :: tmp
if (im_m <= 3500000000.0d0) then
tmp = -im_m * sin(re)
else
tmp = -im_m * re
end if
code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
double tmp;
if (im_m <= 3500000000.0) {
tmp = -im_m * Math.sin(re);
} else {
tmp = -im_m * re;
}
return im_s * tmp;
}
im_m = math.fabs(im) im_s = math.copysign(1.0, im) def code(im_s, re, im_m): tmp = 0 if im_m <= 3500000000.0: tmp = -im_m * math.sin(re) else: tmp = -im_m * re return im_s * tmp
im_m = abs(im) im_s = copysign(1.0, im) function code(im_s, re, im_m) tmp = 0.0 if (im_m <= 3500000000.0) tmp = Float64(Float64(-im_m) * sin(re)); else tmp = Float64(Float64(-im_m) * re); end return Float64(im_s * tmp) end
im_m = abs(im); im_s = sign(im) * abs(1.0); function tmp_2 = code(im_s, re, im_m) tmp = 0.0; if (im_m <= 3500000000.0) tmp = -im_m * sin(re); else tmp = -im_m * re; end tmp_2 = im_s * tmp; end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 3500000000.0], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], N[((-im$95$m) * re), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)
\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 3500000000:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\
\mathbf{else}:\\
\;\;\;\;\left(-im\_m\right) \cdot re\\
\end{array}
\end{array}
if im < 3.5e9Initial program 52.7%
Taylor expanded in im around 0 69.1%
associate-*r*69.1%
neg-mul-169.1%
Simplified69.1%
if 3.5e9 < im Initial program 100.0%
Taylor expanded in im around 0 4.5%
associate-*r*4.5%
neg-mul-14.5%
Simplified4.5%
Taylor expanded in re around 0 24.6%
associate-*r*24.6%
mul-1-neg24.6%
Simplified24.6%
Final simplification59.0%
im_m = (fabs.f64 im) im_s = (copysign.f64 1 im) (FPCore (im_s re im_m) :precision binary64 (* im_s (* (- im_m) re)))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
return im_s * (-im_m * re);
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
real(8), intent (in) :: im_s
real(8), intent (in) :: re
real(8), intent (in) :: im_m
code = im_s * (-im_m * re)
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
return im_s * (-im_m * re);
}
im_m = math.fabs(im) im_s = math.copysign(1.0, im) def code(im_s, re, im_m): return im_s * (-im_m * re)
im_m = abs(im) im_s = copysign(1.0, im) function code(im_s, re, im_m) return Float64(im_s * Float64(Float64(-im_m) * re)) end
im_m = abs(im); im_s = sign(im) * abs(1.0); function tmp = code(im_s, re, im_m) tmp = im_s * (-im_m * re); end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * N[((-im$95$m) * re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)
\\
im\_s \cdot \left(\left(-im\_m\right) \cdot re\right)
\end{array}
Initial program 63.4%
Taylor expanded in im around 0 54.4%
associate-*r*54.4%
neg-mul-154.4%
Simplified54.4%
Taylor expanded in re around 0 36.3%
associate-*r*36.3%
mul-1-neg36.3%
Simplified36.3%
Final simplification36.3%
(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 2024039
(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))))