Average Error: 3.9 → 1.7
Time: 7.1s
Precision: binary64
Cost: 960
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t \cdot 0.3333333333333333}{z}}{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
 (+ (- x (/ y (* z 3.0))) (/ (/ (* t 0.3333333333333333) z) 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 (x - (y / (z * 3.0))) + (((t * 0.3333333333333333) / z) / 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 = (x - (y / (z * 3.0d0))) + (((t * 0.3333333333333333d0) / z) / 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 (x - (y / (z * 3.0))) + (((t * 0.3333333333333333) / z) / 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 (x - (y / (z * 3.0))) + (((t * 0.3333333333333333) / z) / 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(x - Float64(y / Float64(z * 3.0))) + Float64(Float64(Float64(t * 0.3333333333333333) / z) / 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 = (x - (y / (z * 3.0))) + (((t * 0.3333333333333333) / z) / 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[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(t * 0.3333333333333333), $MachinePrecision] / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t \cdot 0.3333333333333333}{z}}{y}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 3.9

    \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
  2. Applied egg-rr1.7

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

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

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

Alternatives

Alternative 1
Error4.0
Cost1224
\[\begin{array}{l} t_1 := x + \frac{y - \frac{t}{y}}{z \cdot -3}\\ \mathbf{if}\;z \cdot 3 \leq -1.5 \cdot 10^{+200}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot 3 \leq -2 \cdot 10^{+180}:\\ \;\;\;\;x + t \cdot \frac{\frac{0.3333333333333333}{y}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error8.9
Cost840
\[\begin{array}{l} t_1 := x + y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{if}\;y \leq -420385767404173440:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.5027853642709671 \cdot 10^{-5}:\\ \;\;\;\;x + t \cdot \frac{\frac{0.3333333333333333}{y}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error8.6
Cost840
\[\begin{array}{l} t_1 := x + y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{if}\;y \leq -420385767404173440:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.5027853642709671 \cdot 10^{-5}:\\ \;\;\;\;x + 0.3333333333333333 \cdot \frac{t}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error15.5
Cost712
\[\begin{array}{l} t_1 := x + y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{if}\;y \leq -1.12 \cdot 10^{-147}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{-180}:\\ \;\;\;\;\frac{t \cdot \frac{0.3333333333333333}{z}}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error15.6
Cost712
\[\begin{array}{l} t_1 := x + y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{if}\;y \leq -1.12 \cdot 10^{-147}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{-180}:\\ \;\;\;\;\frac{0.3333333333333333}{y \cdot \frac{z}{t}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error31.4
Cost584
\[\begin{array}{l} t_1 := \frac{\frac{y}{-3}}{z}\\ \mathbf{if}\;y \leq -5.33031095332923 \cdot 10^{+101}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6.848495287851678 \cdot 10^{+95}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error31.4
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -5.33031095332923 \cdot 10^{+101}:\\ \;\;\;\;\frac{\frac{y}{z}}{-3}\\ \mathbf{elif}\;y \leq 6.848495287851678 \cdot 10^{+95}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{-3}}{z}\\ \end{array} \]
Alternative 8
Error31.4
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -5.33031095332923 \cdot 10^{+101}:\\ \;\;\;\;\frac{\frac{y}{z}}{-3}\\ \mathbf{elif}\;y \leq 6.848495287851678 \cdot 10^{+95}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot -0.3333333333333333}{z}\\ \end{array} \]
Alternative 9
Error18.0
Cost448
\[x + y \cdot \frac{-0.3333333333333333}{z} \]
Alternative 10
Error37.7
Cost64
\[x \]

Error

Reproduce

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