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

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original5.8
Target0.1
Herbie0.1
\[x + y \cdot \frac{y}{z} \]

Derivation

  1. Initial program 5.8

    \[x + \frac{y \cdot y}{z} \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{y}{z}, x\right)} \]
    Proof
    (fma.f64 y (/.f64 y z) x): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y (/.f64 y z)) x)): 0 points increase in error, 1 points decrease in error
    (+.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 y y) z)) x): 39 points increase in error, 7 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 x (/.f64 (*.f64 y y) z))): 0 points increase in error, 0 points decrease in error
  3. Applied egg-rr0.1

    \[\leadsto \color{blue}{y \cdot \frac{y}{z} + x} \]
  4. Applied egg-rr0.1

    \[\leadsto \color{blue}{\frac{y}{\frac{z}{y}}} + x \]
  5. Final simplification0.1

    \[\leadsto \frac{y}{\frac{z}{y}} + x \]

Alternatives

Alternative 1
Error10.9
Cost1096
\[\begin{array}{l} t_0 := \frac{y \cdot y}{z}\\ t_1 := \frac{y}{\frac{z}{y}}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+43}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 10^{+60}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error10.9
Cost1096
\[\begin{array}{l} t_0 := \frac{y \cdot y}{z}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+43}:\\ \;\;\;\;y \cdot \frac{y}{z}\\ \mathbf{elif}\;t_0 \leq 10^{+60}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{y}}\\ \end{array} \]
Alternative 3
Error18.5
Cost980
\[\begin{array}{l} t_0 := \frac{y \cdot y}{z}\\ \mathbf{if}\;y \leq -1.06 \cdot 10^{+147}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{+56}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.913500775179816 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.55 \cdot 10^{+43}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error21.2
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022291 
(FPCore (x y z)
  :name "Crypto.Random.Test:calculate from crypto-random-0.0.9"
  :precision binary64

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

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