Average Error: 3.8 → 1.7
Time: 5.7s
Precision: binary64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
\[\left(\frac{\frac{t \cdot 0.3333333333333333}{z}}{y} + x\right) - \frac{1}{\frac{z}{0.3333333333333333 \cdot y}} \]
(FPCore (x y z t)
 :precision binary64
 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
(FPCore (x y z t)
 :precision binary64
 (-
  (+ (/ (/ (* t 0.3333333333333333) z) y) x)
  (/ 1.0 (/ z (* 0.3333333333333333 y)))))
double code(double x, double y, double z, double t) {
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
double code(double x, double y, double z, double t) {
	return ((((t * 0.3333333333333333) / z) / y) + x) - (1.0 / (z / (0.3333333333333333 * y)));
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (x - (y / (z * 3.0d0))) + (t / ((z * 3.0d0) * y))
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = ((((t * 0.3333333333333333d0) / z) / y) + x) - (1.0d0 / (z / (0.3333333333333333d0 * y)))
end function
public static double code(double x, double y, double z, double t) {
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
public static double code(double x, double y, double z, double t) {
	return ((((t * 0.3333333333333333) / z) / y) + x) - (1.0 / (z / (0.3333333333333333 * y)));
}
def code(x, y, z, t):
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
def code(x, y, z, t):
	return ((((t * 0.3333333333333333) / z) / y) + x) - (1.0 / (z / (0.3333333333333333 * y)))
function code(x, y, z, t)
	return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(z * 3.0) * y)))
end
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(Float64(t * 0.3333333333333333) / z) / y) + x) - Float64(1.0 / Float64(z / Float64(0.3333333333333333 * y))))
end
function tmp = code(x, y, z, t)
	tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
end
function tmp = code(x, y, z, t)
	tmp = ((((t * 0.3333333333333333) / z) / y) + x) - (1.0 / (z / (0.3333333333333333 * y)));
end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(N[(N[(N[(t * 0.3333333333333333), $MachinePrecision] / z), $MachinePrecision] / y), $MachinePrecision] + x), $MachinePrecision] - N[(1.0 / N[(z / N[(0.3333333333333333 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\left(\frac{\frac{t \cdot 0.3333333333333333}{z}}{y} + x\right) - \frac{1}{\frac{z}{0.3333333333333333 \cdot y}}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.8
Target1.6
Herbie1.7
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y} \]

Derivation

  1. Initial program 3.8

    \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
  2. Simplified4.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-0.3333333333333333}{z}, y - \frac{t}{y}, x\right)} \]
  3. Taylor expanded in z around 0 3.9

    \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot \frac{t}{y \cdot z} + x\right) - 0.3333333333333333 \cdot \frac{y}{z}} \]
  4. Applied egg-rr3.8

    \[\leadsto \left(0.3333333333333333 \cdot \frac{t}{y \cdot z} + x\right) - \color{blue}{\frac{1}{\frac{z}{y \cdot 0.3333333333333333}}} \]
  5. Applied egg-rr1.7

    \[\leadsto \left(\color{blue}{\frac{\frac{t \cdot 0.3333333333333333}{z}}{y}} + x\right) - \frac{1}{\frac{z}{y \cdot 0.3333333333333333}} \]
  6. Final simplification1.7

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

Reproduce

herbie shell --seed 2022131 
(FPCore (x y z t)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, H"
  :precision binary64

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

  (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))