?

Average Error: 10.2 → 0.0
Time: 11.2s
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.2
Target0.0
Herbie0.0
\[\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}} \]

Derivation?

  1. Initial program 10.2

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

    \[\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.5

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

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

    \[ 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
Error0.7
Cost712
\[\begin{array}{l} t_0 := y \cdot \frac{z - x}{z}\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.7
Cost712
\[\begin{array}{l} t_0 := \frac{y}{\frac{z}{z - x}}\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error20.6
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{-36}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{-125}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 4
Error9.0
Cost320
\[y + \frac{x}{z} \]
Alternative 5
Error31.1
Cost64
\[y \]

Error

Reproduce?

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