Average Error: 7.8 → 4.6
Time: 17.0s
Precision: binary64
Cost: 2632
\[ \begin{array}{c}[z, t] = \mathsf{sort}([z, t])\\ \end{array} \]
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
\[\begin{array}{l} t_1 := \frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+303}:\\ \;\;\;\;\frac{t}{\frac{a}{z}} \cdot -4.5\\ \mathbf{elif}\;t_1 \leq 10^{+296}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t \cdot -9\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{a} \cdot \frac{t}{-0.2222222222222222}\\ \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0))))
   (if (<= t_1 -1e+303)
     (* (/ t (/ a z)) -4.5)
     (if (<= t_1 1e+296)
       (/ (+ (* x y) (* z (* t -9.0))) (* a 2.0))
       (* (/ z a) (/ t -0.2222222222222222))))))
double code(double x, double y, double z, double t, double a) {
	return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
	double tmp;
	if (t_1 <= -1e+303) {
		tmp = (t / (a / z)) * -4.5;
	} else if (t_1 <= 1e+296) {
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0);
	} else {
		tmp = (z / a) * (t / -0.2222222222222222);
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = ((x * y) - ((z * 9.0d0) * t)) / (a * 2.0d0)
end function
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: t_1
    real(8) :: tmp
    t_1 = ((x * y) - ((z * 9.0d0) * t)) / (a * 2.0d0)
    if (t_1 <= (-1d+303)) then
        tmp = (t / (a / z)) * (-4.5d0)
    else if (t_1 <= 1d+296) then
        tmp = ((x * y) + (z * (t * (-9.0d0)))) / (a * 2.0d0)
    else
        tmp = (z / a) * (t / (-0.2222222222222222d0))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
	double tmp;
	if (t_1 <= -1e+303) {
		tmp = (t / (a / z)) * -4.5;
	} else if (t_1 <= 1e+296) {
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0);
	} else {
		tmp = (z / a) * (t / -0.2222222222222222);
	}
	return tmp;
}
def code(x, y, z, t, a):
	return ((x * y) - ((z * 9.0) * t)) / (a * 2.0)
def code(x, y, z, t, a):
	t_1 = ((x * y) - ((z * 9.0) * t)) / (a * 2.0)
	tmp = 0
	if t_1 <= -1e+303:
		tmp = (t / (a / z)) * -4.5
	elif t_1 <= 1e+296:
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0)
	else:
		tmp = (z / a) * (t / -0.2222222222222222)
	return tmp
function code(x, y, z, t, a)
	return Float64(Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0))
end
function code(x, y, z, t, a)
	t_1 = Float64(Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0))
	tmp = 0.0
	if (t_1 <= -1e+303)
		tmp = Float64(Float64(t / Float64(a / z)) * -4.5);
	elseif (t_1 <= 1e+296)
		tmp = Float64(Float64(Float64(x * y) + Float64(z * Float64(t * -9.0))) / Float64(a * 2.0));
	else
		tmp = Float64(Float64(z / a) * Float64(t / -0.2222222222222222));
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
	tmp = 0.0;
	if (t_1 <= -1e+303)
		tmp = (t / (a / z)) * -4.5;
	elseif (t_1 <= 1e+296)
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0);
	else
		tmp = (z / a) * (t / -0.2222222222222222);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+303], N[(N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision] * -4.5), $MachinePrecision], If[LessEqual[t$95$1, 1e+296], N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(z / a), $MachinePrecision] * N[(t / -0.2222222222222222), $MachinePrecision]), $MachinePrecision]]]]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
t_1 := \frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+303}:\\
\;\;\;\;\frac{t}{\frac{a}{z}} \cdot -4.5\\

\mathbf{elif}\;t_1 \leq 10^{+296}:\\
\;\;\;\;\frac{x \cdot y + z \cdot \left(t \cdot -9\right)}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{z}{a} \cdot \frac{t}{-0.2222222222222222}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.8
Target5.5
Herbie4.6
\[\begin{array}{l} \mathbf{if}\;a < -2.090464557976709 \cdot 10^{+86}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a < 2.144030707833976 \cdot 10^{+99}:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot \left(x \cdot 0.5\right) - \frac{t}{a} \cdot \left(z \cdot 4.5\right)\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) (*.f64 a 2)) < -1e303

    1. Initial program 61.3

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Taylor expanded in x around 0 61.5

      \[\leadsto \color{blue}{-4.5 \cdot \frac{t \cdot z}{a}} \]
    3. Applied egg-rr61.5

      \[\leadsto \color{blue}{\frac{-4.5}{\frac{a}{t \cdot z}}} \]
    4. Applied egg-rr30.9

      \[\leadsto \color{blue}{\frac{t}{\frac{a}{z}} \cdot -4.5} \]

    if -1e303 < (/.f64 (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) (*.f64 a 2)) < 9.99999999999999981e295

    1. Initial program 0.8

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Taylor expanded in z around 0 0.8

      \[\leadsto \frac{x \cdot y - \color{blue}{9 \cdot \left(t \cdot z\right)}}{a \cdot 2} \]
    3. Simplified0.9

      \[\leadsto \frac{x \cdot y - \color{blue}{z \cdot \left(t \cdot 9\right)}}{a \cdot 2} \]
      Proof
      (*.f64 z (*.f64 t 9)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 z t) 9)): 43 points increase in error, 45 points decrease in error
      (*.f64 (Rewrite<= *-commutative_binary64 (*.f64 t z)) 9): 0 points increase in error, 0 points decrease in error
      (Rewrite<= *-commutative_binary64 (*.f64 9 (*.f64 t z))): 0 points increase in error, 0 points decrease in error

    if 9.99999999999999981e295 < (/.f64 (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) (*.f64 a 2))

    1. Initial program 56.4

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Taylor expanded in x around 0 59.1

      \[\leadsto \frac{\color{blue}{-9 \cdot \left(t \cdot z\right)}}{a \cdot 2} \]
    3. Simplified59.1

      \[\leadsto \frac{\color{blue}{z \cdot \left(t \cdot -9\right)}}{a \cdot 2} \]
      Proof
      (*.f64 z (*.f64 t -9)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 z t) -9)): 41 points increase in error, 47 points decrease in error
      (*.f64 (Rewrite<= *-commutative_binary64 (*.f64 t z)) -9): 0 points increase in error, 0 points decrease in error
      (Rewrite<= *-commutative_binary64 (*.f64 -9 (*.f64 t z))): 0 points increase in error, 0 points decrease in error
    4. Applied egg-rr32.2

      \[\leadsto \color{blue}{\frac{z}{a} \cdot \frac{t}{-0.2222222222222222}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification4.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \leq -1 \cdot 10^{+303}:\\ \;\;\;\;\frac{t}{\frac{a}{z}} \cdot -4.5\\ \mathbf{elif}\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \leq 10^{+296}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t \cdot -9\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{a} \cdot \frac{t}{-0.2222222222222222}\\ \end{array} \]

Alternatives

Alternative 1
Error23.9
Cost976
\[\begin{array}{l} t_1 := \frac{x}{a \cdot \frac{2}{y}}\\ t_2 := z \cdot \frac{t}{\frac{a}{-4.5}}\\ \mathbf{if}\;z \leq -7.6 \cdot 10^{+170}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{+145}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.2122091563563366 \cdot 10^{+40}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 2.9085414354113414 \cdot 10^{-95}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error23.7
Cost976
\[\begin{array}{l} t_1 := \frac{y \cdot 0.5}{\frac{a}{x}}\\ t_2 := z \cdot \frac{t}{\frac{a}{-4.5}}\\ \mathbf{if}\;t \leq -1.1741227309619492 \cdot 10^{-172}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 9.151004894346438 \cdot 10^{-242}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.2953648376784832 \cdot 10^{-65}:\\ \;\;\;\;\frac{x}{a \cdot \frac{2}{y}}\\ \mathbf{elif}\;t \leq 2.3435658089956605 \cdot 10^{+57}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error24.6
Cost976
\[\begin{array}{l} t_1 := t \cdot \left(-4.5 \cdot \frac{z}{a}\right)\\ \mathbf{if}\;z \leq -7.6 \cdot 10^{+170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{+145}:\\ \;\;\;\;\frac{x}{a \cdot \frac{2}{y}}\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{+106}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.3286160881565906 \cdot 10^{-96}:\\ \;\;\;\;\frac{y \cdot 0.5}{\frac{a}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error24.6
Cost976
\[\begin{array}{l} t_1 := t \cdot \left(-4.5 \cdot \frac{z}{a}\right)\\ \mathbf{if}\;z \leq -7.6 \cdot 10^{+170}:\\ \;\;\;\;\frac{t}{\frac{a}{z}} \cdot -4.5\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{+145}:\\ \;\;\;\;\frac{x}{a \cdot \frac{2}{y}}\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{+106}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.3286160881565906 \cdot 10^{-96}:\\ \;\;\;\;\frac{y \cdot 0.5}{\frac{a}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error24.6
Cost976
\[\begin{array}{l} t_1 := \frac{t \cdot -4.5}{\frac{a}{z}}\\ \mathbf{if}\;z \leq -7.6 \cdot 10^{+170}:\\ \;\;\;\;\frac{t}{\frac{a}{z}} \cdot -4.5\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{+145}:\\ \;\;\;\;\frac{x}{a \cdot \frac{2}{y}}\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{+106}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.3286160881565906 \cdot 10^{-96}:\\ \;\;\;\;\frac{y \cdot 0.5}{\frac{a}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error24.5
Cost976
\[\begin{array}{l} \mathbf{if}\;z \leq -7.6 \cdot 10^{+170}:\\ \;\;\;\;\frac{t}{\frac{a}{z}} \cdot -4.5\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{+145}:\\ \;\;\;\;\frac{x}{a \cdot \frac{2}{y}}\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{+106}:\\ \;\;\;\;\frac{t \cdot -4.5}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq 2.3286160881565906 \cdot 10^{-96}:\\ \;\;\;\;\frac{y \cdot 0.5}{\frac{a}{x}}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{z}{\frac{a}{-4.5}}\\ \end{array} \]
Alternative 7
Error24.0
Cost976
\[\begin{array}{l} \mathbf{if}\;z \leq -7.6 \cdot 10^{+170}:\\ \;\;\;\;\frac{t}{\frac{a}{z}} \cdot -4.5\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{+145}:\\ \;\;\;\;\frac{x}{a \cdot \frac{2}{y}}\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{+106}:\\ \;\;\;\;\frac{t \cdot -4.5}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq 2.3286160881565906 \cdot 10^{-96}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{z}{\frac{a}{-4.5}}\\ \end{array} \]
Alternative 8
Error23.9
Cost976
\[\begin{array}{l} \mathbf{if}\;z \leq -7.6 \cdot 10^{+170}:\\ \;\;\;\;\frac{t}{\frac{a}{z}} \cdot -4.5\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{+145}:\\ \;\;\;\;\frac{x}{a \cdot \frac{2}{y}}\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{+106}:\\ \;\;\;\;\frac{t \cdot -4.5}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq 2.3286160881565906 \cdot 10^{-96}:\\ \;\;\;\;\frac{x \cdot y}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{z}{\frac{a}{-4.5}}\\ \end{array} \]
Alternative 9
Error33.0
Cost448
\[z \cdot \frac{t}{\frac{a}{-4.5}} \]

Error

Reproduce

herbie shell --seed 2022300 
(FPCore (x y z t a)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, I"
  :precision binary64

  :herbie-target
  (if (< a -2.090464557976709e+86) (- (* 0.5 (/ (* y x) a)) (* 4.5 (/ t (/ a z)))) (if (< a 2.144030707833976e+99) (/ (- (* x y) (* z (* 9.0 t))) (* a 2.0)) (- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5)))))

  (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))