
(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
(let* ((t_0 (- (tan x) x)))
(if (<= x 0.0058)
(+ (* 0.225 (* x x)) -0.5)
(- (/ (sin x) t_0) (/ x t_0)))))x = abs(x);
double code(double x) {
double t_0 = tan(x) - x;
double tmp;
if (x <= 0.0058) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = (sin(x) / t_0) - (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 = tan(x) - x
if (x <= 0.0058d0) then
tmp = (0.225d0 * (x * x)) + (-0.5d0)
else
tmp = (sin(x) / t_0) - (x / t_0)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double t_0 = Math.tan(x) - x;
double tmp;
if (x <= 0.0058) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = (Math.sin(x) / t_0) - (x / t_0);
}
return tmp;
}
x = abs(x) def code(x): t_0 = math.tan(x) - x tmp = 0 if x <= 0.0058: tmp = (0.225 * (x * x)) + -0.5 else: tmp = (math.sin(x) / t_0) - (x / t_0) return tmp
x = abs(x) function code(x) t_0 = Float64(tan(x) - x) tmp = 0.0 if (x <= 0.0058) tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5); else tmp = Float64(Float64(sin(x) / t_0) - Float64(x / t_0)); end return tmp end
x = abs(x) function tmp_2 = code(x) t_0 = tan(x) - x; tmp = 0.0; if (x <= 0.0058) tmp = (0.225 * (x * x)) + -0.5; else tmp = (sin(x) / t_0) - (x / t_0); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
code[x_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[x, 0.0058], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(N[(N[Sin[x], $MachinePrecision] / t$95$0), $MachinePrecision] - N[(x / t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := \tan x - x\\
\mathbf{if}\;x \leq 0.0058:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin x}{t_0} - \frac{x}{t_0}\\
\end{array}
\end{array}
if x < 0.0058Initial program 34.1%
sub-neg34.1%
+-commutative34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
sub-neg34.1%
+-commutative34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
times-frac34.1%
metadata-eval34.1%
*-lft-identity34.1%
Simplified34.1%
Taylor expanded in x around 0 68.4%
fma-neg68.4%
unpow268.4%
metadata-eval68.4%
Simplified68.4%
fma-udef68.4%
Applied egg-rr68.4%
if 0.0058 < 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%
div-sub99.9%
Applied egg-rr99.9%
Final simplification75.3%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 0.0044) (+ (* 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.0044) {
tmp = (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.0044d0) then
tmp = (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.0044) {
tmp = (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.0044: tmp = (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.0044) tmp = Float64(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.0044) tmp = (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.0044], N[(N[(0.225 * N[(x * x), $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.0044:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\tan x - x}{\sin x - x}\right)}^{-1}\\
\end{array}
\end{array}
if x < 0.00440000000000000027Initial program 34.1%
sub-neg34.1%
+-commutative34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
sub-neg34.1%
+-commutative34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
times-frac34.1%
metadata-eval34.1%
*-lft-identity34.1%
Simplified34.1%
Taylor expanded in x around 0 68.4%
fma-neg68.4%
unpow268.4%
metadata-eval68.4%
Simplified68.4%
fma-udef68.4%
Applied egg-rr68.4%
if 0.00440000000000000027 < 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 simplification75.3%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 0.0044) (+ (* 0.225 (* x x)) -0.5) (/ (- x (sin x)) (- x (tan x)))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 0.0044) {
tmp = (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.0044d0) then
tmp = (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.0044) {
tmp = (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.0044: tmp = (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.0044) tmp = Float64(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.0044) tmp = (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.0044], N[(N[(0.225 * N[(x * x), $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.0044:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\
\end{array}
\end{array}
if x < 0.00440000000000000027Initial program 34.1%
sub-neg34.1%
+-commutative34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
sub-neg34.1%
+-commutative34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
times-frac34.1%
metadata-eval34.1%
*-lft-identity34.1%
Simplified34.1%
Taylor expanded in x around 0 68.4%
fma-neg68.4%
unpow268.4%
metadata-eval68.4%
Simplified68.4%
fma-udef68.4%
Applied egg-rr68.4%
if 0.00440000000000000027 < x Initial program 99.9%
Final simplification75.3%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.2) (+ (* 0.225 (* x x)) -0.5) (/ (- x) (+ x (- (tan x) (+ x x))))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.2) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = -x / (x + (tan(x) - (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.2d0) then
tmp = (0.225d0 * (x * x)) + (-0.5d0)
else
tmp = -x / (x + (tan(x) - (x + x)))
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 2.2) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = -x / (x + (Math.tan(x) - (x + x)));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.2: tmp = (0.225 * (x * x)) + -0.5 else: tmp = -x / (x + (math.tan(x) - (x + x))) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.2) tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5); else tmp = Float64(Float64(-x) / Float64(x + Float64(tan(x) - Float64(x + x)))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 2.2) tmp = (0.225 * (x * x)) + -0.5; else tmp = -x / (x + (tan(x) - (x + x))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 2.2], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[((-x) / N[(x + N[(N[Tan[x], $MachinePrecision] - N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.2:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{x + \left(\tan x - \left(x + x\right)\right)}\\
\end{array}
\end{array}
if x < 2.2000000000000002Initial program 34.1%
sub-neg34.1%
+-commutative34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
sub-neg34.1%
+-commutative34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
times-frac34.1%
metadata-eval34.1%
*-lft-identity34.1%
Simplified34.1%
Taylor expanded in x around 0 68.4%
fma-neg68.4%
unpow268.4%
metadata-eval68.4%
Simplified68.4%
fma-udef68.4%
Applied egg-rr68.4%
if 2.2000000000000002 < 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%
Taylor expanded in x around inf 95.0%
neg-mul-195.0%
Simplified95.0%
add-sqr-sqrt50.9%
*-un-lft-identity50.9%
prod-diff50.9%
*-commutative50.9%
*-un-lft-identity50.9%
fma-neg50.9%
add-sqr-sqrt95.0%
*-commutative95.0%
*-un-lft-identity95.0%
Applied egg-rr95.0%
+-commutative95.0%
fma-udef95.0%
*-rgt-identity95.0%
+-commutative95.0%
associate-+l+95.0%
sub-neg95.0%
associate-+l+95.0%
+-commutative95.0%
sub-neg95.0%
unsub-neg95.0%
Simplified95.0%
associate--l-95.0%
sub-neg95.0%
Applied egg-rr95.0%
unsub-neg95.0%
Simplified95.0%
Final simplification74.2%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.2) (+ (* 0.225 (* x x)) -0.5) (/ x (- x (tan x)))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.2) {
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.2d0) 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.2) {
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.2: 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.2) 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.2) 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.2], 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.2:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x - \tan x}\\
\end{array}
\end{array}
if x < 2.2000000000000002Initial program 34.1%
sub-neg34.1%
+-commutative34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
sub-neg34.1%
+-commutative34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
times-frac34.1%
metadata-eval34.1%
*-lft-identity34.1%
Simplified34.1%
Taylor expanded in x around 0 68.4%
fma-neg68.4%
unpow268.4%
metadata-eval68.4%
Simplified68.4%
fma-udef68.4%
Applied egg-rr68.4%
if 2.2000000000000002 < 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%
Taylor expanded in x around inf 95.0%
neg-mul-195.0%
Simplified95.0%
frac-2neg95.0%
div-inv94.9%
remove-double-neg94.9%
sub-neg94.9%
distribute-neg-in94.9%
remove-double-neg94.9%
Applied egg-rr94.9%
associate-*r/95.0%
*-rgt-identity95.0%
+-commutative95.0%
unsub-neg95.0%
Simplified95.0%
Final simplification74.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 34.1%
sub-neg34.1%
+-commutative34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
sub-neg34.1%
+-commutative34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
times-frac34.1%
metadata-eval34.1%
*-lft-identity34.1%
Simplified34.1%
Taylor expanded in x around 0 68.4%
fma-neg68.4%
unpow268.4%
metadata-eval68.4%
Simplified68.4%
fma-udef68.4%
Applied egg-rr68.4%
if 2.60000000000000009 < 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%
Taylor expanded in x around inf 95.0%
Final simplification74.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 34.1%
sub-neg34.1%
+-commutative34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
sub-neg34.1%
+-commutative34.1%
neg-sub034.1%
associate-+l-34.1%
sub0-neg34.1%
neg-mul-134.1%
times-frac34.1%
metadata-eval34.1%
*-lft-identity34.1%
Simplified34.1%
Taylor expanded in x around 0 67.1%
if 1.6000000000000001 < 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%
Taylor expanded in x around inf 95.0%
Final simplification73.2%
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 48.5%
sub-neg48.5%
+-commutative48.5%
neg-sub048.5%
associate-+l-48.5%
sub0-neg48.5%
neg-mul-148.5%
sub-neg48.5%
+-commutative48.5%
neg-sub048.5%
associate-+l-48.5%
sub0-neg48.5%
neg-mul-148.5%
times-frac48.5%
metadata-eval48.5%
*-lft-identity48.5%
Simplified48.5%
Taylor expanded in x around 0 52.8%
Final simplification52.8%
herbie shell --seed 2023238
(FPCore (x)
:name "sintan (problem 3.4.5)"
:precision binary64
(/ (- x (sin x)) (- x (tan x))))