
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
:precision binary64
(*
im_s
(if (<= (- (exp (- im_m)) (exp im_m)) -1e+100)
(* 0.5 (* (- 27.0 (exp im_m)) (log (exp (cos re)))))
(*
0.5
(*
(cos re)
(*
im_m
(-
(*
(pow im_m 2.0)
(-
(*
(pow im_m 2.0)
(- (* (pow im_m 2.0) -0.0003968253968253968) 0.016666666666666666))
0.3333333333333333))
2.0)))))))im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
double tmp;
if ((exp(-im_m) - exp(im_m)) <= -1e+100) {
tmp = 0.5 * ((27.0 - exp(im_m)) * log(exp(cos(re))));
} else {
tmp = 0.5 * (cos(re) * (im_m * ((pow(im_m, 2.0) * ((pow(im_m, 2.0) * ((pow(im_m, 2.0) * -0.0003968253968253968) - 0.016666666666666666)) - 0.3333333333333333)) - 2.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 ((exp(-im_m) - exp(im_m)) <= (-1d+100)) then
tmp = 0.5d0 * ((27.0d0 - exp(im_m)) * log(exp(cos(re))))
else
tmp = 0.5d0 * (cos(re) * (im_m * (((im_m ** 2.0d0) * (((im_m ** 2.0d0) * (((im_m ** 2.0d0) * (-0.0003968253968253968d0)) - 0.016666666666666666d0)) - 0.3333333333333333d0)) - 2.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 ((Math.exp(-im_m) - Math.exp(im_m)) <= -1e+100) {
tmp = 0.5 * ((27.0 - Math.exp(im_m)) * Math.log(Math.exp(Math.cos(re))));
} else {
tmp = 0.5 * (Math.cos(re) * (im_m * ((Math.pow(im_m, 2.0) * ((Math.pow(im_m, 2.0) * ((Math.pow(im_m, 2.0) * -0.0003968253968253968) - 0.016666666666666666)) - 0.3333333333333333)) - 2.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 (math.exp(-im_m) - math.exp(im_m)) <= -1e+100: tmp = 0.5 * ((27.0 - math.exp(im_m)) * math.log(math.exp(math.cos(re)))) else: tmp = 0.5 * (math.cos(re) * (im_m * ((math.pow(im_m, 2.0) * ((math.pow(im_m, 2.0) * ((math.pow(im_m, 2.0) * -0.0003968253968253968) - 0.016666666666666666)) - 0.3333333333333333)) - 2.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 (Float64(exp(Float64(-im_m)) - exp(im_m)) <= -1e+100) tmp = Float64(0.5 * Float64(Float64(27.0 - exp(im_m)) * log(exp(cos(re))))); else tmp = Float64(0.5 * Float64(cos(re) * Float64(im_m * Float64(Float64((im_m ^ 2.0) * Float64(Float64((im_m ^ 2.0) * Float64(Float64((im_m ^ 2.0) * -0.0003968253968253968) - 0.016666666666666666)) - 0.3333333333333333)) - 2.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 ((exp(-im_m) - exp(im_m)) <= -1e+100) tmp = 0.5 * ((27.0 - exp(im_m)) * log(exp(cos(re)))); else tmp = 0.5 * (cos(re) * (im_m * (((im_m ^ 2.0) * (((im_m ^ 2.0) * (((im_m ^ 2.0) * -0.0003968253968253968) - 0.016666666666666666)) - 0.3333333333333333)) - 2.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[N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision], -1e+100], N[(0.5 * N[(N[(27.0 - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision] * N[Log[N[Exp[N[Cos[re], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(im$95$m * N[(N[(N[Power[im$95$m, 2.0], $MachinePrecision] * N[(N[(N[Power[im$95$m, 2.0], $MachinePrecision] * N[(N[(N[Power[im$95$m, 2.0], $MachinePrecision] * -0.0003968253968253968), $MachinePrecision] - 0.016666666666666666), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $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}\;e^{-im\_m} - e^{im\_m} \leq -1 \cdot 10^{+100}:\\
\;\;\;\;0.5 \cdot \left(\left(27 - e^{im\_m}\right) \cdot \log \left(e^{\cos re}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(im\_m \cdot \left({im\_m}^{2} \cdot \left({im\_m}^{2} \cdot \left({im\_m}^{2} \cdot -0.0003968253968253968 - 0.016666666666666666\right) - 0.3333333333333333\right) - 2\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)) < -1.00000000000000002e100Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Applied egg-rr100.0%
Applied egg-rr100.0%
if -1.00000000000000002e100 < (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)) Initial program 42.7%
/-rgt-identity42.7%
exp-042.7%
associate-*l/42.7%
cos-neg42.7%
associate-*l*42.7%
associate-*r/42.7%
exp-042.7%
/-rgt-identity42.7%
*-commutative42.7%
neg-sub042.7%
cos-neg42.7%
Simplified42.7%
Taylor expanded in im around 0 95.4%
Final simplification96.6%
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
:precision binary64
(let* ((t_0 (- (exp (- im_m)) (exp im_m))))
(*
im_s
(if (<= t_0 -0.05)
(* 0.5 (* (cos re) t_0))
(*
0.5
(*
(cos re)
(*
im_m
(-
(*
(pow im_m 2.0)
(- (* (pow im_m 2.0) -0.016666666666666666) 0.3333333333333333))
2.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 tmp;
if (t_0 <= -0.05) {
tmp = 0.5 * (cos(re) * t_0);
} else {
tmp = 0.5 * (cos(re) * (im_m * ((pow(im_m, 2.0) * ((pow(im_m, 2.0) * -0.016666666666666666) - 0.3333333333333333)) - 2.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) :: tmp
t_0 = exp(-im_m) - exp(im_m)
if (t_0 <= (-0.05d0)) then
tmp = 0.5d0 * (cos(re) * t_0)
else
tmp = 0.5d0 * (cos(re) * (im_m * (((im_m ** 2.0d0) * (((im_m ** 2.0d0) * (-0.016666666666666666d0)) - 0.3333333333333333d0)) - 2.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 tmp;
if (t_0 <= -0.05) {
tmp = 0.5 * (Math.cos(re) * t_0);
} else {
tmp = 0.5 * (Math.cos(re) * (im_m * ((Math.pow(im_m, 2.0) * ((Math.pow(im_m, 2.0) * -0.016666666666666666) - 0.3333333333333333)) - 2.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) tmp = 0 if t_0 <= -0.05: tmp = 0.5 * (math.cos(re) * t_0) else: tmp = 0.5 * (math.cos(re) * (im_m * ((math.pow(im_m, 2.0) * ((math.pow(im_m, 2.0) * -0.016666666666666666) - 0.3333333333333333)) - 2.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)) tmp = 0.0 if (t_0 <= -0.05) tmp = Float64(0.5 * Float64(cos(re) * t_0)); else tmp = Float64(0.5 * Float64(cos(re) * Float64(im_m * Float64(Float64((im_m ^ 2.0) * Float64(Float64((im_m ^ 2.0) * -0.016666666666666666) - 0.3333333333333333)) - 2.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); tmp = 0.0; if (t_0 <= -0.05) tmp = 0.5 * (cos(re) * t_0); else tmp = 0.5 * (cos(re) * (im_m * (((im_m ^ 2.0) * (((im_m ^ 2.0) * -0.016666666666666666) - 0.3333333333333333)) - 2.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]}, N[(im$95$s * If[LessEqual[t$95$0, -0.05], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(im$95$m * N[(N[(N[Power[im$95$m, 2.0], $MachinePrecision] * N[(N[(N[Power[im$95$m, 2.0], $MachinePrecision] * -0.016666666666666666), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision] - 2.0), $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}\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -0.05:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(im\_m \cdot \left({im\_m}^{2} \cdot \left({im\_m}^{2} \cdot -0.016666666666666666 - 0.3333333333333333\right) - 2\right)\right)\right)\\
\end{array}
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)) < -0.050000000000000003Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
if -0.050000000000000003 < (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)) Initial program 42.7%
/-rgt-identity42.7%
exp-042.7%
associate-*l/42.7%
cos-neg42.7%
associate-*l*42.7%
associate-*r/42.7%
exp-042.7%
/-rgt-identity42.7%
*-commutative42.7%
neg-sub042.7%
cos-neg42.7%
Simplified42.7%
Taylor expanded in im around 0 91.9%
Final simplification93.9%
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
:precision binary64
(let* ((t_0 (- (exp (- im_m)) (exp im_m))))
(*
im_s
(if (<= t_0 -0.02)
(* 0.5 (* (cos re) t_0))
(*
0.5
(*
(cos re)
(* im_m (- (* (pow im_m 2.0) -0.3333333333333333) 2.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 tmp;
if (t_0 <= -0.02) {
tmp = 0.5 * (cos(re) * t_0);
} else {
tmp = 0.5 * (cos(re) * (im_m * ((pow(im_m, 2.0) * -0.3333333333333333) - 2.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) :: tmp
t_0 = exp(-im_m) - exp(im_m)
if (t_0 <= (-0.02d0)) then
tmp = 0.5d0 * (cos(re) * t_0)
else
tmp = 0.5d0 * (cos(re) * (im_m * (((im_m ** 2.0d0) * (-0.3333333333333333d0)) - 2.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 tmp;
if (t_0 <= -0.02) {
tmp = 0.5 * (Math.cos(re) * t_0);
} else {
tmp = 0.5 * (Math.cos(re) * (im_m * ((Math.pow(im_m, 2.0) * -0.3333333333333333) - 2.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) tmp = 0 if t_0 <= -0.02: tmp = 0.5 * (math.cos(re) * t_0) else: tmp = 0.5 * (math.cos(re) * (im_m * ((math.pow(im_m, 2.0) * -0.3333333333333333) - 2.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)) tmp = 0.0 if (t_0 <= -0.02) tmp = Float64(0.5 * Float64(cos(re) * t_0)); else tmp = Float64(0.5 * Float64(cos(re) * Float64(im_m * Float64(Float64((im_m ^ 2.0) * -0.3333333333333333) - 2.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); tmp = 0.0; if (t_0 <= -0.02) tmp = 0.5 * (cos(re) * t_0); else tmp = 0.5 * (cos(re) * (im_m * (((im_m ^ 2.0) * -0.3333333333333333) - 2.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]}, N[(im$95$s * If[LessEqual[t$95$0, -0.02], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(im$95$m * N[(N[(N[Power[im$95$m, 2.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision] - 2.0), $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}\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -0.02:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(im\_m \cdot \left({im\_m}^{2} \cdot -0.3333333333333333 - 2\right)\right)\right)\\
\end{array}
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)) < -0.0200000000000000004Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
if -0.0200000000000000004 < (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)) Initial program 42.7%
/-rgt-identity42.7%
exp-042.7%
associate-*l/42.7%
cos-neg42.7%
associate-*l*42.7%
associate-*r/42.7%
exp-042.7%
/-rgt-identity42.7%
*-commutative42.7%
neg-sub042.7%
cos-neg42.7%
Simplified42.7%
Taylor expanded in im around 0 83.6%
Final simplification87.8%
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
:precision binary64
(*
im_s
(if (<= im_m 4.0)
(*
0.5
(* (cos re) (* im_m (- (* (pow im_m 2.0) -0.3333333333333333) 2.0))))
(* 0.5 (* (- 27.0 (exp im_m)) (cos 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 <= 4.0) {
tmp = 0.5 * (cos(re) * (im_m * ((pow(im_m, 2.0) * -0.3333333333333333) - 2.0)));
} else {
tmp = 0.5 * ((27.0 - exp(im_m)) * cos(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 <= 4.0d0) then
tmp = 0.5d0 * (cos(re) * (im_m * (((im_m ** 2.0d0) * (-0.3333333333333333d0)) - 2.0d0)))
else
tmp = 0.5d0 * ((27.0d0 - exp(im_m)) * cos(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 <= 4.0) {
tmp = 0.5 * (Math.cos(re) * (im_m * ((Math.pow(im_m, 2.0) * -0.3333333333333333) - 2.0)));
} else {
tmp = 0.5 * ((27.0 - Math.exp(im_m)) * Math.cos(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 <= 4.0: tmp = 0.5 * (math.cos(re) * (im_m * ((math.pow(im_m, 2.0) * -0.3333333333333333) - 2.0))) else: tmp = 0.5 * ((27.0 - math.exp(im_m)) * math.cos(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 <= 4.0) tmp = Float64(0.5 * Float64(cos(re) * Float64(im_m * Float64(Float64((im_m ^ 2.0) * -0.3333333333333333) - 2.0)))); else tmp = Float64(0.5 * Float64(Float64(27.0 - exp(im_m)) * cos(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 <= 4.0) tmp = 0.5 * (cos(re) * (im_m * (((im_m ^ 2.0) * -0.3333333333333333) - 2.0))); else tmp = 0.5 * ((27.0 - exp(im_m)) * cos(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, 4.0], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(im$95$m * N[(N[(N[Power[im$95$m, 2.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(27.0 - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision] * N[Cos[re], $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 4:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(im\_m \cdot \left({im\_m}^{2} \cdot -0.3333333333333333 - 2\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(27 - e^{im\_m}\right) \cdot \cos re\right)\\
\end{array}
\end{array}
if im < 4Initial program 42.7%
/-rgt-identity42.7%
exp-042.7%
associate-*l/42.7%
cos-neg42.7%
associate-*l*42.7%
associate-*r/42.7%
exp-042.7%
/-rgt-identity42.7%
*-commutative42.7%
neg-sub042.7%
cos-neg42.7%
Simplified42.7%
Taylor expanded in im around 0 83.6%
if 4 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Applied egg-rr100.0%
Final simplification87.8%
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
:precision binary64
(*
im_s
(if (<= im_m 5.6e-5)
(* (cos re) (- im_m))
(if (<= im_m 4.9e+59)
(* 0.5 (- (exp (- im_m)) (exp im_m)))
(* (cos re) (* -0.008333333333333333 (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 <= 5.6e-5) {
tmp = cos(re) * -im_m;
} else if (im_m <= 4.9e+59) {
tmp = 0.5 * (exp(-im_m) - exp(im_m));
} else {
tmp = cos(re) * (-0.008333333333333333 * 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 <= 5.6d-5) then
tmp = cos(re) * -im_m
else if (im_m <= 4.9d+59) then
tmp = 0.5d0 * (exp(-im_m) - exp(im_m))
else
tmp = cos(re) * ((-0.008333333333333333d0) * (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 <= 5.6e-5) {
tmp = Math.cos(re) * -im_m;
} else if (im_m <= 4.9e+59) {
tmp = 0.5 * (Math.exp(-im_m) - Math.exp(im_m));
} else {
tmp = Math.cos(re) * (-0.008333333333333333 * 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 <= 5.6e-5: tmp = math.cos(re) * -im_m elif im_m <= 4.9e+59: tmp = 0.5 * (math.exp(-im_m) - math.exp(im_m)) else: tmp = math.cos(re) * (-0.008333333333333333 * 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 <= 5.6e-5) tmp = Float64(cos(re) * Float64(-im_m)); elseif (im_m <= 4.9e+59) tmp = Float64(0.5 * Float64(exp(Float64(-im_m)) - exp(im_m))); else tmp = Float64(cos(re) * Float64(-0.008333333333333333 * (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 <= 5.6e-5) tmp = cos(re) * -im_m; elseif (im_m <= 4.9e+59) tmp = 0.5 * (exp(-im_m) - exp(im_m)); else tmp = cos(re) * (-0.008333333333333333 * (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, 5.6e-5], N[(N[Cos[re], $MachinePrecision] * (-im$95$m)), $MachinePrecision], If[LessEqual[im$95$m, 4.9e+59], N[(0.5 * N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(-0.008333333333333333 * 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 5.6 \cdot 10^{-5}:\\
\;\;\;\;\cos re \cdot \left(-im\_m\right)\\
\mathbf{elif}\;im\_m \leq 4.9 \cdot 10^{+59}:\\
\;\;\;\;0.5 \cdot \left(e^{-im\_m} - e^{im\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-0.008333333333333333 \cdot {im\_m}^{5}\right)\\
\end{array}
\end{array}
if im < 5.59999999999999992e-5Initial program 42.5%
/-rgt-identity42.5%
exp-042.5%
associate-*l/42.5%
cos-neg42.5%
associate-*l*42.5%
associate-*r/42.5%
exp-042.5%
/-rgt-identity42.5%
*-commutative42.5%
neg-sub042.5%
cos-neg42.5%
Simplified42.5%
Taylor expanded in im around 0 63.8%
Taylor expanded in im around 0 63.8%
associate-*r*63.8%
mul-1-neg63.8%
Simplified63.8%
if 5.59999999999999992e-5 < im < 4.90000000000000007e59Initial program 98.8%
/-rgt-identity98.8%
exp-098.8%
associate-*l/98.8%
cos-neg98.8%
associate-*l*98.8%
associate-*r/98.8%
exp-098.8%
/-rgt-identity98.8%
*-commutative98.8%
neg-sub098.8%
cos-neg98.8%
Simplified98.8%
Taylor expanded in re around 0 76.7%
if 4.90000000000000007e59 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 98.1%
Taylor expanded in im around inf 98.1%
associate-*r*98.1%
Simplified98.1%
Final simplification71.2%
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
:precision binary64
(*
im_s
(if (<= im_m 5.6e-5)
(* (cos re) (- im_m))
(if (<= im_m 1.05e+103)
(* 0.5 (- (exp (- im_m)) (exp im_m)))
(*
0.5
(*
(cos re)
(+
26.0
(*
im_m
(+ (* im_m (- (* im_m -0.16666666666666666) 0.5)) -1.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 <= 5.6e-5) {
tmp = cos(re) * -im_m;
} else if (im_m <= 1.05e+103) {
tmp = 0.5 * (exp(-im_m) - exp(im_m));
} else {
tmp = 0.5 * (cos(re) * (26.0 + (im_m * ((im_m * ((im_m * -0.16666666666666666) - 0.5)) + -1.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 <= 5.6d-5) then
tmp = cos(re) * -im_m
else if (im_m <= 1.05d+103) then
tmp = 0.5d0 * (exp(-im_m) - exp(im_m))
else
tmp = 0.5d0 * (cos(re) * (26.0d0 + (im_m * ((im_m * ((im_m * (-0.16666666666666666d0)) - 0.5d0)) + (-1.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 <= 5.6e-5) {
tmp = Math.cos(re) * -im_m;
} else if (im_m <= 1.05e+103) {
tmp = 0.5 * (Math.exp(-im_m) - Math.exp(im_m));
} else {
tmp = 0.5 * (Math.cos(re) * (26.0 + (im_m * ((im_m * ((im_m * -0.16666666666666666) - 0.5)) + -1.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 <= 5.6e-5: tmp = math.cos(re) * -im_m elif im_m <= 1.05e+103: tmp = 0.5 * (math.exp(-im_m) - math.exp(im_m)) else: tmp = 0.5 * (math.cos(re) * (26.0 + (im_m * ((im_m * ((im_m * -0.16666666666666666) - 0.5)) + -1.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 <= 5.6e-5) tmp = Float64(cos(re) * Float64(-im_m)); elseif (im_m <= 1.05e+103) tmp = Float64(0.5 * Float64(exp(Float64(-im_m)) - exp(im_m))); else tmp = Float64(0.5 * Float64(cos(re) * Float64(26.0 + Float64(im_m * Float64(Float64(im_m * Float64(Float64(im_m * -0.16666666666666666) - 0.5)) + -1.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 <= 5.6e-5) tmp = cos(re) * -im_m; elseif (im_m <= 1.05e+103) tmp = 0.5 * (exp(-im_m) - exp(im_m)); else tmp = 0.5 * (cos(re) * (26.0 + (im_m * ((im_m * ((im_m * -0.16666666666666666) - 0.5)) + -1.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, 5.6e-5], N[(N[Cos[re], $MachinePrecision] * (-im$95$m)), $MachinePrecision], If[LessEqual[im$95$m, 1.05e+103], N[(0.5 * N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(26.0 + N[(im$95$m * N[(N[(im$95$m * N[(N[(im$95$m * -0.16666666666666666), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $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 5.6 \cdot 10^{-5}:\\
\;\;\;\;\cos re \cdot \left(-im\_m\right)\\
\mathbf{elif}\;im\_m \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;0.5 \cdot \left(e^{-im\_m} - e^{im\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(26 + im\_m \cdot \left(im\_m \cdot \left(im\_m \cdot -0.16666666666666666 - 0.5\right) + -1\right)\right)\right)\\
\end{array}
\end{array}
if im < 5.59999999999999992e-5Initial program 42.5%
/-rgt-identity42.5%
exp-042.5%
associate-*l/42.5%
cos-neg42.5%
associate-*l*42.5%
associate-*r/42.5%
exp-042.5%
/-rgt-identity42.5%
*-commutative42.5%
neg-sub042.5%
cos-neg42.5%
Simplified42.5%
Taylor expanded in im around 0 63.8%
Taylor expanded in im around 0 63.8%
associate-*r*63.8%
mul-1-neg63.8%
Simplified63.8%
if 5.59999999999999992e-5 < im < 1.0500000000000001e103Initial program 99.3%
/-rgt-identity99.3%
exp-099.3%
associate-*l/99.3%
cos-neg99.3%
associate-*l*99.3%
associate-*r/99.3%
exp-099.3%
/-rgt-identity99.3%
*-commutative99.3%
neg-sub099.3%
cos-neg99.3%
Simplified99.3%
Taylor expanded in re around 0 74.4%
if 1.0500000000000001e103 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
Final simplification69.9%
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
:precision binary64
(*
im_s
(if (<= im_m 3.5)
(* (cos re) (- im_m))
(* 0.5 (* (- 27.0 (exp im_m)) (cos 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 <= 3.5) {
tmp = cos(re) * -im_m;
} else {
tmp = 0.5 * ((27.0 - exp(im_m)) * cos(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 <= 3.5d0) then
tmp = cos(re) * -im_m
else
tmp = 0.5d0 * ((27.0d0 - exp(im_m)) * cos(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 <= 3.5) {
tmp = Math.cos(re) * -im_m;
} else {
tmp = 0.5 * ((27.0 - Math.exp(im_m)) * Math.cos(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 <= 3.5: tmp = math.cos(re) * -im_m else: tmp = 0.5 * ((27.0 - math.exp(im_m)) * math.cos(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 <= 3.5) tmp = Float64(cos(re) * Float64(-im_m)); else tmp = Float64(0.5 * Float64(Float64(27.0 - exp(im_m)) * cos(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 <= 3.5) tmp = cos(re) * -im_m; else tmp = 0.5 * ((27.0 - exp(im_m)) * cos(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, 3.5], N[(N[Cos[re], $MachinePrecision] * (-im$95$m)), $MachinePrecision], N[(0.5 * N[(N[(27.0 - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision] * N[Cos[re], $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 3.5:\\
\;\;\;\;\cos re \cdot \left(-im\_m\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(27 - e^{im\_m}\right) \cdot \cos re\right)\\
\end{array}
\end{array}
if im < 3.5Initial program 42.7%
/-rgt-identity42.7%
exp-042.7%
associate-*l/42.7%
cos-neg42.7%
associate-*l*42.7%
associate-*r/42.7%
exp-042.7%
/-rgt-identity42.7%
*-commutative42.7%
neg-sub042.7%
cos-neg42.7%
Simplified42.7%
Taylor expanded in im around 0 63.8%
Taylor expanded in im around 0 63.8%
associate-*r*63.8%
mul-1-neg63.8%
Simplified63.8%
if 3.5 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Applied egg-rr100.0%
Final simplification73.0%
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
:precision binary64
(*
im_s
(if (<= im_m 235.0)
(* (cos re) (- im_m))
(if (<= im_m 1.05e+103)
(* 0.5 (- 27.0 (exp im_m)))
(*
0.5
(*
(cos re)
(+
26.0
(*
im_m
(+ (* im_m (- (* im_m -0.16666666666666666) 0.5)) -1.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 <= 235.0) {
tmp = cos(re) * -im_m;
} else if (im_m <= 1.05e+103) {
tmp = 0.5 * (27.0 - exp(im_m));
} else {
tmp = 0.5 * (cos(re) * (26.0 + (im_m * ((im_m * ((im_m * -0.16666666666666666) - 0.5)) + -1.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 <= 235.0d0) then
tmp = cos(re) * -im_m
else if (im_m <= 1.05d+103) then
tmp = 0.5d0 * (27.0d0 - exp(im_m))
else
tmp = 0.5d0 * (cos(re) * (26.0d0 + (im_m * ((im_m * ((im_m * (-0.16666666666666666d0)) - 0.5d0)) + (-1.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 <= 235.0) {
tmp = Math.cos(re) * -im_m;
} else if (im_m <= 1.05e+103) {
tmp = 0.5 * (27.0 - Math.exp(im_m));
} else {
tmp = 0.5 * (Math.cos(re) * (26.0 + (im_m * ((im_m * ((im_m * -0.16666666666666666) - 0.5)) + -1.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 <= 235.0: tmp = math.cos(re) * -im_m elif im_m <= 1.05e+103: tmp = 0.5 * (27.0 - math.exp(im_m)) else: tmp = 0.5 * (math.cos(re) * (26.0 + (im_m * ((im_m * ((im_m * -0.16666666666666666) - 0.5)) + -1.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 <= 235.0) tmp = Float64(cos(re) * Float64(-im_m)); elseif (im_m <= 1.05e+103) tmp = Float64(0.5 * Float64(27.0 - exp(im_m))); else tmp = Float64(0.5 * Float64(cos(re) * Float64(26.0 + Float64(im_m * Float64(Float64(im_m * Float64(Float64(im_m * -0.16666666666666666) - 0.5)) + -1.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 <= 235.0) tmp = cos(re) * -im_m; elseif (im_m <= 1.05e+103) tmp = 0.5 * (27.0 - exp(im_m)); else tmp = 0.5 * (cos(re) * (26.0 + (im_m * ((im_m * ((im_m * -0.16666666666666666) - 0.5)) + -1.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, 235.0], N[(N[Cos[re], $MachinePrecision] * (-im$95$m)), $MachinePrecision], If[LessEqual[im$95$m, 1.05e+103], N[(0.5 * N[(27.0 - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(26.0 + N[(im$95$m * N[(N[(im$95$m * N[(N[(im$95$m * -0.16666666666666666), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $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 235:\\
\;\;\;\;\cos re \cdot \left(-im\_m\right)\\
\mathbf{elif}\;im\_m \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;0.5 \cdot \left(27 - e^{im\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(26 + im\_m \cdot \left(im\_m \cdot \left(im\_m \cdot -0.16666666666666666 - 0.5\right) + -1\right)\right)\right)\\
\end{array}
\end{array}
if im < 235Initial program 43.0%
/-rgt-identity43.0%
exp-043.0%
associate-*l/43.0%
cos-neg43.0%
associate-*l*43.0%
associate-*r/43.0%
exp-043.0%
/-rgt-identity43.0%
*-commutative43.0%
neg-sub043.0%
cos-neg43.0%
Simplified43.0%
Taylor expanded in im around 0 63.5%
Taylor expanded in im around 0 63.5%
associate-*r*63.5%
mul-1-neg63.5%
Simplified63.5%
if 235 < im < 1.0500000000000001e103Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 76.7%
if 1.0500000000000001e103 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
Final simplification69.9%
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
:precision binary64
(*
im_s
(if (<= im_m 235.0)
(* (cos re) (- im_m))
(if (<= im_m 1.9e+154)
(* 0.5 (- 27.0 (exp im_m)))
(* 0.5 (* (cos re) (+ 26.0 (* im_m (+ (* im_m -0.5) -1.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 <= 235.0) {
tmp = cos(re) * -im_m;
} else if (im_m <= 1.9e+154) {
tmp = 0.5 * (27.0 - exp(im_m));
} else {
tmp = 0.5 * (cos(re) * (26.0 + (im_m * ((im_m * -0.5) + -1.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 <= 235.0d0) then
tmp = cos(re) * -im_m
else if (im_m <= 1.9d+154) then
tmp = 0.5d0 * (27.0d0 - exp(im_m))
else
tmp = 0.5d0 * (cos(re) * (26.0d0 + (im_m * ((im_m * (-0.5d0)) + (-1.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 <= 235.0) {
tmp = Math.cos(re) * -im_m;
} else if (im_m <= 1.9e+154) {
tmp = 0.5 * (27.0 - Math.exp(im_m));
} else {
tmp = 0.5 * (Math.cos(re) * (26.0 + (im_m * ((im_m * -0.5) + -1.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 <= 235.0: tmp = math.cos(re) * -im_m elif im_m <= 1.9e+154: tmp = 0.5 * (27.0 - math.exp(im_m)) else: tmp = 0.5 * (math.cos(re) * (26.0 + (im_m * ((im_m * -0.5) + -1.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 <= 235.0) tmp = Float64(cos(re) * Float64(-im_m)); elseif (im_m <= 1.9e+154) tmp = Float64(0.5 * Float64(27.0 - exp(im_m))); else tmp = Float64(0.5 * Float64(cos(re) * Float64(26.0 + Float64(im_m * Float64(Float64(im_m * -0.5) + -1.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 <= 235.0) tmp = cos(re) * -im_m; elseif (im_m <= 1.9e+154) tmp = 0.5 * (27.0 - exp(im_m)); else tmp = 0.5 * (cos(re) * (26.0 + (im_m * ((im_m * -0.5) + -1.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, 235.0], N[(N[Cos[re], $MachinePrecision] * (-im$95$m)), $MachinePrecision], If[LessEqual[im$95$m, 1.9e+154], N[(0.5 * N[(27.0 - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(26.0 + N[(im$95$m * N[(N[(im$95$m * -0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $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 235:\\
\;\;\;\;\cos re \cdot \left(-im\_m\right)\\
\mathbf{elif}\;im\_m \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \left(27 - e^{im\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(26 + im\_m \cdot \left(im\_m \cdot -0.5 + -1\right)\right)\right)\\
\end{array}
\end{array}
if im < 235Initial program 43.0%
/-rgt-identity43.0%
exp-043.0%
associate-*l/43.0%
cos-neg43.0%
associate-*l*43.0%
associate-*r/43.0%
exp-043.0%
/-rgt-identity43.0%
*-commutative43.0%
neg-sub043.0%
cos-neg43.0%
Simplified43.0%
Taylor expanded in im around 0 63.5%
Taylor expanded in im around 0 63.5%
associate-*r*63.5%
mul-1-neg63.5%
Simplified63.5%
if 235 < im < 1.8999999999999999e154Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 72.2%
if 1.8999999999999999e154 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
Final simplification68.7%
im\_m = (fabs.f64 im) im\_s = (copysign.f64 #s(literal 1 binary64) im) (FPCore (im_s re im_m) :precision binary64 (* im_s (if (<= im_m 235.0) (* (cos re) (- im_m)) (* 0.5 (- 27.0 (exp im_m))))))
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 <= 235.0) {
tmp = cos(re) * -im_m;
} else {
tmp = 0.5 * (27.0 - exp(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) :: tmp
if (im_m <= 235.0d0) then
tmp = cos(re) * -im_m
else
tmp = 0.5d0 * (27.0d0 - exp(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 tmp;
if (im_m <= 235.0) {
tmp = Math.cos(re) * -im_m;
} else {
tmp = 0.5 * (27.0 - Math.exp(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): tmp = 0 if im_m <= 235.0: tmp = math.cos(re) * -im_m else: tmp = 0.5 * (27.0 - math.exp(im_m)) 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 <= 235.0) tmp = Float64(cos(re) * Float64(-im_m)); else tmp = Float64(0.5 * Float64(27.0 - exp(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) tmp = 0.0; if (im_m <= 235.0) tmp = cos(re) * -im_m; else tmp = 0.5 * (27.0 - exp(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_] := N[(im$95$s * If[LessEqual[im$95$m, 235.0], N[(N[Cos[re], $MachinePrecision] * (-im$95$m)), $MachinePrecision], N[(0.5 * N[(27.0 - N[Exp[im$95$m], $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 235:\\
\;\;\;\;\cos re \cdot \left(-im\_m\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(27 - e^{im\_m}\right)\\
\end{array}
\end{array}
if im < 235Initial program 43.0%
/-rgt-identity43.0%
exp-043.0%
associate-*l/43.0%
cos-neg43.0%
associate-*l*43.0%
associate-*r/43.0%
exp-043.0%
/-rgt-identity43.0%
*-commutative43.0%
neg-sub043.0%
cos-neg43.0%
Simplified43.0%
Taylor expanded in im around 0 63.5%
Taylor expanded in im around 0 63.5%
associate-*r*63.5%
mul-1-neg63.5%
Simplified63.5%
if 235 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 71.9%
Final simplification65.6%
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
:precision binary64
(*
im_s
(if (<= im_m 3.1e+25)
(* (cos re) (- im_m))
(* -0.008333333333333333 (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 <= 3.1e+25) {
tmp = cos(re) * -im_m;
} else {
tmp = -0.008333333333333333 * 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 <= 3.1d+25) then
tmp = cos(re) * -im_m
else
tmp = (-0.008333333333333333d0) * (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 <= 3.1e+25) {
tmp = Math.cos(re) * -im_m;
} else {
tmp = -0.008333333333333333 * 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 <= 3.1e+25: tmp = math.cos(re) * -im_m else: tmp = -0.008333333333333333 * 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 <= 3.1e+25) tmp = Float64(cos(re) * Float64(-im_m)); else tmp = Float64(-0.008333333333333333 * (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 <= 3.1e+25) tmp = cos(re) * -im_m; else tmp = -0.008333333333333333 * (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, 3.1e+25], N[(N[Cos[re], $MachinePrecision] * (-im$95$m)), $MachinePrecision], N[(-0.008333333333333333 * N[Power[im$95$m, 5.0], $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 3.1 \cdot 10^{+25}:\\
\;\;\;\;\cos re \cdot \left(-im\_m\right)\\
\mathbf{else}:\\
\;\;\;\;-0.008333333333333333 \cdot {im\_m}^{5}\\
\end{array}
\end{array}
if im < 3.0999999999999998e25Initial program 44.7%
/-rgt-identity44.7%
exp-044.7%
associate-*l/44.7%
cos-neg44.7%
associate-*l*44.7%
associate-*r/44.7%
exp-044.7%
/-rgt-identity44.7%
*-commutative44.7%
neg-sub044.7%
cos-neg44.7%
Simplified44.7%
Taylor expanded in im around 0 61.7%
Taylor expanded in im around 0 61.7%
associate-*r*61.7%
mul-1-neg61.7%
Simplified61.7%
if 3.0999999999999998e25 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 82.2%
Taylor expanded in im around inf 82.2%
associate-*r*82.2%
Simplified82.2%
Taylor expanded in re around 0 57.6%
Final simplification60.8%
im\_m = (fabs.f64 im) im\_s = (copysign.f64 #s(literal 1 binary64) im) (FPCore (im_s re im_m) :precision binary64 (* im_s (if (<= im_m 235.0) (- im_m) (* -0.008333333333333333 (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 <= 235.0) {
tmp = -im_m;
} else {
tmp = -0.008333333333333333 * 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 <= 235.0d0) then
tmp = -im_m
else
tmp = (-0.008333333333333333d0) * (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 <= 235.0) {
tmp = -im_m;
} else {
tmp = -0.008333333333333333 * 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 <= 235.0: tmp = -im_m else: tmp = -0.008333333333333333 * 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 <= 235.0) tmp = Float64(-im_m); else tmp = Float64(-0.008333333333333333 * (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 <= 235.0) tmp = -im_m; else tmp = -0.008333333333333333 * (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, 235.0], (-im$95$m), N[(-0.008333333333333333 * N[Power[im$95$m, 5.0], $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 235:\\
\;\;\;\;-im\_m\\
\mathbf{else}:\\
\;\;\;\;-0.008333333333333333 \cdot {im\_m}^{5}\\
\end{array}
\end{array}
if im < 235Initial program 43.0%
/-rgt-identity43.0%
exp-043.0%
associate-*l/43.0%
cos-neg43.0%
associate-*l*43.0%
associate-*r/43.0%
exp-043.0%
/-rgt-identity43.0%
*-commutative43.0%
neg-sub043.0%
cos-neg43.0%
Simplified43.0%
Taylor expanded in im around 0 63.5%
Taylor expanded in re around 0 36.1%
mul-1-neg36.1%
Simplified36.1%
if 235 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 74.8%
Taylor expanded in im around inf 74.8%
associate-*r*74.8%
Simplified74.8%
Taylor expanded in re around 0 52.5%
im\_m = (fabs.f64 im) im\_s = (copysign.f64 #s(literal 1 binary64) im) (FPCore (im_s re im_m) :precision binary64 (* im_s (if (<= im_m 760000.0) (- im_m) (- (* (* re re) (* im_m 0.5)) im_m))))
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 <= 760000.0) {
tmp = -im_m;
} else {
tmp = ((re * re) * (im_m * 0.5)) - 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) :: tmp
if (im_m <= 760000.0d0) then
tmp = -im_m
else
tmp = ((re * re) * (im_m * 0.5d0)) - 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 tmp;
if (im_m <= 760000.0) {
tmp = -im_m;
} else {
tmp = ((re * re) * (im_m * 0.5)) - 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): tmp = 0 if im_m <= 760000.0: tmp = -im_m else: tmp = ((re * re) * (im_m * 0.5)) - im_m 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 <= 760000.0) tmp = Float64(-im_m); else tmp = Float64(Float64(Float64(re * re) * Float64(im_m * 0.5)) - 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) tmp = 0.0; if (im_m <= 760000.0) tmp = -im_m; else tmp = ((re * re) * (im_m * 0.5)) - 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_] := N[(im$95$s * If[LessEqual[im$95$m, 760000.0], (-im$95$m), N[(N[(N[(re * re), $MachinePrecision] * N[(im$95$m * 0.5), $MachinePrecision]), $MachinePrecision] - im$95$m), $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 760000:\\
\;\;\;\;-im\_m\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(im\_m \cdot 0.5\right) - im\_m\\
\end{array}
\end{array}
if im < 7.6e5Initial program 43.0%
/-rgt-identity43.0%
exp-043.0%
associate-*l/43.0%
cos-neg43.0%
associate-*l*43.0%
associate-*r/43.0%
exp-043.0%
/-rgt-identity43.0%
*-commutative43.0%
neg-sub043.0%
cos-neg43.0%
Simplified43.0%
Taylor expanded in im around 0 63.5%
Taylor expanded in re around 0 36.1%
mul-1-neg36.1%
Simplified36.1%
if 7.6e5 < im Initial program 100.0%
/-rgt-identity100.0%
exp-0100.0%
associate-*l/100.0%
cos-neg100.0%
associate-*l*100.0%
associate-*r/100.0%
exp-0100.0%
/-rgt-identity100.0%
*-commutative100.0%
neg-sub0100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 4.9%
Taylor expanded in re around 0 18.8%
+-commutative18.8%
mul-1-neg18.8%
unsub-neg18.8%
*-commutative18.8%
*-commutative18.8%
associate-*r*18.8%
Simplified18.8%
unpow218.8%
Applied egg-rr18.8%
im\_m = (fabs.f64 im) im\_s = (copysign.f64 #s(literal 1 binary64) im) (FPCore (im_s re im_m) :precision binary64 (* im_s (- im_m)))
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;
}
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
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;
}
im\_m = math.fabs(im) im\_s = math.copysign(1.0, im) def code(im_s, re, im_m): return im_s * -im_m
im\_m = abs(im) im\_s = copysign(1.0, im) function code(im_s, re, im_m) return Float64(im_s * Float64(-im_m)) 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; 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 * (-im$95$m)), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)
\\
im\_s \cdot \left(-im\_m\right)
\end{array}
Initial program 57.3%
/-rgt-identity57.3%
exp-057.3%
associate-*l/57.3%
cos-neg57.3%
associate-*l*57.3%
associate-*r/57.3%
exp-057.3%
/-rgt-identity57.3%
*-commutative57.3%
neg-sub057.3%
cos-neg57.3%
Simplified57.3%
Taylor expanded in im around 0 48.9%
Taylor expanded in re around 0 28.0%
mul-1-neg28.0%
Simplified28.0%
im\_m = (fabs.f64 im) im\_s = (copysign.f64 #s(literal 1 binary64) im) (FPCore (im_s re im_m) :precision binary64 (* im_s -1.0))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
return im_s * -1.0;
}
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 * (-1.0d0)
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 * -1.0;
}
im\_m = math.fabs(im) im\_s = math.copysign(1.0, im) def code(im_s, re, im_m): return im_s * -1.0
im\_m = abs(im) im\_s = copysign(1.0, im) function code(im_s, re, im_m) return Float64(im_s * -1.0) end
im\_m = abs(im); im\_s = sign(im) * abs(1.0); function tmp = code(im_s, re, im_m) tmp = im_s * -1.0; 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 * -1.0), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)
\\
im\_s \cdot -1
\end{array}
Initial program 57.3%
/-rgt-identity57.3%
exp-057.3%
associate-*l/57.3%
cos-neg57.3%
associate-*l*57.3%
associate-*r/57.3%
exp-057.3%
/-rgt-identity57.3%
*-commutative57.3%
neg-sub057.3%
cos-neg57.3%
Simplified57.3%
Applied egg-rr2.7%
metadata-eval2.7%
Applied egg-rr2.7%
(FPCore (re im)
:precision binary64
(if (< (fabs im) 1.0)
(-
(*
(cos re)
(+
(+ im (* (* (* 0.16666666666666666 im) im) im))
(* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
double code(double re, double im) {
double tmp;
if (fabs(im) < 1.0) {
tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * cos(re)) * (exp((0.0 - 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 = -(cos(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
else
tmp = (0.5d0 * cos(re)) * (exp((0.0d0 - 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.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if math.fabs(im) < 1.0: tmp = -(math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))) else: tmp = (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (abs(im) < 1.0) tmp = Float64(-Float64(cos(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 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (abs(im) < 1.0) tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))); else tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Cos[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[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\cos 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 \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\
\end{array}
\end{array}
herbie shell --seed 2024139
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
:alt
(! :herbie-platform default (if (< (fabs im) 1) (- (* (cos re) (+ im (* 1/6 im im im) (* 1/120 im im im im im)))) (* (* 1/2 (cos re)) (- (exp (- 0 im)) (exp im)))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))