Average Error: 3.5 → 0.9
Time: 13.7s
Precision: binary64
Cost: 1352
\[\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}\;t \leq -5 \cdot 10^{+39}:\\ \;\;\;\;t_1 + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{elif}\;t \leq 1.3211675385380704 \cdot 10^{-117}:\\ \;\;\;\;\left(x + \frac{y \cdot -0.3333333333333333}{z}\right) + \frac{0.3333333333333333 \cdot \frac{t}{y}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{1}{y} \cdot \left(t \cdot \frac{0.3333333333333333}{z}\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 (<= t -5e+39)
     (+ t_1 (/ t (* y (* z 3.0))))
     (if (<= t 1.3211675385380704e-117)
       (+
        (+ x (/ (* y -0.3333333333333333) z))
        (/ (* 0.3333333333333333 (/ t y)) z))
       (+ t_1 (* (/ 1.0 y) (* t (/ 0.3333333333333333 z))))))))
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 (t <= -5e+39) {
		tmp = t_1 + (t / (y * (z * 3.0)));
	} else if (t <= 1.3211675385380704e-117) {
		tmp = (x + ((y * -0.3333333333333333) / z)) + ((0.3333333333333333 * (t / y)) / z);
	} else {
		tmp = t_1 + ((1.0 / y) * (t * (0.3333333333333333 / z)));
	}
	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 (t <= (-5d+39)) then
        tmp = t_1 + (t / (y * (z * 3.0d0)))
    else if (t <= 1.3211675385380704d-117) then
        tmp = (x + ((y * (-0.3333333333333333d0)) / z)) + ((0.3333333333333333d0 * (t / y)) / z)
    else
        tmp = t_1 + ((1.0d0 / y) * (t * (0.3333333333333333d0 / z)))
    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 (t <= -5e+39) {
		tmp = t_1 + (t / (y * (z * 3.0)));
	} else if (t <= 1.3211675385380704e-117) {
		tmp = (x + ((y * -0.3333333333333333) / z)) + ((0.3333333333333333 * (t / y)) / z);
	} else {
		tmp = t_1 + ((1.0 / y) * (t * (0.3333333333333333 / z)));
	}
	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 t <= -5e+39:
		tmp = t_1 + (t / (y * (z * 3.0)))
	elif t <= 1.3211675385380704e-117:
		tmp = (x + ((y * -0.3333333333333333) / z)) + ((0.3333333333333333 * (t / y)) / z)
	else:
		tmp = t_1 + ((1.0 / y) * (t * (0.3333333333333333 / z)))
	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 (t <= -5e+39)
		tmp = Float64(t_1 + Float64(t / Float64(y * Float64(z * 3.0))));
	elseif (t <= 1.3211675385380704e-117)
		tmp = Float64(Float64(x + Float64(Float64(y * -0.3333333333333333) / z)) + Float64(Float64(0.3333333333333333 * Float64(t / y)) / z));
	else
		tmp = Float64(t_1 + Float64(Float64(1.0 / y) * Float64(t * Float64(0.3333333333333333 / z))));
	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 (t <= -5e+39)
		tmp = t_1 + (t / (y * (z * 3.0)));
	elseif (t <= 1.3211675385380704e-117)
		tmp = (x + ((y * -0.3333333333333333) / z)) + ((0.3333333333333333 * (t / y)) / z);
	else
		tmp = t_1 + ((1.0 / y) * (t * (0.3333333333333333 / z)));
	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[t, -5e+39], N[(t$95$1 + N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.3211675385380704e-117], N[(N[(x + N[(N[(y * -0.3333333333333333), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[(t / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(N[(1.0 / y), $MachinePrecision] * N[(t * N[(0.3333333333333333 / z), $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}\;t \leq -5 \cdot 10^{+39}:\\
\;\;\;\;t_1 + \frac{t}{y \cdot \left(z \cdot 3\right)}\\

\mathbf{elif}\;t \leq 1.3211675385380704 \cdot 10^{-117}:\\
\;\;\;\;\left(x + \frac{y \cdot -0.3333333333333333}{z}\right) + \frac{0.3333333333333333 \cdot \frac{t}{y}}{z}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 3 regimes
  2. if t < -5.00000000000000015e39

    1. Initial program 0.8

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

    if -5.00000000000000015e39 < t < 1.32116753853807045e-117

    1. Initial program 5.6

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

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{1}{y} \cdot \left(t \cdot \frac{0.3333333333333333}{z}\right)} \]
    3. Taylor expanded in y around 0 1.4

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

      \[\leadsto \left(x - \color{blue}{\frac{0.3333333333333333 \cdot y}{z}}\right) + \frac{1}{y} \cdot \left(t \cdot \frac{0.3333333333333333}{z}\right) \]
      Proof
      (/.f64 (*.f64 1/3 y) z): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*r/_binary64 (*.f64 1/3 (/.f64 y z))): 34 points increase in error, 39 points decrease in error
    5. Applied egg-rr0.3

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

    if 1.32116753853807045e-117 < t

    1. Initial program 1.6

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

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

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

Alternatives

Alternative 1
Error0.8
Cost1352
\[\begin{array}{l} t_1 := x + \frac{y \cdot -0.3333333333333333}{z}\\ \mathbf{if}\;t \leq -5 \cdot 10^{+39}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{elif}\;t \leq 9.573898730330432 \cdot 10^{-38}:\\ \;\;\;\;t_1 + \frac{0.3333333333333333 \cdot \frac{t}{y}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{1}{y} \cdot \left(t \cdot \frac{0.3333333333333333}{z}\right)\\ \end{array} \]
Alternative 2
Error4.0
Cost1224
\[\begin{array}{l} t_1 := \left(x + \frac{y \cdot -0.3333333333333333}{z}\right) + \frac{0.3333333333333333 \cdot \frac{t}{y}}{z}\\ \mathbf{if}\;y \leq -3.1236381369920163 \cdot 10^{-59}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-185}:\\ \;\;\;\;x + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error4.0
Cost1224
\[\begin{array}{l} t_1 := \frac{0.3333333333333333 \cdot \frac{t}{y}}{z}\\ \mathbf{if}\;y \leq -3.1236381369920163 \cdot 10^{-59}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + t_1\\ \mathbf{elif}\;y \leq 10^{-185}:\\ \;\;\;\;x + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(x + \frac{y \cdot -0.3333333333333333}{z}\right) + t_1\\ \end{array} \]
Alternative 4
Error0.6
Cost1224
\[\begin{array}{l} t_1 := \left(x - \frac{y}{z \cdot 3}\right) + 0.3333333333333333 \cdot \frac{t}{y \cdot z}\\ \mathbf{if}\;t \leq -5 \cdot 10^{+39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5 \cdot 10^{+41}:\\ \;\;\;\;\left(x + \frac{y \cdot -0.3333333333333333}{z}\right) + \frac{0.3333333333333333 \cdot \frac{t}{y}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error0.5
Cost1224
\[\begin{array}{l} t_1 := x - \frac{y}{z \cdot 3}\\ \mathbf{if}\;t \leq -1.3948317448942416 \cdot 10^{-7}:\\ \;\;\;\;t_1 + t \cdot \frac{\frac{0.3333333333333333}{z}}{y}\\ \mathbf{elif}\;t \leq 5 \cdot 10^{+41}:\\ \;\;\;\;\left(x + \frac{y \cdot -0.3333333333333333}{z}\right) + \frac{0.3333333333333333 \cdot \frac{t}{y}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1 + 0.3333333333333333 \cdot \frac{t}{y \cdot z}\\ \end{array} \]
Alternative 6
Error0.6
Cost1224
\[\begin{array}{l} t_1 := x - \frac{y}{z \cdot 3}\\ \mathbf{if}\;t \leq -5 \cdot 10^{+39}:\\ \;\;\;\;t_1 + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{elif}\;t \leq 5 \cdot 10^{+41}:\\ \;\;\;\;\left(x + \frac{y \cdot -0.3333333333333333}{z}\right) + \frac{0.3333333333333333 \cdot \frac{t}{y}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1 + 0.3333333333333333 \cdot \frac{t}{y \cdot z}\\ \end{array} \]
Alternative 7
Error27.7
Cost980
\[\begin{array}{l} t_1 := \frac{y}{z \cdot -3}\\ \mathbf{if}\;x \leq -2641.590905507976:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.427011044750324 \cdot 10^{-67}:\\ \;\;\;\;\frac{\frac{\frac{t}{z}}{3}}{y}\\ \mathbf{elif}\;x \leq 3.42 \cdot 10^{-233}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.239169404932953 \cdot 10^{-131}:\\ \;\;\;\;\frac{t \cdot \frac{0.3333333333333333}{y}}{z}\\ \mathbf{elif}\;x \leq 0.0009343902028203919:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error27.7
Cost980
\[\begin{array}{l} t_1 := \frac{y}{z \cdot -3}\\ \mathbf{if}\;x \leq -2641.590905507976:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.427011044750324 \cdot 10^{-67}:\\ \;\;\;\;\frac{\frac{\frac{t}{z}}{3}}{y}\\ \mathbf{elif}\;x \leq 3.42 \cdot 10^{-233}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.239169404932953 \cdot 10^{-131}:\\ \;\;\;\;\frac{t}{y} \cdot \frac{0.3333333333333333}{z}\\ \mathbf{elif}\;x \leq 0.0009343902028203919:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error4.0
Cost968
\[\begin{array}{l} t_1 := x + \frac{-0.3333333333333333}{z} \cdot \left(y - \frac{t}{y}\right)\\ \mathbf{if}\;y \leq -3.1236381369920163 \cdot 10^{-59}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-183}:\\ \;\;\;\;x + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error27.7
Cost848
\[\begin{array}{l} t_1 := \frac{y}{z \cdot -3}\\ \mathbf{if}\;x \leq -1018099304841.8228:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.42 \cdot 10^{-233}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.239169404932953 \cdot 10^{-131}:\\ \;\;\;\;\frac{t \cdot \frac{0.3333333333333333}{y}}{z}\\ \mathbf{elif}\;x \leq 0.0009343902028203919:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error9.5
Cost840
\[\begin{array}{l} t_1 := x + -0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{if}\;y \leq -1.100020005997294 \cdot 10^{-28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.738723695768415 \cdot 10^{-74}:\\ \;\;\;\;x + \frac{\frac{t \cdot 0.3333333333333333}{y}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error8.7
Cost840
\[\begin{array}{l} t_1 := x + -0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{if}\;y \leq -1.100020005997294 \cdot 10^{-28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.738723695768415 \cdot 10^{-74}:\\ \;\;\;\;x + 0.3333333333333333 \cdot \frac{t}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error8.7
Cost840
\[\begin{array}{l} t_1 := x + -0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{if}\;y \leq -1.100020005997294 \cdot 10^{-28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.738723695768415 \cdot 10^{-74}:\\ \;\;\;\;x + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 14
Error15.9
Cost712
\[\begin{array}{l} t_1 := x + -0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{if}\;y \leq -1.5 \cdot 10^{-116}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{-162}:\\ \;\;\;\;\frac{\frac{\frac{t}{z}}{3}}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 15
Error27.3
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1018099304841.8228:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 0.0009343902028203919:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 16
Error37.7
Cost64
\[x \]

Error

Reproduce

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