?

Average Error: 5.75% → 0.95%
Time: 13.3s
Precision: binary64
Cost: 1480

?

\[\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 -5 \cdot 10^{-42}:\\ \;\;\;\;t_1 + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{elif}\;z \cdot 3 \leq 2 \cdot 10^{+62}:\\ \;\;\;\;x + \frac{\frac{y - \frac{t}{y}}{z}}{-3}\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{t}{z \cdot \left(3 \cdot y\right)}\\ \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) -5e-42)
     (+ t_1 (/ t (* (* z 3.0) y)))
     (if (<= (* z 3.0) 2e+62)
       (+ x (/ (/ (- y (/ t y)) z) -3.0))
       (+ 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) <= -5e-42) {
		tmp = t_1 + (t / ((z * 3.0) * y));
	} else if ((z * 3.0) <= 2e+62) {
		tmp = x + (((y - (t / y)) / z) / -3.0);
	} 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) <= (-5d-42)) then
        tmp = t_1 + (t / ((z * 3.0d0) * y))
    else if ((z * 3.0d0) <= 2d+62) then
        tmp = x + (((y - (t / y)) / z) / (-3.0d0))
    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) <= -5e-42) {
		tmp = t_1 + (t / ((z * 3.0) * y));
	} else if ((z * 3.0) <= 2e+62) {
		tmp = x + (((y - (t / y)) / z) / -3.0);
	} 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) <= -5e-42:
		tmp = t_1 + (t / ((z * 3.0) * y))
	elif (z * 3.0) <= 2e+62:
		tmp = x + (((y - (t / y)) / z) / -3.0)
	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) <= -5e-42)
		tmp = Float64(t_1 + Float64(t / Float64(Float64(z * 3.0) * y)));
	elseif (Float64(z * 3.0) <= 2e+62)
		tmp = Float64(x + Float64(Float64(Float64(y - Float64(t / y)) / z) / -3.0));
	else
		tmp = Float64(t_1 + Float64(t / Float64(z * Float64(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) <= -5e-42)
		tmp = t_1 + (t / ((z * 3.0) * y));
	elseif ((z * 3.0) <= 2e+62)
		tmp = x + (((y - (t / y)) / z) / -3.0);
	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], -5e-42], N[(t$95$1 + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * 3.0), $MachinePrecision], 2e+62], N[(x + N[(N[(N[(y - N[(t / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] / -3.0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(t / N[(z * N[(3.0 * y), $MachinePrecision]), $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 -5 \cdot 10^{-42}:\\
\;\;\;\;t_1 + \frac{t}{\left(z \cdot 3\right) \cdot y}\\

\mathbf{elif}\;z \cdot 3 \leq 2 \cdot 10^{+62}:\\
\;\;\;\;x + \frac{\frac{y - \frac{t}{y}}{z}}{-3}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original5.75%
Target2.46%
Herbie0.95%
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y} \]

Derivation?

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

    1. Initial program 0.71

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

    if -5.00000000000000003e-42 < (*.f64 z 3) < 2.00000000000000007e62

    1. Initial program 15

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

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

      [Start]15

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

      associate-+l- [=>]15

      \[ \color{blue}{x - \left(\frac{y}{z \cdot 3} - \frac{t}{\left(z \cdot 3\right) \cdot y}\right)} \]

      sub-neg [=>]15

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

      neg-mul-1 [=>]15

      \[ x + \color{blue}{-1 \cdot \left(\frac{y}{z \cdot 3} - \frac{t}{\left(z \cdot 3\right) \cdot y}\right)} \]

      distribute-lft-out-- [<=]15

      \[ x + \color{blue}{\left(-1 \cdot \frac{y}{z \cdot 3} - -1 \cdot \frac{t}{\left(z \cdot 3\right) \cdot y}\right)} \]

      associate-*r/ [=>]15

      \[ x + \left(\color{blue}{\frac{-1 \cdot y}{z \cdot 3}} - -1 \cdot \frac{t}{\left(z \cdot 3\right) \cdot y}\right) \]

      associate-*l/ [<=]15.06

      \[ x + \left(\color{blue}{\frac{-1}{z \cdot 3} \cdot y} - -1 \cdot \frac{t}{\left(z \cdot 3\right) \cdot y}\right) \]

      associate-*r/ [=>]15.06

      \[ x + \left(\frac{-1}{z \cdot 3} \cdot y - \color{blue}{\frac{-1 \cdot t}{\left(z \cdot 3\right) \cdot y}}\right) \]

      times-frac [=>]1.19

      \[ x + \left(\frac{-1}{z \cdot 3} \cdot y - \color{blue}{\frac{-1}{z \cdot 3} \cdot \frac{t}{y}}\right) \]

      distribute-lft-out-- [=>]1.19

      \[ x + \color{blue}{\frac{-1}{z \cdot 3} \cdot \left(y - \frac{t}{y}\right)} \]

      *-commutative [=>]1.19

      \[ x + \frac{-1}{\color{blue}{3 \cdot z}} \cdot \left(y - \frac{t}{y}\right) \]

      associate-/r* [=>]1.21

      \[ x + \color{blue}{\frac{\frac{-1}{3}}{z}} \cdot \left(y - \frac{t}{y}\right) \]

      metadata-eval [=>]1.21

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

      \[\leadsto x + \color{blue}{\frac{\frac{y - \frac{t}{y}}{z}}{-3}} \]

    if 2.00000000000000007e62 < (*.f64 z 3)

    1. Initial program 0.62

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
    2. Taylor expanded in t around 0 0.63

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

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

      [Start]0.63

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

      associate-/r* [=>]11.63

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

      associate-*r/ [=>]11.63

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

      associate-*l/ [<=]11.64

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

      metadata-eval [<=]11.64

      \[ \left(x - \frac{y}{z \cdot 3}\right) + \frac{\color{blue}{\frac{1}{3}}}{z} \cdot \frac{t}{y} \]

      associate-/r* [<=]11.64

      \[ \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{1}{3 \cdot z}} \cdot \frac{t}{y} \]

      *-commutative [<=]11.64

      \[ \left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{\color{blue}{z \cdot 3}} \cdot \frac{t}{y} \]

      associate-/r* [=>]11.63

      \[ \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{\frac{1}{z}}{3}} \cdot \frac{t}{y} \]

      times-frac [<=]1.67

      \[ \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{\frac{1}{z} \cdot t}{3 \cdot y}} \]

      associate-*r/ [<=]11.54

      \[ \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{1}{z} \cdot \frac{t}{3 \cdot y}} \]

      associate-*l/ [=>]11.52

      \[ \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{1 \cdot \frac{t}{3 \cdot y}}{z}} \]

      *-lft-identity [=>]11.52

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

      associate-/r* [<=]0.61

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

      *-commutative [=>]0.61

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

      *-commutative [=>]0.61

      \[ \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{z \cdot \color{blue}{\left(y \cdot 3\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.95

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

Alternatives

Alternative 1
Error2.1%
Cost1225
\[\begin{array}{l} \mathbf{if}\;t \leq -4.1 \cdot 10^{+180} \lor \neg \left(t \leq 5 \cdot 10^{-95}\right):\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{z \cdot \left(3 \cdot y\right)}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y - \frac{t}{y}}{z}}{-3}\\ \end{array} \]
Alternative 2
Error2.52%
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{-71} \lor \neg \left(y \leq 8 \cdot 10^{-97}\right):\\ \;\;\;\;x + \left(y - \frac{t}{y}\right) \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{t}{z \cdot 3}}{y}\\ \end{array} \]
Alternative 3
Error2.55%
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -7.2 \cdot 10^{-71} \lor \neg \left(y \leq 4.2 \cdot 10^{-98}\right):\\ \;\;\;\;x + \frac{-0.3333333333333333}{\frac{z}{y - \frac{t}{y}}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{t}{z \cdot 3}}{y}\\ \end{array} \]
Alternative 4
Error2.59%
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{-71} \lor \neg \left(y \leq 4 \cdot 10^{-96}\right):\\ \;\;\;\;x + \frac{\frac{y - \frac{t}{y}}{z}}{-3}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{t}{z \cdot 3}}{y}\\ \end{array} \]
Alternative 5
Error2.56%
Cost968
\[\begin{array}{l} t_1 := y - \frac{t}{y}\\ \mathbf{if}\;y \leq -2 \cdot 10^{-70}:\\ \;\;\;\;x + \frac{t_1 \cdot -0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-97}:\\ \;\;\;\;x + \frac{\frac{t}{z \cdot 3}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{-0.3333333333333333}{\frac{z}{t_1}}\\ \end{array} \]
Alternative 6
Error2.52%
Cost968
\[\begin{array}{l} t_1 := y - \frac{t}{y}\\ \mathbf{if}\;y \leq -1.8 \cdot 10^{-70}:\\ \;\;\;\;x + \frac{t_1}{z \cdot -3}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-96}:\\ \;\;\;\;x + \frac{\frac{t}{z \cdot 3}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{-0.3333333333333333}{\frac{z}{t_1}}\\ \end{array} \]
Alternative 7
Error44.51%
Cost849
\[\begin{array}{l} \mathbf{if}\;x \leq -8.5 \cdot 10^{-27}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-51} \lor \neg \left(x \leq 9.5 \cdot 10^{-9}\right) \land x \leq 2.4 \cdot 10^{+45}:\\ \;\;\;\;-0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error44.32%
Cost849
\[\begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-17}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8.9 \cdot 10^{-51} \lor \neg \left(x \leq 3.7 \cdot 10^{-9}\right) \land x \leq 3.5 \cdot 10^{+45}:\\ \;\;\;\;\frac{\frac{y}{-3}}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error44.34%
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{-20}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-51}:\\ \;\;\;\;\frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{elif}\;x \leq 4.1 \cdot 10^{-9}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+42}:\\ \;\;\;\;-0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error13.19%
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -1.4 \cdot 10^{-41}:\\ \;\;\;\;x + \frac{\frac{y}{z}}{-3}\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{-9}:\\ \;\;\;\;x + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y}{-3}}{z}\\ \end{array} \]
Alternative 11
Error9.38%
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{-41}:\\ \;\;\;\;x + \frac{\frac{y}{z}}{-3}\\ \mathbf{elif}\;y \leq 1.12 \cdot 10^{-10}:\\ \;\;\;\;x + \frac{\frac{t}{z} \cdot 0.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y}{-3}}{z}\\ \end{array} \]
Alternative 12
Error9.32%
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -2.3 \cdot 10^{-41}:\\ \;\;\;\;x + \frac{\frac{y}{z}}{-3}\\ \mathbf{elif}\;y \leq 2.15 \cdot 10^{-8}:\\ \;\;\;\;x + \frac{\frac{t}{z \cdot 3}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y}{-3}}{z}\\ \end{array} \]
Alternative 13
Error28.78%
Cost448
\[x + \frac{\frac{y}{z}}{-3} \]
Alternative 14
Error28.67%
Cost448
\[x + \frac{\frac{y}{-3}}{z} \]
Alternative 15
Error58.76%
Cost64
\[x \]

Error

Reproduce?

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