
(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.082)
(-
(+
(* 0.225 (pow x 2.0))
(+
(* 0.00024107142857142857 (pow x 6.0))
(* -0.009642857142857142 (pow x 4.0))))
0.5)
(/ (- x (sin x)) (- x (tan x)))))x = abs(x);
double code(double x) {
double tmp;
if (x <= 0.082) {
tmp = ((0.225 * pow(x, 2.0)) + ((0.00024107142857142857 * pow(x, 6.0)) + (-0.009642857142857142 * pow(x, 4.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.082d0) then
tmp = ((0.225d0 * (x ** 2.0d0)) + ((0.00024107142857142857d0 * (x ** 6.0d0)) + ((-0.009642857142857142d0) * (x ** 4.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.082) {
tmp = ((0.225 * Math.pow(x, 2.0)) + ((0.00024107142857142857 * Math.pow(x, 6.0)) + (-0.009642857142857142 * Math.pow(x, 4.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.082: tmp = ((0.225 * math.pow(x, 2.0)) + ((0.00024107142857142857 * math.pow(x, 6.0)) + (-0.009642857142857142 * math.pow(x, 4.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.082) tmp = Float64(Float64(Float64(0.225 * (x ^ 2.0)) + Float64(Float64(0.00024107142857142857 * (x ^ 6.0)) + Float64(-0.009642857142857142 * (x ^ 4.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.082) tmp = ((0.225 * (x ^ 2.0)) + ((0.00024107142857142857 * (x ^ 6.0)) + (-0.009642857142857142 * (x ^ 4.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.082], N[(N[(N[(0.225 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.00024107142857142857 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $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.082:\\
\;\;\;\;\left(0.225 \cdot {x}^{2} + \left(0.00024107142857142857 \cdot {x}^{6} + -0.009642857142857142 \cdot {x}^{4}\right)\right) - 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\
\end{array}
\end{array}
if x < 0.0820000000000000034Initial program 33.9%
sub-neg33.9%
+-commutative33.9%
neg-sub033.9%
associate-+l-33.9%
sub0-neg33.9%
neg-mul-133.9%
sub-neg33.9%
+-commutative33.9%
neg-sub033.9%
associate-+l-33.9%
sub0-neg33.9%
neg-mul-133.9%
times-frac33.9%
metadata-eval33.9%
*-lft-identity33.9%
Simplified33.9%
Taylor expanded in x around 0 68.1%
if 0.0820000000000000034 < x Initial program 99.9%
Final simplification77.3%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.6) (+ (+ (* 0.225 (* x x)) (* -0.009642857142857142 (pow x 4.0))) -0.5) (+ 1.0 (/ (- (tan x) (sin x)) x))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.6) {
tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * pow(x, 4.0))) + -0.5;
} else {
tmp = 1.0 + ((tan(x) - sin(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.225d0 * (x * x)) + ((-0.009642857142857142d0) * (x ** 4.0d0))) + (-0.5d0)
else
tmp = 1.0d0 + ((tan(x) - sin(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.225 * (x * x)) + (-0.009642857142857142 * Math.pow(x, 4.0))) + -0.5;
} else {
tmp = 1.0 + ((Math.tan(x) - Math.sin(x)) / x);
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.6: tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * math.pow(x, 4.0))) + -0.5 else: tmp = 1.0 + ((math.tan(x) - math.sin(x)) / x) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.6) tmp = Float64(Float64(Float64(0.225 * Float64(x * x)) + Float64(-0.009642857142857142 * (x ^ 4.0))) + -0.5); else tmp = Float64(1.0 + Float64(Float64(tan(x) - sin(x)) / x)); 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.009642857142857142 * (x ^ 4.0))) + -0.5; else tmp = 1.0 + ((tan(x) - sin(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.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(1.0 + N[(N[(N[Tan[x], $MachinePrecision] - N[Sin[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.6:\\
\;\;\;\;\left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\tan x - \sin x}{x}\\
\end{array}
\end{array}
if x < 2.60000000000000009Initial program 34.2%
sub-neg34.2%
+-commutative34.2%
neg-sub034.2%
associate-+l-34.2%
sub0-neg34.2%
neg-mul-134.2%
sub-neg34.2%
+-commutative34.2%
neg-sub034.2%
associate-+l-34.2%
sub0-neg34.2%
neg-mul-134.2%
times-frac34.2%
metadata-eval34.2%
*-lft-identity34.2%
Simplified34.2%
clear-num34.2%
inv-pow34.2%
Applied egg-rr34.2%
Taylor expanded in x around 0 67.6%
sub-neg67.6%
fma-def67.6%
unpow267.6%
*-commutative67.6%
metadata-eval67.6%
Simplified67.6%
fma-udef67.6%
Applied egg-rr67.6%
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 100.0%
associate--l+100.0%
associate-*r/100.0%
associate-/r*100.0%
associate-*r/100.0%
div-sub100.0%
distribute-lft-out--100.0%
associate-*r/100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
sub-neg100.0%
quot-tan100.0%
Applied egg-rr100.0%
sub-neg100.0%
Simplified100.0%
Final simplification76.8%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 0.028) (+ (+ (* 0.225 (* x x)) (* -0.009642857142857142 (pow x 4.0))) -0.5) (/ (- x (sin x)) (- x (tan x)))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 0.028) {
tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * pow(x, 4.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.028d0) then
tmp = ((0.225d0 * (x * x)) + ((-0.009642857142857142d0) * (x ** 4.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.028) {
tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * Math.pow(x, 4.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.028: tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * math.pow(x, 4.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.028) tmp = Float64(Float64(Float64(0.225 * Float64(x * x)) + Float64(-0.009642857142857142 * (x ^ 4.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.028) tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * (x ^ 4.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.028], N[(N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(-0.009642857142857142 * N[Power[x, 4.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.028:\\
\;\;\;\;\left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\
\end{array}
\end{array}
if x < 0.0280000000000000006Initial program 33.9%
sub-neg33.9%
+-commutative33.9%
neg-sub033.9%
associate-+l-33.9%
sub0-neg33.9%
neg-mul-133.9%
sub-neg33.9%
+-commutative33.9%
neg-sub033.9%
associate-+l-33.9%
sub0-neg33.9%
neg-mul-133.9%
times-frac33.9%
metadata-eval33.9%
*-lft-identity33.9%
Simplified33.9%
clear-num33.9%
inv-pow33.9%
Applied egg-rr33.9%
Taylor expanded in x around 0 67.8%
sub-neg67.8%
fma-def67.8%
unpow267.8%
*-commutative67.8%
metadata-eval67.8%
Simplified67.8%
fma-udef67.8%
Applied egg-rr67.8%
if 0.0280000000000000006 < x Initial program 99.9%
Final simplification77.1%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.8) (+ (+ (* 0.225 (* x x)) (* -0.009642857142857142 (pow x 4.0))) -0.5) (/ (- x) (- (tan x) x))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.8) {
tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * pow(x, 4.0))) + -0.5;
} else {
tmp = -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.8d0) then
tmp = ((0.225d0 * (x * x)) + ((-0.009642857142857142d0) * (x ** 4.0d0))) + (-0.5d0)
else
tmp = -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.8) {
tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * Math.pow(x, 4.0))) + -0.5;
} else {
tmp = -x / (Math.tan(x) - x);
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.8: tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * math.pow(x, 4.0))) + -0.5 else: tmp = -x / (math.tan(x) - x) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.8) tmp = Float64(Float64(Float64(0.225 * Float64(x * x)) + Float64(-0.009642857142857142 * (x ^ 4.0))) + -0.5); else tmp = Float64(Float64(-x) / Float64(tan(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.009642857142857142 * (x ^ 4.0))) + -0.5; else tmp = -x / (tan(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[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[((-x) / N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.8:\\
\;\;\;\;\left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{\tan x - x}\\
\end{array}
\end{array}
if x < 2.7999999999999998Initial program 34.2%
sub-neg34.2%
+-commutative34.2%
neg-sub034.2%
associate-+l-34.2%
sub0-neg34.2%
neg-mul-134.2%
sub-neg34.2%
+-commutative34.2%
neg-sub034.2%
associate-+l-34.2%
sub0-neg34.2%
neg-mul-134.2%
times-frac34.2%
metadata-eval34.2%
*-lft-identity34.2%
Simplified34.2%
clear-num34.2%
inv-pow34.2%
Applied egg-rr34.2%
Taylor expanded in x around 0 67.6%
sub-neg67.6%
fma-def67.6%
unpow267.6%
*-commutative67.6%
metadata-eval67.6%
Simplified67.6%
fma-udef67.6%
Applied egg-rr67.6%
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%
add-cube-cbrt100.0%
*-un-lft-identity100.0%
prod-diff100.0%
*-commutative100.0%
*-un-lft-identity100.0%
fma-neg100.0%
add-cube-cbrt100.0%
*-commutative100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
+-commutative100.0%
fma-udef100.0%
*-rgt-identity100.0%
+-commutative100.0%
associate-+l+100.0%
sub-neg100.0%
associate-+l+100.0%
+-commutative100.0%
sub-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 98.8%
mul-1-neg98.8%
Simplified98.8%
Final simplification76.5%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.3) (+ (* 0.225 (* x x)) -0.5) (/ (- x) (- (tan x) x))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.3) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = -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.3d0) then
tmp = (0.225d0 * (x * x)) + (-0.5d0)
else
tmp = -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.3) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = -x / (Math.tan(x) - 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 / (math.tan(x) - 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(Float64(-x) / Float64(tan(x) - 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 / (tan(x) - 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[(N[Tan[x], $MachinePrecision] - x), $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}{\tan x - x}\\
\end{array}
\end{array}
if x < 2.2999999999999998Initial program 34.2%
sub-neg34.2%
+-commutative34.2%
neg-sub034.2%
associate-+l-34.2%
sub0-neg34.2%
neg-mul-134.2%
sub-neg34.2%
+-commutative34.2%
neg-sub034.2%
associate-+l-34.2%
sub0-neg34.2%
neg-mul-134.2%
times-frac34.2%
metadata-eval34.2%
*-lft-identity34.2%
Simplified34.2%
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 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%
add-cube-cbrt100.0%
*-un-lft-identity100.0%
prod-diff100.0%
*-commutative100.0%
*-un-lft-identity100.0%
fma-neg100.0%
add-cube-cbrt100.0%
*-commutative100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
+-commutative100.0%
fma-udef100.0%
*-rgt-identity100.0%
+-commutative100.0%
associate-+l+100.0%
sub-neg100.0%
associate-+l+100.0%
+-commutative100.0%
sub-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 98.8%
mul-1-neg98.8%
Simplified98.8%
Final simplification77.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 34.2%
sub-neg34.2%
+-commutative34.2%
neg-sub034.2%
associate-+l-34.2%
sub0-neg34.2%
neg-mul-134.2%
sub-neg34.2%
+-commutative34.2%
neg-sub034.2%
associate-+l-34.2%
sub0-neg34.2%
neg-mul-134.2%
times-frac34.2%
metadata-eval34.2%
*-lft-identity34.2%
Simplified34.2%
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 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 98.8%
Final simplification77.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 34.2%
sub-neg34.2%
+-commutative34.2%
neg-sub034.2%
associate-+l-34.2%
sub0-neg34.2%
neg-mul-134.2%
sub-neg34.2%
+-commutative34.2%
neg-sub034.2%
associate-+l-34.2%
sub0-neg34.2%
neg-mul-134.2%
times-frac34.2%
metadata-eval34.2%
*-lft-identity34.2%
Simplified34.2%
Taylor expanded in x around 0 67.0%
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 98.8%
Final simplification76.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 53.0%
sub-neg53.0%
+-commutative53.0%
neg-sub053.0%
associate-+l-53.0%
sub0-neg53.0%
neg-mul-153.0%
sub-neg53.0%
+-commutative53.0%
neg-sub053.0%
associate-+l-53.0%
sub0-neg53.0%
neg-mul-153.0%
times-frac53.0%
metadata-eval53.0%
*-lft-identity53.0%
Simplified53.0%
Taylor expanded in x around 0 48.3%
Final simplification48.3%
herbie shell --seed 2023258
(FPCore (x)
:name "sintan (problem 3.4.5)"
:precision binary64
(/ (- x (sin x)) (- x (tan x))))