Average Error: 10.0 → 0.1
Time: 7.1s
Precision: binary64
Cost: 704
\[\frac{x + y \cdot \left(z - x\right)}{z} \]
\[\frac{x}{z} + \left(1 - \frac{x}{z}\right) \cdot y \]
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
(FPCore (x y z) :precision binary64 (+ (/ x z) (* (- 1.0 (/ x z)) y)))
double code(double x, double y, double z) {
	return (x + (y * (z - x))) / z;
}
double code(double x, double y, double z) {
	return (x / z) + ((1.0 - (x / z)) * y);
}
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 = (x / z) + ((1.0d0 - (x / z)) * y)
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 (x / z) + ((1.0 - (x / z)) * y);
}
def code(x, y, z):
	return (x + (y * (z - x))) / z
def code(x, y, z):
	return (x / z) + ((1.0 - (x / z)) * y)
function code(x, y, z)
	return Float64(Float64(x + Float64(y * Float64(z - x))) / z)
end
function code(x, y, z)
	return Float64(Float64(x / z) + Float64(Float64(1.0 - Float64(x / z)) * y))
end
function tmp = code(x, y, z)
	tmp = (x + (y * (z - x))) / z;
end
function tmp = code(x, y, z)
	tmp = (x / z) + ((1.0 - (x / z)) * y);
end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := N[(N[(x / z), $MachinePrecision] + N[(N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\frac{x + y \cdot \left(z - x\right)}{z}
\frac{x}{z} + \left(1 - \frac{x}{z}\right) \cdot y

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 10.0

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

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

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

Alternatives

Alternative 1
Error0.5
Cost1864
\[\begin{array}{l} t_0 := \frac{x + y \cdot \left(z - x\right)}{z}\\ t_1 := \left(1 - \frac{x}{z}\right) \cdot y\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+291}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error9.9
Cost1108
\[\begin{array}{l} t_0 := \frac{x}{z} + y\\ t_1 := \frac{x}{\frac{z}{1 - y}}\\ \mathbf{if}\;x \leq -4.6 \cdot 10^{+173}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.4941530778943612 \cdot 10^{-138}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.930112861205471 \cdot 10^{-94}:\\ \;\;\;\;\frac{y \cdot \left(z - x\right)}{z}\\ \mathbf{elif}\;x \leq 3.5984261973140385 \cdot 10^{-15}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+52}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error9.2
Cost844
\[\begin{array}{l} t_0 := \frac{x}{z} + y\\ t_1 := \frac{x}{\frac{z}{1 - y}}\\ \mathbf{if}\;x \leq -4.6 \cdot 10^{+173}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.5984261973140385 \cdot 10^{-15}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+52}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.0
Cost712
\[\begin{array}{l} t_0 := \left(1 - \frac{x}{z}\right) \cdot y\\ \mathbf{if}\;y \leq -1296949.680851089:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.9570055291872127 \cdot 10^{-18}:\\ \;\;\;\;\frac{x}{z} + y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error9.4
Cost648
\[\begin{array}{l} t_0 := \frac{x}{z} + y\\ \mathbf{if}\;y \leq -2.2322738979989566 \cdot 10^{+61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.3729984763004903 \cdot 10^{+34}:\\ \;\;\;\;\frac{x}{z} \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error19.7
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -5.8547347651076085 \cdot 10^{-43}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 2.8119025787597107 \cdot 10^{-50}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 7
Error9.0
Cost320
\[\frac{x}{z} + y \]
Alternative 8
Error32.0
Cost64
\[y \]

Error

Reproduce

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