?

Average Error: 6.5 → 1.5
Time: 10.3s
Precision: binary64
Cost: 1865

?

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.5
Target2.1
Herbie1.5
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]

Derivation?

  1. Split input into 2 regimes
  2. if (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 2.00000000000000013e-152 or 1.9999999999999999e304 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t))

    1. Initial program 10.4

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

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

      [Start]10.4

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

      associate-*l/ [<=]2.3

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

    if 2.00000000000000013e-152 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 1.9999999999999999e304

    1. Initial program 0.4

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

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

Alternatives

Alternative 1
Error25.6
Cost1505
\[\begin{array}{l} t_1 := y \cdot \frac{z - x}{t}\\ \mathbf{if}\;x \leq -6 \cdot 10^{+100}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.15 \cdot 10^{+54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -45000000000000:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-277}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-109} \lor \neg \left(x \leq 1.5 \cdot 10^{-85}\right) \land x \leq 4.2 \cdot 10^{+55}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error32.6
Cost1380
\[\begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{+151} \lor \neg \left(z \leq -1.18 \cdot 10^{+85} \lor \neg \left(z \leq -27000\right) \land \left(z \leq -1.55 \cdot 10^{-22} \lor \neg \left(z \leq -8.6 \cdot 10^{-27}\right) \land \left(z \leq 3.4 \cdot 10^{-41} \lor \neg \left(z \leq 1.8 \cdot 10^{+155}\right) \land z \leq 7.5 \cdot 10^{+283}\right)\right)\right):\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error30.8
Cost1376
\[\begin{array}{l} t_1 := \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;z \leq -5.6 \cdot 10^{+149}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.4 \cdot 10^{+84}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -102000:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{-22}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -8 \cdot 10^{-27}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{-307}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-283}:\\ \;\;\;\;\frac{-y}{\frac{t}{x}}\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{-35}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error30.8
Cost1376
\[\begin{array}{l} t_1 := \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;z \leq -1.8 \cdot 10^{+148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.55 \cdot 10^{+83}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -64000:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{elif}\;z \leq -1.55 \cdot 10^{-22}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -8.2 \cdot 10^{-27}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-308}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-283}:\\ \;\;\;\;x \cdot \frac{-y}{t}\\ \mathbf{elif}\;z \leq 4.7 \cdot 10^{-35}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error23.6
Cost1242
\[\begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{+101}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6.4 \cdot 10^{+53} \lor \neg \left(x \leq -4 \cdot 10^{+14}\right) \land \left(x \leq 1.65 \cdot 10^{-110} \lor \neg \left(x \leq 1.92 \cdot 10^{-81}\right) \land x \leq 1.8 \cdot 10^{+50}\right):\\ \;\;\;\;\left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error30.5
Cost1112
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;z \leq -3.5 \cdot 10^{+148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{+81}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2900:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.7 \cdot 10^{-22}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-28}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 4.7 \cdot 10^{-35}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error8.8
Cost1108
\[\begin{array}{l} t_1 := x - \frac{x}{\frac{t}{y}}\\ t_2 := x + \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;z \leq -2.8 \cdot 10^{-95}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-127}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-95}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 7.8 \cdot 10^{-36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 205:\\ \;\;\;\;y \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error8.8
Cost1108
\[\begin{array}{l} t_1 := x - \frac{x}{\frac{t}{y}}\\ t_2 := x + \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;z \leq -6.5 \cdot 10^{-96}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{-128}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-96}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 350:\\ \;\;\;\;\frac{y}{\frac{t}{z - x}}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error1.9
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq 5.5 \cdot 10^{-275} \lor \neg \left(x \leq 10^{-82}\right):\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \end{array} \]
Alternative 10
Error11.2
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -4 \cdot 10^{-146} \lor \neg \left(t \leq 5.2 \cdot 10^{-152}\right):\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;\left(z - x\right) \cdot \frac{y}{t}\\ \end{array} \]
Alternative 11
Error26.3
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -6.2 \cdot 10^{-27}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{-143}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error2.1
Cost576
\[x + \left(z - x\right) \cdot \frac{y}{t} \]
Alternative 13
Error2.1
Cost576
\[x + \frac{z - x}{\frac{t}{y}} \]
Alternative 14
Error31.4
Cost64
\[x \]

Error

Reproduce?

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

  :herbie-target
  (- x (+ (* x (/ y t)) (* (- z) (/ y t))))

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