
(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 11 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.088)
(-
(+
(* -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.088) {
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.088d0) 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.088) {
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.088: 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.088) 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.088) 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.088], 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.088:\\
\;\;\;\;\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.087999999999999995Initial program 37.8%
Taylor expanded in x around 0 64.6%
if 0.087999999999999995 < x Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Final simplification75.4%
NOTE: x should be positive before calling this function
(FPCore (x)
:precision binary64
(let* ((t_0 (- x (tan x))))
(if (<= x 0.088)
(-
(+
(* -0.009642857142857142 (pow x 4.0))
(+
(* 0.00024107142857142857 (pow x 6.0))
(+ (+ 1.0 (* x (* x 0.225))) -1.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.088) {
tmp = ((-0.009642857142857142 * pow(x, 4.0)) + ((0.00024107142857142857 * pow(x, 6.0)) + ((1.0 + (x * (x * 0.225))) + -1.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.088d0) then
tmp = (((-0.009642857142857142d0) * (x ** 4.0d0)) + ((0.00024107142857142857d0 * (x ** 6.0d0)) + ((1.0d0 + (x * (x * 0.225d0))) + (-1.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.088) {
tmp = ((-0.009642857142857142 * Math.pow(x, 4.0)) + ((0.00024107142857142857 * Math.pow(x, 6.0)) + ((1.0 + (x * (x * 0.225))) + -1.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.088: tmp = ((-0.009642857142857142 * math.pow(x, 4.0)) + ((0.00024107142857142857 * math.pow(x, 6.0)) + ((1.0 + (x * (x * 0.225))) + -1.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.088) tmp = Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + Float64(Float64(0.00024107142857142857 * (x ^ 6.0)) + Float64(Float64(1.0 + Float64(x * Float64(x * 0.225))) + -1.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.088) tmp = ((-0.009642857142857142 * (x ^ 4.0)) + ((0.00024107142857142857 * (x ^ 6.0)) + ((1.0 + (x * (x * 0.225))) + -1.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.088], N[(N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.00024107142857142857 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + N[(x * N[(x * 0.225), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $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.088:\\
\;\;\;\;\left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + \left(\left(1 + x \cdot \left(x \cdot 0.225\right)\right) + -1\right)\right)\right) - 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t_0} - \frac{\sin x}{t_0}\\
\end{array}
\end{array}
if x < 0.087999999999999995Initial program 37.8%
Taylor expanded in x around 0 64.6%
pow264.6%
*-commutative64.6%
associate-*r*64.6%
expm1-log1p-u64.6%
expm1-def64.6%
log1p-udef64.6%
add-exp-log64.6%
Applied egg-rr64.6%
if 0.087999999999999995 < x Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Final simplification75.4%
NOTE: x should be positive before calling this function
(FPCore (x)
:precision binary64
(if (<= x 0.08)
(-
(+
(* -0.009642857142857142 (pow x 4.0))
(+
(* 0.00024107142857142857 (pow x 6.0))
(+ (+ 1.0 (* x (* x 0.225))) -1.0)))
0.5)
(/ (- x (sin x)) (- x (tan x)))))x = abs(x);
double code(double x) {
double tmp;
if (x <= 0.08) {
tmp = ((-0.009642857142857142 * pow(x, 4.0)) + ((0.00024107142857142857 * pow(x, 6.0)) + ((1.0 + (x * (x * 0.225))) + -1.0))) - 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.08d0) then
tmp = (((-0.009642857142857142d0) * (x ** 4.0d0)) + ((0.00024107142857142857d0 * (x ** 6.0d0)) + ((1.0d0 + (x * (x * 0.225d0))) + (-1.0d0)))) - 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.08) {
tmp = ((-0.009642857142857142 * Math.pow(x, 4.0)) + ((0.00024107142857142857 * Math.pow(x, 6.0)) + ((1.0 + (x * (x * 0.225))) + -1.0))) - 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.08: tmp = ((-0.009642857142857142 * math.pow(x, 4.0)) + ((0.00024107142857142857 * math.pow(x, 6.0)) + ((1.0 + (x * (x * 0.225))) + -1.0))) - 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.08) tmp = Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + Float64(Float64(0.00024107142857142857 * (x ^ 6.0)) + Float64(Float64(1.0 + Float64(x * Float64(x * 0.225))) + -1.0))) - 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.08) tmp = ((-0.009642857142857142 * (x ^ 4.0)) + ((0.00024107142857142857 * (x ^ 6.0)) + ((1.0 + (x * (x * 0.225))) + -1.0))) - 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.08], N[(N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.00024107142857142857 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + N[(x * N[(x * 0.225), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $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.08:\\
\;\;\;\;\left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + \left(\left(1 + x \cdot \left(x \cdot 0.225\right)\right) + -1\right)\right)\right) - 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\
\end{array}
\end{array}
if x < 0.0800000000000000017Initial program 37.8%
Taylor expanded in x around 0 64.6%
pow264.6%
*-commutative64.6%
associate-*r*64.6%
expm1-log1p-u64.6%
expm1-def64.6%
log1p-udef64.6%
add-exp-log64.6%
Applied egg-rr64.6%
if 0.0800000000000000017 < x Initial program 100.0%
Final simplification75.3%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.6) (+ (+ (* -0.009642857142857142 (pow x 4.0)) (* x (* x 0.225))) -0.5) (- 1.0 (/ (- (sin x) (tan x)) x))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.6) {
tmp = ((-0.009642857142857142 * pow(x, 4.0)) + (x * (x * 0.225))) + -0.5;
} else {
tmp = 1.0 - ((sin(x) - tan(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.6d0) then
tmp = (((-0.009642857142857142d0) * (x ** 4.0d0)) + (x * (x * 0.225d0))) + (-0.5d0)
else
tmp = 1.0d0 - ((sin(x) - tan(x)) / x)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 2.6) {
tmp = ((-0.009642857142857142 * Math.pow(x, 4.0)) + (x * (x * 0.225))) + -0.5;
} else {
tmp = 1.0 - ((Math.sin(x) - Math.tan(x)) / x);
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.6: tmp = ((-0.009642857142857142 * math.pow(x, 4.0)) + (x * (x * 0.225))) + -0.5 else: tmp = 1.0 - ((math.sin(x) - math.tan(x)) / x) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.6) tmp = Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + Float64(x * Float64(x * 0.225))) + -0.5); else tmp = Float64(1.0 - Float64(Float64(sin(x) - tan(x)) / x)); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 2.6) tmp = ((-0.009642857142857142 * (x ^ 4.0)) + (x * (x * 0.225))) + -0.5; else tmp = 1.0 - ((sin(x) - tan(x)) / x); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 2.6], N[(N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(x * 0.225), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(1.0 - N[(N[(N[Sin[x], $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.6:\\
\;\;\;\;\left(-0.009642857142857142 \cdot {x}^{4} + x \cdot \left(x \cdot 0.225\right)\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{\sin x - \tan x}{x}\\
\end{array}
\end{array}
if x < 2.60000000000000009Initial program 37.8%
Taylor expanded in x around 0 64.1%
sub-neg64.1%
fma-def64.1%
unpow264.1%
metadata-eval64.1%
Simplified64.1%
fma-udef64.1%
+-commutative64.1%
*-commutative64.1%
associate-*l*64.1%
Applied egg-rr64.1%
if 2.60000000000000009 < x Initial program 100.0%
Taylor expanded in x around inf 99.7%
associate--l+99.7%
sub-neg99.7%
*-lft-identity99.7%
metadata-eval99.7%
cancel-sign-sub-inv99.7%
distribute-lft-out--99.7%
mul-1-neg99.7%
remove-double-neg99.7%
*-commutative99.7%
associate-/r*99.7%
div-sub99.7%
Simplified99.7%
tan-quot99.7%
sub-neg99.7%
Applied egg-rr99.7%
sub-neg99.7%
Simplified99.7%
Final simplification74.9%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 0.03) (+ (+ (* -0.009642857142857142 (pow x 4.0)) (* x (* x 0.225))) -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)) + (x * (x * 0.225))) + -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)) + (x * (x * 0.225d0))) + (-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)) + (x * (x * 0.225))) + -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)) + (x * (x * 0.225))) + -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(x * Float64(x * 0.225))) + -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)) + (x * (x * 0.225))) + -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[(x * N[(x * 0.225), $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} + x \cdot \left(x \cdot 0.225\right)\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\
\end{array}
\end{array}
if x < 0.029999999999999999Initial program 37.8%
Taylor expanded in x around 0 64.1%
sub-neg64.1%
fma-def64.1%
unpow264.1%
metadata-eval64.1%
Simplified64.1%
fma-udef64.1%
+-commutative64.1%
*-commutative64.1%
associate-*l*64.1%
Applied egg-rr64.1%
if 0.029999999999999999 < x Initial program 100.0%
Final simplification75.0%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.8) (+ (+ (* -0.009642857142857142 (pow x 4.0)) (* x (* x 0.225))) -0.5) (/ 1.0 (/ 1.0 (/ x (- x (tan x)))))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.8) {
tmp = ((-0.009642857142857142 * pow(x, 4.0)) + (x * (x * 0.225))) + -0.5;
} else {
tmp = 1.0 / (1.0 / (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.8d0) then
tmp = (((-0.009642857142857142d0) * (x ** 4.0d0)) + (x * (x * 0.225d0))) + (-0.5d0)
else
tmp = 1.0d0 / (1.0d0 / (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.8) {
tmp = ((-0.009642857142857142 * Math.pow(x, 4.0)) + (x * (x * 0.225))) + -0.5;
} else {
tmp = 1.0 / (1.0 / (x / (x - Math.tan(x))));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.8: tmp = ((-0.009642857142857142 * math.pow(x, 4.0)) + (x * (x * 0.225))) + -0.5 else: tmp = 1.0 / (1.0 / (x / (x - math.tan(x)))) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.8) tmp = Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + Float64(x * Float64(x * 0.225))) + -0.5); else tmp = Float64(1.0 / Float64(1.0 / Float64(x / Float64(x - tan(x))))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 2.8) tmp = ((-0.009642857142857142 * (x ^ 4.0)) + (x * (x * 0.225))) + -0.5; else tmp = 1.0 / (1.0 / (x / (x - tan(x)))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 2.8], N[(N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(x * 0.225), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(1.0 / N[(1.0 / N[(x / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.8:\\
\;\;\;\;\left(-0.009642857142857142 \cdot {x}^{4} + x \cdot \left(x \cdot 0.225\right)\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{\frac{x}{x - \tan x}}}\\
\end{array}
\end{array}
if x < 2.7999999999999998Initial program 37.8%
Taylor expanded in x around 0 64.1%
sub-neg64.1%
fma-def64.1%
unpow264.1%
metadata-eval64.1%
Simplified64.1%
fma-udef64.1%
+-commutative64.1%
*-commutative64.1%
associate-*l*64.1%
Applied egg-rr64.1%
if 2.7999999999999998 < x Initial program 100.0%
clear-num100.0%
inv-pow100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
Taylor expanded in x around inf 98.4%
clear-num98.4%
inv-pow98.4%
Applied egg-rr98.4%
unpow-198.4%
Simplified98.4%
Final simplification74.5%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.25) (+ (* x (* x 0.225)) -0.5) (/ 1.0 (/ 1.0 (/ x (- x (tan x)))))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.25) {
tmp = (x * (x * 0.225)) + -0.5;
} else {
tmp = 1.0 / (1.0 / (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.25d0) then
tmp = (x * (x * 0.225d0)) + (-0.5d0)
else
tmp = 1.0d0 / (1.0d0 / (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.25) {
tmp = (x * (x * 0.225)) + -0.5;
} else {
tmp = 1.0 / (1.0 / (x / (x - Math.tan(x))));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.25: tmp = (x * (x * 0.225)) + -0.5 else: tmp = 1.0 / (1.0 / (x / (x - math.tan(x)))) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.25) tmp = Float64(Float64(x * Float64(x * 0.225)) + -0.5); else tmp = Float64(1.0 / Float64(1.0 / Float64(x / Float64(x - tan(x))))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 2.25) tmp = (x * (x * 0.225)) + -0.5; else tmp = 1.0 / (1.0 / (x / (x - tan(x)))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 2.25], N[(N[(x * N[(x * 0.225), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(1.0 / N[(1.0 / N[(x / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.25:\\
\;\;\;\;x \cdot \left(x \cdot 0.225\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{\frac{x}{x - \tan x}}}\\
\end{array}
\end{array}
if x < 2.25Initial program 37.8%
Taylor expanded in x around 0 65.2%
fma-neg65.2%
unpow265.2%
metadata-eval65.2%
Simplified65.2%
fma-udef65.2%
*-commutative65.2%
associate-*l*65.2%
Applied egg-rr65.2%
if 2.25 < x Initial program 100.0%
clear-num100.0%
inv-pow100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
Taylor expanded in x around inf 98.4%
clear-num98.4%
inv-pow98.4%
Applied egg-rr98.4%
unpow-198.4%
Simplified98.4%
Final simplification75.4%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.25) (+ (* x (* x 0.225)) -0.5) (/ x (- x (tan x)))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.25) {
tmp = (x * (x * 0.225)) + -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.25d0) then
tmp = (x * (x * 0.225d0)) + (-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.25) {
tmp = (x * (x * 0.225)) + -0.5;
} else {
tmp = x / (x - Math.tan(x));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.25: tmp = (x * (x * 0.225)) + -0.5 else: tmp = x / (x - math.tan(x)) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.25) tmp = Float64(Float64(x * Float64(x * 0.225)) + -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.25) tmp = (x * (x * 0.225)) + -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.25], N[(N[(x * N[(x * 0.225), $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.25:\\
\;\;\;\;x \cdot \left(x \cdot 0.225\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x - \tan x}\\
\end{array}
\end{array}
if x < 2.25Initial program 37.8%
Taylor expanded in x around 0 65.2%
fma-neg65.2%
unpow265.2%
metadata-eval65.2%
Simplified65.2%
fma-udef65.2%
*-commutative65.2%
associate-*l*65.2%
Applied egg-rr65.2%
if 2.25 < x Initial program 100.0%
Taylor expanded in x around inf 98.4%
Final simplification75.4%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.5) (+ (* x (* x 0.225)) -0.5) 1.0))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.5) {
tmp = (x * (x * 0.225)) + -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.5d0) then
tmp = (x * (x * 0.225d0)) + (-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.5) {
tmp = (x * (x * 0.225)) + -0.5;
} else {
tmp = 1.0;
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.5: tmp = (x * (x * 0.225)) + -0.5 else: tmp = 1.0 return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.5) tmp = Float64(Float64(x * Float64(x * 0.225)) + -0.5); else tmp = 1.0; end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 2.5) tmp = (x * (x * 0.225)) + -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.5], N[(N[(x * N[(x * 0.225), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], 1.0]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.5:\\
\;\;\;\;x \cdot \left(x \cdot 0.225\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 2.5Initial program 37.8%
Taylor expanded in x around 0 65.2%
fma-neg65.2%
unpow265.2%
metadata-eval65.2%
Simplified65.2%
fma-udef65.2%
*-commutative65.2%
associate-*l*65.2%
Applied egg-rr65.2%
if 2.5 < x Initial program 100.0%
Taylor expanded in x around inf 98.4%
Final simplification75.3%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 1.55) -0.5 1.0))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 1.55) {
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.55d0) 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.55) {
tmp = -0.5;
} else {
tmp = 1.0;
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 1.55: tmp = -0.5 else: tmp = 1.0 return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 1.55) 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.55) 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.55], -0.5, 1.0]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.55:\\
\;\;\;\;-0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 1.55000000000000004Initial program 37.8%
Taylor expanded in x around 0 63.3%
if 1.55000000000000004 < x Initial program 100.0%
Taylor expanded in x around inf 98.4%
Final simplification74.0%
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 56.7%
Taylor expanded in x around 0 44.5%
Final simplification44.5%
herbie shell --seed 2023293
(FPCore (x)
:name "sintan (problem 3.4.5)"
:precision binary64
(/ (- x (sin x)) (- x (tan x))))