Average Error: 0.0 → 0.0
Time: 9.7s
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
Error16.3
Cost980
\[\begin{array}{l} t_0 := 1 - \frac{x}{y}\\ t_1 := \frac{x - y}{z}\\ \mathbf{if}\;y \leq -2.633861076155421 \cdot 10^{+103}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.47838262919257 \cdot 10^{-80}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.081853682012868 \cdot 10^{-105}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 10^{-214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.6450982533080215 \cdot 10^{-11}:\\ \;\;\;\;\frac{x}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error16.3
Cost980
\[\begin{array}{l} t_0 := 1 - \frac{x}{y}\\ t_1 := \frac{x - y}{z}\\ \mathbf{if}\;y \leq -2.633861076155421 \cdot 10^{+103}:\\ \;\;\;\;\frac{y - x}{y}\\ \mathbf{elif}\;y \leq -1.47838262919257 \cdot 10^{-80}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.081853682012868 \cdot 10^{-105}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 10^{-214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.6450982533080215 \cdot 10^{-11}:\\ \;\;\;\;\frac{x}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error20.1
Cost716
\[\begin{array}{l} \mathbf{if}\;y \leq -2.633861076155421 \cdot 10^{+103}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 10^{-214}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{elif}\;y \leq 3.6450982533080215 \cdot 10^{-11}:\\ \;\;\;\;\frac{x}{z - y}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 4
Error25.3
Cost588
\[\begin{array}{l} \mathbf{if}\;y \leq -2.633861076155421 \cdot 10^{+103}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -4.891696322130794 \cdot 10^{-30}:\\ \;\;\;\;\frac{-y}{z}\\ \mathbf{elif}\;y \leq 3.6450982533080215 \cdot 10^{-11}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 5
Error20.2
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -2.633861076155421 \cdot 10^{+103}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 3.6450982533080215 \cdot 10^{-11}:\\ \;\;\;\;\frac{x}{z - y}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Error24.7
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -27878821712121102000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 3.6450982533080215 \cdot 10^{-11}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 7
Error0.0
Cost448
\[\frac{y - x}{y - z} \]
Alternative 8
Error40.8
Cost64
\[1 \]

Error

Reproduce

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