
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (* x x)))
double code(double x) {
return (1.0 - cos(x)) / (x * x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 - cos(x)) / (x * x)
end function
public static double code(double x) {
return (1.0 - Math.cos(x)) / (x * x);
}
def code(x): return (1.0 - math.cos(x)) / (x * x)
function code(x) return Float64(Float64(1.0 - cos(x)) / Float64(x * x)) end
function tmp = code(x) tmp = (1.0 - cos(x)) / (x * x); end
code[x_] := N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - \cos x}{x \cdot x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (* x x)))
double code(double x) {
return (1.0 - cos(x)) / (x * x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 - cos(x)) / (x * x)
end function
public static double code(double x) {
return (1.0 - Math.cos(x)) / (x * x);
}
def code(x): return (1.0 - math.cos(x)) / (x * x)
function code(x) return Float64(Float64(1.0 - cos(x)) / Float64(x * x)) end
function tmp = code(x) tmp = (1.0 - cos(x)) / (x * x); end
code[x_] := N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - \cos x}{x \cdot x}
\end{array}
(FPCore (x) :precision binary64 (* (/ (tan (/ x 2.0)) x) (/ (sin x) x)))
double code(double x) {
return (tan((x / 2.0)) / x) * (sin(x) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (tan((x / 2.0d0)) / x) * (sin(x) / x)
end function
public static double code(double x) {
return (Math.tan((x / 2.0)) / x) * (Math.sin(x) / x);
}
def code(x): return (math.tan((x / 2.0)) / x) * (math.sin(x) / x)
function code(x) return Float64(Float64(tan(Float64(x / 2.0)) / x) * Float64(sin(x) / x)) end
function tmp = code(x) tmp = (tan((x / 2.0)) / x) * (sin(x) / x); end
code[x_] := N[(N[(N[Tan[N[(x / 2.0), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\tan \left(\frac{x}{2}\right)}{x} \cdot \frac{\sin x}{x}
\end{array}
Initial program 55.1%
flip--N/A
associate-/l/N/A
metadata-evalN/A
1-sub-cosN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
hang-0p-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f6476.1%
Applied egg-rr76.1%
*-commutativeN/A
associate-*r/N/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
tan-lowering-tan.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f6499.8%
Applied egg-rr99.8%
(FPCore (x)
:precision binary64
(if (<= x 0.088)
(+
0.5
(*
x
(*
x
(+
-0.041666666666666664
(*
(* x x)
(+ 0.001388888888888889 (* (* x x) -2.48015873015873e-5)))))))
(/ (* (/ 1.0 x) (- 1.0 (cos x))) x)))
double code(double x) {
double tmp;
if (x <= 0.088) {
tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
} else {
tmp = ((1.0 / x) * (1.0 - cos(x))) / x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.088d0) then
tmp = 0.5d0 + (x * (x * ((-0.041666666666666664d0) + ((x * x) * (0.001388888888888889d0 + ((x * x) * (-2.48015873015873d-5)))))))
else
tmp = ((1.0d0 / x) * (1.0d0 - cos(x))) / x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.088) {
tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
} else {
tmp = ((1.0 / x) * (1.0 - Math.cos(x))) / x;
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.088: tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5)))))) else: tmp = ((1.0 / x) * (1.0 - math.cos(x))) / x return tmp
function code(x) tmp = 0.0 if (x <= 0.088) tmp = Float64(0.5 + Float64(x * Float64(x * Float64(-0.041666666666666664 + Float64(Float64(x * x) * Float64(0.001388888888888889 + Float64(Float64(x * x) * -2.48015873015873e-5))))))); else tmp = Float64(Float64(Float64(1.0 / x) * Float64(1.0 - cos(x))) / x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.088) tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5)))))); else tmp = ((1.0 / x) * (1.0 - cos(x))) / x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.088], N[(0.5 + N[(x * N[(x * N[(-0.041666666666666664 + N[(N[(x * x), $MachinePrecision] * N[(0.001388888888888889 + N[(N[(x * x), $MachinePrecision] * -2.48015873015873e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] * N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.088:\\
\;\;\;\;0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} \cdot \left(1 - \cos x\right)}{x}\\
\end{array}
\end{array}
if x < 0.087999999999999995Initial program 39.3%
flip--N/A
associate-/l/N/A
metadata-evalN/A
1-sub-cosN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
hang-0p-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f6467.7%
Applied egg-rr67.7%
Taylor expanded in x around 0
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6463.4%
Simplified63.4%
if 0.087999999999999995 < x Initial program 98.6%
Taylor expanded in x around inf
unpow2N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
cos-lowering-cos.f6499.2%
Simplified99.2%
clear-numN/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
cos-lowering-cos.f6499.2%
Applied egg-rr99.2%
(FPCore (x)
:precision binary64
(if (<= x 0.088)
(+
0.5
(*
x
(*
x
(+
-0.041666666666666664
(*
(* x x)
(+ 0.001388888888888889 (* (* x x) -2.48015873015873e-5)))))))
(* (/ -1.0 x) (/ (+ (cos x) -1.0) x))))
double code(double x) {
double tmp;
if (x <= 0.088) {
tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
} else {
tmp = (-1.0 / x) * ((cos(x) + -1.0) / x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.088d0) then
tmp = 0.5d0 + (x * (x * ((-0.041666666666666664d0) + ((x * x) * (0.001388888888888889d0 + ((x * x) * (-2.48015873015873d-5)))))))
else
tmp = ((-1.0d0) / x) * ((cos(x) + (-1.0d0)) / x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.088) {
tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
} else {
tmp = (-1.0 / x) * ((Math.cos(x) + -1.0) / x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.088: tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5)))))) else: tmp = (-1.0 / x) * ((math.cos(x) + -1.0) / x) return tmp
function code(x) tmp = 0.0 if (x <= 0.088) tmp = Float64(0.5 + Float64(x * Float64(x * Float64(-0.041666666666666664 + Float64(Float64(x * x) * Float64(0.001388888888888889 + Float64(Float64(x * x) * -2.48015873015873e-5))))))); else tmp = Float64(Float64(-1.0 / x) * Float64(Float64(cos(x) + -1.0) / x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.088) tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5)))))); else tmp = (-1.0 / x) * ((cos(x) + -1.0) / x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.088], N[(0.5 + N[(x * N[(x * N[(-0.041666666666666664 + N[(N[(x * x), $MachinePrecision] * N[(0.001388888888888889 + N[(N[(x * x), $MachinePrecision] * -2.48015873015873e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / x), $MachinePrecision] * N[(N[(N[Cos[x], $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.088:\\
\;\;\;\;0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{x} \cdot \frac{\cos x + -1}{x}\\
\end{array}
\end{array}
if x < 0.087999999999999995Initial program 39.3%
flip--N/A
associate-/l/N/A
metadata-evalN/A
1-sub-cosN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
hang-0p-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f6467.7%
Applied egg-rr67.7%
Taylor expanded in x around 0
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6463.4%
Simplified63.4%
if 0.087999999999999995 < x Initial program 98.6%
Applied egg-rr99.3%
(FPCore (x)
:precision binary64
(if (<= x 0.1)
(+
0.5
(*
x
(*
x
(+
-0.041666666666666664
(*
(* x x)
(+ 0.001388888888888889 (* (* x x) -2.48015873015873e-5)))))))
(/ (/ (- 1.0 (cos x)) x) x)))
double code(double x) {
double tmp;
if (x <= 0.1) {
tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
} else {
tmp = ((1.0 - cos(x)) / x) / x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.1d0) then
tmp = 0.5d0 + (x * (x * ((-0.041666666666666664d0) + ((x * x) * (0.001388888888888889d0 + ((x * x) * (-2.48015873015873d-5)))))))
else
tmp = ((1.0d0 - cos(x)) / x) / x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.1) {
tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
} else {
tmp = ((1.0 - Math.cos(x)) / x) / x;
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.1: tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5)))))) else: tmp = ((1.0 - math.cos(x)) / x) / x return tmp
function code(x) tmp = 0.0 if (x <= 0.1) tmp = Float64(0.5 + Float64(x * Float64(x * Float64(-0.041666666666666664 + Float64(Float64(x * x) * Float64(0.001388888888888889 + Float64(Float64(x * x) * -2.48015873015873e-5))))))); else tmp = Float64(Float64(Float64(1.0 - cos(x)) / x) / x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.1) tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5)))))); else tmp = ((1.0 - cos(x)) / x) / x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.1], N[(0.5 + N[(x * N[(x * N[(-0.041666666666666664 + N[(N[(x * x), $MachinePrecision] * N[(0.001388888888888889 + N[(N[(x * x), $MachinePrecision] * -2.48015873015873e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.1:\\
\;\;\;\;0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\
\end{array}
\end{array}
if x < 0.10000000000000001Initial program 39.6%
flip--N/A
associate-/l/N/A
metadata-evalN/A
1-sub-cosN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
hang-0p-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f6467.9%
Applied egg-rr67.9%
Taylor expanded in x around 0
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6463.6%
Simplified63.6%
if 0.10000000000000001 < x Initial program 98.7%
Taylor expanded in x around inf
unpow2N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
cos-lowering-cos.f6499.3%
Simplified99.3%
(FPCore (x)
:precision binary64
(if (<= x 0.1)
(+
0.5
(*
x
(*
x
(+
-0.041666666666666664
(*
(* x x)
(+ 0.001388888888888889 (* (* x x) -2.48015873015873e-5)))))))
(/ (- 1.0 (cos x)) (* x x))))
double code(double x) {
double tmp;
if (x <= 0.1) {
tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
} else {
tmp = (1.0 - cos(x)) / (x * x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.1d0) then
tmp = 0.5d0 + (x * (x * ((-0.041666666666666664d0) + ((x * x) * (0.001388888888888889d0 + ((x * x) * (-2.48015873015873d-5)))))))
else
tmp = (1.0d0 - cos(x)) / (x * x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.1) {
tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
} else {
tmp = (1.0 - Math.cos(x)) / (x * x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.1: tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5)))))) else: tmp = (1.0 - math.cos(x)) / (x * x) return tmp
function code(x) tmp = 0.0 if (x <= 0.1) tmp = Float64(0.5 + Float64(x * Float64(x * Float64(-0.041666666666666664 + Float64(Float64(x * x) * Float64(0.001388888888888889 + Float64(Float64(x * x) * -2.48015873015873e-5))))))); else tmp = Float64(Float64(1.0 - cos(x)) / Float64(x * x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.1) tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5)))))); else tmp = (1.0 - cos(x)) / (x * x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.1], N[(0.5 + N[(x * N[(x * N[(-0.041666666666666664 + N[(N[(x * x), $MachinePrecision] * N[(0.001388888888888889 + N[(N[(x * x), $MachinePrecision] * -2.48015873015873e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.1:\\
\;\;\;\;0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \cos x}{x \cdot x}\\
\end{array}
\end{array}
if x < 0.10000000000000001Initial program 39.6%
flip--N/A
associate-/l/N/A
metadata-evalN/A
1-sub-cosN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
hang-0p-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f6467.9%
Applied egg-rr67.9%
Taylor expanded in x around 0
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6463.6%
Simplified63.6%
if 0.10000000000000001 < x Initial program 98.7%
(FPCore (x) :precision binary64 (if (<= x 3.5) (+ 0.5 (* -0.041666666666666664 (* x x))) (/ (+ 1.0 -1.0) (* x x))))
double code(double x) {
double tmp;
if (x <= 3.5) {
tmp = 0.5 + (-0.041666666666666664 * (x * x));
} else {
tmp = (1.0 + -1.0) / (x * x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 3.5d0) then
tmp = 0.5d0 + ((-0.041666666666666664d0) * (x * x))
else
tmp = (1.0d0 + (-1.0d0)) / (x * x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 3.5) {
tmp = 0.5 + (-0.041666666666666664 * (x * x));
} else {
tmp = (1.0 + -1.0) / (x * x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 3.5: tmp = 0.5 + (-0.041666666666666664 * (x * x)) else: tmp = (1.0 + -1.0) / (x * x) return tmp
function code(x) tmp = 0.0 if (x <= 3.5) tmp = Float64(0.5 + Float64(-0.041666666666666664 * Float64(x * x))); else tmp = Float64(Float64(1.0 + -1.0) / Float64(x * x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 3.5) tmp = 0.5 + (-0.041666666666666664 * (x * x)); else tmp = (1.0 + -1.0) / (x * x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 3.5], N[(0.5 + N[(-0.041666666666666664 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + -1.0), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5:\\
\;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + -1}{x \cdot x}\\
\end{array}
\end{array}
if x < 3.5Initial program 40.2%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6462.8%
Simplified62.8%
if 3.5 < x Initial program 98.8%
Taylor expanded in x around 0
Simplified50.4%
Final simplification59.7%
(FPCore (x) :precision binary64 (if (<= x 3.5) (+ 0.5 (* -0.041666666666666664 (* x x))) 0.0))
double code(double x) {
double tmp;
if (x <= 3.5) {
tmp = 0.5 + (-0.041666666666666664 * (x * x));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 3.5d0) then
tmp = 0.5d0 + ((-0.041666666666666664d0) * (x * x))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 3.5) {
tmp = 0.5 + (-0.041666666666666664 * (x * x));
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 3.5: tmp = 0.5 + (-0.041666666666666664 * (x * x)) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 3.5) tmp = Float64(0.5 + Float64(-0.041666666666666664 * Float64(x * x))); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 3.5) tmp = 0.5 + (-0.041666666666666664 * (x * x)); else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 3.5], N[(0.5 + N[(-0.041666666666666664 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5:\\
\;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 3.5Initial program 40.2%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6462.8%
Simplified62.8%
if 3.5 < x Initial program 98.8%
Taylor expanded in x around inf
unpow2N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
cos-lowering-cos.f6499.4%
Simplified99.4%
Taylor expanded in x around 0
Simplified50.4%
metadata-evalN/A
div0N/A
div050.4%
Applied egg-rr50.4%
(FPCore (x) :precision binary64 (/ -1.0 (+ -2.0 (* x (* x -0.16666666666666666)))))
double code(double x) {
return -1.0 / (-2.0 + (x * (x * -0.16666666666666666)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-1.0d0) / ((-2.0d0) + (x * (x * (-0.16666666666666666d0))))
end function
public static double code(double x) {
return -1.0 / (-2.0 + (x * (x * -0.16666666666666666)));
}
def code(x): return -1.0 / (-2.0 + (x * (x * -0.16666666666666666)))
function code(x) return Float64(-1.0 / Float64(-2.0 + Float64(x * Float64(x * -0.16666666666666666)))) end
function tmp = code(x) tmp = -1.0 / (-2.0 + (x * (x * -0.16666666666666666))); end
code[x_] := N[(-1.0 / N[(-2.0 + N[(x * N[(x * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{-2 + x \cdot \left(x \cdot -0.16666666666666666\right)}
\end{array}
Initial program 55.1%
Taylor expanded in x around inf
unpow2N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
cos-lowering-cos.f6456.1%
Simplified56.1%
clear-numN/A
frac-2negN/A
metadata-evalN/A
/-lowering-/.f64N/A
div-invN/A
clear-numN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
distribute-frac-neg2N/A
/-lowering-/.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
remove-double-negN/A
metadata-evalN/A
+-lowering-+.f64N/A
cos-lowering-cos.f6455.5%
Applied egg-rr55.5%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6475.6%
Simplified75.6%
(FPCore (x) :precision binary64 (if (<= x 8e+76) 0.5 0.0))
double code(double x) {
double tmp;
if (x <= 8e+76) {
tmp = 0.5;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 8d+76) then
tmp = 0.5d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 8e+76) {
tmp = 0.5;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 8e+76: tmp = 0.5 else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 8e+76) tmp = 0.5; else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 8e+76) tmp = 0.5; else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 8e+76], 0.5, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8 \cdot 10^{+76}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 8.0000000000000004e76Initial program 45.0%
Taylor expanded in x around 0
Simplified58.2%
if 8.0000000000000004e76 < x Initial program 98.5%
Taylor expanded in x around inf
unpow2N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
cos-lowering-cos.f6499.4%
Simplified99.4%
Taylor expanded in x around 0
Simplified66.9%
metadata-evalN/A
div0N/A
div066.9%
Applied egg-rr66.9%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 55.1%
Taylor expanded in x around inf
unpow2N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
cos-lowering-cos.f6456.1%
Simplified56.1%
Taylor expanded in x around 0
Simplified27.8%
metadata-evalN/A
div0N/A
div027.8%
Applied egg-rr27.8%
herbie shell --seed 2024140
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1.0 (cos x)) (* x x)))