Average Error: 0.0 → 0.0
Time: 2.6s
Precision: binary64
Cost: 576
\[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
\[\left(y \cdot \left(-0.5 + x\right) - x\right) + 0.918938533204673 \]
(FPCore (x y)
 :precision binary64
 (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))
(FPCore (x y) :precision binary64 (+ (- (* y (+ -0.5 x)) x) 0.918938533204673))
double code(double x, double y) {
	return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
double code(double x, double y) {
	return ((y * (-0.5 + x)) - x) + 0.918938533204673;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((x * (y - 1.0d0)) - (y * 0.5d0)) + 0.918938533204673d0
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((y * ((-0.5d0) + x)) - x) + 0.918938533204673d0
end function
public static double code(double x, double y) {
	return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
public static double code(double x, double y) {
	return ((y * (-0.5 + x)) - x) + 0.918938533204673;
}
def code(x, y):
	return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673
def code(x, y):
	return ((y * (-0.5 + x)) - x) + 0.918938533204673
function code(x, y)
	return Float64(Float64(Float64(x * Float64(y - 1.0)) - Float64(y * 0.5)) + 0.918938533204673)
end
function code(x, y)
	return Float64(Float64(Float64(y * Float64(-0.5 + x)) - x) + 0.918938533204673)
end
function tmp = code(x, y)
	tmp = ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
end
function tmp = code(x, y)
	tmp = ((y * (-0.5 + x)) - x) + 0.918938533204673;
end
code[x_, y_] := N[(N[(N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision] - N[(y * 0.5), $MachinePrecision]), $MachinePrecision] + 0.918938533204673), $MachinePrecision]
code[x_, y_] := N[(N[(N[(y * N[(-0.5 + x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.918938533204673), $MachinePrecision]
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
\left(y \cdot \left(-0.5 + x\right) - x\right) + 0.918938533204673

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.0

    \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
  2. Taylor expanded in x around 0 0.0

    \[\leadsto \color{blue}{\left(\left(y - 1\right) \cdot x + -0.5 \cdot y\right)} + 0.918938533204673 \]
  3. Simplified0.0

    \[\leadsto \color{blue}{\left(y \cdot \left(-0.5 + x\right) - x\right)} + 0.918938533204673 \]
    Proof
    (-.f64 (*.f64 y (+.f64 -1/2 x)) x): 0 points increase in error, 0 points decrease in error
    (-.f64 (Rewrite=> distribute-lft-in_binary64 (+.f64 (*.f64 y -1/2) (*.f64 y x))) x): 1 points increase in error, 0 points decrease in error
    (-.f64 (+.f64 (*.f64 y (Rewrite<= metadata-eval (neg.f64 1/2))) (*.f64 y x)) x): 0 points increase in error, 0 points decrease in error
    (-.f64 (+.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 y 1/2))) (*.f64 y x)) x): 0 points increase in error, 0 points decrease in error
    (Rewrite=> associate--l+_binary64 (+.f64 (neg.f64 (*.f64 y 1/2)) (-.f64 (*.f64 y x) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite=> distribute-rgt-neg-in_binary64 (*.f64 y (neg.f64 1/2))) (-.f64 (*.f64 y x) x)): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 y (Rewrite=> metadata-eval -1/2)) (-.f64 (*.f64 y x) x)): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 y -1/2) (Rewrite<= unsub-neg_binary64 (+.f64 (*.f64 y x) (neg.f64 x)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 y -1/2) (+.f64 (*.f64 y x) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 x)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 y -1/2) (Rewrite<= distribute-rgt-in_binary64 (*.f64 x (+.f64 y -1)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 y -1/2) (*.f64 x (+.f64 y (Rewrite<= metadata-eval (neg.f64 1))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 y -1/2) (*.f64 x (Rewrite<= sub-neg_binary64 (-.f64 y 1)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 y -1/2) (Rewrite<= *-commutative_binary64 (*.f64 (-.f64 y 1) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 -1/2 y)) (*.f64 (-.f64 y 1) x)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 (-.f64 y 1) x) (*.f64 -1/2 y))): 0 points increase in error, 0 points decrease in error
  4. Final simplification0.0

    \[\leadsto \left(y \cdot \left(-0.5 + x\right) - x\right) + 0.918938533204673 \]

Alternatives

Alternative 1
Error1.9
Cost712
\[\begin{array}{l} t_0 := y \cdot \left(-0.5 + x\right)\\ \mathbf{if}\;y \leq -1.5408773491812858 \cdot 10^{+27}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.1438132165957093 \cdot 10^{-11}:\\ \;\;\;\;0.918938533204673 + \left(y \cdot -0.5 - x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.9
Cost712
\[\begin{array}{l} t_0 := 0.918938533204673 + y \cdot \left(-0.5 + x\right)\\ \mathbf{if}\;y \leq -6893.50182897125:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.487064303855046 \cdot 10^{-12}:\\ \;\;\;\;0.918938533204673 + \left(y \cdot -0.5 - x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error1.1
Cost712
\[\begin{array}{l} t_0 := 0.918938533204673 + \left(y \cdot x - x\right)\\ \mathbf{if}\;x \leq -3.3314034762393124 \cdot 10^{-16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 257609935.23354307:\\ \;\;\;\;0.918938533204673 + y \cdot \left(-0.5 + x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.9
Cost584
\[\begin{array}{l} t_0 := y \cdot \left(-0.5 + x\right)\\ \mathbf{if}\;y \leq -1896.4048845480497:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.1438132165957093 \cdot 10^{-11}:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error28.3
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -1.845721660222086 \cdot 10^{-5}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.1438132165957093 \cdot 10^{-11}:\\ \;\;\;\;0.918938533204673\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]
Alternative 6
Error10.7
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -1896.4048845480497:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.1438132165957093 \cdot 10^{-11}:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]
Alternative 7
Error45.0
Cost64
\[0.918938533204673 \]

Error

Reproduce

herbie shell --seed 2022300 
(FPCore (x y)
  :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, A"
  :precision binary64
  (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))