?

Average Error: 7.3 → 0.8
Time: 12.7s
Precision: binary64
Cost: 2509

?

\[ \begin{array}{c}[y, t] = \mathsf{sort}([y, t])\\ \end{array} \]
\[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \]
\[\begin{array}{l} t_1 := \frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{-305} \lor \neg \left(t_1 \leq 0\right) \land t_1 \leq 2 \cdot 10^{+149}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z - t}}{z - y}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (/ x (* (- y z) (- t z))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ x (* (- y z) (- t z)))))
   (if (or (<= t_1 -1e-305) (and (not (<= t_1 0.0)) (<= t_1 2e+149)))
     t_1
     (/ (/ x (- z t)) (- z y)))))
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 = x / ((y - z) * (t - z));
	double tmp;
	if ((t_1 <= -1e-305) || (!(t_1 <= 0.0) && (t_1 <= 2e+149))) {
		tmp = t_1;
	} else {
		tmp = (x / (z - t)) / (z - y);
	}
	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 = x / ((y - z) * (t - z))
    if ((t_1 <= (-1d-305)) .or. (.not. (t_1 <= 0.0d0)) .and. (t_1 <= 2d+149)) then
        tmp = t_1
    else
        tmp = (x / (z - t)) / (z - y)
    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 = x / ((y - z) * (t - z));
	double tmp;
	if ((t_1 <= -1e-305) || (!(t_1 <= 0.0) && (t_1 <= 2e+149))) {
		tmp = t_1;
	} else {
		tmp = (x / (z - t)) / (z - y);
	}
	return tmp;
}
def code(x, y, z, t):
	return x / ((y - z) * (t - z))
def code(x, y, z, t):
	t_1 = x / ((y - z) * (t - z))
	tmp = 0
	if (t_1 <= -1e-305) or (not (t_1 <= 0.0) and (t_1 <= 2e+149)):
		tmp = t_1
	else:
		tmp = (x / (z - t)) / (z - y)
	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(x / Float64(Float64(y - z) * Float64(t - z)))
	tmp = 0.0
	if ((t_1 <= -1e-305) || (!(t_1 <= 0.0) && (t_1 <= 2e+149)))
		tmp = t_1;
	else
		tmp = Float64(Float64(x / Float64(z - t)) / Float64(z - y));
	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 = x / ((y - z) * (t - z));
	tmp = 0.0;
	if ((t_1 <= -1e-305) || (~((t_1 <= 0.0)) && (t_1 <= 2e+149)))
		tmp = t_1;
	else
		tmp = (x / (z - t)) / (z - y);
	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[(x / N[(N[(y - z), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e-305], And[N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision], LessEqual[t$95$1, 2e+149]]], t$95$1, N[(N[(x / N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]]]
\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}
\begin{array}{l}
t_1 := \frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{-305} \lor \neg \left(t_1 \leq 0\right) \land t_1 \leq 2 \cdot 10^{+149}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z - t}}{z - y}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.3
Target8.1
Herbie0.8
\[\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 x (*.f64 (-.f64 y z) (-.f64 t z))) < -9.99999999999999996e-306 or 0.0 < (/.f64 x (*.f64 (-.f64 y z) (-.f64 t z))) < 2.0000000000000001e149

    1. Initial program 0.9

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

    if -9.99999999999999996e-306 < (/.f64 x (*.f64 (-.f64 y z) (-.f64 t z))) < 0.0 or 2.0000000000000001e149 < (/.f64 x (*.f64 (-.f64 y z) (-.f64 t z)))

    1. Initial program 12.4

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

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

      [Start]12.4

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

      sub-neg [=>]12.4

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

      +-commutative [=>]12.4

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

      neg-sub0 [=>]12.4

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

      associate-+l- [=>]12.4

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

      sub0-neg [=>]12.4

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

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

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

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

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

      neg-sub0 [=>]12.4

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

      associate-+l- [<=]12.4

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

      neg-sub0 [<=]12.4

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

      +-commutative [<=]12.4

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

      sub-neg [<=]12.4

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

      associate-/l/ [<=]0.8

      \[ \color{blue}{\frac{\frac{x}{z - t}}{z - y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

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

Alternatives

Alternative 1
Error21.3
Cost1504
\[\begin{array}{l} t_1 := \frac{\frac{x}{z}}{z}\\ \mathbf{if}\;t \leq -3 \cdot 10^{+23}:\\ \;\;\;\;\frac{\frac{x}{y}}{t}\\ \mathbf{elif}\;t \leq -5.4 \cdot 10^{-106}:\\ \;\;\;\;\frac{\frac{-x}{y}}{z}\\ \mathbf{elif}\;t \leq -4.8 \cdot 10^{-126}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{1}{t}\\ \mathbf{elif}\;t \leq 1.9 \cdot 10^{-308}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 9.6 \cdot 10^{-278}:\\ \;\;\;\;\frac{-x}{y \cdot z}\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{-248}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.9 \cdot 10^{-154}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{-1}{y}\\ \mathbf{elif}\;t \leq 2.3 \cdot 10^{+19}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot t}\\ \end{array} \]
Alternative 2
Error21.0
Cost1176
\[\begin{array}{l} t_1 := \frac{\frac{x}{z}}{z}\\ t_2 := \frac{\frac{x}{t}}{y}\\ \mathbf{if}\;z \leq -1.08 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -8.2 \cdot 10^{-206}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-196}:\\ \;\;\;\;\frac{x}{y \cdot t}\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-7}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{+29}:\\ \;\;\;\;\frac{\frac{-x}{y}}{z}\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+35}:\\ \;\;\;\;\frac{-x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error13.2
Cost976
\[\begin{array}{l} t_1 := \frac{\frac{x}{y - z}}{t}\\ \mathbf{if}\;z \leq -1.35 \cdot 10^{-31}:\\ \;\;\;\;\frac{\frac{x}{z}}{z - y}\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-290}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.15 \cdot 10^{-181}:\\ \;\;\;\;\frac{-x}{y \cdot \left(z - t\right)}\\ \mathbf{elif}\;z \leq 1.75 \cdot 10^{-7}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z - y}}{z}\\ \end{array} \]
Alternative 4
Error13.3
Cost976
\[\begin{array}{l} \mathbf{if}\;z \leq -3.2 \cdot 10^{-31}:\\ \;\;\;\;\frac{\frac{x}{z}}{z - y}\\ \mathbf{elif}\;z \leq -1.5 \cdot 10^{-136}:\\ \;\;\;\;\frac{\frac{-x}{t}}{z - y}\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{-177}:\\ \;\;\;\;\frac{-x}{y \cdot \left(z - t\right)}\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-8}:\\ \;\;\;\;\frac{\frac{x}{y - z}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z - y}}{z}\\ \end{array} \]
Alternative 5
Error13.5
Cost976
\[\begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{-31}:\\ \;\;\;\;\frac{1}{z \cdot \frac{z - y}{x}}\\ \mathbf{elif}\;z \leq -5.6 \cdot 10^{-139}:\\ \;\;\;\;\frac{\frac{-x}{t}}{z - y}\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-182}:\\ \;\;\;\;\frac{-x}{y \cdot \left(z - t\right)}\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-8}:\\ \;\;\;\;\frac{\frac{x}{y - z}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z - y}}{z}\\ \end{array} \]
Alternative 6
Error6.2
Cost972
\[\begin{array}{l} t_1 := \frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\ \mathbf{if}\;t \leq 2.4 \cdot 10^{-282}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.7 \cdot 10^{-170}:\\ \;\;\;\;\frac{\frac{x}{z}}{z - y}\\ \mathbf{elif}\;t \leq 1.08 \cdot 10^{+219}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-x}{t}}{z - y}\\ \end{array} \]
Alternative 7
Error23.2
Cost848
\[\begin{array}{l} t_1 := \frac{x}{z \cdot z}\\ t_2 := \frac{\frac{x}{t}}{y}\\ \mathbf{if}\;z \leq -3.6 \cdot 10^{+37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -8.8 \cdot 10^{-206}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{-198}:\\ \;\;\;\;\frac{x}{y \cdot t}\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-8}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error21.0
Cost848
\[\begin{array}{l} t_1 := \frac{\frac{x}{z}}{z}\\ t_2 := \frac{\frac{x}{t}}{y}\\ \mathbf{if}\;z \leq -7.6 \cdot 10^{+36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -8.8 \cdot 10^{-206}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-197}:\\ \;\;\;\;\frac{x}{y \cdot t}\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-7}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error16.0
Cost844
\[\begin{array}{l} t_1 := \frac{x}{z \cdot \left(z - t\right)}\\ \mathbf{if}\;z \leq -2 \cdot 10^{-32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{-22}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot t}\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{+186}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{z}\\ \end{array} \]
Alternative 10
Error16.2
Cost844
\[\begin{array}{l} t_1 := \frac{x}{z \cdot \left(z - y\right)}\\ \mathbf{if}\;z \leq -5.8 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-7}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot t}\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{+186}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{z}\\ \end{array} \]
Alternative 11
Error13.5
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -6.8 \cdot 10^{-34} \lor \neg \left(z \leq 5.8 \cdot 10^{-22}\right):\\ \;\;\;\;\frac{\frac{x}{z}}{z - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot t}\\ \end{array} \]
Alternative 12
Error13.7
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -3.6 \cdot 10^{-29} \lor \neg \left(z \leq 1.95 \cdot 10^{-7}\right):\\ \;\;\;\;\frac{\frac{x}{z}}{z - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot t}\\ \end{array} \]
Alternative 13
Error13.3
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -2.25 \cdot 10^{-32} \lor \neg \left(z \leq 2.05 \cdot 10^{-7}\right):\\ \;\;\;\;\frac{\frac{x}{z}}{z - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y - z}}{t}\\ \end{array} \]
Alternative 14
Error13.3
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -6.2 \cdot 10^{-32}:\\ \;\;\;\;\frac{\frac{x}{z}}{z - y}\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{x}{y - z}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z - y}}{z}\\ \end{array} \]
Alternative 15
Error34.6
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -2.3 \cdot 10^{+21} \lor \neg \left(z \leq 0.0048\right):\\ \;\;\;\;\frac{x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot t}\\ \end{array} \]
Alternative 16
Error35.2
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{+45} \lor \neg \left(z \leq 7 \cdot 10^{-7}\right):\\ \;\;\;\;\frac{x}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot t}\\ \end{array} \]
Alternative 17
Error24.3
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -2.4 \cdot 10^{-31} \lor \neg \left(z \leq 5.5 \cdot 10^{-7}\right):\\ \;\;\;\;\frac{x}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot t}\\ \end{array} \]
Alternative 18
Error50.1
Cost320
\[\frac{x}{z \cdot t} \]

Error

Reproduce?

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