Alternative 1 | |
---|---|
Error | 1.0 |
Cost | 584 |
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.38:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;x \cdot -4 + -2\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x}\\
\end{array}
\]
(FPCore (x) :precision binary64 (/ 1.0 (- x 0.5)))
(FPCore (x) :precision binary64 (/ 1.0 (+ x -0.5)))
double code(double x) { return 1.0 / (x - 0.5); }
double code(double x) { return 1.0 / (x + -0.5); }
real(8) function code(x) real(8), intent (in) :: x code = 1.0d0 / (x - 0.5d0) end function
real(8) function code(x) real(8), intent (in) :: x code = 1.0d0 / (x + (-0.5d0)) end function
public static double code(double x) { return 1.0 / (x - 0.5); }
public static double code(double x) { return 1.0 / (x + -0.5); }
def code(x): return 1.0 / (x - 0.5)
def code(x): return 1.0 / (x + -0.5)
function code(x) return Float64(1.0 / Float64(x - 0.5)) end
function code(x) return Float64(1.0 / Float64(x + -0.5)) end
function tmp = code(x) tmp = 1.0 / (x - 0.5); end
function tmp = code(x) tmp = 1.0 / (x + -0.5); end
code[x_] := N[(1.0 / N[(x - 0.5), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(1.0 / N[(x + -0.5), $MachinePrecision]), $MachinePrecision]
\frac{1}{x - 0.5}
\frac{1}{x + -0.5}
Results
Initial program 0.0
Final simplification0.0
Alternative 1 | |
---|---|
Error | 1.0 |
Cost | 584 |
Alternative 2 | |
---|---|
Error | 1.3 |
Cost | 456 |
Alternative 3 | |
---|---|
Error | 31.5 |
Cost | 64 |
herbie shell --seed 1
(FPCore (x)
:name "1 / (x - 0.5)"
:precision binary64
:pre (and (<= -1.79e+308 x) (<= x 1.79e+308))
(/ 1.0 (- x 0.5)))