?

Average Error: 7.1 → 0.8
Time: 15.2s
Precision: binary64
Cost: 2248

?

\[ \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{t}{a} \cdot \left(z \cdot -4.5\right) + 0.5 \cdot \left(y \cdot \frac{x}{a}\right)\\ t_2 := x \cdot y - \left(z \cdot 9\right) \cdot t\\ \mathbf{if}\;t_2 \leq -5 \cdot 10^{+242}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+263}:\\ \;\;\;\;\frac{x \cdot y - 9 \cdot \left(t \cdot z\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (+ (* (/ t a) (* z -4.5)) (* 0.5 (* y (/ x a)))))
        (t_2 (- (* x y) (* (* z 9.0) t))))
   (if (<= t_2 -5e+242)
     t_1
     (if (<= t_2 2e+263) (/ (- (* x y) (* 9.0 (* t z))) (* a 2.0)) t_1))))
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 = ((t / a) * (z * -4.5)) + (0.5 * (y * (x / a)));
	double t_2 = (x * y) - ((z * 9.0) * t);
	double tmp;
	if (t_2 <= -5e+242) {
		tmp = t_1;
	} else if (t_2 <= 2e+263) {
		tmp = ((x * y) - (9.0 * (t * z))) / (a * 2.0);
	} else {
		tmp = t_1;
	}
	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) :: t_2
    real(8) :: tmp
    t_1 = ((t / a) * (z * (-4.5d0))) + (0.5d0 * (y * (x / a)))
    t_2 = (x * y) - ((z * 9.0d0) * t)
    if (t_2 <= (-5d+242)) then
        tmp = t_1
    else if (t_2 <= 2d+263) then
        tmp = ((x * y) - (9.0d0 * (t * z))) / (a * 2.0d0)
    else
        tmp = t_1
    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 = ((t / a) * (z * -4.5)) + (0.5 * (y * (x / a)));
	double t_2 = (x * y) - ((z * 9.0) * t);
	double tmp;
	if (t_2 <= -5e+242) {
		tmp = t_1;
	} else if (t_2 <= 2e+263) {
		tmp = ((x * y) - (9.0 * (t * z))) / (a * 2.0);
	} else {
		tmp = t_1;
	}
	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 = ((t / a) * (z * -4.5)) + (0.5 * (y * (x / a)))
	t_2 = (x * y) - ((z * 9.0) * t)
	tmp = 0
	if t_2 <= -5e+242:
		tmp = t_1
	elif t_2 <= 2e+263:
		tmp = ((x * y) - (9.0 * (t * z))) / (a * 2.0)
	else:
		tmp = t_1
	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(t / a) * Float64(z * -4.5)) + Float64(0.5 * Float64(y * Float64(x / a))))
	t_2 = Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t))
	tmp = 0.0
	if (t_2 <= -5e+242)
		tmp = t_1;
	elseif (t_2 <= 2e+263)
		tmp = Float64(Float64(Float64(x * y) - Float64(9.0 * Float64(t * z))) / Float64(a * 2.0));
	else
		tmp = t_1;
	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 = ((t / a) * (z * -4.5)) + (0.5 * (y * (x / a)));
	t_2 = (x * y) - ((z * 9.0) * t);
	tmp = 0.0;
	if (t_2 <= -5e+242)
		tmp = t_1;
	elseif (t_2 <= 2e+263)
		tmp = ((x * y) - (9.0 * (t * z))) / (a * 2.0);
	else
		tmp = t_1;
	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[(t / a), $MachinePrecision] * N[(z * -4.5), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+242], t$95$1, If[LessEqual[t$95$2, 2e+263], N[(N[(N[(x * y), $MachinePrecision] - N[(9.0 * N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
t_1 := \frac{t}{a} \cdot \left(z \cdot -4.5\right) + 0.5 \cdot \left(y \cdot \frac{x}{a}\right)\\
t_2 := x \cdot y - \left(z \cdot 9\right) \cdot t\\
\mathbf{if}\;t_2 \leq -5 \cdot 10^{+242}:\\
\;\;\;\;t_1\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.1
Target5.5
Herbie0.8
\[\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 2 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) < -5.0000000000000004e242 or 2.00000000000000003e263 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t))

    1. Initial program 40.2

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Simplified40.2

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

      [Start]40.2

      \[ \frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]

      rational.json-simplify-2 [=>]40.2

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

      rational.json-simplify-43 [=>]40.2

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

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

      \[\leadsto \color{blue}{-4.5 \cdot \frac{t \cdot z}{a} + 0.5 \cdot \frac{y \cdot x}{a}} \]
    5. Simplified0.8

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

      [Start]40.0

      \[ -4.5 \cdot \frac{t \cdot z}{a} + 0.5 \cdot \frac{y \cdot x}{a} \]

      rational.json-simplify-49 [=>]21.5

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

      rational.json-simplify-2 [=>]21.5

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

      rational.json-simplify-43 [=>]21.6

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

      rational.json-simplify-2 [=>]21.6

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

      rational.json-simplify-49 [=>]0.8

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

    if -5.0000000000000004e242 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) < 2.00000000000000003e263

    1. Initial program 0.8

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

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

      [Start]0.8

      \[ \frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]

      rational.json-simplify-2 [=>]0.8

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

      rational.json-simplify-43 [=>]0.8

      \[ \frac{x \cdot y - \color{blue}{z \cdot \left(9 \cdot t\right)}}{a \cdot 2} \]
    3. 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. Recombined 2 regimes into one program.
  4. Final simplification0.8

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

Alternatives

Alternative 1
Error3.9
Cost2120
\[\begin{array}{l} t_1 := x \cdot y - \left(z \cdot 9\right) \cdot t\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;0.5 \cdot \left(y \cdot \frac{x}{a}\right)\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+303}:\\ \;\;\;\;\frac{x \cdot y - 9 \cdot \left(t \cdot z\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \end{array} \]
Alternative 2
Error24.1
Cost1372
\[\begin{array}{l} t_1 := 0.5 \cdot \left(y \cdot \frac{x}{a}\right)\\ \mathbf{if}\;t \leq -1.2 \cdot 10^{-77}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;t \leq -3.15 \cdot 10^{-167}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -8.6 \cdot 10^{-190}:\\ \;\;\;\;-4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;t \leq 7.2 \cdot 10^{-279}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a}\\ \mathbf{elif}\;t \leq 5.2 \cdot 10^{-156}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{-140}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \mathbf{elif}\;t \leq 3.2 \cdot 10^{-50}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \end{array} \]
Alternative 3
Error24.1
Cost1372
\[\begin{array}{l} t_1 := 0.5 \cdot \left(y \cdot \frac{x}{a}\right)\\ \mathbf{if}\;t \leq -3.2 \cdot 10^{-77}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;t \leq -2.2 \cdot 10^{-165}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -4.45 \cdot 10^{-190}:\\ \;\;\;\;-4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;t \leq 2.5 \cdot 10^{-276}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a}\\ \mathbf{elif}\;t \leq 1.4 \cdot 10^{-156}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{-140}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \mathbf{elif}\;t \leq 1.45 \cdot 10^{-49}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{z}{\frac{a}{-4.5}}\\ \end{array} \]
Alternative 4
Error24.1
Cost1372
\[\begin{array}{l} t_1 := 0.5 \cdot \left(y \cdot \frac{x}{a}\right)\\ \mathbf{if}\;t \leq -1.75 \cdot 10^{-77}:\\ \;\;\;\;z \cdot \left(-4.5 \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;t \leq -2.55 \cdot 10^{-167}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -9 \cdot 10^{-190}:\\ \;\;\;\;-4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;t \leq 1.75 \cdot 10^{-278}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a}\\ \mathbf{elif}\;t \leq 5.2 \cdot 10^{-156}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.1 \cdot 10^{-140}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \mathbf{elif}\;t \leq 5.2 \cdot 10^{-51}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{z}{\frac{a}{-4.5}}\\ \end{array} \]
Alternative 5
Error5.8
Cost1092
\[\begin{array}{l} \mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+204}:\\ \;\;\;\;\frac{y}{a} \cdot \left(0.5 \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y - z \cdot \left(9 \cdot t\right)\right)\\ \end{array} \]
Alternative 6
Error25.0
Cost976
\[\begin{array}{l} t_1 := 0.5 \cdot \left(y \cdot \frac{x}{a}\right)\\ \mathbf{if}\;y \leq -9.8 \cdot 10^{-70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{-243}:\\ \;\;\;\;-4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{-213}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+57}:\\ \;\;\;\;-4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error31.1
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -2.8 \cdot 10^{+128}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \mathbf{elif}\;a \leq 3.8 \cdot 10^{+70}:\\ \;\;\;\;-4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \end{array} \]
Alternative 8
Error32.0
Cost580
\[\begin{array}{l} \mathbf{if}\;t \leq 2.55 \cdot 10^{+191}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \end{array} \]
Alternative 9
Error32.1
Cost580
\[\begin{array}{l} \mathbf{if}\;t \leq 6.8 \cdot 10^{+192}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\ \end{array} \]
Alternative 10
Error32.5
Cost448
\[-4.5 \cdot \left(t \cdot \frac{z}{a}\right) \]

Error

Reproduce?

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