Average Error: 3.4 → 0.5
Time: 20.0s
Precision: binary64
Cost: 1608
\[\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^{-19}:\\ \;\;\;\;t_1 + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{elif}\;z \cdot 3 \leq 5 \cdot 10^{-13}:\\ \;\;\;\;t_1 + \frac{1}{z} \cdot \frac{t}{3 \cdot y}\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{\frac{t \cdot 0.3333333333333333}{z}}{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) -5e-19)
     (+ t_1 (/ t (* (* z 3.0) y)))
     (if (<= (* z 3.0) 5e-13)
       (+ t_1 (* (/ 1.0 z) (/ t (* 3.0 y))))
       (+ t_1 (/ (/ (* 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) {
	double t_1 = x - (y / (z * 3.0));
	double tmp;
	if ((z * 3.0) <= -5e-19) {
		tmp = t_1 + (t / ((z * 3.0) * y));
	} else if ((z * 3.0) <= 5e-13) {
		tmp = t_1 + ((1.0 / z) * (t / (3.0 * y)));
	} else {
		tmp = t_1 + (((t * 0.3333333333333333) / z) / 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-19)) then
        tmp = t_1 + (t / ((z * 3.0d0) * y))
    else if ((z * 3.0d0) <= 5d-13) then
        tmp = t_1 + ((1.0d0 / z) * (t / (3.0d0 * y)))
    else
        tmp = t_1 + (((t * 0.3333333333333333d0) / z) / 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-19) {
		tmp = t_1 + (t / ((z * 3.0) * y));
	} else if ((z * 3.0) <= 5e-13) {
		tmp = t_1 + ((1.0 / z) * (t / (3.0 * y)));
	} else {
		tmp = t_1 + (((t * 0.3333333333333333) / z) / 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-19:
		tmp = t_1 + (t / ((z * 3.0) * y))
	elif (z * 3.0) <= 5e-13:
		tmp = t_1 + ((1.0 / z) * (t / (3.0 * y)))
	else:
		tmp = t_1 + (((t * 0.3333333333333333) / z) / 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-19)
		tmp = Float64(t_1 + Float64(t / Float64(Float64(z * 3.0) * y)));
	elseif (Float64(z * 3.0) <= 5e-13)
		tmp = Float64(t_1 + Float64(Float64(1.0 / z) * Float64(t / Float64(3.0 * y))));
	else
		tmp = Float64(t_1 + Float64(Float64(Float64(t * 0.3333333333333333) / z) / 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-19)
		tmp = t_1 + (t / ((z * 3.0) * y));
	elseif ((z * 3.0) <= 5e-13)
		tmp = t_1 + ((1.0 / z) * (t / (3.0 * y)));
	else
		tmp = t_1 + (((t * 0.3333333333333333) / z) / 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-19], N[(t$95$1 + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * 3.0), $MachinePrecision], 5e-13], N[(t$95$1 + N[(N[(1.0 / z), $MachinePrecision] * N[(t / N[(3.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + 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}
\begin{array}{l}
t_1 := x - \frac{y}{z \cdot 3}\\
\mathbf{if}\;z \cdot 3 \leq -5 \cdot 10^{-19}:\\
\;\;\;\;t_1 + \frac{t}{\left(z \cdot 3\right) \cdot y}\\

\mathbf{elif}\;z \cdot 3 \leq 5 \cdot 10^{-13}:\\
\;\;\;\;t_1 + \frac{1}{z} \cdot \frac{t}{3 \cdot y}\\

\mathbf{else}:\\
\;\;\;\;t_1 + \frac{\frac{t \cdot 0.3333333333333333}{z}}{y}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.4
Target1.7
Herbie0.5
\[\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.0000000000000004e-19

    1. Initial program 0.4

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

    if -5.0000000000000004e-19 < (*.f64 z 3) < 4.9999999999999999e-13

    1. Initial program 10.2

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

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

    if 4.9999999999999999e-13 < (*.f64 z 3)

    1. Initial program 0.4

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
    2. Applied egg-rr1.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. Applied egg-rr1.0

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

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

Alternatives

Alternative 1
Error0.6
Cost1480
\[\begin{array}{l} t_1 := x - \frac{y}{z \cdot 3}\\ \mathbf{if}\;z \cdot 3 \leq -2 \cdot 10^{+49}:\\ \;\;\;\;t_1 + t \cdot \frac{\frac{0.3333333333333333}{z}}{y}\\ \mathbf{elif}\;z \cdot 3 \leq 5 \cdot 10^{-13}:\\ \;\;\;\;t_1 + \frac{\frac{t}{y}}{z \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{\frac{t \cdot 0.3333333333333333}{z}}{y}\\ \end{array} \]
Alternative 2
Error0.5
Cost1480
\[\begin{array}{l} t_1 := x - \frac{y}{z \cdot 3}\\ \mathbf{if}\;z \cdot 3 \leq -5 \cdot 10^{-19}:\\ \;\;\;\;t_1 + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{elif}\;z \cdot 3 \leq 5 \cdot 10^{-13}:\\ \;\;\;\;t_1 + \frac{\frac{t}{y}}{z \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{\frac{t \cdot 0.3333333333333333}{z}}{y}\\ \end{array} \]
Alternative 3
Error3.8
Cost1224
\[\begin{array}{l} t_1 := \left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{y}}{z \cdot 3}\\ \mathbf{if}\;y \leq -1.63207071240834 \cdot 10^{-77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-200}:\\ \;\;\;\;x + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error9.0
Cost1104
\[\begin{array}{l} t_1 := x + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{if}\;y \leq -1.9130439560080355 \cdot 10^{-23}:\\ \;\;\;\;x + -0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq 1.0384609240765286 \cdot 10^{-57}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3291.832730261774:\\ \;\;\;\;\frac{-0.3333333333333333}{\frac{z}{y - \frac{t}{y}}}\\ \mathbf{elif}\;y \leq 9.201440716915238 \cdot 10^{+40}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{\frac{z}{y \cdot -0.3333333333333333}}\\ \end{array} \]
Alternative 5
Error9.1
Cost1104
\[\begin{array}{l} t_1 := x + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{if}\;y \leq -1.9130439560080355 \cdot 10^{-23}:\\ \;\;\;\;x + -0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq 5.5994902908308476 \cdot 10^{-61}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3291.832730261774:\\ \;\;\;\;\left(y - \frac{t}{y}\right) \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 9.201440716915238 \cdot 10^{+40}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{\frac{z}{y \cdot -0.3333333333333333}}\\ \end{array} \]
Alternative 6
Error28.6
Cost980
\[\begin{array}{l} t_1 := \frac{y}{z \cdot -3}\\ t_2 := \frac{t}{z} \cdot \frac{0.3333333333333333}{y}\\ \mathbf{if}\;x \leq -47.19925751736354:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4.179641626625153 \cdot 10^{-91}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -4.337159555487898 \cdot 10^{-292}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.7975417652463077 \cdot 10^{-271}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 19.72395639979516:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error15.6
Cost976
\[\begin{array}{l} t_1 := x + \frac{-0.3333333333333333}{\frac{z}{y}}\\ \mathbf{if}\;y \leq -1.800621096348438 \cdot 10^{-80}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -7 \cdot 10^{-146}:\\ \;\;\;\;\frac{t}{z} \cdot \frac{0.3333333333333333}{y}\\ \mathbf{elif}\;y \leq -5 \cdot 10^{-221}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.32 \cdot 10^{-148}:\\ \;\;\;\;\frac{\frac{\frac{t}{z}}{y}}{3}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error15.6
Cost976
\[\begin{array}{l} \mathbf{if}\;y \leq -1.800621096348438 \cdot 10^{-80}:\\ \;\;\;\;x + -0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq -7 \cdot 10^{-146}:\\ \;\;\;\;\frac{t}{z} \cdot \frac{0.3333333333333333}{y}\\ \mathbf{elif}\;y \leq -5 \cdot 10^{-221}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.32 \cdot 10^{-148}:\\ \;\;\;\;\frac{\frac{\frac{t}{z}}{y}}{3}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{-0.3333333333333333}{\frac{z}{y}}\\ \end{array} \]
Alternative 9
Error1.7
Cost960
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t \cdot 0.3333333333333333}{z}}{y} \]
Alternative 10
Error12.0
Cost840
\[\begin{array}{l} t_1 := x + -0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{if}\;x \leq -0.004691301708411824:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.53443350160369 \cdot 10^{-44}:\\ \;\;\;\;\frac{-0.3333333333333333}{\frac{z}{y - \frac{t}{y}}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error12.0
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -0.004691301708411824:\\ \;\;\;\;x + -0.3333333333333333 \cdot \frac{y}{z}\\ \mathbf{elif}\;x \leq 2.53443350160369 \cdot 10^{-44}:\\ \;\;\;\;\frac{-0.3333333333333333}{\frac{z}{y - \frac{t}{y}}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{\frac{z}{y \cdot -0.3333333333333333}}\\ \end{array} \]
Alternative 12
Error28.5
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -4.0982218594646872 \cdot 10^{-84}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 19.72395639979516:\\ \;\;\;\;\frac{y}{z \cdot -3}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 13
Error37.7
Cost64
\[x \]

Error

Reproduce

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