?

Average Error: 10.2 → 0.1
Time: 6.3s
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.2
Target0.0
Herbie0.1
\[\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 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.8
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1720000 \lor \neg \left(y \leq 1.15 \cdot 10^{-5}\right):\\ \;\;\;\;\left(1 - \frac{x}{z}\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} + y\\ \end{array} \]
Alternative 2
Error0.8
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1720000 \lor \neg \left(y \leq 1.15 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{y}{\frac{z}{z - x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} + y\\ \end{array} \]
Alternative 3
Error0.1
Cost576
\[y + \frac{1 - y}{\frac{z}{x}} \]
Alternative 4
Error20.0
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -2.4 \cdot 10^{-86}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 8.8 \cdot 10^{-67}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 5
Error9.4
Cost320
\[\frac{x}{z} + y \]
Alternative 6
Error32.1
Cost64
\[y \]

Error

Reproduce?

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