Average Error: 9.8 → 0.0
Time: 5.8s
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

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

Derivation

  1. Initial program 9.8

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

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

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

Alternatives

Alternative 1
Error0.8
Cost712
\[\begin{array}{l} t_0 := \left(1 - \frac{x}{z}\right) \cdot y\\ \mathbf{if}\;y \leq -63:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\frac{x}{z} + y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.0
Cost576
\[y + \frac{x}{z} \cdot \left(1 - y\right) \]
Alternative 3
Error20.5
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-50}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-133}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 4
Error9.1
Cost320
\[\frac{x}{z} + y \]
Alternative 5
Error32.5
Cost64
\[y \]

Error

Reproduce

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