?

Average Error: 6.1 → 0.4
Time: 11.1s
Precision: binary64
Cost: 1353

?

\[x - \frac{y \cdot \left(z - t\right)}{a} \]
\[\begin{array}{l} t_1 := y \cdot \left(z - t\right)\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+185} \lor \neg \left(t_1 \leq 4 \cdot 10^{+188}\right):\\ \;\;\;\;x + \frac{t - z}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot \left(t - z\right)}{a}\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (- x (/ (* y (- z t)) a)))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* y (- z t))))
   (if (or (<= t_1 -2e+185) (not (<= t_1 4e+188)))
     (+ x (/ (- t z) (/ a y)))
     (+ x (/ (* y (- t z)) a)))))
double code(double x, double y, double z, double t, double a) {
	return x - ((y * (z - t)) / a);
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = y * (z - t);
	double tmp;
	if ((t_1 <= -2e+185) || !(t_1 <= 4e+188)) {
		tmp = x + ((t - z) / (a / y));
	} else {
		tmp = x + ((y * (t - z)) / a);
	}
	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 - t)) / a)
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 = y * (z - t)
    if ((t_1 <= (-2d+185)) .or. (.not. (t_1 <= 4d+188))) then
        tmp = x + ((t - z) / (a / y))
    else
        tmp = x + ((y * (t - z)) / a)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	return x - ((y * (z - t)) / a);
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = y * (z - t);
	double tmp;
	if ((t_1 <= -2e+185) || !(t_1 <= 4e+188)) {
		tmp = x + ((t - z) / (a / y));
	} else {
		tmp = x + ((y * (t - z)) / a);
	}
	return tmp;
}
def code(x, y, z, t, a):
	return x - ((y * (z - t)) / a)
def code(x, y, z, t, a):
	t_1 = y * (z - t)
	tmp = 0
	if (t_1 <= -2e+185) or not (t_1 <= 4e+188):
		tmp = x + ((t - z) / (a / y))
	else:
		tmp = x + ((y * (t - z)) / a)
	return tmp
function code(x, y, z, t, a)
	return Float64(x - Float64(Float64(y * Float64(z - t)) / a))
end
function code(x, y, z, t, a)
	t_1 = Float64(y * Float64(z - t))
	tmp = 0.0
	if ((t_1 <= -2e+185) || !(t_1 <= 4e+188))
		tmp = Float64(x + Float64(Float64(t - z) / Float64(a / y)));
	else
		tmp = Float64(x + Float64(Float64(y * Float64(t - z)) / a));
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = x - ((y * (z - t)) / a);
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = y * (z - t);
	tmp = 0.0;
	if ((t_1 <= -2e+185) || ~((t_1 <= 4e+188)))
		tmp = x + ((t - z) / (a / y));
	else
		tmp = x + ((y * (t - z)) / a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+185], N[Not[LessEqual[t$95$1, 4e+188]], $MachinePrecision]], N[(x + N[(N[(t - z), $MachinePrecision] / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y * N[(t - z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
t_1 := y \cdot \left(z - t\right)\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+185} \lor \neg \left(t_1 \leq 4 \cdot 10^{+188}\right):\\
\;\;\;\;x + \frac{t - z}{\frac{a}{y}}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{y \cdot \left(t - z\right)}{a}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.1
Target0.7
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;y < -1.0761266216389975 \cdot 10^{-10}:\\ \;\;\;\;x - \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 y (-.f64 z t)) < -2e185 or 4.0000000000000001e188 < (*.f64 y (-.f64 z t))

    1. Initial program 26.2

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

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

      [Start]26.2

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

      associate-*l/ [<=]0.9

      \[ x - \color{blue}{\frac{y}{a} \cdot \left(z - t\right)} \]
    3. Applied egg-rr0.9

      \[\leadsto x - \color{blue}{\frac{z - t}{\frac{a}{y}}} \]

    if -2e185 < (*.f64 y (-.f64 z t)) < 4.0000000000000001e188

    1. Initial program 0.3

      \[x - \frac{y \cdot \left(z - t\right)}{a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \leq -2 \cdot 10^{+185} \lor \neg \left(y \cdot \left(z - t\right) \leq 4 \cdot 10^{+188}\right):\\ \;\;\;\;x + \frac{t - z}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot \left(t - z\right)}{a}\\ \end{array} \]

Alternatives

Alternative 1
Error0.4
Cost1352
\[\begin{array}{l} t_1 := y \cdot \left(z - t\right)\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+185}:\\ \;\;\;\;x + \frac{y}{a} \cdot \left(t - z\right)\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+236}:\\ \;\;\;\;x + \frac{y \cdot \left(t - z\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \end{array} \]
Alternative 2
Error1.7
Cost1097
\[\begin{array}{l} \mathbf{if}\;z - t \leq -2 \cdot 10^{+38} \lor \neg \left(z - t \leq 10^{+60}\right):\\ \;\;\;\;x + \frac{y}{a} \cdot \left(t - z\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \end{array} \]
Alternative 3
Error31.4
Cost1044
\[\begin{array}{l} t_1 := z \cdot \frac{-y}{a}\\ \mathbf{if}\;z \leq -2.3 \cdot 10^{+168}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{-85}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -6.6 \cdot 10^{-160}:\\ \;\;\;\;\frac{y \cdot t}{a}\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{+144}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 7.8 \cdot 10^{+210}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error31.5
Cost1044
\[\begin{array}{l} t_1 := \frac{z}{\frac{-a}{y}}\\ \mathbf{if}\;z \leq -2.9 \cdot 10^{+169}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{-85}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.95 \cdot 10^{-159}:\\ \;\;\;\;\frac{y \cdot t}{a}\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{+141}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+210}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error17.0
Cost845
\[\begin{array}{l} \mathbf{if}\;z \leq -2.8 \cdot 10^{+169} \lor \neg \left(z \leq 7.2 \cdot 10^{+159}\right) \land z \leq 3.9 \cdot 10^{+210}:\\ \;\;\;\;\frac{z}{\frac{-a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t}{\frac{a}{y}}\\ \end{array} \]
Alternative 6
Error31.2
Cost717
\[\begin{array}{l} \mathbf{if}\;y \leq 1.8 \cdot 10^{+90}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{+157} \lor \neg \left(y \leq 9.2 \cdot 10^{+216}\right):\\ \;\;\;\;y \cdot \frac{t}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error15.6
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -1.26 \cdot 10^{-111} \lor \neg \left(x \leq 7.2 \cdot 10^{-88}\right):\\ \;\;\;\;x + y \cdot \frac{t}{a}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{t - z}{a}\\ \end{array} \]
Alternative 8
Error10.8
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -6 \cdot 10^{-45} \lor \neg \left(t \leq 10^{-96}\right):\\ \;\;\;\;x + \frac{t}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z}{a}\\ \end{array} \]
Alternative 9
Error20.1
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{+14}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-69}:\\ \;\;\;\;y \cdot \frac{t - z}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error2.8
Cost576
\[x + \frac{y}{a} \cdot \left(t - z\right) \]
Alternative 11
Error31.0
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023039 
(FPCore (x y z t a)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, F"
  :precision binary64

  :herbie-target
  (if (< y -1.0761266216389975e-10) (- x (/ 1.0 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (- x (/ (* y (- z t)) a)) (- x (/ y (/ a (- z t))))))

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