Average Error: 3.9 → 1.6
Time: 13.3s
Precision: binary64
Cost: 1220
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
\[\begin{array}{l} t_1 := x - \frac{y}{z \cdot 3}\\ \mathbf{if}\;z \cdot 3 \leq 10^{-122}:\\ \;\;\;\;t_1 + \frac{\frac{t}{z}}{3 \cdot y}\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- x (/ y (* z 3.0)))))
   (if (<= (* z 3.0) 1e-122)
     (+ t_1 (/ (/ t z) (* 3.0 y)))
     (+ t_1 (/ t (* (* z 3.0) 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) {
	double t_1 = x - (y / (z * 3.0));
	double tmp;
	if ((z * 3.0) <= 1e-122) {
		tmp = t_1 + ((t / z) / (3.0 * y));
	} else {
		tmp = t_1 + (t / ((z * 3.0) * y));
	}
	return tmp;
}
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
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x - (y / (z * 3.0d0))
    if ((z * 3.0d0) <= 1d-122) then
        tmp = t_1 + ((t / z) / (3.0d0 * y))
    else
        tmp = t_1 + (t / ((z * 3.0d0) * y))
    end if
    code = tmp
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) {
	double t_1 = x - (y / (z * 3.0));
	double tmp;
	if ((z * 3.0) <= 1e-122) {
		tmp = t_1 + ((t / z) / (3.0 * y));
	} else {
		tmp = t_1 + (t / ((z * 3.0) * y));
	}
	return tmp;
}
def code(x, y, z, t):
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
def code(x, y, z, t):
	t_1 = x - (y / (z * 3.0))
	tmp = 0
	if (z * 3.0) <= 1e-122:
		tmp = t_1 + ((t / z) / (3.0 * y))
	else:
		tmp = t_1 + (t / ((z * 3.0) * y))
	return tmp
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)
	t_1 = Float64(x - Float64(y / Float64(z * 3.0)))
	tmp = 0.0
	if (Float64(z * 3.0) <= 1e-122)
		tmp = Float64(t_1 + Float64(Float64(t / z) / Float64(3.0 * y)));
	else
		tmp = Float64(t_1 + Float64(t / Float64(Float64(z * 3.0) * y)));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
end
function tmp_2 = code(x, y, z, t)
	t_1 = x - (y / (z * 3.0));
	tmp = 0.0;
	if ((z * 3.0) <= 1e-122)
		tmp = t_1 + ((t / z) / (3.0 * y));
	else
		tmp = t_1 + (t / ((z * 3.0) * y));
	end
	tmp_2 = tmp;
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_] := Block[{t$95$1 = N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * 3.0), $MachinePrecision], 1e-122], N[(t$95$1 + N[(N[(t / z), $MachinePrecision] / N[(3.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
t_1 := x - \frac{y}{z \cdot 3}\\
\mathbf{if}\;z \cdot 3 \leq 10^{-122}:\\
\;\;\;\;t_1 + \frac{\frac{t}{z}}{3 \cdot y}\\

\mathbf{else}:\\
\;\;\;\;t_1 + \frac{t}{\left(z \cdot 3\right) \cdot y}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 z 3) < 1.00000000000000006e-122

    1. Initial program 6.0

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

      \[\leadsto \color{blue}{\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z}}{y \cdot 3}} \]
      Proof
      (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 (/.f64 t z) (*.f64 y 3))): 0 points increase in error, 0 points decrease in error
      (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 (/.f64 t z) (Rewrite<= *-commutative_binary64 (*.f64 3 y)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (Rewrite<= associate-/r*_binary64 (/.f64 t (*.f64 z (*.f64 3 y))))): 19 points increase in error, 17 points decrease in error
      (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 z 3) y)))): 10 points increase in error, 9 points decrease in error

    if 1.00000000000000006e-122 < (*.f64 z 3)

    1. Initial program 1.1

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot 3 \leq 10^{-122}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z}}{3 \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \end{array} \]

Alternatives

Alternative 1
Error7.7
Cost1364
\[\begin{array}{l} t_1 := x + \frac{\frac{t}{z \cdot 3}}{y}\\ t_2 := x + \frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{if}\;y \leq -1.62 \cdot 10^{-59}:\\ \;\;\;\;x + \frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-107}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.25 \cdot 10^{-36}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{+23}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{\frac{t}{z}}{y}\right) \cdot -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error11.0
Cost1236
\[\begin{array}{l} t_1 := x + 0.3333333333333333 \cdot \frac{\frac{t}{y}}{z}\\ \mathbf{if}\;y \leq -1 \cdot 10^{-57}:\\ \;\;\;\;x + \frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-145}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{-34}:\\ \;\;\;\;x + \frac{y}{z} \cdot -0.3333333333333333\\ \mathbf{elif}\;y \leq 2.95 \cdot 10^{-10}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{+23}:\\ \;\;\;\;\left(y - \frac{t}{y}\right) \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{-0.3333333333333333}{\frac{z}{y}}\\ \end{array} \]
Alternative 3
Error7.7
Cost1236
\[\begin{array}{l} t_1 := x + \frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{if}\;y \leq -1.52 \cdot 10^{-61}:\\ \;\;\;\;x + \frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-107}:\\ \;\;\;\;x + \frac{t \cdot \frac{0.3333333333333333}{z}}{y}\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-10}:\\ \;\;\;\;x + 0.3333333333333333 \cdot \frac{\frac{t}{y}}{z}\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+23}:\\ \;\;\;\;\left(y - \frac{t}{y}\right) \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error7.7
Cost1236
\[\begin{array}{l} t_1 := x + \frac{\frac{t}{z \cdot 3}}{y}\\ t_2 := x + \frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{if}\;y \leq -1 \cdot 10^{-57}:\\ \;\;\;\;x + \frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-107}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{-36}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-10}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{+23}:\\ \;\;\;\;\left(y - \frac{t}{y}\right) \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error1.6
Cost1220
\[\begin{array}{l} \mathbf{if}\;z \cdot 3 \leq 10^{-122}:\\ \;\;\;\;x + \frac{\frac{\frac{t}{z}}{y} - \frac{y}{z}}{3}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{\left(z \cdot 3\right) \cdot y} + \left(x + \frac{y}{z} \cdot -0.3333333333333333\right)\\ \end{array} \]
Alternative 6
Error1.6
Cost1220
\[\begin{array}{l} \mathbf{if}\;z \cdot 3 \leq 10^{-122}:\\ \;\;\;\;x + \frac{\frac{\frac{t}{z}}{y} - \frac{y}{z}}{3}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \end{array} \]
Alternative 7
Error28.3
Cost1112
\[\begin{array}{l} \mathbf{if}\;x \leq -8.5 \cdot 10^{+134}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{+102}:\\ \;\;\;\;y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{elif}\;x \leq -3.7 \cdot 10^{+40}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-91}:\\ \;\;\;\;\frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{elif}\;x \leq -1.88 \cdot 10^{-121}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{y}}{z}\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{+19}:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error28.2
Cost1112
\[\begin{array}{l} \mathbf{if}\;x \leq -8.5 \cdot 10^{+134}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2 \cdot 10^{+102}:\\ \;\;\;\;y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{+41}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-91}:\\ \;\;\;\;\frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{elif}\;x \leq -1.85 \cdot 10^{-124}:\\ \;\;\;\;\frac{t}{z} \cdot \frac{0.3333333333333333}{y}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+16}:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error1.6
Cost968
\[\begin{array}{l} t_1 := x + \left(y - \frac{t}{y}\right) \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{if}\;y \leq -4.5 \cdot 10^{-59}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-132}:\\ \;\;\;\;x + \frac{\frac{t}{z \cdot 3}}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error1.6
Cost968
\[\begin{array}{l} t_1 := y - \frac{t}{y}\\ \mathbf{if}\;y \leq -1.02 \cdot 10^{-63}:\\ \;\;\;\;x + t_1 \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-130}:\\ \;\;\;\;x + \frac{\frac{t}{z \cdot 3}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{-0.3333333333333333}{\frac{z}{t_1}}\\ \end{array} \]
Alternative 11
Error1.6
Cost968
\[\begin{array}{l} t_1 := x + \frac{y - \frac{t}{y}}{z \cdot -3}\\ \mathbf{if}\;y \leq -9.5 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-130}:\\ \;\;\;\;x + \frac{\frac{t}{z \cdot 3}}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error28.1
Cost848
\[\begin{array}{l} t_1 := y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{if}\;x \leq -8.5 \cdot 10^{+134}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.2 \cdot 10^{+102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.1 \cdot 10^{+40}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{+19}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 13
Error28.1
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -1.16 \cdot 10^{+135}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{+102}:\\ \;\;\;\;y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{elif}\;x \leq -5.5 \cdot 10^{+40}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+16}:\\ \;\;\;\;\frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Error28.1
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -8.5 \cdot 10^{+134}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.2 \cdot 10^{+102}:\\ \;\;\;\;y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{elif}\;x \leq -5.5 \cdot 10^{+40}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.3 \cdot 10^{+16}:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 15
Error11.7
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -8.5 \cdot 10^{-11}:\\ \;\;\;\;x + \frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-93}:\\ \;\;\;\;\left(y - \frac{t}{y}\right) \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot -0.3333333333333333}{z}\\ \end{array} \]
Alternative 16
Error1.8
Cost832
\[x + \frac{\frac{\frac{t}{z}}{y} - \frac{y}{z}}{3} \]
Alternative 17
Error15.9
Cost712
\[\begin{array}{l} t_1 := x + \frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{if}\;y \leq -5.8 \cdot 10^{-129}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-242}:\\ \;\;\;\;\frac{t}{z} \cdot \frac{0.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 18
Error15.9
Cost712
\[\begin{array}{l} t_1 := x + \frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{if}\;y \leq -7.8 \cdot 10^{-129}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-242}:\\ \;\;\;\;\frac{t}{z} \cdot \frac{0.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 19
Error37.4
Cost64
\[x \]

Error

Reproduce

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