?

Average Error: 11.59% → 1.18%
Time: 12.6s
Precision: binary64
Cost: 1609

?

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.59%
Target12.82%
Herbie1.18%
\[\begin{array}{l} \mathbf{if}\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} < 0:\\ \;\;\;\;\frac{\frac{x}{y - z}}{t - z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1}{\left(y - z\right) \cdot \left(t - z\right)}\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 (-.f64 y z) (-.f64 t z)) < -5.0000000000000001e261 or 4.9999999999999999e185 < (*.f64 (-.f64 y z) (-.f64 t z))

    1. Initial program 19.29

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

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

      [Start]19.29

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

      sub-neg [=>]19.29

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

      +-commutative [=>]19.29

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

      neg-sub0 [=>]19.29

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

      associate-+l- [=>]19.29

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

      sub0-neg [=>]19.29

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

      distribute-lft-neg-out [=>]19.29

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

      distribute-rgt-neg-in [=>]19.29

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

      neg-sub0 [=>]19.29

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

      associate-+l- [<=]19.29

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

      neg-sub0 [<=]19.29

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

      +-commutative [<=]19.29

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

      sub-neg [<=]19.29

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

      associate-/l/ [<=]0.37

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

    if -5.0000000000000001e261 < (*.f64 (-.f64 y z) (-.f64 t z)) < 4.9999999999999999e185

    1. Initial program 2.18

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

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

Alternatives

Alternative 1
Error6.9%
Cost1608
\[\begin{array}{l} t_1 := \left(y - z\right) \cdot \left(t - z\right)\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\frac{\frac{x}{y}}{t - z}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+306}:\\ \;\;\;\;\frac{x}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z - y}}{z}\\ \end{array} \]
Alternative 2
Error24.65%
Cost1504
\[\begin{array}{l} t_1 := \frac{x}{\left(y - z\right) \cdot t}\\ t_2 := \frac{\frac{x}{z}}{z}\\ t_3 := \frac{x}{z \cdot \left(z - y\right)}\\ t_4 := \frac{x}{z \cdot \left(z - t\right)}\\ \mathbf{if}\;z \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-47}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 10^{-33}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-19}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 105:\\ \;\;\;\;t_4\\ \mathbf{elif}\;z \leq 3 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{+78}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+165}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error26.86%
Cost1372
\[\begin{array}{l} t_1 := \frac{x}{z \cdot \left(z - t\right)}\\ t_2 := \frac{\frac{x}{z}}{z}\\ t_3 := \frac{\frac{x}{y}}{t - z}\\ \mathbf{if}\;z \leq -2.4 \cdot 10^{+107}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.56 \cdot 10^{-49}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{-70}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot t}\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-67}:\\ \;\;\;\;\frac{\frac{x}{t}}{y}\\ \mathbf{elif}\;z \leq 16000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 8 \cdot 10^{+60}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+165}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error25%
Cost1240
\[\begin{array}{l} t_1 := \frac{\frac{x}{y}}{t - z}\\ t_2 := \frac{\frac{x}{z}}{z - t}\\ \mathbf{if}\;z \leq -3.7 \cdot 10^{+108}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-70}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot t}\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-67}:\\ \;\;\;\;\frac{\frac{x}{t}}{y}\\ \mathbf{elif}\;z \leq 0.00024:\\ \;\;\;\;\frac{x}{z \cdot \left(z - t\right)}\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{+58}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error25.32%
Cost1172
\[\begin{array}{l} t_1 := \frac{\frac{x}{y}}{t - z}\\ \mathbf{if}\;t \leq -8.5 \cdot 10^{-76}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.15 \cdot 10^{-28}:\\ \;\;\;\;\frac{\frac{x}{z}}{z - y}\\ \mathbf{elif}\;t \leq 0.005:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 0.008:\\ \;\;\;\;\frac{\frac{x}{z}}{z}\\ \mathbf{elif}\;t \leq 2.4 \cdot 10^{+195}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-x}{t}}{z - y}\\ \end{array} \]
Alternative 6
Error35.97%
Cost980
\[\begin{array}{l} t_1 := \frac{\frac{x}{z}}{z}\\ \mathbf{if}\;z \leq -1.6 \cdot 10^{+107}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.55 \cdot 10^{-43}:\\ \;\;\;\;\frac{\frac{-x}{y}}{z}\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-57}:\\ \;\;\;\;\frac{\frac{x}{y}}{t}\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-6}:\\ \;\;\;\;\frac{-x}{z \cdot t}\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{+57}:\\ \;\;\;\;\frac{\frac{x}{t}}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error36.09%
Cost980
\[\begin{array}{l} t_1 := \frac{\frac{x}{z}}{z}\\ \mathbf{if}\;z \leq -1.6 \cdot 10^{+107}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.35 \cdot 10^{-50}:\\ \;\;\;\;\frac{\frac{-x}{y}}{z}\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-57}:\\ \;\;\;\;\frac{\frac{x}{y}}{t}\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{x}{z}}{-t}\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+57}:\\ \;\;\;\;\frac{\frac{x}{t}}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error26.6%
Cost976
\[\begin{array}{l} t_1 := \frac{\frac{x}{y}}{t - z}\\ \mathbf{if}\;t \leq -1.75 \cdot 10^{-94}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.5 \cdot 10^{-28}:\\ \;\;\;\;\frac{\frac{x}{z}}{z - y}\\ \mathbf{elif}\;t \leq 0.0032:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 0.008:\\ \;\;\;\;\frac{\frac{x}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot t}\\ \end{array} \]
Alternative 9
Error29.58%
Cost844
\[\begin{array}{l} t_1 := \frac{\frac{x}{z}}{z}\\ \mathbf{if}\;z \leq -7.8 \cdot 10^{+107}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{-23}:\\ \;\;\;\;\frac{\frac{-x}{y}}{z}\\ \mathbf{elif}\;z \leq 1.36 \cdot 10^{+62}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error28.97%
Cost844
\[\begin{array}{l} t_1 := \frac{\frac{x}{z}}{z}\\ \mathbf{if}\;z \leq -1.24 \cdot 10^{+110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-83}:\\ \;\;\;\;\frac{x}{y \cdot \left(t - z\right)}\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{+57}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error27.4%
Cost844
\[\begin{array}{l} t_1 := \frac{\frac{x}{z}}{z}\\ \mathbf{if}\;z \leq -1.6 \cdot 10^{+107}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-85}:\\ \;\;\;\;\frac{x}{y \cdot \left(t - z\right)}\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+165}:\\ \;\;\;\;\frac{x}{z \cdot \left(z - t\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error35.58%
Cost716
\[\begin{array}{l} t_1 := \frac{\frac{x}{z}}{z}\\ \mathbf{if}\;z \leq -2 \cdot 10^{+107}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.45 \cdot 10^{-40}:\\ \;\;\;\;\frac{\frac{-x}{y}}{z}\\ \mathbf{elif}\;z \leq 1.28 \cdot 10^{+57}:\\ \;\;\;\;\frac{\frac{x}{y}}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error55.95%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -8 \cdot 10^{+109} \lor \neg \left(z \leq 1.22 \cdot 10^{+106}\right):\\ \;\;\;\;\frac{x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot t}\\ \end{array} \]
Alternative 14
Error41.12%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -2.4 \cdot 10^{+74} \lor \neg \left(z \leq 1.8 \cdot 10^{+57}\right):\\ \;\;\;\;\frac{x}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot t}\\ \end{array} \]
Alternative 15
Error39.18%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -2.9 \cdot 10^{+81} \lor \neg \left(z \leq 2.35 \cdot 10^{+57}\right):\\ \;\;\;\;\frac{x}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{t}}{y}\\ \end{array} \]
Alternative 16
Error38.66%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -8.2 \cdot 10^{+77} \lor \neg \left(z \leq 1.9 \cdot 10^{+58}\right):\\ \;\;\;\;\frac{x}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{t}\\ \end{array} \]
Alternative 17
Error34.99%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -3.3 \cdot 10^{+74} \lor \neg \left(z \leq 8.2 \cdot 10^{+57}\right):\\ \;\;\;\;\frac{\frac{x}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{t}\\ \end{array} \]
Alternative 18
Error79%
Cost320
\[\frac{x}{z \cdot t} \]

Error

Reproduce?

herbie shell --seed 2023090 
(FPCore (x y z t)
  :name "Data.Random.Distribution.Triangular:triangularCDF from random-fu-0.2.6.2, B"
  :precision binary64

  :herbie-target
  (if (< (/ x (* (- y z) (- t z))) 0.0) (/ (/ x (- y z)) (- t z)) (* x (/ 1.0 (* (- y z) (- t z)))))

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