
(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 10 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}
(FPCore (x)
:precision binary64
(let* ((t_0 (- (tan x) x)))
(if (<= (/ (- x (sin x)) (- x (tan x))) 2.0)
(- (/ (sin x) t_0) (/ x t_0))
(+ (* 0.225 (* x x)) -0.5))))
double code(double x) {
double t_0 = tan(x) - x;
double tmp;
if (((x - sin(x)) / (x - tan(x))) <= 2.0) {
tmp = (sin(x) / t_0) - (x / t_0);
} else {
tmp = (0.225 * (x * x)) + -0.5;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = tan(x) - x
if (((x - sin(x)) / (x - tan(x))) <= 2.0d0) then
tmp = (sin(x) / t_0) - (x / t_0)
else
tmp = (0.225d0 * (x * x)) + (-0.5d0)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.tan(x) - x;
double tmp;
if (((x - Math.sin(x)) / (x - Math.tan(x))) <= 2.0) {
tmp = (Math.sin(x) / t_0) - (x / t_0);
} else {
tmp = (0.225 * (x * x)) + -0.5;
}
return tmp;
}
def code(x): t_0 = math.tan(x) - x tmp = 0 if ((x - math.sin(x)) / (x - math.tan(x))) <= 2.0: tmp = (math.sin(x) / t_0) - (x / t_0) else: tmp = (0.225 * (x * x)) + -0.5 return tmp
function code(x) t_0 = Float64(tan(x) - x) tmp = 0.0 if (Float64(Float64(x - sin(x)) / Float64(x - tan(x))) <= 2.0) tmp = Float64(Float64(sin(x) / t_0) - Float64(x / t_0)); else tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5); end return tmp end
function tmp_2 = code(x) t_0 = tan(x) - x; tmp = 0.0; if (((x - sin(x)) / (x - tan(x))) <= 2.0) tmp = (sin(x) / t_0) - (x / t_0); else tmp = (0.225 * (x * x)) + -0.5; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], N[(N[(N[Sin[x], $MachinePrecision] / t$95$0), $MachinePrecision] - N[(x / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x - x\\
\mathbf{if}\;\frac{x - \sin x}{x - \tan x} \leq 2:\\
\;\;\;\;\frac{\sin x}{t_0} - \frac{x}{t_0}\\
\mathbf{else}:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\end{array}
\end{array}
if (/.f64 (-.f64 x (sin.f64 x)) (-.f64 x (tan.f64 x))) < 2Initial program 99.6%
sub-neg99.6%
+-commutative99.6%
neg-sub099.6%
associate-+l-99.6%
sub0-neg99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
neg-sub099.6%
associate-+l-99.6%
sub0-neg99.6%
neg-mul-199.6%
times-frac99.6%
metadata-eval99.6%
*-lft-identity99.6%
Simplified99.6%
div-sub99.6%
Applied egg-rr99.6%
if 2 < (/.f64 (-.f64 x (sin.f64 x)) (-.f64 x (tan.f64 x))) Initial program 0.0%
sub-neg0.0%
+-commutative0.0%
neg-sub00.0%
associate-+l-0.0%
sub0-neg0.0%
neg-mul-10.0%
sub-neg0.0%
+-commutative0.0%
neg-sub00.0%
associate-+l-0.0%
sub0-neg0.0%
neg-mul-10.0%
times-frac0.0%
metadata-eval0.0%
*-lft-identity0.0%
Simplified0.0%
Taylor expanded in x around 0 100.0%
fma-neg100.0%
unpow2100.0%
metadata-eval100.0%
Simplified100.0%
fma-udef100.0%
Applied egg-rr100.0%
Final simplification99.8%
(FPCore (x) :precision binary64 (let* ((t_0 (/ (- x (sin x)) (- x (tan x))))) (if (<= t_0 2.0) t_0 (+ (* 0.225 (* x x)) -0.5))))
double code(double x) {
double t_0 = (x - sin(x)) / (x - tan(x));
double tmp;
if (t_0 <= 2.0) {
tmp = t_0;
} else {
tmp = (0.225 * (x * x)) + -0.5;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (x - sin(x)) / (x - tan(x))
if (t_0 <= 2.0d0) then
tmp = t_0
else
tmp = (0.225d0 * (x * x)) + (-0.5d0)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x - Math.sin(x)) / (x - Math.tan(x));
double tmp;
if (t_0 <= 2.0) {
tmp = t_0;
} else {
tmp = (0.225 * (x * x)) + -0.5;
}
return tmp;
}
def code(x): t_0 = (x - math.sin(x)) / (x - math.tan(x)) tmp = 0 if t_0 <= 2.0: tmp = t_0 else: tmp = (0.225 * (x * x)) + -0.5 return tmp
function code(x) t_0 = Float64(Float64(x - sin(x)) / Float64(x - tan(x))) tmp = 0.0 if (t_0 <= 2.0) tmp = t_0; else tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5); end return tmp end
function tmp_2 = code(x) t_0 = (x - sin(x)) / (x - tan(x)); tmp = 0.0; if (t_0 <= 2.0) tmp = t_0; else tmp = (0.225 * (x * x)) + -0.5; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2.0], t$95$0, N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - \sin x}{x - \tan x}\\
\mathbf{if}\;t_0 \leq 2:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\end{array}
\end{array}
if (/.f64 (-.f64 x (sin.f64 x)) (-.f64 x (tan.f64 x))) < 2Initial program 99.6%
if 2 < (/.f64 (-.f64 x (sin.f64 x)) (-.f64 x (tan.f64 x))) Initial program 0.0%
sub-neg0.0%
+-commutative0.0%
neg-sub00.0%
associate-+l-0.0%
sub0-neg0.0%
neg-mul-10.0%
sub-neg0.0%
+-commutative0.0%
neg-sub00.0%
associate-+l-0.0%
sub0-neg0.0%
neg-mul-10.0%
times-frac0.0%
metadata-eval0.0%
*-lft-identity0.0%
Simplified0.0%
Taylor expanded in x around 0 100.0%
fma-neg100.0%
unpow2100.0%
metadata-eval100.0%
Simplified100.0%
fma-udef100.0%
Applied egg-rr100.0%
Final simplification99.8%
(FPCore (x) :precision binary64 (if (or (<= x -2.6) (not (<= x 2.6))) (+ 1.0 (/ (- (tan x) (sin x)) x)) (+ -0.5 (+ (* 0.225 (* x x)) (* -0.009642857142857142 (pow x 4.0))))))
double code(double x) {
double tmp;
if ((x <= -2.6) || !(x <= 2.6)) {
tmp = 1.0 + ((tan(x) - sin(x)) / x);
} else {
tmp = -0.5 + ((0.225 * (x * x)) + (-0.009642857142857142 * pow(x, 4.0)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-2.6d0)) .or. (.not. (x <= 2.6d0))) then
tmp = 1.0d0 + ((tan(x) - sin(x)) / x)
else
tmp = (-0.5d0) + ((0.225d0 * (x * x)) + ((-0.009642857142857142d0) * (x ** 4.0d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -2.6) || !(x <= 2.6)) {
tmp = 1.0 + ((Math.tan(x) - Math.sin(x)) / x);
} else {
tmp = -0.5 + ((0.225 * (x * x)) + (-0.009642857142857142 * Math.pow(x, 4.0)));
}
return tmp;
}
def code(x): tmp = 0 if (x <= -2.6) or not (x <= 2.6): tmp = 1.0 + ((math.tan(x) - math.sin(x)) / x) else: tmp = -0.5 + ((0.225 * (x * x)) + (-0.009642857142857142 * math.pow(x, 4.0))) return tmp
function code(x) tmp = 0.0 if ((x <= -2.6) || !(x <= 2.6)) tmp = Float64(1.0 + Float64(Float64(tan(x) - sin(x)) / x)); else tmp = Float64(-0.5 + Float64(Float64(0.225 * Float64(x * x)) + Float64(-0.009642857142857142 * (x ^ 4.0)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -2.6) || ~((x <= 2.6))) tmp = 1.0 + ((tan(x) - sin(x)) / x); else tmp = -0.5 + ((0.225 * (x * x)) + (-0.009642857142857142 * (x ^ 4.0))); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -2.6], N[Not[LessEqual[x, 2.6]], $MachinePrecision]], N[(1.0 + N[(N[(N[Tan[x], $MachinePrecision] - N[Sin[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(-0.5 + N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6 \lor \neg \left(x \leq 2.6\right):\\
\;\;\;\;1 + \frac{\tan x - \sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;-0.5 + \left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right)\\
\end{array}
\end{array}
if x < -2.60000000000000009 or 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.3%
associate--l+99.3%
associate-*r/99.3%
associate-/r*99.3%
associate-*r/99.3%
div-sub99.3%
distribute-lft-out--99.3%
associate-*r/99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
tan-quot99.3%
sub-neg99.3%
Applied egg-rr99.3%
sub-neg99.3%
Simplified99.3%
if -2.60000000000000009 < x < 2.60000000000000009Initial program 1.3%
sub-neg1.3%
+-commutative1.3%
neg-sub01.3%
associate-+l-1.3%
sub0-neg1.3%
neg-mul-11.3%
sub-neg1.3%
+-commutative1.3%
neg-sub01.3%
associate-+l-1.3%
sub0-neg1.3%
neg-mul-11.3%
times-frac1.3%
metadata-eval1.3%
*-lft-identity1.3%
Simplified1.3%
Taylor expanded in x around 0 99.8%
sub-neg99.8%
fma-def99.8%
unpow299.8%
metadata-eval99.8%
Simplified99.8%
fma-udef99.8%
Applied egg-rr99.8%
Final simplification99.5%
(FPCore (x)
:precision binary64
(if (<= x -3.6)
(- (* (pow x -2.0) -3.0) -1.0)
(if (<= x 2.9)
(+ -0.5 (+ (* 0.225 (* x x)) (* -0.009642857142857142 (pow x 4.0))))
(/ (+ x (sin x)) x))))
double code(double x) {
double tmp;
if (x <= -3.6) {
tmp = (pow(x, -2.0) * -3.0) - -1.0;
} else if (x <= 2.9) {
tmp = -0.5 + ((0.225 * (x * x)) + (-0.009642857142857142 * pow(x, 4.0)));
} else {
tmp = (x + sin(x)) / x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-3.6d0)) then
tmp = ((x ** (-2.0d0)) * (-3.0d0)) - (-1.0d0)
else if (x <= 2.9d0) then
tmp = (-0.5d0) + ((0.225d0 * (x * x)) + ((-0.009642857142857142d0) * (x ** 4.0d0)))
else
tmp = (x + sin(x)) / x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -3.6) {
tmp = (Math.pow(x, -2.0) * -3.0) - -1.0;
} else if (x <= 2.9) {
tmp = -0.5 + ((0.225 * (x * x)) + (-0.009642857142857142 * Math.pow(x, 4.0)));
} else {
tmp = (x + Math.sin(x)) / x;
}
return tmp;
}
def code(x): tmp = 0 if x <= -3.6: tmp = (math.pow(x, -2.0) * -3.0) - -1.0 elif x <= 2.9: tmp = -0.5 + ((0.225 * (x * x)) + (-0.009642857142857142 * math.pow(x, 4.0))) else: tmp = (x + math.sin(x)) / x return tmp
function code(x) tmp = 0.0 if (x <= -3.6) tmp = Float64(Float64((x ^ -2.0) * -3.0) - -1.0); elseif (x <= 2.9) tmp = Float64(-0.5 + Float64(Float64(0.225 * Float64(x * x)) + Float64(-0.009642857142857142 * (x ^ 4.0)))); else tmp = Float64(Float64(x + sin(x)) / x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -3.6) tmp = ((x ^ -2.0) * -3.0) - -1.0; elseif (x <= 2.9) tmp = -0.5 + ((0.225 * (x * x)) + (-0.009642857142857142 * (x ^ 4.0))); else tmp = (x + sin(x)) / x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -3.6], N[(N[(N[Power[x, -2.0], $MachinePrecision] * -3.0), $MachinePrecision] - -1.0), $MachinePrecision], If[LessEqual[x, 2.9], N[(-0.5 + N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[Sin[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6:\\
\;\;\;\;{x}^{-2} \cdot -3 - -1\\
\mathbf{elif}\;x \leq 2.9:\\
\;\;\;\;-0.5 + \left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \sin x}{x}\\
\end{array}
\end{array}
if x < -3.60000000000000009Initial 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-sub100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 97.6%
unpow297.6%
Simplified97.6%
Taylor expanded in x around inf 97.8%
frac-2neg97.8%
div-inv97.8%
metadata-eval97.8%
distribute-lft-neg-in97.8%
add-sqr-sqrt97.8%
sqrt-unprod97.8%
sqr-neg97.8%
sqrt-prod0.0%
add-sqr-sqrt97.8%
pow297.8%
pow-flip97.8%
metadata-eval97.8%
Applied egg-rr97.8%
*-commutative97.8%
Simplified97.8%
if -3.60000000000000009 < x < 2.89999999999999991Initial program 1.3%
sub-neg1.3%
+-commutative1.3%
neg-sub01.3%
associate-+l-1.3%
sub0-neg1.3%
neg-mul-11.3%
sub-neg1.3%
+-commutative1.3%
neg-sub01.3%
associate-+l-1.3%
sub0-neg1.3%
neg-mul-11.3%
times-frac1.3%
metadata-eval1.3%
*-lft-identity1.3%
Simplified1.3%
Taylor expanded in x around 0 99.8%
sub-neg99.8%
fma-def99.8%
unpow299.8%
metadata-eval99.8%
Simplified99.8%
fma-udef99.8%
Applied egg-rr99.8%
if 2.89999999999999991 < 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.0%
neg-mul-199.0%
Simplified99.0%
expm1-log1p-u99.0%
expm1-udef99.0%
sub-neg99.0%
add-sqr-sqrt0.0%
sqrt-unprod0.7%
sqr-neg0.7%
sqrt-prod1.1%
add-sqr-sqrt1.5%
add-sqr-sqrt0.0%
sqrt-unprod48.7%
sqr-neg48.7%
sqrt-prod98.8%
add-sqr-sqrt99.1%
Applied egg-rr99.1%
expm1-def99.1%
expm1-log1p99.1%
+-commutative99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x) :precision binary64 (if (<= x -2.6) 1.0 (if (<= x 2.7) (+ (* 0.225 (* x x)) -0.5) (/ (+ x (sin x)) x))))
double code(double x) {
double tmp;
if (x <= -2.6) {
tmp = 1.0;
} else if (x <= 2.7) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = (x + sin(x)) / x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-2.6d0)) then
tmp = 1.0d0
else if (x <= 2.7d0) then
tmp = (0.225d0 * (x * x)) + (-0.5d0)
else
tmp = (x + sin(x)) / x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -2.6) {
tmp = 1.0;
} else if (x <= 2.7) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = (x + Math.sin(x)) / x;
}
return tmp;
}
def code(x): tmp = 0 if x <= -2.6: tmp = 1.0 elif x <= 2.7: tmp = (0.225 * (x * x)) + -0.5 else: tmp = (x + math.sin(x)) / x return tmp
function code(x) tmp = 0.0 if (x <= -2.6) tmp = 1.0; elseif (x <= 2.7) tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5); else tmp = Float64(Float64(x + sin(x)) / x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2.6) tmp = 1.0; elseif (x <= 2.7) tmp = (0.225 * (x * x)) + -0.5; else tmp = (x + sin(x)) / x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2.6], 1.0, If[LessEqual[x, 2.7], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(N[(x + N[Sin[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.7:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \sin x}{x}\\
\end{array}
\end{array}
if x < -2.60000000000000009Initial 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 97.8%
if -2.60000000000000009 < x < 2.7000000000000002Initial program 1.3%
sub-neg1.3%
+-commutative1.3%
neg-sub01.3%
associate-+l-1.3%
sub0-neg1.3%
neg-mul-11.3%
sub-neg1.3%
+-commutative1.3%
neg-sub01.3%
associate-+l-1.3%
sub0-neg1.3%
neg-mul-11.3%
times-frac1.3%
metadata-eval1.3%
*-lft-identity1.3%
Simplified1.3%
Taylor expanded in x around 0 99.6%
fma-neg99.6%
unpow299.6%
metadata-eval99.6%
Simplified99.6%
fma-udef99.6%
Applied egg-rr99.6%
if 2.7000000000000002 < 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.0%
neg-mul-199.0%
Simplified99.0%
expm1-log1p-u99.0%
expm1-udef99.0%
sub-neg99.0%
add-sqr-sqrt0.0%
sqrt-unprod0.7%
sqr-neg0.7%
sqrt-prod1.1%
add-sqr-sqrt1.5%
add-sqr-sqrt0.0%
sqrt-unprod48.7%
sqr-neg48.7%
sqrt-prod98.8%
add-sqr-sqrt99.1%
Applied egg-rr99.1%
expm1-def99.1%
expm1-log1p99.1%
+-commutative99.1%
Simplified99.1%
Final simplification99.0%
(FPCore (x) :precision binary64 (if (<= x -1.85) (- (* (pow x -2.0) -3.0) -1.0) (if (<= x 2.7) (+ (* 0.225 (* x x)) -0.5) (/ (+ x (sin x)) x))))
double code(double x) {
double tmp;
if (x <= -1.85) {
tmp = (pow(x, -2.0) * -3.0) - -1.0;
} else if (x <= 2.7) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = (x + sin(x)) / x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.85d0)) then
tmp = ((x ** (-2.0d0)) * (-3.0d0)) - (-1.0d0)
else if (x <= 2.7d0) then
tmp = (0.225d0 * (x * x)) + (-0.5d0)
else
tmp = (x + sin(x)) / x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.85) {
tmp = (Math.pow(x, -2.0) * -3.0) - -1.0;
} else if (x <= 2.7) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = (x + Math.sin(x)) / x;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.85: tmp = (math.pow(x, -2.0) * -3.0) - -1.0 elif x <= 2.7: tmp = (0.225 * (x * x)) + -0.5 else: tmp = (x + math.sin(x)) / x return tmp
function code(x) tmp = 0.0 if (x <= -1.85) tmp = Float64(Float64((x ^ -2.0) * -3.0) - -1.0); elseif (x <= 2.7) tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5); else tmp = Float64(Float64(x + sin(x)) / x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.85) tmp = ((x ^ -2.0) * -3.0) - -1.0; elseif (x <= 2.7) tmp = (0.225 * (x * x)) + -0.5; else tmp = (x + sin(x)) / x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.85], N[(N[(N[Power[x, -2.0], $MachinePrecision] * -3.0), $MachinePrecision] - -1.0), $MachinePrecision], If[LessEqual[x, 2.7], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(N[(x + N[Sin[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.85:\\
\;\;\;\;{x}^{-2} \cdot -3 - -1\\
\mathbf{elif}\;x \leq 2.7:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \sin x}{x}\\
\end{array}
\end{array}
if x < -1.8500000000000001Initial 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-sub100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 97.6%
unpow297.6%
Simplified97.6%
Taylor expanded in x around inf 97.8%
frac-2neg97.8%
div-inv97.8%
metadata-eval97.8%
distribute-lft-neg-in97.8%
add-sqr-sqrt97.8%
sqrt-unprod97.8%
sqr-neg97.8%
sqrt-prod0.0%
add-sqr-sqrt97.8%
pow297.8%
pow-flip97.8%
metadata-eval97.8%
Applied egg-rr97.8%
*-commutative97.8%
Simplified97.8%
if -1.8500000000000001 < x < 2.7000000000000002Initial program 1.3%
sub-neg1.3%
+-commutative1.3%
neg-sub01.3%
associate-+l-1.3%
sub0-neg1.3%
neg-mul-11.3%
sub-neg1.3%
+-commutative1.3%
neg-sub01.3%
associate-+l-1.3%
sub0-neg1.3%
neg-mul-11.3%
times-frac1.3%
metadata-eval1.3%
*-lft-identity1.3%
Simplified1.3%
Taylor expanded in x around 0 99.6%
fma-neg99.6%
unpow299.6%
metadata-eval99.6%
Simplified99.6%
fma-udef99.6%
Applied egg-rr99.6%
if 2.7000000000000002 < 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.0%
neg-mul-199.0%
Simplified99.0%
expm1-log1p-u99.0%
expm1-udef99.0%
sub-neg99.0%
add-sqr-sqrt0.0%
sqrt-unprod0.7%
sqr-neg0.7%
sqrt-prod1.1%
add-sqr-sqrt1.5%
add-sqr-sqrt0.0%
sqrt-unprod48.7%
sqr-neg48.7%
sqrt-prod98.8%
add-sqr-sqrt99.1%
Applied egg-rr99.1%
expm1-def99.1%
expm1-log1p99.1%
+-commutative99.1%
Simplified99.1%
Final simplification99.0%
(FPCore (x) :precision binary64 (if (<= x -2.6) 1.0 (if (<= x 2.55) (+ (* 0.225 (* x x)) -0.5) 1.0)))
double code(double x) {
double tmp;
if (x <= -2.6) {
tmp = 1.0;
} else if (x <= 2.55) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-2.6d0)) then
tmp = 1.0d0
else if (x <= 2.55d0) then
tmp = (0.225d0 * (x * x)) + (-0.5d0)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -2.6) {
tmp = 1.0;
} else if (x <= 2.55) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -2.6: tmp = 1.0 elif x <= 2.55: tmp = (0.225 * (x * x)) + -0.5 else: tmp = 1.0 return tmp
function code(x) tmp = 0.0 if (x <= -2.6) tmp = 1.0; elseif (x <= 2.55) tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5); else tmp = 1.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2.6) tmp = 1.0; elseif (x <= 2.55) tmp = (0.225 * (x * x)) + -0.5; else tmp = 1.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2.6], 1.0, If[LessEqual[x, 2.55], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.55:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -2.60000000000000009 or 2.5499999999999998 < 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.5%
if -2.60000000000000009 < x < 2.5499999999999998Initial program 1.3%
sub-neg1.3%
+-commutative1.3%
neg-sub01.3%
associate-+l-1.3%
sub0-neg1.3%
neg-mul-11.3%
sub-neg1.3%
+-commutative1.3%
neg-sub01.3%
associate-+l-1.3%
sub0-neg1.3%
neg-mul-11.3%
times-frac1.3%
metadata-eval1.3%
*-lft-identity1.3%
Simplified1.3%
Taylor expanded in x around 0 99.6%
fma-neg99.6%
unpow299.6%
metadata-eval99.6%
Simplified99.6%
fma-udef99.6%
Applied egg-rr99.6%
Final simplification99.0%
(FPCore (x) :precision binary64 (if (<= x -2.6) 1.0 (if (<= x 2.85) (+ (* 0.225 (* x x)) -0.5) (- (/ 3.0 (* x x)) -1.0))))
double code(double x) {
double tmp;
if (x <= -2.6) {
tmp = 1.0;
} else if (x <= 2.85) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = (3.0 / (x * x)) - -1.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-2.6d0)) then
tmp = 1.0d0
else if (x <= 2.85d0) then
tmp = (0.225d0 * (x * x)) + (-0.5d0)
else
tmp = (3.0d0 / (x * x)) - (-1.0d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -2.6) {
tmp = 1.0;
} else if (x <= 2.85) {
tmp = (0.225 * (x * x)) + -0.5;
} else {
tmp = (3.0 / (x * x)) - -1.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -2.6: tmp = 1.0 elif x <= 2.85: tmp = (0.225 * (x * x)) + -0.5 else: tmp = (3.0 / (x * x)) - -1.0 return tmp
function code(x) tmp = 0.0 if (x <= -2.6) tmp = 1.0; elseif (x <= 2.85) tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5); else tmp = Float64(Float64(3.0 / Float64(x * x)) - -1.0); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2.6) tmp = 1.0; elseif (x <= 2.85) tmp = (0.225 * (x * x)) + -0.5; else tmp = (3.0 / (x * x)) - -1.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2.6], 1.0, If[LessEqual[x, 2.85], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(N[(3.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.85:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{3}{x \cdot x} - -1\\
\end{array}
\end{array}
if x < -2.60000000000000009Initial 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 97.8%
if -2.60000000000000009 < x < 2.85000000000000009Initial program 1.3%
sub-neg1.3%
+-commutative1.3%
neg-sub01.3%
associate-+l-1.3%
sub0-neg1.3%
neg-mul-11.3%
sub-neg1.3%
+-commutative1.3%
neg-sub01.3%
associate-+l-1.3%
sub0-neg1.3%
neg-mul-11.3%
times-frac1.3%
metadata-eval1.3%
*-lft-identity1.3%
Simplified1.3%
Taylor expanded in x around 0 99.6%
fma-neg99.6%
unpow299.6%
metadata-eval99.6%
Simplified99.6%
fma-udef99.6%
Applied egg-rr99.6%
if 2.85000000000000009 < 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%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 99.0%
unpow299.0%
Simplified99.0%
Taylor expanded in x around inf 99.1%
Final simplification99.0%
(FPCore (x) :precision binary64 (if (<= x -1.55) 1.0 (if (<= x 1.6) -0.5 1.0)))
double code(double x) {
double tmp;
if (x <= -1.55) {
tmp = 1.0;
} else if (x <= 1.6) {
tmp = -0.5;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.55d0)) then
tmp = 1.0d0
else if (x <= 1.6d0) then
tmp = -0.5d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.55) {
tmp = 1.0;
} else if (x <= 1.6) {
tmp = -0.5;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.55: tmp = 1.0 elif x <= 1.6: tmp = -0.5 else: tmp = 1.0 return tmp
function code(x) tmp = 0.0 if (x <= -1.55) tmp = 1.0; elseif (x <= 1.6) tmp = -0.5; else tmp = 1.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.55) tmp = 1.0; elseif (x <= 1.6) tmp = -0.5; else tmp = 1.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.55], 1.0, If[LessEqual[x, 1.6], -0.5, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.6:\\
\;\;\;\;-0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1.55000000000000004 or 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.5%
if -1.55000000000000004 < x < 1.6000000000000001Initial program 1.3%
sub-neg1.3%
+-commutative1.3%
neg-sub01.3%
associate-+l-1.3%
sub0-neg1.3%
neg-mul-11.3%
sub-neg1.3%
+-commutative1.3%
neg-sub01.3%
associate-+l-1.3%
sub0-neg1.3%
neg-mul-11.3%
times-frac1.3%
metadata-eval1.3%
*-lft-identity1.3%
Simplified1.3%
Taylor expanded in x around 0 99.0%
Final simplification98.7%
(FPCore (x) :precision binary64 -0.5)
double code(double x) {
return -0.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -0.5d0
end function
public static double code(double x) {
return -0.5;
}
def code(x): return -0.5
function code(x) return -0.5 end
function tmp = code(x) tmp = -0.5; end
code[x_] := -0.5
\begin{array}{l}
\\
-0.5
\end{array}
Initial program 55.6%
sub-neg55.6%
+-commutative55.6%
neg-sub055.6%
associate-+l-55.6%
sub0-neg55.6%
neg-mul-155.6%
sub-neg55.6%
+-commutative55.6%
neg-sub055.6%
associate-+l-55.6%
sub0-neg55.6%
neg-mul-155.6%
times-frac55.6%
metadata-eval55.6%
*-lft-identity55.6%
Simplified55.6%
Taylor expanded in x around 0 45.3%
Final simplification45.3%
herbie shell --seed 2023173
(FPCore (x)
:name "sintan (problem 3.4.5)"
:precision binary64
(/ (- x (sin x)) (- x (tan x))))