Average Error: 0.0 → 0.0
Time: 6.4s
Precision: binary64
Cost: 704
\[\frac{x - y}{z - y} \]
\[\frac{y}{y - z} - \frac{x}{y - z} \]
(FPCore (x y z) :precision binary64 (/ (- x y) (- z y)))
(FPCore (x y z) :precision binary64 (- (/ y (- y z)) (/ 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 / (y - z)) - (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 / (y - z)) - (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 / (y - z)) - (x / (y - z));
}
def code(x, y, z):
	return (x - y) / (z - y)
def code(x, y, z):
	return (y / (y - z)) - (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 / Float64(y - z)) - Float64(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 / (y - z)) - (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 / N[(y - z), $MachinePrecision]), $MachinePrecision] - N[(x / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x - y}{z - y}
\frac{y}{y - z} - \frac{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. Applied egg-rr0.0

    \[\leadsto \color{blue}{\frac{y}{y - z} - \frac{x}{y - z}} \]
  4. Final simplification0.0

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

Alternatives

Alternative 1
Error17.0
Cost1240
\[\begin{array}{l} t_0 := \frac{x}{z - y}\\ t_1 := \frac{y}{y - z}\\ \mathbf{if}\;x \leq -2.75 \cdot 10^{+54}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 82000000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{+47}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{+82}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{+189}:\\ \;\;\;\;1 + \frac{z - x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error16.6
Cost1112
\[\begin{array}{l} t_0 := \frac{x}{z - y}\\ t_1 := \frac{y}{y - z}\\ \mathbf{if}\;x \leq -2.7 \cdot 10^{+54}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+14}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.3 \cdot 10^{+120}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+189}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error17.0
Cost1112
\[\begin{array}{l} t_0 := \frac{x}{z - y}\\ t_1 := \frac{y}{y - z}\\ \mathbf{if}\;x \leq -2.6 \cdot 10^{+54}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 8.6 \cdot 10^{-45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 82000000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{+80}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{+189}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error25.2
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -7.2 \cdot 10^{-21}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-34}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{z}{y}\\ \end{array} \]
Alternative 5
Error18.8
Cost584
\[\begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -2.35 \cdot 10^{-34}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.42 \cdot 10^{-46}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error15.2
Cost584
\[\begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -2.9 \cdot 10^{-20}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 180:\\ \;\;\;\;\frac{x}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error25.1
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -4.2 \cdot 10^{-21}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 2.75 \cdot 10^{-37}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Error0.0
Cost448
\[\frac{x - y}{z - y} \]
Alternative 9
Error40.9
Cost64
\[1 \]

Error

Reproduce

herbie shell --seed 2022337 
(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)))