?

Average Error: 12.7 → 3.2
Time: 18.4s
Precision: binary64
Cost: 448

?

\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\frac{x}{\frac{y}{y - z}} \]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z) :precision binary64 (/ x (/ y (- y z))))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
	return x / (y / (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 = x / (y / (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 x / (y / (y - z));
}
def code(x, y, z):
	return (x * (y - z)) / y
def code(x, y, z):
	return x / (y / (y - z))
function code(x, y, z)
	return Float64(Float64(x * Float64(y - z)) / y)
end
function code(x, y, z)
	return Float64(x / Float64(y / Float64(y - z)))
end
function tmp = code(x, y, z)
	tmp = (x * (y - z)) / y;
end
function tmp = code(x, y, z)
	tmp = x / (y / (y - z));
end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_] := N[(x / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x \cdot \left(y - z\right)}{y}
\frac{x}{\frac{y}{y - z}}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.7
Target3.2
Herbie3.2
\[\begin{array}{l} \mathbf{if}\;z < -2.060202331921739 \cdot 10^{+104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z < 1.6939766013828526 \cdot 10^{+213}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array} \]

Derivation?

  1. Initial program 12.7

    \[\frac{x \cdot \left(y - z\right)}{y} \]
  2. Simplified3.4

    \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
    Proof

    [Start]12.7

    \[ \frac{x \cdot \left(y - z\right)}{y} \]

    rational.json-simplify-2 [=>]12.7

    \[ \frac{\color{blue}{\left(y - z\right) \cdot x}}{y} \]

    rational.json-simplify-49 [=>]3.4

    \[ \color{blue}{x \cdot \frac{y - z}{y}} \]
  3. Applied egg-rr3.2

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

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

Alternatives

Alternative 1
Error20.2
Cost912
\[\begin{array}{l} t_0 := x \cdot \left(-\frac{z}{y}\right)\\ \mathbf{if}\;y \leq -7 \cdot 10^{-97}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-169}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-141}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-39}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error19.0
Cost912
\[\begin{array}{l} t_0 := z \cdot \left(-\frac{x}{y}\right)\\ \mathbf{if}\;y \leq -1.15 \cdot 10^{-97}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.18 \cdot 10^{-179}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3 \cdot 10^{-141}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.22 \cdot 10^{-39}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error18.9
Cost912
\[\begin{array}{l} t_0 := \frac{-z}{\frac{y}{x}}\\ \mathbf{if}\;y \leq -7.6 \cdot 10^{-98}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-182}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.85 \cdot 10^{-144}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 9 \cdot 10^{-39}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error3.4
Cost448
\[x \cdot \left(1 - \frac{z}{y}\right) \]
Alternative 5
Error25.2
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023064 
(FPCore (x y z)
  :name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))

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