
(FPCore (x) :precision binary64 (/ (- x (sin x)) (- x (tan x))))
double code(double x) {
return (x - sin(x)) / (x - tan(x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x - sin(x)) / (x - tan(x))
end function
public static double code(double x) {
return (x - Math.sin(x)) / (x - Math.tan(x));
}
def code(x): return (x - math.sin(x)) / (x - math.tan(x))
function code(x) return Float64(Float64(x - sin(x)) / Float64(x - tan(x))) end
function tmp = code(x) tmp = (x - sin(x)) / (x - tan(x)); end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - \sin x}{x - \tan x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ (- x (sin x)) (- x (tan x))))
double code(double x) {
return (x - sin(x)) / (x - tan(x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x - sin(x)) / (x - tan(x))
end function
public static double code(double x) {
return (x - Math.sin(x)) / (x - Math.tan(x));
}
def code(x): return (x - math.sin(x)) / (x - math.tan(x))
function code(x) return Float64(Float64(x - sin(x)) / Float64(x - tan(x))) end
function tmp = code(x) tmp = (x - sin(x)) / (x - tan(x)); end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - \sin x}{x - \tan x}
\end{array}
NOTE: x should be positive before calling this function
(FPCore (x)
:precision binary64
(let* ((t_0 (- x (tan x))))
(if (<= x 0.102)
(-
(+
(* -0.009642857142857142 (pow x 4.0))
(+ (* 0.00024107142857142857 (pow x 6.0)) (* 0.225 (pow x 2.0))))
0.5)
(- (/ x t_0) (/ (sin x) t_0)))))x = abs(x);
double code(double x) {
double t_0 = x - tan(x);
double tmp;
if (x <= 0.102) {
tmp = ((-0.009642857142857142 * pow(x, 4.0)) + ((0.00024107142857142857 * pow(x, 6.0)) + (0.225 * pow(x, 2.0)))) - 0.5;
} else {
tmp = (x / t_0) - (sin(x) / t_0);
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = x - tan(x)
if (x <= 0.102d0) then
tmp = (((-0.009642857142857142d0) * (x ** 4.0d0)) + ((0.00024107142857142857d0 * (x ** 6.0d0)) + (0.225d0 * (x ** 2.0d0)))) - 0.5d0
else
tmp = (x / t_0) - (sin(x) / t_0)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double t_0 = x - Math.tan(x);
double tmp;
if (x <= 0.102) {
tmp = ((-0.009642857142857142 * Math.pow(x, 4.0)) + ((0.00024107142857142857 * Math.pow(x, 6.0)) + (0.225 * Math.pow(x, 2.0)))) - 0.5;
} else {
tmp = (x / t_0) - (Math.sin(x) / t_0);
}
return tmp;
}
x = abs(x) def code(x): t_0 = x - math.tan(x) tmp = 0 if x <= 0.102: tmp = ((-0.009642857142857142 * math.pow(x, 4.0)) + ((0.00024107142857142857 * math.pow(x, 6.0)) + (0.225 * math.pow(x, 2.0)))) - 0.5 else: tmp = (x / t_0) - (math.sin(x) / t_0) return tmp
x = abs(x) function code(x) t_0 = Float64(x - tan(x)) tmp = 0.0 if (x <= 0.102) tmp = Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + Float64(Float64(0.00024107142857142857 * (x ^ 6.0)) + Float64(0.225 * (x ^ 2.0)))) - 0.5); else tmp = Float64(Float64(x / t_0) - Float64(sin(x) / t_0)); end return tmp end
x = abs(x) function tmp_2 = code(x) t_0 = x - tan(x); tmp = 0.0; if (x <= 0.102) tmp = ((-0.009642857142857142 * (x ^ 4.0)) + ((0.00024107142857142857 * (x ^ 6.0)) + (0.225 * (x ^ 2.0)))) - 0.5; else tmp = (x / t_0) - (sin(x) / t_0); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
code[x_] := Block[{t$95$0 = N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 0.102], N[(N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.00024107142857142857 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(0.225 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision], N[(N[(x / t$95$0), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := x - \tan x\\
\mathbf{if}\;x \leq 0.102:\\
\;\;\;\;\left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + 0.225 \cdot {x}^{2}\right)\right) - 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t_0} - \frac{\sin x}{t_0}\\
\end{array}
\end{array}
if x < 0.101999999999999993Initial program 33.7%
Taylor expanded in x around 0 67.8%
if 0.101999999999999993 < x Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
Final simplification75.6%
NOTE: x should be positive before calling this function
(FPCore (x)
:precision binary64
(let* ((t_0 (- x (tan x))))
(if (<= x 0.026)
(+ (+ (* -0.009642857142857142 (pow x 4.0)) (* 0.225 (* x x))) -0.5)
(- (/ x t_0) (/ (sin x) t_0)))))x = abs(x);
double code(double x) {
double t_0 = x - tan(x);
double tmp;
if (x <= 0.026) {
tmp = ((-0.009642857142857142 * pow(x, 4.0)) + (0.225 * (x * x))) + -0.5;
} else {
tmp = (x / t_0) - (sin(x) / t_0);
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = x - tan(x)
if (x <= 0.026d0) then
tmp = (((-0.009642857142857142d0) * (x ** 4.0d0)) + (0.225d0 * (x * x))) + (-0.5d0)
else
tmp = (x / t_0) - (sin(x) / t_0)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double t_0 = x - Math.tan(x);
double tmp;
if (x <= 0.026) {
tmp = ((-0.009642857142857142 * Math.pow(x, 4.0)) + (0.225 * (x * x))) + -0.5;
} else {
tmp = (x / t_0) - (Math.sin(x) / t_0);
}
return tmp;
}
x = abs(x) def code(x): t_0 = x - math.tan(x) tmp = 0 if x <= 0.026: tmp = ((-0.009642857142857142 * math.pow(x, 4.0)) + (0.225 * (x * x))) + -0.5 else: tmp = (x / t_0) - (math.sin(x) / t_0) return tmp
x = abs(x) function code(x) t_0 = Float64(x - tan(x)) tmp = 0.0 if (x <= 0.026) tmp = Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + Float64(0.225 * Float64(x * x))) + -0.5); else tmp = Float64(Float64(x / t_0) - Float64(sin(x) / t_0)); end return tmp end
x = abs(x) function tmp_2 = code(x) t_0 = x - tan(x); tmp = 0.0; if (x <= 0.026) tmp = ((-0.009642857142857142 * (x ^ 4.0)) + (0.225 * (x * x))) + -0.5; else tmp = (x / t_0) - (sin(x) / t_0); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
code[x_] := Block[{t$95$0 = N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 0.026], N[(N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(N[(x / t$95$0), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := x - \tan x\\
\mathbf{if}\;x \leq 0.026:\\
\;\;\;\;\left(-0.009642857142857142 \cdot {x}^{4} + 0.225 \cdot \left(x \cdot x\right)\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t_0} - \frac{\sin x}{t_0}\\
\end{array}
\end{array}
if x < 0.0259999999999999988Initial program 33.7%
Taylor expanded in x around 0 67.6%
sub-neg67.6%
fma-def67.6%
unpow267.6%
metadata-eval67.6%
Simplified67.6%
fma-udef67.6%
+-commutative67.6%
Applied egg-rr67.6%
if 0.0259999999999999988 < x Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
Final simplification75.5%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 0.03) (+ (+ (* -0.009642857142857142 (pow x 4.0)) (* 0.225 (* x x))) -0.5) (/ (/ 1.0 (- x (tan x))) (/ 1.0 (- x (sin x))))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 0.03) {
tmp = ((-0.009642857142857142 * pow(x, 4.0)) + (0.225 * (x * x))) + -0.5;
} else {
tmp = (1.0 / (x - tan(x))) / (1.0 / (x - sin(x)));
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.03d0) then
tmp = (((-0.009642857142857142d0) * (x ** 4.0d0)) + (0.225d0 * (x * x))) + (-0.5d0)
else
tmp = (1.0d0 / (x - tan(x))) / (1.0d0 / (x - sin(x)))
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 0.03) {
tmp = ((-0.009642857142857142 * Math.pow(x, 4.0)) + (0.225 * (x * x))) + -0.5;
} else {
tmp = (1.0 / (x - Math.tan(x))) / (1.0 / (x - Math.sin(x)));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 0.03: tmp = ((-0.009642857142857142 * math.pow(x, 4.0)) + (0.225 * (x * x))) + -0.5 else: tmp = (1.0 / (x - math.tan(x))) / (1.0 / (x - math.sin(x))) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 0.03) tmp = Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + Float64(0.225 * Float64(x * x))) + -0.5); else tmp = Float64(Float64(1.0 / Float64(x - tan(x))) / Float64(1.0 / Float64(x - sin(x)))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 0.03) tmp = ((-0.009642857142857142 * (x ^ 4.0)) + (0.225 * (x * x))) + -0.5; else tmp = (1.0 / (x - tan(x))) / (1.0 / (x - sin(x))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 0.03], N[(N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(N[(1.0 / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 / N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.03:\\
\;\;\;\;\left(-0.009642857142857142 \cdot {x}^{4} + 0.225 \cdot \left(x \cdot x\right)\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x - \tan x}}{\frac{1}{x - \sin x}}\\
\end{array}
\end{array}
if x < 0.029999999999999999Initial program 33.7%
Taylor expanded in x around 0 67.6%
sub-neg67.6%
fma-def67.6%
unpow267.6%
metadata-eval67.6%
Simplified67.6%
fma-udef67.6%
+-commutative67.6%
Applied egg-rr67.6%
if 0.029999999999999999 < x Initial program 99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
unpow-199.9%
div-inv99.8%
associate-/r*99.9%
Applied egg-rr99.9%
Final simplification75.4%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 0.03) (+ (+ (* -0.009642857142857142 (pow x 4.0)) (* 0.225 (* x x))) -0.5) (/ 1.0 (/ (- x (tan x)) (- x (sin x))))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 0.03) {
tmp = ((-0.009642857142857142 * pow(x, 4.0)) + (0.225 * (x * x))) + -0.5;
} else {
tmp = 1.0 / ((x - tan(x)) / (x - sin(x)));
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.03d0) then
tmp = (((-0.009642857142857142d0) * (x ** 4.0d0)) + (0.225d0 * (x * x))) + (-0.5d0)
else
tmp = 1.0d0 / ((x - tan(x)) / (x - sin(x)))
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 0.03) {
tmp = ((-0.009642857142857142 * Math.pow(x, 4.0)) + (0.225 * (x * x))) + -0.5;
} else {
tmp = 1.0 / ((x - Math.tan(x)) / (x - Math.sin(x)));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 0.03: tmp = ((-0.009642857142857142 * math.pow(x, 4.0)) + (0.225 * (x * x))) + -0.5 else: tmp = 1.0 / ((x - math.tan(x)) / (x - math.sin(x))) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 0.03) tmp = Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + Float64(0.225 * Float64(x * x))) + -0.5); else tmp = Float64(1.0 / Float64(Float64(x - tan(x)) / Float64(x - sin(x)))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 0.03) tmp = ((-0.009642857142857142 * (x ^ 4.0)) + (0.225 * (x * x))) + -0.5; else tmp = 1.0 / ((x - tan(x)) / (x - sin(x))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 0.03], N[(N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(1.0 / N[(N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.03:\\
\;\;\;\;\left(-0.009642857142857142 \cdot {x}^{4} + 0.225 \cdot \left(x \cdot x\right)\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x - \tan x}{x - \sin x}}\\
\end{array}
\end{array}
if x < 0.029999999999999999Initial program 33.7%
Taylor expanded in x around 0 67.6%
sub-neg67.6%
fma-def67.6%
unpow267.6%
metadata-eval67.6%
Simplified67.6%
fma-udef67.6%
+-commutative67.6%
Applied egg-rr67.6%
if 0.029999999999999999 < x Initial program 99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
unpow-199.9%
Applied egg-rr99.9%
Final simplification75.4%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 0.03) (+ (+ (* -0.009642857142857142 (pow x 4.0)) (* 0.225 (* x x))) -0.5) (/ (- x (sin x)) (- x (tan x)))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 0.03) {
tmp = ((-0.009642857142857142 * pow(x, 4.0)) + (0.225 * (x * x))) + -0.5;
} else {
tmp = (x - sin(x)) / (x - tan(x));
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.03d0) then
tmp = (((-0.009642857142857142d0) * (x ** 4.0d0)) + (0.225d0 * (x * x))) + (-0.5d0)
else
tmp = (x - sin(x)) / (x - tan(x))
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 0.03) {
tmp = ((-0.009642857142857142 * Math.pow(x, 4.0)) + (0.225 * (x * x))) + -0.5;
} else {
tmp = (x - Math.sin(x)) / (x - Math.tan(x));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 0.03: tmp = ((-0.009642857142857142 * math.pow(x, 4.0)) + (0.225 * (x * x))) + -0.5 else: tmp = (x - math.sin(x)) / (x - math.tan(x)) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 0.03) tmp = Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + Float64(0.225 * Float64(x * x))) + -0.5); else tmp = Float64(Float64(x - sin(x)) / Float64(x - tan(x))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 0.03) tmp = ((-0.009642857142857142 * (x ^ 4.0)) + (0.225 * (x * x))) + -0.5; else tmp = (x - sin(x)) / (x - tan(x)); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 0.03], N[(N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.03:\\
\;\;\;\;\left(-0.009642857142857142 \cdot {x}^{4} + 0.225 \cdot \left(x \cdot x\right)\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\
\end{array}
\end{array}
if x < 0.029999999999999999Initial program 33.7%
Taylor expanded in x around 0 67.6%
sub-neg67.6%
fma-def67.6%
unpow267.6%
metadata-eval67.6%
Simplified67.6%
fma-udef67.6%
+-commutative67.6%
Applied egg-rr67.6%
if 0.029999999999999999 < x Initial program 99.9%
Final simplification75.4%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 3.0) (+ (+ (* -0.009642857142857142 (pow x 4.0)) (* 0.225 (* x x))) -0.5) (- (/ x (- x (tan x))) (/ -3.0 (* x x)))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 3.0) {
tmp = ((-0.009642857142857142 * pow(x, 4.0)) + (0.225 * (x * x))) + -0.5;
} else {
tmp = (x / (x - tan(x))) - (-3.0 / (x * x));
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 3.0d0) then
tmp = (((-0.009642857142857142d0) * (x ** 4.0d0)) + (0.225d0 * (x * x))) + (-0.5d0)
else
tmp = (x / (x - tan(x))) - ((-3.0d0) / (x * x))
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 3.0) {
tmp = ((-0.009642857142857142 * Math.pow(x, 4.0)) + (0.225 * (x * x))) + -0.5;
} else {
tmp = (x / (x - Math.tan(x))) - (-3.0 / (x * x));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 3.0: tmp = ((-0.009642857142857142 * math.pow(x, 4.0)) + (0.225 * (x * x))) + -0.5 else: tmp = (x / (x - math.tan(x))) - (-3.0 / (x * x)) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 3.0) tmp = Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + Float64(0.225 * Float64(x * x))) + -0.5); else tmp = Float64(Float64(x / Float64(x - tan(x))) - Float64(-3.0 / Float64(x * x))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 3.0) tmp = ((-0.009642857142857142 * (x ^ 4.0)) + (0.225 * (x * x))) + -0.5; else tmp = (x / (x - tan(x))) - (-3.0 / (x * x)); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 3.0], N[(N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(N[(x / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-3.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3:\\
\;\;\;\;\left(-0.009642857142857142 \cdot {x}^{4} + 0.225 \cdot \left(x \cdot x\right)\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x - \tan x} - \frac{-3}{x \cdot x}\\
\end{array}
\end{array}
if x < 3Initial program 33.7%
Taylor expanded in x around 0 67.6%
sub-neg67.6%
fma-def67.6%
unpow267.6%
metadata-eval67.6%
Simplified67.6%
fma-udef67.6%
+-commutative67.6%
Applied egg-rr67.6%
if 3 < x Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 96.2%
unpow296.2%
Simplified96.2%
Final simplification74.5%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.8) (+ (* 0.225 (* x x)) -0.5) (- (/ x (- x (tan x))) (/ -3.0 (* x x)))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.8) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = (x / (x - tan(x))) - (-3.0 / (x * x));
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 2.8d0) then
tmp = (0.225d0 * (x * x)) + (-0.5d0)
else
tmp = (x / (x - tan(x))) - ((-3.0d0) / (x * x))
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 2.8) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = (x / (x - Math.tan(x))) - (-3.0 / (x * x));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.8: tmp = (0.225 * (x * x)) + -0.5 else: tmp = (x / (x - math.tan(x))) - (-3.0 / (x * x)) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.8) tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5); else tmp = Float64(Float64(x / Float64(x - tan(x))) - Float64(-3.0 / Float64(x * x))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 2.8) tmp = (0.225 * (x * x)) + -0.5; else tmp = (x / (x - tan(x))) - (-3.0 / (x * x)); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 2.8], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(N[(x / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-3.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.8:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x - \tan x} - \frac{-3}{x \cdot x}\\
\end{array}
\end{array}
if x < 2.7999999999999998Initial program 33.7%
Taylor expanded in x around 0 68.5%
fma-neg68.5%
unpow268.5%
metadata-eval68.5%
Simplified68.5%
fma-udef68.5%
Applied egg-rr68.5%
if 2.7999999999999998 < x Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 96.2%
unpow296.2%
Simplified96.2%
Final simplification75.2%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.3) (+ (* 0.225 (* x x)) -0.5) (/ x (- x (tan x)))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.3) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = x / (x - tan(x));
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 2.3d0) then
tmp = (0.225d0 * (x * x)) + (-0.5d0)
else
tmp = x / (x - tan(x))
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 2.3) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = x / (x - Math.tan(x));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.3: tmp = (0.225 * (x * x)) + -0.5 else: tmp = x / (x - math.tan(x)) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.3) tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5); else tmp = Float64(x / Float64(x - tan(x))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 2.3) tmp = (0.225 * (x * x)) + -0.5; else tmp = x / (x - tan(x)); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 2.3], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(x / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.3:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x - \tan x}\\
\end{array}
\end{array}
if x < 2.2999999999999998Initial program 33.7%
Taylor expanded in x around 0 68.5%
fma-neg68.5%
unpow268.5%
metadata-eval68.5%
Simplified68.5%
fma-udef68.5%
Applied egg-rr68.5%
if 2.2999999999999998 < x Initial program 99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
unpow-199.9%
div-inv99.8%
associate-/r*99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 96.2%
expm1-log1p-u96.2%
expm1-udef96.2%
associate-/r/96.2%
/-rgt-identity96.2%
Applied egg-rr96.2%
expm1-def96.2%
expm1-log1p96.0%
associate-*l/96.2%
*-lft-identity96.2%
Simplified96.2%
Final simplification75.2%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.9) (+ (* 0.225 (* x x)) -0.5) (- (/ x x) (/ -3.0 (* x x)))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.9) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = (x / x) - (-3.0 / (x * x));
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 2.9d0) then
tmp = (0.225d0 * (x * x)) + (-0.5d0)
else
tmp = (x / x) - ((-3.0d0) / (x * x))
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 2.9) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = (x / x) - (-3.0 / (x * x));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.9: tmp = (0.225 * (x * x)) + -0.5 else: tmp = (x / x) - (-3.0 / (x * x)) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.9) tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5); else tmp = Float64(Float64(x / x) - Float64(-3.0 / Float64(x * x))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 2.9) tmp = (0.225 * (x * x)) + -0.5; else tmp = (x / x) - (-3.0 / (x * x)); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 2.9], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(N[(x / x), $MachinePrecision] - N[(-3.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.9:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x} - \frac{-3}{x \cdot x}\\
\end{array}
\end{array}
if x < 2.89999999999999991Initial program 33.7%
Taylor expanded in x around 0 68.5%
fma-neg68.5%
unpow268.5%
metadata-eval68.5%
Simplified68.5%
fma-udef68.5%
Applied egg-rr68.5%
if 2.89999999999999991 < x Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 96.2%
unpow296.2%
Simplified96.2%
Taylor expanded in x around inf 96.1%
Final simplification75.2%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.6) (+ (* 0.225 (* x x)) -0.5) 1.0))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.6) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = 1.0;
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 2.6d0) then
tmp = (0.225d0 * (x * x)) + (-0.5d0)
else
tmp = 1.0d0
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 2.6) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = 1.0;
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.6: tmp = (0.225 * (x * x)) + -0.5 else: tmp = 1.0 return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.6) tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5); else tmp = 1.0; end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 2.6) tmp = (0.225 * (x * x)) + -0.5; else tmp = 1.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 2.6], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], 1.0]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.6:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 2.60000000000000009Initial program 33.7%
Taylor expanded in x around 0 68.5%
fma-neg68.5%
unpow268.5%
metadata-eval68.5%
Simplified68.5%
fma-udef68.5%
Applied egg-rr68.5%
if 2.60000000000000009 < x Initial program 99.9%
Taylor expanded in x around inf 96.1%
Final simplification75.2%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 1.6) -0.5 1.0))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 1.6) {
tmp = -0.5;
} else {
tmp = 1.0;
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.6d0) then
tmp = -0.5d0
else
tmp = 1.0d0
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 1.6) {
tmp = -0.5;
} else {
tmp = 1.0;
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 1.6: tmp = -0.5 else: tmp = 1.0 return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 1.6) tmp = -0.5; else tmp = 1.0; end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 1.6) tmp = -0.5; else tmp = 1.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 1.6], -0.5, 1.0]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6:\\
\;\;\;\;-0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 1.6000000000000001Initial program 33.7%
Taylor expanded in x around 0 67.1%
if 1.6000000000000001 < x Initial program 99.9%
Taylor expanded in x around inf 96.1%
Final simplification74.1%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 -0.5)
x = abs(x);
double code(double x) {
return -0.5;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
code = -0.5d0
end function
x = Math.abs(x);
public static double code(double x) {
return -0.5;
}
x = abs(x) def code(x): return -0.5
x = abs(x) function code(x) return -0.5 end
x = abs(x) function tmp = code(x) tmp = -0.5; end
NOTE: x should be positive before calling this function code[x_] := -0.5
\begin{array}{l}
x = |x|\\
\\
-0.5
\end{array}
Initial program 49.8%
Taylor expanded in x around 0 51.2%
Final simplification51.2%
herbie shell --seed 2023280
(FPCore (x)
:name "sintan (problem 3.4.5)"
:precision binary64
(/ (- x (sin x)) (- x (tan x))))