Average Error: 0.0 → 0.0
Time: 7.3s
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. Taylor expanded in x around 0 0.0

    \[\leadsto \color{blue}{\frac{y}{y - z} + -1 \cdot \frac{x}{y - z}} \]
  4. Simplified0.0

    \[\leadsto \color{blue}{\frac{y}{y - z} - \frac{x}{y - z}} \]
    Proof
    (-.f64 (/.f64 y (-.f64 y z)) (/.f64 x (-.f64 y z))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= unsub-neg_binary64 (+.f64 (/.f64 y (-.f64 y z)) (neg.f64 (/.f64 x (-.f64 y z))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (/.f64 y (-.f64 y z)) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (/.f64 x (-.f64 y z))))): 0 points increase in error, 0 points decrease in error
  5. Final simplification0.0

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

Alternatives

Alternative 1
Error23.0
Cost1244
\[\begin{array}{l} t_0 := \frac{y - x}{y}\\ t_1 := \frac{x - y}{z}\\ \mathbf{if}\;x \leq -1.3885419469183084 \cdot 10^{+149}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -4.396750544621539 \cdot 10^{+90}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.4889261844757886 \cdot 10^{+21}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -8.711994288308491 \cdot 10^{-21}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;x \leq 2.8568982748426848 \cdot 10^{-39}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;x \leq 1.762331201257542 \cdot 10^{+72}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.971582748691123 \cdot 10^{+122}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]
Alternative 2
Error25.3
Cost848
\[\begin{array}{l} t_0 := 1 + \frac{z}{y}\\ \mathbf{if}\;y \leq -4.063086342484234 \cdot 10^{+76}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -3155204.2702262374:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq -2.0009674103390848 \cdot 10^{-23}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 6.691824604067688 \cdot 10^{+22}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error25.1
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -3.592676494446578 \cdot 10^{+58}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -3155204.2702262374:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq -2.0009674103390848 \cdot 10^{-23}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 0.07776719196989526:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 4
Error15.6
Cost648
\[\begin{array}{l} t_0 := \frac{-x}{y - z}\\ \mathbf{if}\;x \leq -2.77091404185716 \cdot 10^{-24}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.1300791559236433 \cdot 10^{-34}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error20.2
Cost584
\[\begin{array}{l} t_0 := 1 + \frac{z}{y}\\ \mathbf{if}\;y \leq -7.364777760508156 \cdot 10^{+71}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 6.691824604067688 \cdot 10^{+22}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error15.3
Cost584
\[\begin{array}{l} t_0 := \frac{y}{y - z}\\ \mathbf{if}\;y \leq -2.0009674103390848 \cdot 10^{-23}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 5.861292630152756 \cdot 10^{-33}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error24.8
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -2.0009674103390848 \cdot 10^{-23}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 0.07776719196989526:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Error0.0
Cost448
\[\frac{y - x}{y - z} \]
Alternative 9
Error41.1
Cost64
\[1 \]

Error

Reproduce

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