Average Error: 0.0 → 0.0
Time: 7.9s
Precision: binary64
Cost: 448
\[\frac{x - y}{z - y} \]
\[\frac{y - x}{y - z} \]
(FPCore (x y z) :precision binary64 (/ (- x y) (- z y)))
(FPCore (x y z) :precision binary64 (/ (- y x) (- y z)))
double code(double x, double y, double z) {
	return (x - y) / (z - y);
}
double code(double x, double y, double z) {
	return (y - x) / (y - z);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x - y) / (z - y)
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (y - x) / (y - z)
end function
public static double code(double x, double y, double z) {
	return (x - y) / (z - y);
}
public static double code(double x, double y, double z) {
	return (y - x) / (y - z);
}
def code(x, y, z):
	return (x - y) / (z - y)
def code(x, y, z):
	return (y - x) / (y - z)
function code(x, y, z)
	return Float64(Float64(x - y) / Float64(z - y))
end
function code(x, y, z)
	return Float64(Float64(y - x) / Float64(y - z))
end
function tmp = code(x, y, z)
	tmp = (x - y) / (z - y);
end
function tmp = code(x, y, z)
	tmp = (y - x) / (y - z);
end
code[x_, y_, z_] := N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]
\frac{x - y}{z - y}
\frac{y - x}{y - z}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.0
Target0.0
Herbie0.0
\[\frac{x}{z - y} - \frac{y}{z - y} \]

Derivation

  1. Initial program 0.0

    \[\frac{x - y}{z - y} \]
  2. Simplified0.0

    \[\leadsto \color{blue}{\frac{y - x}{y - z}} \]
    Proof
    (/.f64 (-.f64 y x) (-.f64 y z)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= *-lft-identity_binary64 (*.f64 1 (/.f64 (-.f64 y x) (-.f64 y z)))): 0 points increase in error, 0 points decrease in error
    (*.f64 (Rewrite<= metadata-eval (/.f64 -1 -1)) (/.f64 (-.f64 y x) (-.f64 y z))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= times-frac_binary64 (/.f64 (*.f64 -1 (-.f64 y x)) (*.f64 -1 (-.f64 y z)))): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 y x))) (*.f64 -1 (-.f64 y z))): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 y x))) (*.f64 -1 (-.f64 y z))): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 y) x)) (*.f64 -1 (-.f64 y z))): 0 points increase in error, 0 points decrease in error
    (/.f64 (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 y)) x) (*.f64 -1 (-.f64 y z))): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= +-commutative_binary64 (+.f64 x (neg.f64 y))) (*.f64 -1 (-.f64 y z))): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= sub-neg_binary64 (-.f64 x y)) (*.f64 -1 (-.f64 y z))): 0 points increase in error, 0 points decrease in error
    (/.f64 (-.f64 x y) (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 y z)))): 0 points increase in error, 0 points decrease in error
    (/.f64 (-.f64 x y) (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 y z)))): 0 points increase in error, 0 points decrease in error
    (/.f64 (-.f64 x y) (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 y) z))): 0 points increase in error, 0 points decrease in error
    (/.f64 (-.f64 x y) (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 y)) z)): 0 points increase in error, 0 points decrease in error
    (/.f64 (-.f64 x y) (Rewrite<= +-commutative_binary64 (+.f64 z (neg.f64 y)))): 0 points increase in error, 0 points decrease in error
    (/.f64 (-.f64 x y) (Rewrite<= sub-neg_binary64 (-.f64 z y))): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.0

    \[\leadsto \frac{y - x}{y - z} \]

Alternatives

Alternative 1
Error15.5
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -2.5102844631271806 \cdot 10^{-43}:\\ \;\;\;\;\frac{y - x}{y}\\ \mathbf{elif}\;y \leq 29169030379786.54:\\ \;\;\;\;\frac{-x}{y - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - z}\\ \end{array} \]
Alternative 2
Error25.1
Cost588
\[\begin{array}{l} \mathbf{if}\;y \leq -1.1689968896135387 \cdot 10^{+78}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -23242193.54920474:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq 3995960211059.49:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 3
Error25.2
Cost588
\[\begin{array}{l} \mathbf{if}\;y \leq -1.1689968896135387 \cdot 10^{+78}:\\ \;\;\;\;1 + \frac{z}{y}\\ \mathbf{elif}\;y \leq -23242193.54920474:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq 3995960211059.49:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 4
Error18.8
Cost584
\[\begin{array}{l} t_0 := \frac{y}{y - z}\\ \mathbf{if}\;y \leq -9.592281269712523 \cdot 10^{-45}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.549030551531526 \cdot 10^{-11}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error18.9
Cost584
\[\begin{array}{l} t_0 := \frac{y - x}{y}\\ \mathbf{if}\;y \leq -2.5102844631271806 \cdot 10^{-43}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.549030551531526 \cdot 10^{-11}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error15.6
Cost584
\[\begin{array}{l} t_0 := \frac{y - x}{y}\\ \mathbf{if}\;y \leq -2.5102844631271806 \cdot 10^{-43}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.549030551531526 \cdot 10^{-11}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error15.6
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -2.5102844631271806 \cdot 10^{-43}:\\ \;\;\;\;1 + \frac{z - x}{y}\\ \mathbf{elif}\;y \leq 4.549030551531526 \cdot 10^{-11}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y - x}{y}\\ \end{array} \]
Alternative 8
Error25.1
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -2.5102844631271806 \cdot 10^{-43}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 3995960211059.49:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Error41.5
Cost64
\[1 \]

Error

Reproduce

herbie shell --seed 2022318 
(FPCore (x y z)
  :name "Graphics.Rasterific.Shading:$sgradientColorAt from Rasterific-0.6.1"
  :precision binary64

  :herbie-target
  (- (/ x (- z y)) (/ y (- z y)))

  (/ (- x y) (- z y)))