
(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 11 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}
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (or (<= t_0 -10000000.0) (not (<= t_0 0.001)))
(* (* 0.5 (cos re)) t_0)
(- (* (pow im 3.0) (* (cos re) -0.16666666666666666)) (* im (cos re))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -10000000.0) || !(t_0 <= 0.001)) {
tmp = (0.5 * cos(re)) * t_0;
} else {
tmp = (pow(im, 3.0) * (cos(re) * -0.16666666666666666)) - (im * cos(re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-im) - exp(im)
if ((t_0 <= (-10000000.0d0)) .or. (.not. (t_0 <= 0.001d0))) then
tmp = (0.5d0 * cos(re)) * t_0
else
tmp = ((im ** 3.0d0) * (cos(re) * (-0.16666666666666666d0))) - (im * cos(re))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double tmp;
if ((t_0 <= -10000000.0) || !(t_0 <= 0.001)) {
tmp = (0.5 * Math.cos(re)) * t_0;
} else {
tmp = (Math.pow(im, 3.0) * (Math.cos(re) * -0.16666666666666666)) - (im * Math.cos(re));
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -10000000.0) or not (t_0 <= 0.001): tmp = (0.5 * math.cos(re)) * t_0 else: tmp = (math.pow(im, 3.0) * (math.cos(re) * -0.16666666666666666)) - (im * math.cos(re)) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= -10000000.0) || !(t_0 <= 0.001)) tmp = Float64(Float64(0.5 * cos(re)) * t_0); else tmp = Float64(Float64((im ^ 3.0) * Float64(cos(re) * -0.16666666666666666)) - Float64(im * cos(re))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -10000000.0) || ~((t_0 <= 0.001))) tmp = (0.5 * cos(re)) * t_0; else tmp = ((im ^ 3.0) * (cos(re) * -0.16666666666666666)) - (im * cos(re)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -10000000.0], N[Not[LessEqual[t$95$0, 0.001]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[Power[im, 3.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] - N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -10000000 \lor \neg \left(t_0 \leq 0.001\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;{im}^{3} \cdot \left(\cos re \cdot -0.16666666666666666\right) - im \cdot \cos re\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -1e7 or 1e-3 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
if -1e7 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1e-3Initial program 8.8%
neg-sub08.8%
Simplified8.8%
Taylor expanded in im around 0 99.9%
+-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
associate-*r*99.9%
distribute-rgt-out--99.8%
*-commutative99.8%
Simplified99.8%
sub-neg99.8%
distribute-rgt-in99.9%
*-commutative99.9%
associate-*r*99.9%
distribute-lft-neg-out99.9%
unsub-neg99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*l*99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))))
(if (or (<= t_0 -10000000.0) (not (<= t_0 0.001)))
(* (* 0.5 (cos re)) t_0)
(* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im)))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double tmp;
if ((t_0 <= -10000000.0) || !(t_0 <= 0.001)) {
tmp = (0.5 * cos(re)) * t_0;
} else {
tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-im) - exp(im)
if ((t_0 <= (-10000000.0d0)) .or. (.not. (t_0 <= 0.001d0))) then
tmp = (0.5d0 * cos(re)) * t_0
else
tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double tmp;
if ((t_0 <= -10000000.0) || !(t_0 <= 0.001)) {
tmp = (0.5 * Math.cos(re)) * t_0;
} else {
tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) tmp = 0 if (t_0 <= -10000000.0) or not (t_0 <= 0.001): tmp = (0.5 * math.cos(re)) * t_0 else: tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) tmp = 0.0 if ((t_0 <= -10000000.0) || !(t_0 <= 0.001)) tmp = Float64(Float64(0.5 * cos(re)) * t_0); else tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); tmp = 0.0; if ((t_0 <= -10000000.0) || ~((t_0 <= 0.001))) tmp = (0.5 * cos(re)) * t_0; else tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -10000000.0], N[Not[LessEqual[t$95$0, 0.001]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -10000000 \lor \neg \left(t_0 \leq 0.001\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -1e7 or 1e-3 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
if -1e7 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1e-3Initial program 8.8%
neg-sub08.8%
Simplified8.8%
Taylor expanded in im around 0 99.9%
+-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
associate-*r*99.9%
distribute-rgt-out--99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
(t_1 (* (pow im 3.0) -0.16666666666666666)))
(if (<= im -1.7e+52)
(* (cos re) (sqrt (* (pow im 6.0) 0.027777777777777776)))
(if (<= im -48000000000.0)
t_0
(if (<= im 4000.0)
(* (cos re) (- t_1 im))
(if (<= im 5.6e+102) t_0 (* (cos re) t_1)))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(-im) - exp(im));
double t_1 = pow(im, 3.0) * -0.16666666666666666;
double tmp;
if (im <= -1.7e+52) {
tmp = cos(re) * sqrt((pow(im, 6.0) * 0.027777777777777776));
} else if (im <= -48000000000.0) {
tmp = t_0;
} else if (im <= 4000.0) {
tmp = cos(re) * (t_1 - im);
} else if (im <= 5.6e+102) {
tmp = t_0;
} else {
tmp = cos(re) * t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * (exp(-im) - exp(im))
t_1 = (im ** 3.0d0) * (-0.16666666666666666d0)
if (im <= (-1.7d+52)) then
tmp = cos(re) * sqrt(((im ** 6.0d0) * 0.027777777777777776d0))
else if (im <= (-48000000000.0d0)) then
tmp = t_0
else if (im <= 4000.0d0) then
tmp = cos(re) * (t_1 - im)
else if (im <= 5.6d+102) then
tmp = t_0
else
tmp = cos(re) * t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
double t_1 = Math.pow(im, 3.0) * -0.16666666666666666;
double tmp;
if (im <= -1.7e+52) {
tmp = Math.cos(re) * Math.sqrt((Math.pow(im, 6.0) * 0.027777777777777776));
} else if (im <= -48000000000.0) {
tmp = t_0;
} else if (im <= 4000.0) {
tmp = Math.cos(re) * (t_1 - im);
} else if (im <= 5.6e+102) {
tmp = t_0;
} else {
tmp = Math.cos(re) * t_1;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.exp(-im) - math.exp(im)) t_1 = math.pow(im, 3.0) * -0.16666666666666666 tmp = 0 if im <= -1.7e+52: tmp = math.cos(re) * math.sqrt((math.pow(im, 6.0) * 0.027777777777777776)) elif im <= -48000000000.0: tmp = t_0 elif im <= 4000.0: tmp = math.cos(re) * (t_1 - im) elif im <= 5.6e+102: tmp = t_0 else: tmp = math.cos(re) * t_1 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))) t_1 = Float64((im ^ 3.0) * -0.16666666666666666) tmp = 0.0 if (im <= -1.7e+52) tmp = Float64(cos(re) * sqrt(Float64((im ^ 6.0) * 0.027777777777777776))); elseif (im <= -48000000000.0) tmp = t_0; elseif (im <= 4000.0) tmp = Float64(cos(re) * Float64(t_1 - im)); elseif (im <= 5.6e+102) tmp = t_0; else tmp = Float64(cos(re) * t_1); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (exp(-im) - exp(im)); t_1 = (im ^ 3.0) * -0.16666666666666666; tmp = 0.0; if (im <= -1.7e+52) tmp = cos(re) * sqrt(((im ^ 6.0) * 0.027777777777777776)); elseif (im <= -48000000000.0) tmp = t_0; elseif (im <= 4000.0) tmp = cos(re) * (t_1 - im); elseif (im <= 5.6e+102) tmp = t_0; else tmp = cos(re) * t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, If[LessEqual[im, -1.7e+52], N[(N[Cos[re], $MachinePrecision] * N[Sqrt[N[(N[Power[im, 6.0], $MachinePrecision] * 0.027777777777777776), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, -48000000000.0], t$95$0, If[LessEqual[im, 4000.0], N[(N[Cos[re], $MachinePrecision] * N[(t$95$1 - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5.6e+102], t$95$0, N[(N[Cos[re], $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := {im}^{3} \cdot -0.16666666666666666\\
\mathbf{if}\;im \leq -1.7 \cdot 10^{+52}:\\
\;\;\;\;\cos re \cdot \sqrt{{im}^{6} \cdot 0.027777777777777776}\\
\mathbf{elif}\;im \leq -48000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 4000:\\
\;\;\;\;\cos re \cdot \left(t_1 - im\right)\\
\mathbf{elif}\;im \leq 5.6 \cdot 10^{+102}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot t_1\\
\end{array}
\end{array}
if im < -1.7e52Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 79.9%
+-commutative79.9%
mul-1-neg79.9%
unsub-neg79.9%
associate-*r*79.9%
distribute-rgt-out--79.9%
*-commutative79.9%
Simplified79.9%
Taylor expanded in im around inf 79.9%
*-commutative79.9%
associate-*r*79.9%
*-commutative79.9%
associate-*r*79.9%
Simplified79.9%
*-commutative79.9%
add-sqr-sqrt79.9%
sqrt-unprod100.0%
swap-sqr100.0%
pow-prod-up100.0%
metadata-eval100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -1.7e52 < im < -4.8e10 or 4e3 < im < 5.60000000000000037e102Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 79.5%
if -4.8e10 < im < 4e3Initial program 12.5%
neg-sub012.5%
Simplified12.5%
Taylor expanded in im around 0 96.0%
+-commutative96.0%
mul-1-neg96.0%
unsub-neg96.0%
associate-*r*96.0%
distribute-rgt-out--96.0%
*-commutative96.0%
Simplified96.0%
if 5.60000000000000037e102 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification95.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
(t_1 (* (cos re) (* (pow im 3.0) -0.16666666666666666))))
(if (<= im -5.5e+102)
t_1
(if (<= im -0.0017)
t_0
(if (<= im 4000.0)
(* im (- (cos re)))
(if (<= im 5.6e+102) t_0 t_1))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(-im) - exp(im));
double t_1 = cos(re) * (pow(im, 3.0) * -0.16666666666666666);
double tmp;
if (im <= -5.5e+102) {
tmp = t_1;
} else if (im <= -0.0017) {
tmp = t_0;
} else if (im <= 4000.0) {
tmp = im * -cos(re);
} else if (im <= 5.6e+102) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * (exp(-im) - exp(im))
t_1 = cos(re) * ((im ** 3.0d0) * (-0.16666666666666666d0))
if (im <= (-5.5d+102)) then
tmp = t_1
else if (im <= (-0.0017d0)) then
tmp = t_0
else if (im <= 4000.0d0) then
tmp = im * -cos(re)
else if (im <= 5.6d+102) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
double t_1 = Math.cos(re) * (Math.pow(im, 3.0) * -0.16666666666666666);
double tmp;
if (im <= -5.5e+102) {
tmp = t_1;
} else if (im <= -0.0017) {
tmp = t_0;
} else if (im <= 4000.0) {
tmp = im * -Math.cos(re);
} else if (im <= 5.6e+102) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.exp(-im) - math.exp(im)) t_1 = math.cos(re) * (math.pow(im, 3.0) * -0.16666666666666666) tmp = 0 if im <= -5.5e+102: tmp = t_1 elif im <= -0.0017: tmp = t_0 elif im <= 4000.0: tmp = im * -math.cos(re) elif im <= 5.6e+102: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))) t_1 = Float64(cos(re) * Float64((im ^ 3.0) * -0.16666666666666666)) tmp = 0.0 if (im <= -5.5e+102) tmp = t_1; elseif (im <= -0.0017) tmp = t_0; elseif (im <= 4000.0) tmp = Float64(im * Float64(-cos(re))); elseif (im <= 5.6e+102) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (exp(-im) - exp(im)); t_1 = cos(re) * ((im ^ 3.0) * -0.16666666666666666); tmp = 0.0; if (im <= -5.5e+102) tmp = t_1; elseif (im <= -0.0017) tmp = t_0; elseif (im <= 4000.0) tmp = im * -cos(re); elseif (im <= 5.6e+102) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[re], $MachinePrecision] * N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.5e+102], t$95$1, If[LessEqual[im, -0.0017], t$95$0, If[LessEqual[im, 4000.0], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 5.6e+102], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := \cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\
\mathbf{if}\;im \leq -5.5 \cdot 10^{+102}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -0.0017:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 4000:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\mathbf{elif}\;im \leq 5.6 \cdot 10^{+102}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -5.49999999999999981e102 or 5.60000000000000037e102 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
if -5.49999999999999981e102 < im < -0.00169999999999999991 or 4e3 < im < 5.60000000000000037e102Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 73.4%
if -0.00169999999999999991 < im < 4e3Initial program 11.1%
neg-sub011.1%
Simplified11.1%
Taylor expanded in im around 0 96.9%
associate-*r*96.9%
neg-mul-196.9%
Simplified96.9%
Final simplification93.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
(t_1 (* (pow im 3.0) -0.16666666666666666))
(t_2 (* (cos re) t_1)))
(if (<= im -5e+103)
t_2
(if (<= im -48000000000.0)
t_0
(if (<= im 4000.0)
(* (cos re) (- t_1 im))
(if (<= im 5.6e+102) t_0 t_2))))))
double code(double re, double im) {
double t_0 = 0.5 * (exp(-im) - exp(im));
double t_1 = pow(im, 3.0) * -0.16666666666666666;
double t_2 = cos(re) * t_1;
double tmp;
if (im <= -5e+103) {
tmp = t_2;
} else if (im <= -48000000000.0) {
tmp = t_0;
} else if (im <= 4000.0) {
tmp = cos(re) * (t_1 - im);
} else if (im <= 5.6e+102) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 0.5d0 * (exp(-im) - exp(im))
t_1 = (im ** 3.0d0) * (-0.16666666666666666d0)
t_2 = cos(re) * t_1
if (im <= (-5d+103)) then
tmp = t_2
else if (im <= (-48000000000.0d0)) then
tmp = t_0
else if (im <= 4000.0d0) then
tmp = cos(re) * (t_1 - im)
else if (im <= 5.6d+102) then
tmp = t_0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
double t_1 = Math.pow(im, 3.0) * -0.16666666666666666;
double t_2 = Math.cos(re) * t_1;
double tmp;
if (im <= -5e+103) {
tmp = t_2;
} else if (im <= -48000000000.0) {
tmp = t_0;
} else if (im <= 4000.0) {
tmp = Math.cos(re) * (t_1 - im);
} else if (im <= 5.6e+102) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (math.exp(-im) - math.exp(im)) t_1 = math.pow(im, 3.0) * -0.16666666666666666 t_2 = math.cos(re) * t_1 tmp = 0 if im <= -5e+103: tmp = t_2 elif im <= -48000000000.0: tmp = t_0 elif im <= 4000.0: tmp = math.cos(re) * (t_1 - im) elif im <= 5.6e+102: tmp = t_0 else: tmp = t_2 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))) t_1 = Float64((im ^ 3.0) * -0.16666666666666666) t_2 = Float64(cos(re) * t_1) tmp = 0.0 if (im <= -5e+103) tmp = t_2; elseif (im <= -48000000000.0) tmp = t_0; elseif (im <= 4000.0) tmp = Float64(cos(re) * Float64(t_1 - im)); elseif (im <= 5.6e+102) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (exp(-im) - exp(im)); t_1 = (im ^ 3.0) * -0.16666666666666666; t_2 = cos(re) * t_1; tmp = 0.0; if (im <= -5e+103) tmp = t_2; elseif (im <= -48000000000.0) tmp = t_0; elseif (im <= 4000.0) tmp = cos(re) * (t_1 - im); elseif (im <= 5.6e+102) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[re], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[im, -5e+103], t$95$2, If[LessEqual[im, -48000000000.0], t$95$0, If[LessEqual[im, 4000.0], N[(N[Cos[re], $MachinePrecision] * N[(t$95$1 - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5.6e+102], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := {im}^{3} \cdot -0.16666666666666666\\
t_2 := \cos re \cdot t_1\\
\mathbf{if}\;im \leq -5 \cdot 10^{+103}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq -48000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 4000:\\
\;\;\;\;\cos re \cdot \left(t_1 - im\right)\\
\mathbf{elif}\;im \leq 5.6 \cdot 10^{+102}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if im < -5e103 or 5.60000000000000037e102 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
if -5e103 < im < -4.8e10 or 4e3 < im < 5.60000000000000037e102Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 76.0%
if -4.8e10 < im < 4e3Initial program 12.5%
neg-sub012.5%
Simplified12.5%
Taylor expanded in im around 0 96.0%
+-commutative96.0%
mul-1-neg96.0%
unsub-neg96.0%
associate-*r*96.0%
distribute-rgt-out--96.0%
*-commutative96.0%
Simplified96.0%
Final simplification93.4%
(FPCore (re im) :precision binary64 (if (or (<= im -0.014) (not (<= im 4000.0))) (* 0.5 (- (exp (- im)) (exp im))) (* im (- (cos re)))))
double code(double re, double im) {
double tmp;
if ((im <= -0.014) || !(im <= 4000.0)) {
tmp = 0.5 * (exp(-im) - exp(im));
} else {
tmp = im * -cos(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-0.014d0)) .or. (.not. (im <= 4000.0d0))) then
tmp = 0.5d0 * (exp(-im) - exp(im))
else
tmp = im * -cos(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -0.014) || !(im <= 4000.0)) {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
} else {
tmp = im * -Math.cos(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -0.014) or not (im <= 4000.0): tmp = 0.5 * (math.exp(-im) - math.exp(im)) else: tmp = im * -math.cos(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -0.014) || !(im <= 4000.0)) tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); else tmp = Float64(im * Float64(-cos(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -0.014) || ~((im <= 4000.0))) tmp = 0.5 * (exp(-im) - exp(im)); else tmp = im * -cos(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -0.014], N[Not[LessEqual[im, 4000.0]], $MachinePrecision]], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.014 \lor \neg \left(im \leq 4000\right):\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\end{array}
\end{array}
if im < -0.0140000000000000003 or 4e3 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 73.1%
if -0.0140000000000000003 < im < 4e3Initial program 11.1%
neg-sub011.1%
Simplified11.1%
Taylor expanded in im around 0 96.9%
associate-*r*96.9%
neg-mul-196.9%
Simplified96.9%
Final simplification84.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im)))
(if (<= im -8.5e+97)
t_0
(if (<= im 620.0)
(* im (- (cos re)))
(if (<= im 8.5e+96) (- (* (pow re 2.0) (* im 0.5)) im) t_0)))))
double code(double re, double im) {
double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
double tmp;
if (im <= -8.5e+97) {
tmp = t_0;
} else if (im <= 620.0) {
tmp = im * -cos(re);
} else if (im <= 8.5e+96) {
tmp = (pow(re, 2.0) * (im * 0.5)) - im;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
if (im <= (-8.5d+97)) then
tmp = t_0
else if (im <= 620.0d0) then
tmp = im * -cos(re)
else if (im <= 8.5d+96) then
tmp = ((re ** 2.0d0) * (im * 0.5d0)) - im
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
double tmp;
if (im <= -8.5e+97) {
tmp = t_0;
} else if (im <= 620.0) {
tmp = im * -Math.cos(re);
} else if (im <= 8.5e+96) {
tmp = (Math.pow(re, 2.0) * (im * 0.5)) - im;
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = (math.pow(im, 3.0) * -0.16666666666666666) - im tmp = 0 if im <= -8.5e+97: tmp = t_0 elif im <= 620.0: tmp = im * -math.cos(re) elif im <= 8.5e+96: tmp = (math.pow(re, 2.0) * (im * 0.5)) - im else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) tmp = 0.0 if (im <= -8.5e+97) tmp = t_0; elseif (im <= 620.0) tmp = Float64(im * Float64(-cos(re))); elseif (im <= 8.5e+96) tmp = Float64(Float64((re ^ 2.0) * Float64(im * 0.5)) - im); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = ((im ^ 3.0) * -0.16666666666666666) - im; tmp = 0.0; if (im <= -8.5e+97) tmp = t_0; elseif (im <= 620.0) tmp = im * -cos(re); elseif (im <= 8.5e+96) tmp = ((re ^ 2.0) * (im * 0.5)) - im; else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, If[LessEqual[im, -8.5e+97], t$95$0, If[LessEqual[im, 620.0], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 8.5e+96], N[(N[(N[Power[re, 2.0], $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{if}\;im \leq -8.5 \cdot 10^{+97}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 620:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\mathbf{elif}\;im \leq 8.5 \cdot 10^{+96}:\\
\;\;\;\;{re}^{2} \cdot \left(im \cdot 0.5\right) - im\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < -8.4999999999999993e97 or 8.50000000000000025e96 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 94.2%
+-commutative94.2%
mul-1-neg94.2%
unsub-neg94.2%
associate-*r*94.2%
distribute-rgt-out--94.2%
*-commutative94.2%
Simplified94.2%
Taylor expanded in re around 0 68.9%
if -8.4999999999999993e97 < im < 620Initial program 26.5%
neg-sub026.5%
Simplified26.5%
Taylor expanded in im around 0 80.7%
associate-*r*80.7%
neg-mul-180.7%
Simplified80.7%
if 620 < im < 8.50000000000000025e96Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 3.4%
associate-*r*3.4%
neg-mul-13.4%
Simplified3.4%
Taylor expanded in re around 0 26.1%
+-commutative26.1%
mul-1-neg26.1%
unsub-neg26.1%
*-commutative26.1%
*-commutative26.1%
associate-*r*26.1%
Simplified26.1%
Final simplification72.0%
(FPCore (re im) :precision binary64 (if (or (<= im -6.2) (not (<= im 3.65e+25))) (* 0.5 (+ (* im -2.0) (* -0.016666666666666666 (pow im 5.0)))) (* im (- (cos re)))))
double code(double re, double im) {
double tmp;
if ((im <= -6.2) || !(im <= 3.65e+25)) {
tmp = 0.5 * ((im * -2.0) + (-0.016666666666666666 * pow(im, 5.0)));
} else {
tmp = im * -cos(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-6.2d0)) .or. (.not. (im <= 3.65d+25))) then
tmp = 0.5d0 * ((im * (-2.0d0)) + ((-0.016666666666666666d0) * (im ** 5.0d0)))
else
tmp = im * -cos(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -6.2) || !(im <= 3.65e+25)) {
tmp = 0.5 * ((im * -2.0) + (-0.016666666666666666 * Math.pow(im, 5.0)));
} else {
tmp = im * -Math.cos(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -6.2) or not (im <= 3.65e+25): tmp = 0.5 * ((im * -2.0) + (-0.016666666666666666 * math.pow(im, 5.0))) else: tmp = im * -math.cos(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -6.2) || !(im <= 3.65e+25)) tmp = Float64(0.5 * Float64(Float64(im * -2.0) + Float64(-0.016666666666666666 * (im ^ 5.0)))); else tmp = Float64(im * Float64(-cos(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -6.2) || ~((im <= 3.65e+25))) tmp = 0.5 * ((im * -2.0) + (-0.016666666666666666 * (im ^ 5.0))); else tmp = im * -cos(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -6.2], N[Not[LessEqual[im, 3.65e+25]], $MachinePrecision]], N[(0.5 * N[(N[(im * -2.0), $MachinePrecision] + N[(-0.016666666666666666 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -6.2 \lor \neg \left(im \leq 3.65 \cdot 10^{+25}\right):\\
\;\;\;\;0.5 \cdot \left(im \cdot -2 + -0.016666666666666666 \cdot {im}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\end{array}
\end{array}
if im < -6.20000000000000018 or 3.6499999999999998e25 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 74.4%
Taylor expanded in im around 0 57.4%
Taylor expanded in im around inf 57.4%
if -6.20000000000000018 < im < 3.6499999999999998e25Initial program 17.3%
neg-sub017.3%
Simplified17.3%
Taylor expanded in im around 0 90.3%
associate-*r*90.3%
neg-mul-190.3%
Simplified90.3%
Final simplification73.9%
(FPCore (re im) :precision binary64 (if (or (<= im -8.5e+97) (not (<= im 1.52e+25))) (- (* (pow im 3.0) -0.16666666666666666) im) (* im (- (cos re)))))
double code(double re, double im) {
double tmp;
if ((im <= -8.5e+97) || !(im <= 1.52e+25)) {
tmp = (pow(im, 3.0) * -0.16666666666666666) - im;
} else {
tmp = im * -cos(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-8.5d+97)) .or. (.not. (im <= 1.52d+25))) then
tmp = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
else
tmp = im * -cos(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -8.5e+97) || !(im <= 1.52e+25)) {
tmp = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
} else {
tmp = im * -Math.cos(re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -8.5e+97) or not (im <= 1.52e+25): tmp = (math.pow(im, 3.0) * -0.16666666666666666) - im else: tmp = im * -math.cos(re) return tmp
function code(re, im) tmp = 0.0 if ((im <= -8.5e+97) || !(im <= 1.52e+25)) tmp = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im); else tmp = Float64(im * Float64(-cos(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -8.5e+97) || ~((im <= 1.52e+25))) tmp = ((im ^ 3.0) * -0.16666666666666666) - im; else tmp = im * -cos(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -8.5e+97], N[Not[LessEqual[im, 1.52e+25]], $MachinePrecision]], N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -8.5 \cdot 10^{+97} \lor \neg \left(im \leq 1.52 \cdot 10^{+25}\right):\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\end{array}
\end{array}
if im < -8.4999999999999993e97 or 1.52000000000000006e25 < im Initial program 100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 85.4%
+-commutative85.4%
mul-1-neg85.4%
unsub-neg85.4%
associate-*r*85.4%
distribute-rgt-out--85.4%
*-commutative85.4%
Simplified85.4%
Taylor expanded in re around 0 62.4%
if -8.4999999999999993e97 < im < 1.52000000000000006e25Initial program 31.7%
neg-sub031.7%
Simplified31.7%
Taylor expanded in im around 0 75.2%
associate-*r*75.2%
neg-mul-175.2%
Simplified75.2%
Final simplification70.2%
(FPCore (re im) :precision binary64 (* im (- (cos re))))
double code(double re, double im) {
return im * -cos(re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * -cos(re)
end function
public static double code(double re, double im) {
return im * -Math.cos(re);
}
def code(re, im): return im * -math.cos(re)
function code(re, im) return Float64(im * Float64(-cos(re))) end
function tmp = code(re, im) tmp = im * -cos(re); end
code[re_, im_] := N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(-\cos re\right)
\end{array}
Initial program 58.7%
neg-sub058.7%
Simplified58.7%
Taylor expanded in im around 0 47.8%
associate-*r*47.8%
neg-mul-147.8%
Simplified47.8%
Final simplification47.8%
(FPCore (re im) :precision binary64 (- im))
double code(double re, double im) {
return -im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -im
end function
public static double code(double re, double im) {
return -im;
}
def code(re, im): return -im
function code(re, im) return Float64(-im) end
function tmp = code(re, im) tmp = -im; end
code[re_, im_] := (-im)
\begin{array}{l}
\\
-im
\end{array}
Initial program 58.7%
neg-sub058.7%
Simplified58.7%
Taylor expanded in im around 0 47.8%
associate-*r*47.8%
neg-mul-147.8%
Simplified47.8%
Taylor expanded in re around 0 37.6%
+-commutative37.6%
mul-1-neg37.6%
unsub-neg37.6%
*-commutative37.6%
*-commutative37.6%
associate-*r*37.6%
Simplified37.6%
Taylor expanded in re around 0 29.2%
mul-1-neg29.2%
Simplified29.2%
Final simplification29.2%
(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 2023320
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
:herbie-target
(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))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))