
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-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(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-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(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-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(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
Initial program 100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
(t_1 (* 0.5 (cos re))))
(if (<= im 0.035)
(*
t_1
(+
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))
(+ 1.0 t_0)))
(if (<= im 2.5e+101)
(* 0.5 (+ (exp (- im)) (exp im)))
(* t_1 (+ 2.0 t_0))))))
double code(double re, double im) {
double t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double t_1 = 0.5 * cos(re);
double tmp;
if (im <= 0.035) {
tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0));
} else if (im <= 2.5e+101) {
tmp = 0.5 * (exp(-im) + exp(im));
} else {
tmp = t_1 * (2.0 + 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) :: t_1
real(8) :: tmp
t_0 = im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))
t_1 = 0.5d0 * cos(re)
if (im <= 0.035d0) then
tmp = t_1 * ((1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))) + (1.0d0 + t_0))
else if (im <= 2.5d+101) then
tmp = 0.5d0 * (exp(-im) + exp(im))
else
tmp = t_1 * (2.0d0 + t_0)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double t_1 = 0.5 * Math.cos(re);
double tmp;
if (im <= 0.035) {
tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0));
} else if (im <= 2.5e+101) {
tmp = 0.5 * (Math.exp(-im) + Math.exp(im));
} else {
tmp = t_1 * (2.0 + t_0);
}
return tmp;
}
def code(re, im): t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))) t_1 = 0.5 * math.cos(re) tmp = 0 if im <= 0.035: tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0)) elif im <= 2.5e+101: tmp = 0.5 * (math.exp(-im) + math.exp(im)) else: tmp = t_1 * (2.0 + t_0) return tmp
function code(re, im) t_0 = Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) t_1 = Float64(0.5 * cos(re)) tmp = 0.0 if (im <= 0.035) tmp = Float64(t_1 * Float64(Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))) + Float64(1.0 + t_0))); elseif (im <= 2.5e+101) tmp = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(t_1 * Float64(2.0 + t_0)); end return tmp end
function tmp_2 = code(re, im) t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))); t_1 = 0.5 * cos(re); tmp = 0.0; if (im <= 0.035) tmp = t_1 * ((1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))) + (1.0 + t_0)); elseif (im <= 2.5e+101) tmp = 0.5 * (exp(-im) + exp(im)); else tmp = t_1 * (2.0 + t_0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.035], N[(t$95$1 * N[(N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.5e+101], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(2.0 + t$95$0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\\
t_1 := 0.5 \cdot \cos re\\
\mathbf{if}\;im \leq 0.035:\\
\;\;\;\;t\_1 \cdot \left(\left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right) + \left(1 + t\_0\right)\right)\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+101}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(2 + t\_0\right)\\
\end{array}
\end{array}
if im < 0.035000000000000003Initial program 100.0%
Taylor expanded in im around 0 87.5%
Taylor expanded in im around 0 68.9%
*-commutative68.9%
Simplified68.9%
if 0.035000000000000003 < im < 2.49999999999999994e101Initial program 99.9%
Taylor expanded in re around 0 66.6%
if 2.49999999999999994e101 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
Final simplification73.6%
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp im) (- 1.0 im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(im) + (1.0 - im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(im) + (1.0d0 - im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(im) + (1.0 - im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(im) + (1.0 - im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(im) + Float64(1.0 - im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(im) + (1.0 - im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + N[(1.0 - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{im} + \left(1 - im\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 76.5%
neg-mul-176.5%
unsub-neg76.5%
Simplified76.5%
Final simplification76.5%
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp im) 1.0)))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(im) + 1.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(im) + 1.0d0)
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(im) + 1.0);
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(im) + 1.0)
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(im) + 1.0)) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(im) + 1.0); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{im} + 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 76.5%
neg-mul-176.5%
unsub-neg76.5%
Simplified76.5%
Taylor expanded in im around 0 75.7%
Final simplification75.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
(t_1 (* 0.5 (cos re)))
(t_2
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(if (<= im 1.85)
(* t_1 (+ t_2 (+ 1.0 t_0)))
(if (<= im 2.5e+101) (* 0.5 (+ (exp im) t_2)) (* t_1 (+ 2.0 t_0))))))
double code(double re, double im) {
double t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double t_1 = 0.5 * cos(re);
double t_2 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0));
double tmp;
if (im <= 1.85) {
tmp = t_1 * (t_2 + (1.0 + t_0));
} else if (im <= 2.5e+101) {
tmp = 0.5 * (exp(im) + t_2);
} else {
tmp = t_1 * (2.0 + 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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))
t_1 = 0.5d0 * cos(re)
t_2 = 1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))
if (im <= 1.85d0) then
tmp = t_1 * (t_2 + (1.0d0 + t_0))
else if (im <= 2.5d+101) then
tmp = 0.5d0 * (exp(im) + t_2)
else
tmp = t_1 * (2.0d0 + t_0)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double t_1 = 0.5 * Math.cos(re);
double t_2 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0));
double tmp;
if (im <= 1.85) {
tmp = t_1 * (t_2 + (1.0 + t_0));
} else if (im <= 2.5e+101) {
tmp = 0.5 * (Math.exp(im) + t_2);
} else {
tmp = t_1 * (2.0 + t_0);
}
return tmp;
}
def code(re, im): t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))) t_1 = 0.5 * math.cos(re) t_2 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)) tmp = 0 if im <= 1.85: tmp = t_1 * (t_2 + (1.0 + t_0)) elif im <= 2.5e+101: tmp = 0.5 * (math.exp(im) + t_2) else: tmp = t_1 * (2.0 + t_0) return tmp
function code(re, im) t_0 = Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) t_1 = Float64(0.5 * cos(re)) t_2 = Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))) tmp = 0.0 if (im <= 1.85) tmp = Float64(t_1 * Float64(t_2 + Float64(1.0 + t_0))); elseif (im <= 2.5e+101) tmp = Float64(0.5 * Float64(exp(im) + t_2)); else tmp = Float64(t_1 * Float64(2.0 + t_0)); end return tmp end
function tmp_2 = code(re, im) t_0 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))); t_1 = 0.5 * cos(re); t_2 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)); tmp = 0.0; if (im <= 1.85) tmp = t_1 * (t_2 + (1.0 + t_0)); elseif (im <= 2.5e+101) tmp = 0.5 * (exp(im) + t_2); else tmp = t_1 * (2.0 + t_0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 1.85], N[(t$95$1 * N[(t$95$2 + N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.5e+101], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(2.0 + t$95$0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\\
t_1 := 0.5 \cdot \cos re\\
t_2 := 1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\\
\mathbf{if}\;im \leq 1.85:\\
\;\;\;\;t\_1 \cdot \left(t\_2 + \left(1 + t\_0\right)\right)\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+101}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + t\_2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(2 + t\_0\right)\\
\end{array}
\end{array}
if im < 1.8500000000000001Initial program 100.0%
Taylor expanded in im around 0 87.5%
Taylor expanded in im around 0 68.9%
*-commutative68.9%
Simplified68.9%
if 1.8500000000000001 < im < 2.49999999999999994e101Initial program 99.9%
Taylor expanded in re around 0 66.6%
Taylor expanded in im around 0 62.4%
if 2.49999999999999994e101 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
Final simplification73.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (cos re)))
(t_1
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(if (<= im 1.85)
(* t_0 (+ t_1 (+ 1.0 (* im (+ 1.0 (* 0.5 im))))))
(if (<= im 2.5e+101)
(* 0.5 (+ (exp im) t_1))
(*
t_0
(+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))))))
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double t_1 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0));
double tmp;
if (im <= 1.85) {
tmp = t_0 * (t_1 + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 2.5e+101) {
tmp = 0.5 * (exp(im) + t_1);
} else {
tmp = t_0 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
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 * cos(re)
t_1 = 1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))
if (im <= 1.85d0) then
tmp = t_0 * (t_1 + (1.0d0 + (im * (1.0d0 + (0.5d0 * im)))))
else if (im <= 2.5d+101) then
tmp = 0.5d0 * (exp(im) + t_1)
else
tmp = t_0 * (2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.cos(re);
double t_1 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0));
double tmp;
if (im <= 1.85) {
tmp = t_0 * (t_1 + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 2.5e+101) {
tmp = 0.5 * (Math.exp(im) + t_1);
} else {
tmp = t_0 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) t_1 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)) tmp = 0 if im <= 1.85: tmp = t_0 * (t_1 + (1.0 + (im * (1.0 + (0.5 * im))))) elif im <= 2.5e+101: tmp = 0.5 * (math.exp(im) + t_1) else: tmp = t_0 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) t_1 = Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))) tmp = 0.0 if (im <= 1.85) tmp = Float64(t_0 * Float64(t_1 + Float64(1.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))))); elseif (im <= 2.5e+101) tmp = Float64(0.5 * Float64(exp(im) + t_1)); else tmp = Float64(t_0 * Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * cos(re); t_1 = 1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)); tmp = 0.0; if (im <= 1.85) tmp = t_0 * (t_1 + (1.0 + (im * (1.0 + (0.5 * im))))); elseif (im <= 2.5e+101) tmp = 0.5 * (exp(im) + t_1); else tmp = t_0 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 1.85], N[(t$95$0 * N[(t$95$1 + N[(1.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.5e+101], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
t_1 := 1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\\
\mathbf{if}\;im \leq 1.85:\\
\;\;\;\;t\_0 \cdot \left(t\_1 + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+101}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 1.8500000000000001Initial program 100.0%
Taylor expanded in im around 0 87.5%
Taylor expanded in im around 0 87.5%
if 1.8500000000000001 < im < 2.49999999999999994e101Initial program 99.9%
Taylor expanded in re around 0 66.6%
Taylor expanded in im around 0 62.4%
if 2.49999999999999994e101 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
Final simplification87.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (cos re)))
(t_1 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))
(if (<= im 1.85)
(* t_0 (+ (- 1.0 im) (+ 1.0 t_1)))
(if (<= im 2.5e+101)
(*
0.5
(+
(exp im)
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(* t_0 (+ 2.0 t_1))))))
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double tmp;
if (im <= 1.85) {
tmp = t_0 * ((1.0 - im) + (1.0 + t_1));
} else if (im <= 2.5e+101) {
tmp = 0.5 * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = t_0 * (2.0 + 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 * cos(re)
t_1 = im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))
if (im <= 1.85d0) then
tmp = t_0 * ((1.0d0 - im) + (1.0d0 + t_1))
else if (im <= 2.5d+101) then
tmp = 0.5d0 * (exp(im) + (1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))))
else
tmp = t_0 * (2.0d0 + t_1)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.cos(re);
double t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double tmp;
if (im <= 1.85) {
tmp = t_0 * ((1.0 - im) + (1.0 + t_1));
} else if (im <= 2.5e+101) {
tmp = 0.5 * (Math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = t_0 * (2.0 + t_1);
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))) tmp = 0 if im <= 1.85: tmp = t_0 * ((1.0 - im) + (1.0 + t_1)) elif im <= 2.5e+101: tmp = 0.5 * (math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))) else: tmp = t_0 * (2.0 + t_1) return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) t_1 = Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) tmp = 0.0 if (im <= 1.85) tmp = Float64(t_0 * Float64(Float64(1.0 - im) + Float64(1.0 + t_1))); elseif (im <= 2.5e+101) tmp = Float64(0.5 * Float64(exp(im) + Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))))); else tmp = Float64(t_0 * Float64(2.0 + t_1)); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * cos(re); t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))); tmp = 0.0; if (im <= 1.85) tmp = t_0 * ((1.0 - im) + (1.0 + t_1)); elseif (im <= 2.5e+101) tmp = 0.5 * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))); else tmp = t_0 * (2.0 + t_1); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 1.85], N[(t$95$0 * N[(N[(1.0 - im), $MachinePrecision] + N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.5e+101], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(2.0 + t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
t_1 := im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\\
\mathbf{if}\;im \leq 1.85:\\
\;\;\;\;t\_0 \cdot \left(\left(1 - im\right) + \left(1 + t\_1\right)\right)\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+101}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(2 + t\_1\right)\\
\end{array}
\end{array}
if im < 1.8500000000000001Initial program 100.0%
Taylor expanded in im around 0 70.1%
neg-mul-170.1%
unsub-neg70.1%
Simplified70.1%
Taylor expanded in im around 0 68.5%
*-commutative68.9%
Simplified68.5%
if 1.8500000000000001 < im < 2.49999999999999994e101Initial program 99.9%
Taylor expanded in re around 0 66.6%
Taylor expanded in im around 0 62.4%
if 2.49999999999999994e101 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
Final simplification73.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (cos re))))
(if (<= im 1.7)
(* t_0 (+ (- 1.0 im) (+ 1.0 (* im (+ 1.0 (* 0.5 im))))))
(if (<= im 2.5e+101)
(*
0.5
(+
(exp im)
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(*
t_0
(+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))))))
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double tmp;
if (im <= 1.7) {
tmp = t_0 * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 2.5e+101) {
tmp = 0.5 * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = t_0 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
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 * cos(re)
if (im <= 1.7d0) then
tmp = t_0 * ((1.0d0 - im) + (1.0d0 + (im * (1.0d0 + (0.5d0 * im)))))
else if (im <= 2.5d+101) then
tmp = 0.5d0 * (exp(im) + (1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))))
else
tmp = t_0 * (2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.cos(re);
double tmp;
if (im <= 1.7) {
tmp = t_0 * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 2.5e+101) {
tmp = 0.5 * (Math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = t_0 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) tmp = 0 if im <= 1.7: tmp = t_0 * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im))))) elif im <= 2.5e+101: tmp = 0.5 * (math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))) else: tmp = t_0 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) tmp = 0.0 if (im <= 1.7) tmp = Float64(t_0 * Float64(Float64(1.0 - im) + Float64(1.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))))); elseif (im <= 2.5e+101) tmp = Float64(0.5 * Float64(exp(im) + Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))))); else tmp = Float64(t_0 * Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * cos(re); tmp = 0.0; if (im <= 1.7) tmp = t_0 * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im))))); elseif (im <= 2.5e+101) tmp = 0.5 * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))); else tmp = t_0 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 1.7], N[(t$95$0 * N[(N[(1.0 - im), $MachinePrecision] + N[(1.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.5e+101], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
\mathbf{if}\;im \leq 1.7:\\
\;\;\;\;t\_0 \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+101}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 1.69999999999999996Initial program 100.0%
Taylor expanded in im around 0 70.1%
neg-mul-170.1%
unsub-neg70.1%
Simplified70.1%
Taylor expanded in im around 0 83.5%
if 1.69999999999999996 < im < 2.49999999999999994e101Initial program 99.9%
Taylor expanded in re around 0 66.6%
Taylor expanded in im around 0 62.4%
if 2.49999999999999994e101 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
Final simplification84.6%
(FPCore (re im)
:precision binary64
(if (<= im 0.0042)
(cos re)
(if (<= im 2.5e+101)
(*
0.5
(+
(exp im)
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(*
(* 0.5 (cos re))
(+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))))
double code(double re, double im) {
double tmp;
if (im <= 0.0042) {
tmp = cos(re);
} else if (im <= 2.5e+101) {
tmp = 0.5 * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = (0.5 * cos(re)) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 0.0042d0) then
tmp = cos(re)
else if (im <= 2.5d+101) then
tmp = 0.5d0 * (exp(im) + (1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))))
else
tmp = (0.5d0 * cos(re)) * (2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.0042) {
tmp = Math.cos(re);
} else if (im <= 2.5e+101) {
tmp = 0.5 * (Math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} else {
tmp = (0.5 * Math.cos(re)) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.0042: tmp = math.cos(re) elif im <= 2.5e+101: tmp = 0.5 * (math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))) else: tmp = (0.5 * math.cos(re)) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.0042) tmp = cos(re); elseif (im <= 2.5e+101) tmp = Float64(0.5 * Float64(exp(im) + Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))))); else tmp = Float64(Float64(0.5 * cos(re)) * Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.0042) tmp = cos(re); elseif (im <= 2.5e+101) tmp = 0.5 * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))); else tmp = (0.5 * cos(re)) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.0042], N[Cos[re], $MachinePrecision], If[LessEqual[im, 2.5e+101], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.0042:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+101}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 0.00419999999999999974Initial program 100.0%
Taylor expanded in im around 0 69.4%
if 0.00419999999999999974 < im < 2.49999999999999994e101Initial program 99.9%
Taylor expanded in re around 0 66.6%
Taylor expanded in im around 0 62.4%
if 2.49999999999999994e101 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
Final simplification73.7%
(FPCore (re im)
:precision binary64
(if (<= im 0.042)
(cos re)
(if (<= im 1.86e+154)
(* 0.5 (+ (exp im) (+ 1.0 (* im (+ (* 0.5 im) -1.0)))))
(* (* 0.5 (cos re)) (+ 2.0 (* im (+ 1.0 (* 0.5 im))))))))
double code(double re, double im) {
double tmp;
if (im <= 0.042) {
tmp = cos(re);
} else if (im <= 1.86e+154) {
tmp = 0.5 * (exp(im) + (1.0 + (im * ((0.5 * im) + -1.0))));
} else {
tmp = (0.5 * cos(re)) * (2.0 + (im * (1.0 + (0.5 * im))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 0.042d0) then
tmp = cos(re)
else if (im <= 1.86d+154) then
tmp = 0.5d0 * (exp(im) + (1.0d0 + (im * ((0.5d0 * im) + (-1.0d0)))))
else
tmp = (0.5d0 * cos(re)) * (2.0d0 + (im * (1.0d0 + (0.5d0 * im))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.042) {
tmp = Math.cos(re);
} else if (im <= 1.86e+154) {
tmp = 0.5 * (Math.exp(im) + (1.0 + (im * ((0.5 * im) + -1.0))));
} else {
tmp = (0.5 * Math.cos(re)) * (2.0 + (im * (1.0 + (0.5 * im))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.042: tmp = math.cos(re) elif im <= 1.86e+154: tmp = 0.5 * (math.exp(im) + (1.0 + (im * ((0.5 * im) + -1.0)))) else: tmp = (0.5 * math.cos(re)) * (2.0 + (im * (1.0 + (0.5 * im)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.042) tmp = cos(re); elseif (im <= 1.86e+154) tmp = Float64(0.5 * Float64(exp(im) + Float64(1.0 + Float64(im * Float64(Float64(0.5 * im) + -1.0))))); else tmp = Float64(Float64(0.5 * cos(re)) * Float64(2.0 + Float64(im * Float64(1.0 + Float64(0.5 * im))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.042) tmp = cos(re); elseif (im <= 1.86e+154) tmp = 0.5 * (exp(im) + (1.0 + (im * ((0.5 * im) + -1.0)))); else tmp = (0.5 * cos(re)) * (2.0 + (im * (1.0 + (0.5 * im)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.042], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.86e+154], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + N[(1.0 + N[(im * N[(N[(0.5 * im), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(2.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.042:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.86 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + \left(1 + im \cdot \left(0.5 \cdot im + -1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 0.0420000000000000026Initial program 100.0%
Taylor expanded in im around 0 69.4%
if 0.0420000000000000026 < im < 1.86000000000000014e154Initial program 99.9%
Taylor expanded in re around 0 62.0%
Taylor expanded in im around 0 59.4%
if 1.86000000000000014e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification71.7%
(FPCore (re im) :precision binary64 (if (<= im 0.92) (cos re) (* 0.5 (+ (exp im) (+ 1.0 (* im (+ (* 0.5 im) -1.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 0.92) {
tmp = cos(re);
} else {
tmp = 0.5 * (exp(im) + (1.0 + (im * ((0.5 * im) + -1.0))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 0.92d0) then
tmp = cos(re)
else
tmp = 0.5d0 * (exp(im) + (1.0d0 + (im * ((0.5d0 * im) + (-1.0d0)))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.92) {
tmp = Math.cos(re);
} else {
tmp = 0.5 * (Math.exp(im) + (1.0 + (im * ((0.5 * im) + -1.0))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.92: tmp = math.cos(re) else: tmp = 0.5 * (math.exp(im) + (1.0 + (im * ((0.5 * im) + -1.0)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.92) tmp = cos(re); else tmp = Float64(0.5 * Float64(exp(im) + Float64(1.0 + Float64(im * Float64(Float64(0.5 * im) + -1.0))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.92) tmp = cos(re); else tmp = 0.5 * (exp(im) + (1.0 + (im * ((0.5 * im) + -1.0)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.92], N[Cos[re], $MachinePrecision], N[(0.5 * N[(N[Exp[im], $MachinePrecision] + N[(1.0 + N[(im * N[(N[(0.5 * im), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.92:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{im} + \left(1 + im \cdot \left(0.5 \cdot im + -1\right)\right)\right)\\
\end{array}
\end{array}
if im < 0.92000000000000004Initial program 100.0%
Taylor expanded in im around 0 69.4%
if 0.92000000000000004 < im Initial program 100.0%
Taylor expanded in re around 0 67.2%
Taylor expanded in im around 0 65.9%
Final simplification68.6%
(FPCore (re im) :precision binary64 (if (<= im 1.85) (cos re) (+ 0.5 (* 0.5 (exp im)))))
double code(double re, double im) {
double tmp;
if (im <= 1.85) {
tmp = cos(re);
} else {
tmp = 0.5 + (0.5 * 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 <= 1.85d0) then
tmp = cos(re)
else
tmp = 0.5d0 + (0.5d0 * exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.85) {
tmp = Math.cos(re);
} else {
tmp = 0.5 + (0.5 * Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.85: tmp = math.cos(re) else: tmp = 0.5 + (0.5 * math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.85) tmp = cos(re); else tmp = Float64(0.5 + Float64(0.5 * exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.85) tmp = cos(re); else tmp = 0.5 + (0.5 * exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.85], N[Cos[re], $MachinePrecision], N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.85:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;0.5 + 0.5 \cdot e^{im}\\
\end{array}
\end{array}
if im < 1.8500000000000001Initial program 100.0%
Taylor expanded in im around 0 69.4%
if 1.8500000000000001 < im Initial program 100.0%
Taylor expanded in im around 0 98.7%
neg-mul-198.7%
unsub-neg98.7%
Simplified98.7%
Taylor expanded in im around 0 98.7%
Taylor expanded in re around 0 65.9%
distribute-lft-in65.9%
metadata-eval65.9%
Simplified65.9%
(FPCore (re im)
:precision binary64
(if (<= im 1.85)
(cos re)
(if (<= im 1.75e+106)
(- 2.0 (* re re))
(*
0.5
(+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))))
double code(double re, double im) {
double tmp;
if (im <= 1.85) {
tmp = cos(re);
} else if (im <= 1.75e+106) {
tmp = 2.0 - (re * re);
} else {
tmp = 0.5 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.85d0) then
tmp = cos(re)
else if (im <= 1.75d+106) then
tmp = 2.0d0 - (re * re)
else
tmp = 0.5d0 * (2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.85) {
tmp = Math.cos(re);
} else if (im <= 1.75e+106) {
tmp = 2.0 - (re * re);
} else {
tmp = 0.5 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.85: tmp = math.cos(re) elif im <= 1.75e+106: tmp = 2.0 - (re * re) else: tmp = 0.5 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.85) tmp = cos(re); elseif (im <= 1.75e+106) tmp = Float64(2.0 - Float64(re * re)); else tmp = Float64(0.5 * Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.85) tmp = cos(re); elseif (im <= 1.75e+106) tmp = 2.0 - (re * re); else tmp = 0.5 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.85], N[Cos[re], $MachinePrecision], If[LessEqual[im, 1.75e+106], N[(2.0 - N[(re * re), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.85:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 1.75 \cdot 10^{+106}:\\
\;\;\;\;2 - re \cdot re\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 1.8500000000000001Initial program 100.0%
Taylor expanded in im around 0 69.4%
if 1.8500000000000001 < im < 1.7499999999999999e106Initial program 99.9%
Applied egg-rr4.1%
count-24.1%
Simplified4.1%
Taylor expanded in re around 0 28.4%
mul-1-neg28.4%
unsub-neg28.4%
Simplified28.4%
unpow228.4%
Applied egg-rr28.4%
if 1.7499999999999999e106 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 71.1%
Final simplification66.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))
(if (<= re 1.26e+158)
(* 0.5 (- t_0 im))
(if (or (<= re 2.5e+226) (not (<= re 6.6e+268)))
(- 2.0 (* re re))
(* 0.5 t_0)))))
double code(double re, double im) {
double t_0 = 2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))));
double tmp;
if (re <= 1.26e+158) {
tmp = 0.5 * (t_0 - im);
} else if ((re <= 2.5e+226) || !(re <= 6.6e+268)) {
tmp = 2.0 - (re * re);
} else {
tmp = 0.5 * 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 = 2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))
if (re <= 1.26d+158) then
tmp = 0.5d0 * (t_0 - im)
else if ((re <= 2.5d+226) .or. (.not. (re <= 6.6d+268))) then
tmp = 2.0d0 - (re * re)
else
tmp = 0.5d0 * t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))));
double tmp;
if (re <= 1.26e+158) {
tmp = 0.5 * (t_0 - im);
} else if ((re <= 2.5e+226) || !(re <= 6.6e+268)) {
tmp = 2.0 - (re * re);
} else {
tmp = 0.5 * t_0;
}
return tmp;
}
def code(re, im): t_0 = 2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) tmp = 0 if re <= 1.26e+158: tmp = 0.5 * (t_0 - im) elif (re <= 2.5e+226) or not (re <= 6.6e+268): tmp = 2.0 - (re * re) else: tmp = 0.5 * t_0 return tmp
function code(re, im) t_0 = Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) tmp = 0.0 if (re <= 1.26e+158) tmp = Float64(0.5 * Float64(t_0 - im)); elseif ((re <= 2.5e+226) || !(re <= 6.6e+268)) tmp = Float64(2.0 - Float64(re * re)); else tmp = Float64(0.5 * t_0); end return tmp end
function tmp_2 = code(re, im) t_0 = 2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))); tmp = 0.0; if (re <= 1.26e+158) tmp = 0.5 * (t_0 - im); elseif ((re <= 2.5e+226) || ~((re <= 6.6e+268))) tmp = 2.0 - (re * re); else tmp = 0.5 * t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, 1.26e+158], N[(0.5 * N[(t$95$0 - im), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[re, 2.5e+226], N[Not[LessEqual[re, 6.6e+268]], $MachinePrecision]], N[(2.0 - N[(re * re), $MachinePrecision]), $MachinePrecision], N[(0.5 * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\\
\mathbf{if}\;re \leq 1.26 \cdot 10^{+158}:\\
\;\;\;\;0.5 \cdot \left(t\_0 - im\right)\\
\mathbf{elif}\;re \leq 2.5 \cdot 10^{+226} \lor \neg \left(re \leq 6.6 \cdot 10^{+268}\right):\\
\;\;\;\;2 - re \cdot re\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot t\_0\\
\end{array}
\end{array}
if re < 1.2599999999999999e158Initial program 100.0%
Taylor expanded in im around 0 77.8%
neg-mul-177.8%
unsub-neg77.8%
Simplified77.8%
Taylor expanded in re around 0 53.7%
Taylor expanded in im around 0 50.3%
if 1.2599999999999999e158 < re < 2.5000000000000002e226 or 6.6000000000000002e268 < re Initial program 100.0%
Applied egg-rr10.7%
count-210.7%
Simplified10.7%
Taylor expanded in re around 0 43.0%
mul-1-neg43.0%
unsub-neg43.0%
Simplified43.0%
unpow243.0%
Applied egg-rr43.0%
if 2.5000000000000002e226 < re < 6.6000000000000002e268Initial program 100.0%
Taylor expanded in im around 0 71.6%
neg-mul-171.6%
unsub-neg71.6%
Simplified71.6%
Taylor expanded in im around 0 70.9%
Taylor expanded in im around 0 70.0%
Taylor expanded in re around 0 17.8%
Final simplification48.2%
(FPCore (re im) :precision binary64 (if (or (<= re 1.26e+158) (and (not (<= re 2.5e+226)) (<= re 6.6e+268))) (* 0.5 (+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))) (- 2.0 (* re re))))
double code(double re, double im) {
double tmp;
if ((re <= 1.26e+158) || (!(re <= 2.5e+226) && (re <= 6.6e+268))) {
tmp = 0.5 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
} else {
tmp = 2.0 - (re * re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((re <= 1.26d+158) .or. (.not. (re <= 2.5d+226)) .and. (re <= 6.6d+268)) then
tmp = 0.5d0 * (2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
else
tmp = 2.0d0 - (re * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= 1.26e+158) || (!(re <= 2.5e+226) && (re <= 6.6e+268))) {
tmp = 0.5 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
} else {
tmp = 2.0 - (re * re);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= 1.26e+158) or (not (re <= 2.5e+226) and (re <= 6.6e+268)): tmp = 0.5 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) else: tmp = 2.0 - (re * re) return tmp
function code(re, im) tmp = 0.0 if ((re <= 1.26e+158) || (!(re <= 2.5e+226) && (re <= 6.6e+268))) tmp = Float64(0.5 * Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); else tmp = Float64(2.0 - Float64(re * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= 1.26e+158) || (~((re <= 2.5e+226)) && (re <= 6.6e+268))) tmp = 0.5 * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); else tmp = 2.0 - (re * re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, 1.26e+158], And[N[Not[LessEqual[re, 2.5e+226]], $MachinePrecision], LessEqual[re, 6.6e+268]]], N[(0.5 * N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 - N[(re * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.26 \cdot 10^{+158} \lor \neg \left(re \leq 2.5 \cdot 10^{+226}\right) \land re \leq 6.6 \cdot 10^{+268}:\\
\;\;\;\;0.5 \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2 - re \cdot re\\
\end{array}
\end{array}
if re < 1.2599999999999999e158 or 2.5000000000000002e226 < re < 6.6000000000000002e268Initial program 100.0%
Taylor expanded in im around 0 77.5%
neg-mul-177.5%
unsub-neg77.5%
Simplified77.5%
Taylor expanded in im around 0 76.7%
Taylor expanded in im around 0 69.7%
Taylor expanded in re around 0 48.6%
if 1.2599999999999999e158 < re < 2.5000000000000002e226 or 6.6000000000000002e268 < re Initial program 100.0%
Applied egg-rr10.7%
count-210.7%
Simplified10.7%
Taylor expanded in re around 0 43.0%
mul-1-neg43.0%
unsub-neg43.0%
Simplified43.0%
unpow243.0%
Applied egg-rr43.0%
Final simplification47.9%
(FPCore (re im) :precision binary64 (if (<= re 1.26e+158) (* 0.5 (- (+ 2.0 (* im (+ 1.0 (* 0.5 im)))) im)) (- 2.0 (* re re))))
double code(double re, double im) {
double tmp;
if (re <= 1.26e+158) {
tmp = 0.5 * ((2.0 + (im * (1.0 + (0.5 * im)))) - im);
} else {
tmp = 2.0 - (re * re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 1.26d+158) then
tmp = 0.5d0 * ((2.0d0 + (im * (1.0d0 + (0.5d0 * im)))) - im)
else
tmp = 2.0d0 - (re * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 1.26e+158) {
tmp = 0.5 * ((2.0 + (im * (1.0 + (0.5 * im)))) - im);
} else {
tmp = 2.0 - (re * re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.26e+158: tmp = 0.5 * ((2.0 + (im * (1.0 + (0.5 * im)))) - im) else: tmp = 2.0 - (re * re) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.26e+158) tmp = Float64(0.5 * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))) - im)); else tmp = Float64(2.0 - Float64(re * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.26e+158) tmp = 0.5 * ((2.0 + (im * (1.0 + (0.5 * im)))) - im); else tmp = 2.0 - (re * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.26e+158], N[(0.5 * N[(N[(2.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(2.0 - N[(re * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.26 \cdot 10^{+158}:\\
\;\;\;\;0.5 \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\\
\mathbf{else}:\\
\;\;\;\;2 - re \cdot re\\
\end{array}
\end{array}
if re < 1.2599999999999999e158Initial program 100.0%
Taylor expanded in im around 0 77.8%
neg-mul-177.8%
unsub-neg77.8%
Simplified77.8%
Taylor expanded in re around 0 53.7%
Taylor expanded in im around 0 54.2%
*-commutative75.7%
Simplified54.2%
if 1.2599999999999999e158 < re Initial program 100.0%
Applied egg-rr11.1%
count-211.1%
Simplified11.1%
Taylor expanded in re around 0 32.8%
mul-1-neg32.8%
unsub-neg32.8%
Simplified32.8%
unpow232.8%
Applied egg-rr32.8%
Final simplification50.8%
(FPCore (re im) :precision binary64 (if (<= im 0.0009) 1.0 (- 2.0 (* re re))))
double code(double re, double im) {
double tmp;
if (im <= 0.0009) {
tmp = 1.0;
} else {
tmp = 2.0 - (re * 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.0009d0) then
tmp = 1.0d0
else
tmp = 2.0d0 - (re * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.0009) {
tmp = 1.0;
} else {
tmp = 2.0 - (re * re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.0009: tmp = 1.0 else: tmp = 2.0 - (re * re) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.0009) tmp = 1.0; else tmp = Float64(2.0 - Float64(re * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.0009) tmp = 1.0; else tmp = 2.0 - (re * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.0009], 1.0, N[(2.0 - N[(re * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.0009:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;2 - re \cdot re\\
\end{array}
\end{array}
if im < 8.9999999999999998e-4Initial program 100.0%
Taylor expanded in im around 0 70.2%
neg-mul-170.2%
unsub-neg70.2%
Simplified70.2%
Taylor expanded in re around 0 40.9%
Taylor expanded in im around 0 40.5%
if 8.9999999999999998e-4 < im Initial program 99.9%
Applied egg-rr3.7%
count-23.7%
Simplified3.7%
Taylor expanded in re around 0 17.9%
mul-1-neg17.9%
unsub-neg17.9%
Simplified17.9%
unpow217.9%
Applied egg-rr17.9%
(FPCore (re im) :precision binary64 1.0)
double code(double re, double im) {
return 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0
end function
public static double code(double re, double im) {
return 1.0;
}
def code(re, im): return 1.0
function code(re, im) return 1.0 end
function tmp = code(re, im) tmp = 1.0; end
code[re_, im_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 76.5%
neg-mul-176.5%
unsub-neg76.5%
Simplified76.5%
Taylor expanded in re around 0 46.4%
Taylor expanded in im around 0 31.7%
(FPCore (re im) :precision binary64 -1.0)
double code(double re, double im) {
return -1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -1.0d0
end function
public static double code(double re, double im) {
return -1.0;
}
def code(re, im): return -1.0
function code(re, im) return -1.0 end
function tmp = code(re, im) tmp = -1.0; end
code[re_, im_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 64.1%
Applied egg-rr4.0%
metadata-eval4.0%
Applied egg-rr4.0%
herbie shell --seed 2024110
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))