
(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 8 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 (if (<= x 0.028) (+ (+ (* (pow x 4.0) -0.009642857142857142) (* 0.225 (* x x))) -0.5) (pow (/ (- (tan x) x) (- (sin x) x)) -1.0)))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 0.028) {
tmp = ((pow(x, 4.0) * -0.009642857142857142) + (0.225 * (x * x))) + -0.5;
} else {
tmp = pow(((tan(x) - x) / (sin(x) - x)), -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 <= 0.028d0) then
tmp = (((x ** 4.0d0) * (-0.009642857142857142d0)) + (0.225d0 * (x * x))) + (-0.5d0)
else
tmp = ((tan(x) - x) / (sin(x) - x)) ** (-1.0d0)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 0.028) {
tmp = ((Math.pow(x, 4.0) * -0.009642857142857142) + (0.225 * (x * x))) + -0.5;
} else {
tmp = Math.pow(((Math.tan(x) - x) / (Math.sin(x) - x)), -1.0);
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 0.028: tmp = ((math.pow(x, 4.0) * -0.009642857142857142) + (0.225 * (x * x))) + -0.5 else: tmp = math.pow(((math.tan(x) - x) / (math.sin(x) - x)), -1.0) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 0.028) tmp = Float64(Float64(Float64((x ^ 4.0) * -0.009642857142857142) + Float64(0.225 * Float64(x * x))) + -0.5); else tmp = Float64(Float64(tan(x) - x) / Float64(sin(x) - x)) ^ -1.0; end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 0.028) tmp = (((x ^ 4.0) * -0.009642857142857142) + (0.225 * (x * x))) + -0.5; else tmp = ((tan(x) - x) / (sin(x) - x)) ^ -1.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 0.028], N[(N[(N[(N[Power[x, 4.0], $MachinePrecision] * -0.009642857142857142), $MachinePrecision] + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[Power[N[(N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision] / N[(N[Sin[x], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.028:\\
\;\;\;\;\left({x}^{4} \cdot -0.009642857142857142 + 0.225 \cdot \left(x \cdot x\right)\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\tan x - x}{\sin x - x}\right)}^{-1}\\
\end{array}
\end{array}
if x < 0.0280000000000000006Initial program 29.6%
sub-neg29.6%
+-commutative29.6%
neg-sub029.6%
associate-+l-29.6%
sub0-neg29.6%
neg-mul-129.6%
sub-neg29.6%
+-commutative29.6%
neg-sub029.6%
associate-+l-29.6%
sub0-neg29.6%
neg-mul-129.6%
times-frac29.6%
metadata-eval29.6%
*-lft-identity29.6%
Simplified29.6%
clear-num29.6%
inv-pow29.6%
Applied egg-rr29.6%
Taylor expanded in x around 0 71.2%
sub-neg71.2%
fma-def71.2%
unpow271.2%
*-commutative71.2%
metadata-eval71.2%
Simplified71.2%
fma-udef71.2%
+-commutative71.2%
Applied egg-rr71.2%
if 0.0280000000000000006 < x Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
neg-sub099.9%
associate-+l-99.9%
sub0-neg99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
neg-sub099.9%
associate-+l-99.9%
sub0-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
*-lft-identity99.9%
Simplified99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
Final simplification78.6%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 0.028) (+ (+ (* (pow x 4.0) -0.009642857142857142) (* 0.225 (* x x))) -0.5) (/ (- x (sin x)) (- x (tan x)))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 0.028) {
tmp = ((pow(x, 4.0) * -0.009642857142857142) + (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.028d0) then
tmp = (((x ** 4.0d0) * (-0.009642857142857142d0)) + (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.028) {
tmp = ((Math.pow(x, 4.0) * -0.009642857142857142) + (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.028: tmp = ((math.pow(x, 4.0) * -0.009642857142857142) + (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.028) tmp = Float64(Float64(Float64((x ^ 4.0) * -0.009642857142857142) + 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.028) tmp = (((x ^ 4.0) * -0.009642857142857142) + (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.028], N[(N[(N[(N[Power[x, 4.0], $MachinePrecision] * -0.009642857142857142), $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.028:\\
\;\;\;\;\left({x}^{4} \cdot -0.009642857142857142 + 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.0280000000000000006Initial program 29.6%
sub-neg29.6%
+-commutative29.6%
neg-sub029.6%
associate-+l-29.6%
sub0-neg29.6%
neg-mul-129.6%
sub-neg29.6%
+-commutative29.6%
neg-sub029.6%
associate-+l-29.6%
sub0-neg29.6%
neg-mul-129.6%
times-frac29.6%
metadata-eval29.6%
*-lft-identity29.6%
Simplified29.6%
clear-num29.6%
inv-pow29.6%
Applied egg-rr29.6%
Taylor expanded in x around 0 71.2%
sub-neg71.2%
fma-def71.2%
unpow271.2%
*-commutative71.2%
metadata-eval71.2%
Simplified71.2%
fma-udef71.2%
+-commutative71.2%
Applied egg-rr71.2%
if 0.0280000000000000006 < x Initial program 99.9%
Final simplification78.6%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.8) (+ (+ (* (pow x 4.0) -0.009642857142857142) (* 0.225 (* x x))) -0.5) (/ x (- x (tan x)))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.8) {
tmp = ((pow(x, 4.0) * -0.009642857142857142) + (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.8d0) then
tmp = (((x ** 4.0d0) * (-0.009642857142857142d0)) + (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.8) {
tmp = ((Math.pow(x, 4.0) * -0.009642857142857142) + (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.8: tmp = ((math.pow(x, 4.0) * -0.009642857142857142) + (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.8) tmp = Float64(Float64(Float64((x ^ 4.0) * -0.009642857142857142) + 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.8) tmp = (((x ^ 4.0) * -0.009642857142857142) + (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.8], N[(N[(N[(N[Power[x, 4.0], $MachinePrecision] * -0.009642857142857142), $MachinePrecision] + N[(0.225 * N[(x * x), $MachinePrecision]), $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.8:\\
\;\;\;\;\left({x}^{4} \cdot -0.009642857142857142 + 0.225 \cdot \left(x \cdot x\right)\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x - \tan x}\\
\end{array}
\end{array}
if x < 2.7999999999999998Initial program 29.9%
sub-neg29.9%
+-commutative29.9%
neg-sub029.9%
associate-+l-29.9%
sub0-neg29.9%
neg-mul-129.9%
sub-neg29.9%
+-commutative29.9%
neg-sub029.9%
associate-+l-29.9%
sub0-neg29.9%
neg-mul-129.9%
times-frac29.9%
metadata-eval29.9%
*-lft-identity29.9%
Simplified29.9%
clear-num30.0%
inv-pow30.0%
Applied egg-rr30.0%
Taylor expanded in x around 0 71.1%
sub-neg71.1%
fma-def71.1%
unpow271.1%
*-commutative71.1%
metadata-eval71.1%
Simplified71.1%
fma-udef71.1%
+-commutative71.1%
Applied egg-rr71.1%
if 2.7999999999999998 < x Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 99.6%
neg-mul-199.6%
Simplified99.6%
frac-2neg99.6%
div-inv99.3%
remove-double-neg99.3%
sub-neg99.3%
distribute-neg-in99.3%
remove-double-neg99.3%
Applied egg-rr99.3%
associate-*r/99.6%
*-rgt-identity99.6%
+-commutative99.6%
sub-neg99.6%
Simplified99.6%
Final simplification78.3%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.25) (+ -0.5 (+ -1.0 (+ (* 0.225 (* x x)) 1.0))) (/ x (- x (tan x)))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.25) {
tmp = -0.5 + (-1.0 + ((0.225 * (x * x)) + 1.0));
} 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 = (-0.5d0) + ((-1.0d0) + ((0.225d0 * (x * x)) + 1.0d0))
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 = -0.5 + (-1.0 + ((0.225 * (x * x)) + 1.0));
} else {
tmp = x / (x - Math.tan(x));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.25: tmp = -0.5 + (-1.0 + ((0.225 * (x * x)) + 1.0)) else: tmp = x / (x - math.tan(x)) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.25) tmp = Float64(-0.5 + Float64(-1.0 + Float64(Float64(0.225 * Float64(x * x)) + 1.0))); 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 = -0.5 + (-1.0 + ((0.225 * (x * x)) + 1.0)); 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[(-0.5 + N[(-1.0 + N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $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:\\
\;\;\;\;-0.5 + \left(-1 + \left(0.225 \cdot \left(x \cdot x\right) + 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x - \tan x}\\
\end{array}
\end{array}
if x < 2.25Initial program 29.9%
sub-neg29.9%
+-commutative29.9%
neg-sub029.9%
associate-+l-29.9%
sub0-neg29.9%
neg-mul-129.9%
sub-neg29.9%
+-commutative29.9%
neg-sub029.9%
associate-+l-29.9%
sub0-neg29.9%
neg-mul-129.9%
times-frac29.9%
metadata-eval29.9%
*-lft-identity29.9%
Simplified29.9%
Taylor expanded in x around 0 72.1%
fma-neg72.1%
unpow272.1%
metadata-eval72.1%
Simplified72.1%
fma-udef72.1%
Applied egg-rr72.1%
expm1-log1p-u72.1%
expm1-udef72.1%
Applied egg-rr72.1%
log1p-udef72.1%
add-exp-log72.1%
+-commutative72.1%
Applied egg-rr72.1%
if 2.25 < x Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 99.6%
neg-mul-199.6%
Simplified99.6%
frac-2neg99.6%
div-inv99.3%
remove-double-neg99.3%
sub-neg99.3%
distribute-neg-in99.3%
remove-double-neg99.3%
Applied egg-rr99.3%
associate-*r/99.6%
*-rgt-identity99.6%
+-commutative99.6%
sub-neg99.6%
Simplified99.6%
Final simplification79.1%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.6) (+ -0.5 (+ -1.0 (+ (* 0.225 (* x x)) 1.0))) 1.0))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.6) {
tmp = -0.5 + (-1.0 + ((0.225 * (x * x)) + 1.0));
} 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.5d0) + ((-1.0d0) + ((0.225d0 * (x * x)) + 1.0d0))
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.5 + (-1.0 + ((0.225 * (x * x)) + 1.0));
} else {
tmp = 1.0;
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.6: tmp = -0.5 + (-1.0 + ((0.225 * (x * x)) + 1.0)) else: tmp = 1.0 return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.6) tmp = Float64(-0.5 + Float64(-1.0 + Float64(Float64(0.225 * Float64(x * x)) + 1.0))); 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.5 + (-1.0 + ((0.225 * (x * x)) + 1.0)); 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[(-0.5 + N[(-1.0 + N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.6:\\
\;\;\;\;-0.5 + \left(-1 + \left(0.225 \cdot \left(x \cdot x\right) + 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 2.60000000000000009Initial program 29.9%
sub-neg29.9%
+-commutative29.9%
neg-sub029.9%
associate-+l-29.9%
sub0-neg29.9%
neg-mul-129.9%
sub-neg29.9%
+-commutative29.9%
neg-sub029.9%
associate-+l-29.9%
sub0-neg29.9%
neg-mul-129.9%
times-frac29.9%
metadata-eval29.9%
*-lft-identity29.9%
Simplified29.9%
Taylor expanded in x around 0 72.1%
fma-neg72.1%
unpow272.1%
metadata-eval72.1%
Simplified72.1%
fma-udef72.1%
Applied egg-rr72.1%
expm1-log1p-u72.1%
expm1-udef72.1%
Applied egg-rr72.1%
log1p-udef72.1%
add-exp-log72.1%
+-commutative72.1%
Applied egg-rr72.1%
if 2.60000000000000009 < x Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 99.6%
Final simplification79.1%
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 29.9%
sub-neg29.9%
+-commutative29.9%
neg-sub029.9%
associate-+l-29.9%
sub0-neg29.9%
neg-mul-129.9%
sub-neg29.9%
+-commutative29.9%
neg-sub029.9%
associate-+l-29.9%
sub0-neg29.9%
neg-mul-129.9%
times-frac29.9%
metadata-eval29.9%
*-lft-identity29.9%
Simplified29.9%
Taylor expanded in x around 0 72.1%
fma-neg72.1%
unpow272.1%
metadata-eval72.1%
Simplified72.1%
fma-udef72.1%
Applied egg-rr72.1%
if 2.60000000000000009 < x Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 99.6%
Final simplification79.1%
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 29.9%
sub-neg29.9%
+-commutative29.9%
neg-sub029.9%
associate-+l-29.9%
sub0-neg29.9%
neg-mul-129.9%
sub-neg29.9%
+-commutative29.9%
neg-sub029.9%
associate-+l-29.9%
sub0-neg29.9%
neg-mul-129.9%
times-frac29.9%
metadata-eval29.9%
*-lft-identity29.9%
Simplified29.9%
Taylor expanded in x around 0 70.8%
if 1.6000000000000001 < x Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 99.6%
Final simplification78.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 47.7%
sub-neg47.7%
+-commutative47.7%
neg-sub047.7%
associate-+l-47.7%
sub0-neg47.7%
neg-mul-147.7%
sub-neg47.7%
+-commutative47.7%
neg-sub047.7%
associate-+l-47.7%
sub0-neg47.7%
neg-mul-147.7%
times-frac47.7%
metadata-eval47.7%
*-lft-identity47.7%
Simplified47.7%
Taylor expanded in x around 0 53.2%
Final simplification53.2%
herbie shell --seed 2023243
(FPCore (x)
:name "sintan (problem 3.4.5)"
:precision binary64
(/ (- x (sin x)) (- x (tan x))))