
(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 12 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 -5.0) (not (<= t_0 0.0005)))
(* (* 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 <= -5.0) || !(t_0 <= 0.0005)) {
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 <= (-5.0d0)) .or. (.not. (t_0 <= 0.0005d0))) 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 <= -5.0) || !(t_0 <= 0.0005)) {
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 <= -5.0) or not (t_0 <= 0.0005): 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 <= -5.0) || !(t_0 <= 0.0005)) 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 <= -5.0) || ~((t_0 <= 0.0005))) 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, -5.0], N[Not[LessEqual[t$95$0, 0.0005]], $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 -5 \lor \neg \left(t_0 \leq 0.0005\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)) < -5 or 5.0000000000000001e-4 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
if -5 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 5.0000000000000001e-4Initial program 8.6%
sub0-neg8.6%
Simplified8.6%
Taylor expanded in im around 0 99.8%
mul-1-neg99.8%
unsub-neg99.8%
*-commutative99.8%
associate-*l*99.8%
distribute-lft-out--99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im)))
(t_1 (* 0.5 t_0))
(t_2 (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))))
(if (<= im -5.6e+102)
t_2
(if (<= im -1e+61)
t_1
(if (<= im -2.6)
(* t_0 (+ 0.5 (* re (* re -0.25))))
(if (or (<= im 2000000000.0) (not (<= im 5.8e+102))) t_2 t_1))))))
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double t_1 = 0.5 * t_0;
double t_2 = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
double tmp;
if (im <= -5.6e+102) {
tmp = t_2;
} else if (im <= -1e+61) {
tmp = t_1;
} else if (im <= -2.6) {
tmp = t_0 * (0.5 + (re * (re * -0.25)));
} else if ((im <= 2000000000.0) || !(im <= 5.8e+102)) {
tmp = t_2;
} 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) :: t_2
real(8) :: tmp
t_0 = exp(-im) - exp(im)
t_1 = 0.5d0 * t_0
t_2 = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
if (im <= (-5.6d+102)) then
tmp = t_2
else if (im <= (-1d+61)) then
tmp = t_1
else if (im <= (-2.6d0)) then
tmp = t_0 * (0.5d0 + (re * (re * (-0.25d0))))
else if ((im <= 2000000000.0d0) .or. (.not. (im <= 5.8d+102))) then
tmp = t_2
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(-im) - Math.exp(im);
double t_1 = 0.5 * t_0;
double t_2 = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
double tmp;
if (im <= -5.6e+102) {
tmp = t_2;
} else if (im <= -1e+61) {
tmp = t_1;
} else if (im <= -2.6) {
tmp = t_0 * (0.5 + (re * (re * -0.25)));
} else if ((im <= 2000000000.0) || !(im <= 5.8e+102)) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = math.exp(-im) - math.exp(im) t_1 = 0.5 * t_0 t_2 = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) tmp = 0 if im <= -5.6e+102: tmp = t_2 elif im <= -1e+61: tmp = t_1 elif im <= -2.6: tmp = t_0 * (0.5 + (re * (re * -0.25))) elif (im <= 2000000000.0) or not (im <= 5.8e+102): tmp = t_2 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(exp(Float64(-im)) - exp(im)) t_1 = Float64(0.5 * t_0) t_2 = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)) tmp = 0.0 if (im <= -5.6e+102) tmp = t_2; elseif (im <= -1e+61) tmp = t_1; elseif (im <= -2.6) tmp = Float64(t_0 * Float64(0.5 + Float64(re * Float64(re * -0.25)))); elseif ((im <= 2000000000.0) || !(im <= 5.8e+102)) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = exp(-im) - exp(im); t_1 = 0.5 * t_0; t_2 = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im); tmp = 0.0; if (im <= -5.6e+102) tmp = t_2; elseif (im <= -1e+61) tmp = t_1; elseif (im <= -2.6) tmp = t_0 * (0.5 + (re * (re * -0.25))); elseif ((im <= 2000000000.0) || ~((im <= 5.8e+102))) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.6e+102], t$95$2, If[LessEqual[im, -1e+61], t$95$1, If[LessEqual[im, -2.6], N[(t$95$0 * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, 2000000000.0], N[Not[LessEqual[im, 5.8e+102]], $MachinePrecision]], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := 0.5 \cdot t_0\\
t_2 := \cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{if}\;im \leq -5.6 \cdot 10^{+102}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;im \leq -1 \cdot 10^{+61}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq -2.6:\\
\;\;\;\;t_0 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\
\mathbf{elif}\;im \leq 2000000000 \lor \neg \left(im \leq 5.8 \cdot 10^{+102}\right):\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < -5.60000000000000037e102 or -2.60000000000000009 < im < 2e9 or 5.8000000000000005e102 < im Initial program 46.2%
sub0-neg46.2%
Simplified46.2%
Taylor expanded in im around 0 98.7%
mul-1-neg98.7%
unsub-neg98.7%
*-commutative98.7%
associate-*l*98.7%
distribute-lft-out--98.7%
Simplified98.7%
if -5.60000000000000037e102 < im < -9.99999999999999949e60 or 2e9 < im < 5.8000000000000005e102Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 92.3%
if -9.99999999999999949e60 < im < -2.60000000000000009Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
associate-*r*0.0%
distribute-rgt-out87.5%
+-commutative87.5%
*-commutative87.5%
unpow287.5%
associate-*l*87.5%
Simplified87.5%
Final simplification97.4%
(FPCore (re im)
:precision binary64
(if (or (<= im -5.6e+102)
(not
(or (<= im -2.6) (and (not (<= im 2000000000.0)) (<= im 5.8e+102)))))
(* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))
(* 0.5 (- (exp (- im)) (exp im)))))
double code(double re, double im) {
double tmp;
if ((im <= -5.6e+102) || !((im <= -2.6) || (!(im <= 2000000000.0) && (im <= 5.8e+102)))) {
tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
} else {
tmp = 0.5 * (exp(-im) - exp(im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-5.6d+102)) .or. (.not. (im <= (-2.6d0)) .or. (.not. (im <= 2000000000.0d0)) .and. (im <= 5.8d+102))) then
tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
else
tmp = 0.5d0 * (exp(-im) - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -5.6e+102) || !((im <= -2.6) || (!(im <= 2000000000.0) && (im <= 5.8e+102)))) {
tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
} else {
tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -5.6e+102) or not ((im <= -2.6) or (not (im <= 2000000000.0) and (im <= 5.8e+102))): tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im) else: tmp = 0.5 * (math.exp(-im) - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if ((im <= -5.6e+102) || !((im <= -2.6) || (!(im <= 2000000000.0) && (im <= 5.8e+102)))) tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)); else tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -5.6e+102) || ~(((im <= -2.6) || (~((im <= 2000000000.0)) && (im <= 5.8e+102))))) tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im); else tmp = 0.5 * (exp(-im) - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -5.6e+102], N[Not[Or[LessEqual[im, -2.6], And[N[Not[LessEqual[im, 2000000000.0]], $MachinePrecision], LessEqual[im, 5.8e+102]]]], $MachinePrecision]], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -5.6 \cdot 10^{+102} \lor \neg \left(im \leq -2.6 \lor \neg \left(im \leq 2000000000\right) \land im \leq 5.8 \cdot 10^{+102}\right):\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\end{array}
\end{array}
if im < -5.60000000000000037e102 or -2.60000000000000009 < im < 2e9 or 5.8000000000000005e102 < im Initial program 46.2%
sub0-neg46.2%
Simplified46.2%
Taylor expanded in im around 0 98.7%
mul-1-neg98.7%
unsub-neg98.7%
*-commutative98.7%
associate-*l*98.7%
distribute-lft-out--98.7%
Simplified98.7%
if -5.60000000000000037e102 < im < -2.60000000000000009 or 2e9 < im < 5.8000000000000005e102Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 78.6%
Final simplification95.4%
(FPCore (re im) :precision binary64 (if (<= (cos re) -0.02) (* im (+ (* 0.5 (* re re)) -1.0)) (if (<= (cos re) 0.95) (* (+ 0.5 (* re (* re -0.25))) -3.0) (- im))))
double code(double re, double im) {
double tmp;
if (cos(re) <= -0.02) {
tmp = im * ((0.5 * (re * re)) + -1.0);
} else if (cos(re) <= 0.95) {
tmp = (0.5 + (re * (re * -0.25))) * -3.0;
} else {
tmp = -im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (cos(re) <= (-0.02d0)) then
tmp = im * ((0.5d0 * (re * re)) + (-1.0d0))
else if (cos(re) <= 0.95d0) then
tmp = (0.5d0 + (re * (re * (-0.25d0)))) * (-3.0d0)
else
tmp = -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.cos(re) <= -0.02) {
tmp = im * ((0.5 * (re * re)) + -1.0);
} else if (Math.cos(re) <= 0.95) {
tmp = (0.5 + (re * (re * -0.25))) * -3.0;
} else {
tmp = -im;
}
return tmp;
}
def code(re, im): tmp = 0 if math.cos(re) <= -0.02: tmp = im * ((0.5 * (re * re)) + -1.0) elif math.cos(re) <= 0.95: tmp = (0.5 + (re * (re * -0.25))) * -3.0 else: tmp = -im return tmp
function code(re, im) tmp = 0.0 if (cos(re) <= -0.02) tmp = Float64(im * Float64(Float64(0.5 * Float64(re * re)) + -1.0)); elseif (cos(re) <= 0.95) tmp = Float64(Float64(0.5 + Float64(re * Float64(re * -0.25))) * -3.0); else tmp = Float64(-im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (cos(re) <= -0.02) tmp = im * ((0.5 * (re * re)) + -1.0); elseif (cos(re) <= 0.95) tmp = (0.5 + (re * (re * -0.25))) * -3.0; else tmp = -im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Cos[re], $MachinePrecision], -0.02], N[(im * N[(N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Cos[re], $MachinePrecision], 0.95], N[(N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -3.0), $MachinePrecision], (-im)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos re \leq -0.02:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right) + -1\right)\\
\mathbf{elif}\;\cos re \leq 0.95:\\
\;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\\
\mathbf{else}:\\
\;\;\;\;-im\\
\end{array}
\end{array}
if (cos.f64 re) < -0.0200000000000000004Initial program 58.1%
sub0-neg58.1%
Simplified58.1%
Taylor expanded in im around 0 48.9%
mul-1-neg48.9%
*-commutative48.9%
distribute-lft-neg-in48.9%
Simplified48.9%
Taylor expanded in re around 0 39.8%
associate-*r*39.8%
distribute-rgt-out39.8%
+-commutative39.8%
*-commutative39.8%
unpow239.8%
Simplified39.8%
if -0.0200000000000000004 < (cos.f64 re) < 0.94999999999999996Initial program 62.3%
sub0-neg62.3%
Simplified62.3%
Taylor expanded in re around 0 1.1%
*-commutative1.1%
associate-*r*1.1%
distribute-rgt-out3.2%
+-commutative3.2%
*-commutative3.2%
unpow23.2%
associate-*l*3.2%
Simplified3.2%
Applied egg-rr21.8%
if 0.94999999999999996 < (cos.f64 re) Initial program 51.0%
sub0-neg51.0%
Simplified51.0%
Taylor expanded in im around 0 55.4%
mul-1-neg55.4%
*-commutative55.4%
distribute-lft-neg-in55.4%
Simplified55.4%
Taylor expanded in re around 0 50.5%
neg-mul-150.5%
Simplified50.5%
Final simplification42.2%
(FPCore (re im) :precision binary64 (if (or (<= im -0.000195) (not (<= im 2000000000.0))) (* 0.5 (- (exp (- im)) (exp im))) (* im (- (cos re)))))
double code(double re, double im) {
double tmp;
if ((im <= -0.000195) || !(im <= 2000000000.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.000195d0)) .or. (.not. (im <= 2000000000.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.000195) || !(im <= 2000000000.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.000195) or not (im <= 2000000000.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.000195) || !(im <= 2000000000.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.000195) || ~((im <= 2000000000.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.000195], N[Not[LessEqual[im, 2000000000.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.000195 \lor \neg \left(im \leq 2000000000\right):\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\end{array}
\end{array}
if im < -1.94999999999999996e-4 or 2e9 < im Initial program 99.9%
sub0-neg99.9%
Simplified99.9%
Taylor expanded in re around 0 73.6%
if -1.94999999999999996e-4 < im < 2e9Initial program 9.4%
sub0-neg9.4%
Simplified9.4%
Taylor expanded in im around 0 98.0%
mul-1-neg98.0%
*-commutative98.0%
distribute-lft-neg-in98.0%
Simplified98.0%
Final simplification85.7%
(FPCore (re im)
:precision binary64
(let* ((t_0
(*
(+ 0.5 (* re (* re -0.25)))
(+ (* im -2.0) (* (pow im 3.0) -0.3333333333333333)))))
(if (<= im -5.6e-5)
t_0
(if (<= im 6.2e-6)
(* im (- (cos re)))
(if (<= im 1e+142) t_0 (- (* (pow im 3.0) -0.16666666666666666) im))))))
double code(double re, double im) {
double t_0 = (0.5 + (re * (re * -0.25))) * ((im * -2.0) + (pow(im, 3.0) * -0.3333333333333333));
double tmp;
if (im <= -5.6e-5) {
tmp = t_0;
} else if (im <= 6.2e-6) {
tmp = im * -cos(re);
} else if (im <= 1e+142) {
tmp = t_0;
} else {
tmp = (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 = (0.5d0 + (re * (re * (-0.25d0)))) * ((im * (-2.0d0)) + ((im ** 3.0d0) * (-0.3333333333333333d0)))
if (im <= (-5.6d-5)) then
tmp = t_0
else if (im <= 6.2d-6) then
tmp = im * -cos(re)
else if (im <= 1d+142) then
tmp = t_0
else
tmp = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (0.5 + (re * (re * -0.25))) * ((im * -2.0) + (Math.pow(im, 3.0) * -0.3333333333333333));
double tmp;
if (im <= -5.6e-5) {
tmp = t_0;
} else if (im <= 6.2e-6) {
tmp = im * -Math.cos(re);
} else if (im <= 1e+142) {
tmp = t_0;
} else {
tmp = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
}
return tmp;
}
def code(re, im): t_0 = (0.5 + (re * (re * -0.25))) * ((im * -2.0) + (math.pow(im, 3.0) * -0.3333333333333333)) tmp = 0 if im <= -5.6e-5: tmp = t_0 elif im <= 6.2e-6: tmp = im * -math.cos(re) elif im <= 1e+142: tmp = t_0 else: tmp = (math.pow(im, 3.0) * -0.16666666666666666) - im return tmp
function code(re, im) t_0 = Float64(Float64(0.5 + Float64(re * Float64(re * -0.25))) * Float64(Float64(im * -2.0) + Float64((im ^ 3.0) * -0.3333333333333333))) tmp = 0.0 if (im <= -5.6e-5) tmp = t_0; elseif (im <= 6.2e-6) tmp = Float64(im * Float64(-cos(re))); elseif (im <= 1e+142) tmp = t_0; else tmp = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im); end return tmp end
function tmp_2 = code(re, im) t_0 = (0.5 + (re * (re * -0.25))) * ((im * -2.0) + ((im ^ 3.0) * -0.3333333333333333)); tmp = 0.0; if (im <= -5.6e-5) tmp = t_0; elseif (im <= 6.2e-6) tmp = im * -cos(re); elseif (im <= 1e+142) tmp = t_0; else tmp = ((im ^ 3.0) * -0.16666666666666666) - im; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(im * -2.0), $MachinePrecision] + N[(N[Power[im, 3.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.6e-5], t$95$0, If[LessEqual[im, 6.2e-6], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1e+142], t$95$0, N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot \left(im \cdot -2 + {im}^{3} \cdot -0.3333333333333333\right)\\
\mathbf{if}\;im \leq -5.6 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 6.2 \cdot 10^{-6}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\mathbf{elif}\;im \leq 10^{+142}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\
\end{array}
\end{array}
if im < -5.59999999999999992e-5 or 6.1999999999999999e-6 < im < 1.00000000000000005e142Initial program 99.6%
sub0-neg99.6%
Simplified99.6%
Taylor expanded in re around 0 1.7%
*-commutative1.7%
associate-*r*1.7%
distribute-rgt-out74.0%
+-commutative74.0%
*-commutative74.0%
unpow274.0%
associate-*l*74.0%
Simplified74.0%
Taylor expanded in im around 0 49.0%
if -5.59999999999999992e-5 < im < 6.1999999999999999e-6Initial program 7.4%
sub0-neg7.4%
Simplified7.4%
Taylor expanded in im around 0 99.6%
mul-1-neg99.6%
*-commutative99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
if 1.00000000000000005e142 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in re around 0 77.4%
Final simplification76.9%
(FPCore (re im) :precision binary64 (if (or (<= im -0.00019) (not (<= im 6.2e-6))) (- (* (pow im 3.0) -0.16666666666666666) im) (* im (- (cos re)))))
double code(double re, double im) {
double tmp;
if ((im <= -0.00019) || !(im <= 6.2e-6)) {
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 <= (-0.00019d0)) .or. (.not. (im <= 6.2d-6))) 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 <= -0.00019) || !(im <= 6.2e-6)) {
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 <= -0.00019) or not (im <= 6.2e-6): 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 <= -0.00019) || !(im <= 6.2e-6)) 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 <= -0.00019) || ~((im <= 6.2e-6))) tmp = ((im ^ 3.0) * -0.16666666666666666) - im; else tmp = im * -cos(re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -0.00019], N[Not[LessEqual[im, 6.2e-6]], $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 -0.00019 \lor \neg \left(im \leq 6.2 \cdot 10^{-6}\right):\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\end{array}
\end{array}
if im < -1.9000000000000001e-4 or 6.1999999999999999e-6 < im Initial program 99.7%
sub0-neg99.7%
Simplified99.7%
Taylor expanded in im around 0 67.9%
mul-1-neg67.9%
unsub-neg67.9%
*-commutative67.9%
associate-*l*67.9%
distribute-lft-out--67.9%
Simplified67.9%
Taylor expanded in re around 0 49.1%
if -1.9000000000000001e-4 < im < 6.1999999999999999e-6Initial program 7.4%
sub0-neg7.4%
Simplified7.4%
Taylor expanded in im around 0 99.6%
mul-1-neg99.6%
*-commutative99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
Final simplification73.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (+ (* 0.5 (* re re)) -1.0)))
(if (<= im -1900000000000.0)
(* im t_0)
(if (<= im 1.2e+38) (* im (- (cos re))) (* t_0 (+ im 3.0))))))
double code(double re, double im) {
double t_0 = (0.5 * (re * re)) + -1.0;
double tmp;
if (im <= -1900000000000.0) {
tmp = im * t_0;
} else if (im <= 1.2e+38) {
tmp = im * -cos(re);
} else {
tmp = t_0 * (im + 3.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = (0.5d0 * (re * re)) + (-1.0d0)
if (im <= (-1900000000000.0d0)) then
tmp = im * t_0
else if (im <= 1.2d+38) then
tmp = im * -cos(re)
else
tmp = t_0 * (im + 3.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (0.5 * (re * re)) + -1.0;
double tmp;
if (im <= -1900000000000.0) {
tmp = im * t_0;
} else if (im <= 1.2e+38) {
tmp = im * -Math.cos(re);
} else {
tmp = t_0 * (im + 3.0);
}
return tmp;
}
def code(re, im): t_0 = (0.5 * (re * re)) + -1.0 tmp = 0 if im <= -1900000000000.0: tmp = im * t_0 elif im <= 1.2e+38: tmp = im * -math.cos(re) else: tmp = t_0 * (im + 3.0) return tmp
function code(re, im) t_0 = Float64(Float64(0.5 * Float64(re * re)) + -1.0) tmp = 0.0 if (im <= -1900000000000.0) tmp = Float64(im * t_0); elseif (im <= 1.2e+38) tmp = Float64(im * Float64(-cos(re))); else tmp = Float64(t_0 * Float64(im + 3.0)); end return tmp end
function tmp_2 = code(re, im) t_0 = (0.5 * (re * re)) + -1.0; tmp = 0.0; if (im <= -1900000000000.0) tmp = im * t_0; elseif (im <= 1.2e+38) tmp = im * -cos(re); else tmp = t_0 * (im + 3.0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[im, -1900000000000.0], N[(im * t$95$0), $MachinePrecision], If[LessEqual[im, 1.2e+38], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], N[(t$95$0 * N[(im + 3.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(re \cdot re\right) + -1\\
\mathbf{if}\;im \leq -1900000000000:\\
\;\;\;\;im \cdot t_0\\
\mathbf{elif}\;im \leq 1.2 \cdot 10^{+38}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(im + 3\right)\\
\end{array}
\end{array}
if im < -1.9e12Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 5.2%
mul-1-neg5.2%
*-commutative5.2%
distribute-lft-neg-in5.2%
Simplified5.2%
Taylor expanded in re around 0 22.2%
associate-*r*22.2%
distribute-rgt-out22.2%
+-commutative22.2%
*-commutative22.2%
unpow222.2%
Simplified22.2%
if -1.9e12 < im < 1.20000000000000009e38Initial program 16.5%
sub0-neg16.5%
Simplified16.5%
Taylor expanded in im around 0 91.0%
mul-1-neg91.0%
*-commutative91.0%
distribute-lft-neg-in91.0%
Simplified91.0%
if 1.20000000000000009e38 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 79.9%
mul-1-neg79.9%
unsub-neg79.9%
*-commutative79.9%
associate-*l*79.9%
distribute-lft-out--79.9%
Simplified79.9%
Applied egg-rr5.6%
Taylor expanded in re around 0 25.6%
unpow225.6%
associate-*r*25.6%
distribute-rgt-out25.6%
+-commutative25.6%
Simplified25.6%
Final simplification60.0%
(FPCore (re im) :precision binary64 (if (or (<= re -6.5e+210) (not (<= re 1.6e+112))) (* (* re re) -6.75) (- im)))
double code(double re, double im) {
double tmp;
if ((re <= -6.5e+210) || !(re <= 1.6e+112)) {
tmp = (re * re) * -6.75;
} else {
tmp = -im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((re <= (-6.5d+210)) .or. (.not. (re <= 1.6d+112))) then
tmp = (re * re) * (-6.75d0)
else
tmp = -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -6.5e+210) || !(re <= 1.6e+112)) {
tmp = (re * re) * -6.75;
} else {
tmp = -im;
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -6.5e+210) or not (re <= 1.6e+112): tmp = (re * re) * -6.75 else: tmp = -im return tmp
function code(re, im) tmp = 0.0 if ((re <= -6.5e+210) || !(re <= 1.6e+112)) tmp = Float64(Float64(re * re) * -6.75); else tmp = Float64(-im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -6.5e+210) || ~((re <= 1.6e+112))) tmp = (re * re) * -6.75; else tmp = -im; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -6.5e+210], N[Not[LessEqual[re, 1.6e+112]], $MachinePrecision]], N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision], (-im)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -6.5 \cdot 10^{+210} \lor \neg \left(re \leq 1.6 \cdot 10^{+112}\right):\\
\;\;\;\;\left(re \cdot re\right) \cdot -6.75\\
\mathbf{else}:\\
\;\;\;\;-im\\
\end{array}
\end{array}
if re < -6.4999999999999996e210 or 1.59999999999999993e112 < re Initial program 70.6%
sub0-neg70.6%
Simplified70.6%
Taylor expanded in re around 0 0.1%
*-commutative0.1%
associate-*r*0.1%
distribute-rgt-out34.1%
+-commutative34.1%
*-commutative34.1%
unpow234.1%
associate-*l*34.1%
Simplified34.1%
Applied egg-rr31.5%
Taylor expanded in re around inf 31.5%
unpow231.5%
Simplified31.5%
if -6.4999999999999996e210 < re < 1.59999999999999993e112Initial program 50.9%
sub0-neg50.9%
Simplified50.9%
Taylor expanded in im around 0 55.8%
mul-1-neg55.8%
*-commutative55.8%
distribute-lft-neg-in55.8%
Simplified55.8%
Taylor expanded in re around 0 36.7%
neg-mul-136.7%
Simplified36.7%
Final simplification35.6%
(FPCore (re im) :precision binary64 (if (<= im -6.6e+29) (* (* re re) 0.75) (if (<= im 2e+29) (- im) (* (* re re) -6.75))))
double code(double re, double im) {
double tmp;
if (im <= -6.6e+29) {
tmp = (re * re) * 0.75;
} else if (im <= 2e+29) {
tmp = -im;
} else {
tmp = (re * re) * -6.75;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-6.6d+29)) then
tmp = (re * re) * 0.75d0
else if (im <= 2d+29) then
tmp = -im
else
tmp = (re * re) * (-6.75d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -6.6e+29) {
tmp = (re * re) * 0.75;
} else if (im <= 2e+29) {
tmp = -im;
} else {
tmp = (re * re) * -6.75;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -6.6e+29: tmp = (re * re) * 0.75 elif im <= 2e+29: tmp = -im else: tmp = (re * re) * -6.75 return tmp
function code(re, im) tmp = 0.0 if (im <= -6.6e+29) tmp = Float64(Float64(re * re) * 0.75); elseif (im <= 2e+29) tmp = Float64(-im); else tmp = Float64(Float64(re * re) * -6.75); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -6.6e+29) tmp = (re * re) * 0.75; elseif (im <= 2e+29) tmp = -im; else tmp = (re * re) * -6.75; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -6.6e+29], N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision], If[LessEqual[im, 2e+29], (-im), N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -6.6 \cdot 10^{+29}:\\
\;\;\;\;\left(re \cdot re\right) \cdot 0.75\\
\mathbf{elif}\;im \leq 2 \cdot 10^{+29}:\\
\;\;\;\;-im\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot -6.75\\
\end{array}
\end{array}
if im < -6.59999999999999968e29Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
associate-*r*0.0%
distribute-rgt-out68.4%
+-commutative68.4%
*-commutative68.4%
unpow268.4%
associate-*l*68.4%
Simplified68.4%
Applied egg-rr18.4%
Taylor expanded in re around inf 18.9%
unpow218.9%
Simplified18.9%
if -6.59999999999999968e29 < im < 1.99999999999999983e29Initial program 17.7%
sub0-neg17.7%
Simplified17.7%
Taylor expanded in im around 0 89.8%
mul-1-neg89.8%
*-commutative89.8%
distribute-lft-neg-in89.8%
Simplified89.8%
Taylor expanded in re around 0 51.8%
neg-mul-151.8%
Simplified51.8%
if 1.99999999999999983e29 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 0.0%
*-commutative0.0%
associate-*r*0.0%
distribute-rgt-out67.8%
+-commutative67.8%
*-commutative67.8%
unpow267.8%
associate-*l*67.8%
Simplified67.8%
Applied egg-rr16.8%
Taylor expanded in re around inf 17.3%
unpow217.3%
Simplified17.3%
Final simplification36.5%
(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 55.0%
sub0-neg55.0%
Simplified55.0%
Taylor expanded in im around 0 51.5%
mul-1-neg51.5%
*-commutative51.5%
distribute-lft-neg-in51.5%
Simplified51.5%
Taylor expanded in re around 0 30.2%
neg-mul-130.2%
Simplified30.2%
Final simplification30.2%
(FPCore (re im) :precision binary64 -1.5)
double code(double re, double im) {
return -1.5;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -1.5d0
end function
public static double code(double re, double im) {
return -1.5;
}
def code(re, im): return -1.5
function code(re, im) return -1.5 end
function tmp = code(re, im) tmp = -1.5; end
code[re_, im_] := -1.5
\begin{array}{l}
\\
-1.5
\end{array}
Initial program 55.0%
sub0-neg55.0%
Simplified55.0%
Taylor expanded in re around 0 3.0%
*-commutative3.0%
associate-*r*3.0%
distribute-rgt-out38.6%
+-commutative38.6%
*-commutative38.6%
unpow238.6%
associate-*l*38.6%
Simplified38.6%
Applied egg-rr8.8%
Taylor expanded in re around 0 2.9%
Final simplification2.9%
(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 2023174
(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))))