?

Average Error: 12.03% → 7.78%
Time: 13.9s
Precision: binary64
Cost: 1612

?

\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+165}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-78}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{0.5}{a} + \frac{t}{2} \cdot \frac{z \cdot -9}{a}\\ \mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{+237}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t \cdot -9\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \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
 (if (<= (* x y) -5e+165)
   (* 0.5 (* x (/ y a)))
   (if (<= (* x y) -1e-78)
     (+ (* (* x y) (/ 0.5 a)) (* (/ t 2.0) (/ (* z -9.0) a)))
     (if (<= (* x y) 4e+237)
       (/ (+ (* x y) (* z (* t -9.0))) (* a 2.0))
       (* 0.5 (/ y (/ a x)))))))
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 tmp;
	if ((x * y) <= -5e+165) {
		tmp = 0.5 * (x * (y / a));
	} else if ((x * y) <= -1e-78) {
		tmp = ((x * y) * (0.5 / a)) + ((t / 2.0) * ((z * -9.0) / a));
	} else if ((x * y) <= 4e+237) {
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0);
	} else {
		tmp = 0.5 * (y / (a / x));
	}
	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) :: tmp
    if ((x * y) <= (-5d+165)) then
        tmp = 0.5d0 * (x * (y / a))
    else if ((x * y) <= (-1d-78)) then
        tmp = ((x * y) * (0.5d0 / a)) + ((t / 2.0d0) * ((z * (-9.0d0)) / a))
    else if ((x * y) <= 4d+237) then
        tmp = ((x * y) + (z * (t * (-9.0d0)))) / (a * 2.0d0)
    else
        tmp = 0.5d0 * (y / (a / x))
    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 tmp;
	if ((x * y) <= -5e+165) {
		tmp = 0.5 * (x * (y / a));
	} else if ((x * y) <= -1e-78) {
		tmp = ((x * y) * (0.5 / a)) + ((t / 2.0) * ((z * -9.0) / a));
	} else if ((x * y) <= 4e+237) {
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0);
	} else {
		tmp = 0.5 * (y / (a / x));
	}
	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):
	tmp = 0
	if (x * y) <= -5e+165:
		tmp = 0.5 * (x * (y / a))
	elif (x * y) <= -1e-78:
		tmp = ((x * y) * (0.5 / a)) + ((t / 2.0) * ((z * -9.0) / a))
	elif (x * y) <= 4e+237:
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0)
	else:
		tmp = 0.5 * (y / (a / x))
	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)
	tmp = 0.0
	if (Float64(x * y) <= -5e+165)
		tmp = Float64(0.5 * Float64(x * Float64(y / a)));
	elseif (Float64(x * y) <= -1e-78)
		tmp = Float64(Float64(Float64(x * y) * Float64(0.5 / a)) + Float64(Float64(t / 2.0) * Float64(Float64(z * -9.0) / a)));
	elseif (Float64(x * y) <= 4e+237)
		tmp = Float64(Float64(Float64(x * y) + Float64(z * Float64(t * -9.0))) / Float64(a * 2.0));
	else
		tmp = Float64(0.5 * Float64(y / Float64(a / x)));
	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)
	tmp = 0.0;
	if ((x * y) <= -5e+165)
		tmp = 0.5 * (x * (y / a));
	elseif ((x * y) <= -1e-78)
		tmp = ((x * y) * (0.5 / a)) + ((t / 2.0) * ((z * -9.0) / a));
	elseif ((x * y) <= 4e+237)
		tmp = ((x * y) + (z * (t * -9.0))) / (a * 2.0);
	else
		tmp = 0.5 * (y / (a / x));
	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_] := If[LessEqual[N[(x * y), $MachinePrecision], -5e+165], N[(0.5 * N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -1e-78], N[(N[(N[(x * y), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] + N[(N[(t / 2.0), $MachinePrecision] * N[(N[(z * -9.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 4e+237], N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+165}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\

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

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

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.03%
Target8.38%
Herbie7.78%
\[\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 4 regimes
  2. if (*.f64 x y) < -4.9999999999999997e165

    1. Initial program 41.02

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

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

      [Start]41.02

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

      associate-*l* [=>]41.02

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{y \cdot x}{a}} \]
    4. Simplified16.87

      \[\leadsto \color{blue}{0.5 \cdot \left(\frac{y}{a} \cdot x\right)} \]
      Proof

      [Start]46.37

      \[ 0.5 \cdot \frac{y \cdot x}{a} \]

      associate-/l* [=>]17.43

      \[ 0.5 \cdot \color{blue}{\frac{y}{\frac{a}{x}}} \]

      associate-/r/ [=>]16.87

      \[ 0.5 \cdot \color{blue}{\left(\frac{y}{a} \cdot x\right)} \]

    if -4.9999999999999997e165 < (*.f64 x y) < -9.99999999999999999e-79

    1. Initial program 5.64

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

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

    if -9.99999999999999999e-79 < (*.f64 x y) < 3.99999999999999976e237

    1. Initial program 7.08

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

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

      [Start]7.08

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

      associate-*l* [=>]7.02

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

    if 3.99999999999999976e237 < (*.f64 x y)

    1. Initial program 56.85

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

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

      [Start]56.85

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

      sub-neg [=>]56.85

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

      remove-double-neg [<=]56.85

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

      distribute-neg-in [<=]56.85

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

      +-commutative [<=]56.85

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

      sub-neg [<=]56.85

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

      neg-mul-1 [=>]56.85

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

      associate-/l* [=>]56.94

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

      associate-/r/ [=>]56.93

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

      sub-neg [=>]56.93

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

      +-commutative [=>]56.93

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

      neg-sub0 [=>]56.93

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

      associate-+l- [=>]56.93

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

      sub0-neg [=>]56.93

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

      distribute-rgt-neg-out [=>]56.93

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

      distribute-lft-neg-in [=>]56.93

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{y \cdot x}{a}} \]
    4. Simplified8.39

      \[\leadsto \color{blue}{0.5 \cdot \frac{y}{\frac{a}{x}}} \]
      Proof

      [Start]58.1

      \[ 0.5 \cdot \frac{y \cdot x}{a} \]

      associate-/l* [=>]8.39

      \[ 0.5 \cdot \color{blue}{\frac{y}{\frac{a}{x}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification7.78

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

Alternatives

Alternative 1
Error7.28%
Cost2632
\[\begin{array}{l} t_1 := \frac{x \cdot y + t \cdot \left(z \cdot -9\right)}{a \cdot 2}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{elif}\;t_1 \leq 10^{+298}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t \cdot -9\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{z}{\frac{a}{-4.5}}}{\frac{1}{t}}\\ \end{array} \]
Alternative 2
Error13.69%
Cost1096
\[\begin{array}{l} \mathbf{if}\;t \leq -4.7 \cdot 10^{+88}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;t \leq 1.35 \cdot 10^{+230}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y + -9 \cdot \left(z \cdot t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \end{array} \]
Alternative 3
Error41.17%
Cost977
\[\begin{array}{l} \mathbf{if}\;z \leq -6.8 \cdot 10^{+26}:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq -1.42 \cdot 10^{-24} \lor \neg \left(z \leq -1 \cdot 10^{-69}\right) \land z \leq 2.9 \cdot 10^{-207}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{t \cdot -4.5}{a}\\ \end{array} \]
Alternative 4
Error41.22%
Cost977
\[\begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{+25}:\\ \;\;\;\;\frac{t \cdot -4.5}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq -1.55 \cdot 10^{-26} \lor \neg \left(z \leq -2.4 \cdot 10^{-71}\right) \land z \leq 2.9 \cdot 10^{-207}:\\ \;\;\;\;\frac{x \cdot 0.5}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{t \cdot -4.5}{a}\\ \end{array} \]
Alternative 5
Error41.06%
Cost976
\[\begin{array}{l} t_1 := 0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\ \mathbf{if}\;z \leq -7.2 \cdot 10^{+23}:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq -1.76 \cdot 10^{-23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.25 \cdot 10^{-74}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-207}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \end{array} \]
Alternative 6
Error37.13%
Cost976
\[\begin{array}{l} t_1 := \frac{x \cdot 0.5}{\frac{a}{y}}\\ \mathbf{if}\;y \leq -8.5 \cdot 10^{-185}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{+68}:\\ \;\;\;\;\left(z \cdot t\right) \cdot \frac{-4.5}{a}\\ \mathbf{elif}\;y \leq 8.8 \cdot 10^{+77}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+105}:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error41.17%
Cost976
\[\begin{array}{l} t_1 := \frac{x \cdot 0.5}{\frac{a}{y}}\\ \mathbf{if}\;z \leq -1.75 \cdot 10^{+25}:\\ \;\;\;\;\frac{t \cdot -4.5}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq -5.1 \cdot 10^{-27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{-74}:\\ \;\;\;\;\frac{z \cdot \left(t \cdot -4.5\right)}{a}\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{-207}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{t \cdot -4.5}{a}\\ \end{array} \]
Alternative 8
Error50.57%
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -4.5 \cdot 10^{-169}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;a \leq 4.6 \cdot 10^{-285}:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \end{array} \]
Alternative 9
Error48.19%
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -2 \cdot 10^{-9}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;t \leq 4.2 \cdot 10^{+143}:\\ \;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{z}{\frac{a}{t}}\\ \end{array} \]
Alternative 10
Error50.22%
Cost580
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-69}:\\ \;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\ \end{array} \]
Alternative 11
Error50.39%
Cost448
\[-4.5 \cdot \left(z \cdot \frac{t}{a}\right) \]

Error

Reproduce?

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