
(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 9 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.086)
(-
(+
(* 0.225 (pow x 2.0))
(+
(* -0.009642857142857142 (pow x 4.0))
(* 0.00024107142857142857 (pow x 6.0))))
0.5)
(/ (- x (sin x)) (- x (tan x)))))x = abs(x);
double code(double x) {
double tmp;
if (x <= 0.086) {
tmp = ((0.225 * pow(x, 2.0)) + ((-0.009642857142857142 * pow(x, 4.0)) + (0.00024107142857142857 * pow(x, 6.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.086d0) then
tmp = ((0.225d0 * (x ** 2.0d0)) + (((-0.009642857142857142d0) * (x ** 4.0d0)) + (0.00024107142857142857d0 * (x ** 6.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.086) {
tmp = ((0.225 * Math.pow(x, 2.0)) + ((-0.009642857142857142 * Math.pow(x, 4.0)) + (0.00024107142857142857 * Math.pow(x, 6.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.086: tmp = ((0.225 * math.pow(x, 2.0)) + ((-0.009642857142857142 * math.pow(x, 4.0)) + (0.00024107142857142857 * math.pow(x, 6.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.086) tmp = Float64(Float64(Float64(0.225 * (x ^ 2.0)) + Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + Float64(0.00024107142857142857 * (x ^ 6.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.086) tmp = ((0.225 * (x ^ 2.0)) + ((-0.009642857142857142 * (x ^ 4.0)) + (0.00024107142857142857 * (x ^ 6.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.086], N[(N[(N[(0.225 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.00024107142857142857 * N[Power[x, 6.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.086:\\
\;\;\;\;\left(0.225 \cdot {x}^{2} + \left(-0.009642857142857142 \cdot {x}^{4} + 0.00024107142857142857 \cdot {x}^{6}\right)\right) - 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\
\end{array}
\end{array}
if x < 0.085999999999999993Initial program 33.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
times-frac33.8%
metadata-eval33.8%
*-lft-identity33.8%
Simplified33.8%
Taylor expanded in x around 0 67.4%
if 0.085999999999999993 < x Initial program 99.9%
Final simplification74.5%
NOTE: x should be positive before calling this function
(FPCore (x)
:precision binary64
(let* ((t_0 (- (sin x) x)))
(if (<= x 0.032)
(+ (+ (* -0.009642857142857142 (pow x 4.0)) -0.5) (* 0.225 (* x x)))
(/ 1.0 (- (/ (tan x) t_0) (/ x t_0))))))x = abs(x);
double code(double x) {
double t_0 = sin(x) - x;
double tmp;
if (x <= 0.032) {
tmp = ((-0.009642857142857142 * pow(x, 4.0)) + -0.5) + (0.225 * (x * x));
} else {
tmp = 1.0 / ((tan(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 = sin(x) - x
if (x <= 0.032d0) then
tmp = (((-0.009642857142857142d0) * (x ** 4.0d0)) + (-0.5d0)) + (0.225d0 * (x * x))
else
tmp = 1.0d0 / ((tan(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.sin(x) - x;
double tmp;
if (x <= 0.032) {
tmp = ((-0.009642857142857142 * Math.pow(x, 4.0)) + -0.5) + (0.225 * (x * x));
} else {
tmp = 1.0 / ((Math.tan(x) / t_0) - (x / t_0));
}
return tmp;
}
x = abs(x) def code(x): t_0 = math.sin(x) - x tmp = 0 if x <= 0.032: tmp = ((-0.009642857142857142 * math.pow(x, 4.0)) + -0.5) + (0.225 * (x * x)) else: tmp = 1.0 / ((math.tan(x) / t_0) - (x / t_0)) return tmp
x = abs(x) function code(x) t_0 = Float64(sin(x) - x) tmp = 0.0 if (x <= 0.032) tmp = Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + -0.5) + Float64(0.225 * Float64(x * x))); else tmp = Float64(1.0 / Float64(Float64(tan(x) / t_0) - Float64(x / t_0))); end return tmp end
x = abs(x) function tmp_2 = code(x) t_0 = sin(x) - x; tmp = 0.0; if (x <= 0.032) tmp = ((-0.009642857142857142 * (x ^ 4.0)) + -0.5) + (0.225 * (x * x)); else tmp = 1.0 / ((tan(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[Sin[x], $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[x, 0.032], N[(N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision] + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[Tan[x], $MachinePrecision] / t$95$0), $MachinePrecision] - N[(x / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := \sin x - x\\
\mathbf{if}\;x \leq 0.032:\\
\;\;\;\;\left(-0.009642857142857142 \cdot {x}^{4} + -0.5\right) + 0.225 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\tan x}{t_0} - \frac{x}{t_0}}\\
\end{array}
\end{array}
if x < 0.032000000000000001Initial program 33.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
times-frac33.8%
metadata-eval33.8%
*-lft-identity33.8%
Simplified33.8%
Taylor expanded in x around 0 67.0%
associate--l+67.0%
fma-def67.0%
unpow267.0%
fma-neg67.0%
metadata-eval67.0%
Simplified67.0%
Taylor expanded in x around 0 67.0%
fma-udef67.0%
sub-neg67.0%
metadata-eval67.0%
associate-+l+67.0%
+-commutative67.0%
+-commutative67.0%
associate-+r+67.0%
Applied egg-rr67.0%
if 0.032000000000000001 < 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%
sub-div99.9%
clear-num99.9%
Applied egg-rr99.9%
div-sub99.9%
Applied egg-rr99.9%
Final simplification74.2%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 0.028) (+ (+ (* -0.009642857142857142 (pow x 4.0)) -0.5) (* 0.225 (* x x))) (/ 1.0 (/ (- (tan x) x) (- (sin x) x)))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 0.028) {
tmp = ((-0.009642857142857142 * pow(x, 4.0)) + -0.5) + (0.225 * (x * x));
} else {
tmp = 1.0 / ((tan(x) - 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 <= 0.028d0) then
tmp = (((-0.009642857142857142d0) * (x ** 4.0d0)) + (-0.5d0)) + (0.225d0 * (x * x))
else
tmp = 1.0d0 / ((tan(x) - x) / (sin(x) - 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.009642857142857142 * Math.pow(x, 4.0)) + -0.5) + (0.225 * (x * x));
} else {
tmp = 1.0 / ((Math.tan(x) - x) / (Math.sin(x) - x));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 0.028: tmp = ((-0.009642857142857142 * math.pow(x, 4.0)) + -0.5) + (0.225 * (x * x)) else: tmp = 1.0 / ((math.tan(x) - x) / (math.sin(x) - x)) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 0.028) tmp = Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + -0.5) + Float64(0.225 * Float64(x * x))); else tmp = Float64(1.0 / Float64(Float64(tan(x) - x) / Float64(sin(x) - x))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 0.028) tmp = ((-0.009642857142857142 * (x ^ 4.0)) + -0.5) + (0.225 * (x * x)); else tmp = 1.0 / ((tan(x) - x) / (sin(x) - 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.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision] + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision] / N[(N[Sin[x], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.028:\\
\;\;\;\;\left(-0.009642857142857142 \cdot {x}^{4} + -0.5\right) + 0.225 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\tan x - x}{\sin x - x}}\\
\end{array}
\end{array}
if x < 0.0280000000000000006Initial program 33.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
times-frac33.8%
metadata-eval33.8%
*-lft-identity33.8%
Simplified33.8%
Taylor expanded in x around 0 67.0%
associate--l+67.0%
fma-def67.0%
unpow267.0%
fma-neg67.0%
metadata-eval67.0%
Simplified67.0%
Taylor expanded in x around 0 67.0%
fma-udef67.0%
sub-neg67.0%
metadata-eval67.0%
associate-+l+67.0%
+-commutative67.0%
+-commutative67.0%
associate-+r+67.0%
Applied egg-rr67.0%
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%
div-sub99.9%
Applied egg-rr99.9%
sub-div99.9%
clear-num99.9%
Applied egg-rr99.9%
Final simplification74.2%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 0.028) (+ (+ (* -0.009642857142857142 (pow x 4.0)) -0.5) (* 0.225 (* x x))) (/ (- x (sin x)) (- x (tan x)))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 0.028) {
tmp = ((-0.009642857142857142 * pow(x, 4.0)) + -0.5) + (0.225 * (x * x));
} 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.009642857142857142d0) * (x ** 4.0d0)) + (-0.5d0)) + (0.225d0 * (x * x))
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.009642857142857142 * Math.pow(x, 4.0)) + -0.5) + (0.225 * (x * x));
} 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.009642857142857142 * math.pow(x, 4.0)) + -0.5) + (0.225 * (x * x)) 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.009642857142857142 * (x ^ 4.0)) + -0.5) + Float64(0.225 * Float64(x * x))); 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.009642857142857142 * (x ^ 4.0)) + -0.5) + (0.225 * (x * x)); 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.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision] + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $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.009642857142857142 \cdot {x}^{4} + -0.5\right) + 0.225 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\
\end{array}
\end{array}
if x < 0.0280000000000000006Initial program 33.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
times-frac33.8%
metadata-eval33.8%
*-lft-identity33.8%
Simplified33.8%
Taylor expanded in x around 0 67.0%
associate--l+67.0%
fma-def67.0%
unpow267.0%
fma-neg67.0%
metadata-eval67.0%
Simplified67.0%
Taylor expanded in x around 0 67.0%
fma-udef67.0%
sub-neg67.0%
metadata-eval67.0%
associate-+l+67.0%
+-commutative67.0%
+-commutative67.0%
associate-+r+67.0%
Applied egg-rr67.0%
if 0.0280000000000000006 < x Initial program 99.9%
Final simplification74.2%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 3.1) (+ (+ (* -0.009642857142857142 (pow x 4.0)) -0.5) (* 0.225 (* x x))) (- (/ 3.0 (* x x)) -1.0)))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 3.1) {
tmp = ((-0.009642857142857142 * pow(x, 4.0)) + -0.5) + (0.225 * (x * x));
} else {
tmp = (3.0 / (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 <= 3.1d0) then
tmp = (((-0.009642857142857142d0) * (x ** 4.0d0)) + (-0.5d0)) + (0.225d0 * (x * x))
else
tmp = (3.0d0 / (x * x)) - (-1.0d0)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 3.1) {
tmp = ((-0.009642857142857142 * Math.pow(x, 4.0)) + -0.5) + (0.225 * (x * x));
} else {
tmp = (3.0 / (x * x)) - -1.0;
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 3.1: tmp = ((-0.009642857142857142 * math.pow(x, 4.0)) + -0.5) + (0.225 * (x * x)) else: tmp = (3.0 / (x * x)) - -1.0 return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 3.1) tmp = Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + -0.5) + Float64(0.225 * Float64(x * x))); else tmp = Float64(Float64(3.0 / Float64(x * x)) - -1.0); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 3.1) tmp = ((-0.009642857142857142 * (x ^ 4.0)) + -0.5) + (0.225 * (x * x)); else tmp = (3.0 / (x * x)) - -1.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 3.1], N[(N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision] + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(3.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.1:\\
\;\;\;\;\left(-0.009642857142857142 \cdot {x}^{4} + -0.5\right) + 0.225 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{3}{x \cdot x} - -1\\
\end{array}
\end{array}
if x < 3.10000000000000009Initial program 33.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
times-frac33.8%
metadata-eval33.8%
*-lft-identity33.8%
Simplified33.8%
Taylor expanded in x around 0 67.0%
associate--l+67.0%
fma-def67.0%
unpow267.0%
fma-neg67.0%
metadata-eval67.0%
Simplified67.0%
Taylor expanded in x around 0 67.0%
fma-udef67.0%
sub-neg67.0%
metadata-eval67.0%
associate-+l+67.0%
+-commutative67.0%
+-commutative67.0%
associate-+r+67.0%
Applied egg-rr67.0%
if 3.10000000000000009 < 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%
Taylor expanded in x around 0 95.0%
unpow295.0%
Simplified95.0%
Taylor expanded in x around inf 95.1%
Final simplification73.1%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.5) (+ -0.5 (* 0.225 (* x x))) 1.0))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.5) {
tmp = -0.5 + (0.225 * (x * x));
} 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 = (-0.5d0) + (0.225d0 * (x * x))
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 = -0.5 + (0.225 * (x * x));
} else {
tmp = 1.0;
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.5: tmp = -0.5 + (0.225 * (x * x)) else: tmp = 1.0 return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.5) tmp = Float64(-0.5 + Float64(0.225 * Float64(x * x))); else tmp = 1.0; end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 2.5) tmp = -0.5 + (0.225 * (x * x)); 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[(-0.5 + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.5:\\
\;\;\;\;-0.5 + 0.225 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 2.5Initial program 33.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
times-frac33.8%
metadata-eval33.8%
*-lft-identity33.8%
Simplified33.8%
Taylor expanded in x around 0 68.0%
fma-neg68.0%
unpow268.0%
metadata-eval68.0%
Simplified68.0%
fma-udef68.0%
Applied egg-rr68.0%
if 2.5 < 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.1%
Final simplification74.0%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 2.9) (+ -0.5 (* 0.225 (* x x))) (- (/ 3.0 (* x x)) -1.0)))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 2.9) {
tmp = -0.5 + (0.225 * (x * x));
} else {
tmp = (3.0 / (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 <= 2.9d0) then
tmp = (-0.5d0) + (0.225d0 * (x * x))
else
tmp = (3.0d0 / (x * x)) - (-1.0d0)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 2.9) {
tmp = -0.5 + (0.225 * (x * x));
} else {
tmp = (3.0 / (x * x)) - -1.0;
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 2.9: tmp = -0.5 + (0.225 * (x * x)) else: tmp = (3.0 / (x * x)) - -1.0 return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 2.9) tmp = Float64(-0.5 + Float64(0.225 * Float64(x * x))); else tmp = Float64(Float64(3.0 / Float64(x * x)) - -1.0); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 2.9) tmp = -0.5 + (0.225 * (x * x)); else tmp = (3.0 / (x * x)) - -1.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 2.9], N[(-0.5 + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(3.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.9:\\
\;\;\;\;-0.5 + 0.225 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{3}{x \cdot x} - -1\\
\end{array}
\end{array}
if x < 2.89999999999999991Initial program 33.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
times-frac33.8%
metadata-eval33.8%
*-lft-identity33.8%
Simplified33.8%
Taylor expanded in x around 0 68.0%
fma-neg68.0%
unpow268.0%
metadata-eval68.0%
Simplified68.0%
fma-udef68.0%
Applied egg-rr68.0%
if 2.89999999999999991 < 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%
Taylor expanded in x around 0 95.0%
unpow295.0%
Simplified95.0%
Taylor expanded in x around inf 95.1%
Final simplification74.0%
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 33.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
sub-neg33.8%
+-commutative33.8%
neg-sub033.8%
associate-+l-33.8%
sub0-neg33.8%
neg-mul-133.8%
times-frac33.8%
metadata-eval33.8%
*-lft-identity33.8%
Simplified33.8%
Taylor expanded in x around 0 66.9%
if 1.55000000000000004 < 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.1%
Final simplification73.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 48.3%
sub-neg48.3%
+-commutative48.3%
neg-sub048.3%
associate-+l-48.3%
sub0-neg48.3%
neg-mul-148.3%
sub-neg48.3%
+-commutative48.3%
neg-sub048.3%
associate-+l-48.3%
sub0-neg48.3%
neg-mul-148.3%
times-frac48.3%
metadata-eval48.3%
*-lft-identity48.3%
Simplified48.3%
Taylor expanded in x around 0 52.6%
Final simplification52.6%
herbie shell --seed 2023240
(FPCore (x)
:name "sintan (problem 3.4.5)"
:precision binary64
(/ (- x (sin x)) (- x (tan x))))