?

Average Error: 10.1 → 0.0
Time: 11.1s
Precision: binary64
Cost: 576

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.1
Target0.0
Herbie0.0
\[\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}} \]

Derivation?

  1. Initial program 10.1

    \[\frac{x + y \cdot \left(z - x\right)}{z} \]
  2. Taylor expanded in x around inf 3.4

    \[\leadsto \color{blue}{y + \frac{\left(1 + -1 \cdot y\right) \cdot x}{z}} \]
  3. Simplified0.0

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

    [Start]3.4

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

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

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

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

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

    rational.json-simplify-17 [=>]0.0

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

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

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

    rational.json-simplify-9 [=>]0.0

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

    rational.json-simplify-12 [=>]0.0

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

    rational.json-simplify-42 [=>]0.0

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

    metadata-eval [=>]0.0

    \[ y + \left(\color{blue}{1} - y\right) \cdot \frac{x}{z} \]
  4. Final simplification0.0

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

Alternatives

Alternative 1
Error20.5
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{-34}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-147}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-101}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{-33}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 2
Error0.7
Cost712
\[\begin{array}{l} t_0 := y \cdot \left(1 - \frac{x}{z}\right)\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error0.7
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;\frac{y}{\frac{z}{z - x}}\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\ \end{array} \]
Alternative 4
Error9.6
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -5.8 \cdot 10^{+211}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq -2.7 \cdot 10^{+174}:\\ \;\;\;\;y \cdot \frac{x}{-z}\\ \mathbf{else}:\\ \;\;\;\;y + \frac{x}{z}\\ \end{array} \]
Alternative 5
Error9.6
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -5.8 \cdot 10^{+211}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq -2.3 \cdot 10^{+174}:\\ \;\;\;\;\frac{y}{-\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;y + \frac{x}{z}\\ \end{array} \]
Alternative 6
Error8.8
Cost320
\[y + \frac{x}{z} \]
Alternative 7
Error31.2
Cost64
\[y \]

Error

Reproduce?

herbie shell --seed 2023068 
(FPCore (x y z)
  :name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
  :precision binary64

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

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