Average Error: 0.6 → 0.3
Time: 13.7s
Precision: binary64
Cost: 836
\[ \begin{array}{c}[z, t] = \mathsf{sort}([z, t])\\ \end{array} \]
\[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -1.8955206388738845 \cdot 10^{+139}:\\ \;\;\;\;1 - \frac{x}{z \cdot \left(t - y\right)}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\frac{x}{t - y}}{y - z}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
(FPCore (x y z t)
 :precision binary64
 (if (<= z -1.8955206388738845e+139)
   (- 1.0 (/ x (* z (- t y))))
   (+ 1.0 (/ (/ x (- t y)) (- y z)))))
double code(double x, double y, double z, double t) {
	return 1.0 - (x / ((y - z) * (y - t)));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -1.8955206388738845e+139) {
		tmp = 1.0 - (x / (z * (t - y)));
	} else {
		tmp = 1.0 + ((x / (t - y)) / (y - z));
	}
	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 = 1.0d0 - (x / ((y - z) * (y - 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) :: tmp
    if (z <= (-1.8955206388738845d+139)) then
        tmp = 1.0d0 - (x / (z * (t - y)))
    else
        tmp = 1.0d0 + ((x / (t - y)) / (y - z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return 1.0 - (x / ((y - z) * (y - t)));
}
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -1.8955206388738845e+139) {
		tmp = 1.0 - (x / (z * (t - y)));
	} else {
		tmp = 1.0 + ((x / (t - y)) / (y - z));
	}
	return tmp;
}
def code(x, y, z, t):
	return 1.0 - (x / ((y - z) * (y - t)))
def code(x, y, z, t):
	tmp = 0
	if z <= -1.8955206388738845e+139:
		tmp = 1.0 - (x / (z * (t - y)))
	else:
		tmp = 1.0 + ((x / (t - y)) / (y - z))
	return tmp
function code(x, y, z, t)
	return Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t))))
end
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -1.8955206388738845e+139)
		tmp = Float64(1.0 - Float64(x / Float64(z * Float64(t - y))));
	else
		tmp = Float64(1.0 + Float64(Float64(x / Float64(t - y)) / Float64(y - z)));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = 1.0 - (x / ((y - z) * (y - t)));
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -1.8955206388738845e+139)
		tmp = 1.0 - (x / (z * (t - y)));
	else
		tmp = 1.0 + ((x / (t - y)) / (y - z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[z, -1.8955206388738845e+139], N[(1.0 - N[(x / N[(z * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x / N[(t - y), $MachinePrecision]), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\begin{array}{l}
\mathbf{if}\;z \leq -1.8955206388738845 \cdot 10^{+139}:\\
\;\;\;\;1 - \frac{x}{z \cdot \left(t - y\right)}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if z < -1.89552063887388454e139

    1. Initial program 0.0

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

      \[\leadsto \color{blue}{1 + \frac{\frac{x}{y - z}}{t - y}} \]
      Proof
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (-.f64 t y))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 (-.f64 t y)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (neg.f64 (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 t y)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (neg.f64 (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 t) y))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (neg.f64 (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 t)) y)))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (neg.f64 (Rewrite<= +-commutative_binary64 (+.f64 y (neg.f64 t)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (neg.f64 (Rewrite<= sub-neg_binary64 (-.f64 y t))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (Rewrite=> neg-mul-1_binary64 (*.f64 -1 (-.f64 y t))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (Rewrite<= *-commutative_binary64 (*.f64 (-.f64 y t) -1)))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (Rewrite<= *-lft-identity_binary64 (*.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (*.f64 (-.f64 y t) -1))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 1 (/.f64 x (-.f64 y z))) (*.f64 (-.f64 y t) -1)))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (*.f64 1 (/.f64 x (-.f64 y z))) (Rewrite=> *-commutative_binary64 (*.f64 -1 (-.f64 y t))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (Rewrite=> times-frac_binary64 (*.f64 (/.f64 1 -1) (/.f64 (/.f64 x (-.f64 y z)) (-.f64 y t))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (*.f64 (Rewrite=> metadata-eval -1) (/.f64 (/.f64 x (-.f64 y z)) (-.f64 y t)))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (*.f64 -1 (Rewrite<= associate-/r*_binary64 (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t)))))): 17 points increase in error, 15 points decrease in error
      (+.f64 1 (Rewrite<= neg-mul-1_binary64 (neg.f64 (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t)))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= sub-neg_binary64 (-.f64 1 (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t))))): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in z around inf 0.0

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

      \[\leadsto \color{blue}{1 - \frac{x}{\left(t - y\right) \cdot z}} \]
      Proof
      (-.f64 1 (/.f64 x (*.f64 (-.f64 t y) z))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= unsub-neg_binary64 (+.f64 1 (neg.f64 (/.f64 x (*.f64 (-.f64 t y) z))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (/.f64 x (*.f64 (-.f64 t y) z))))): 0 points increase in error, 0 points decrease in error

    if -1.89552063887388454e139 < z

    1. Initial program 0.8

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Simplified1.5

      \[\leadsto \color{blue}{1 + \frac{\frac{x}{y - z}}{t - y}} \]
      Proof
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (-.f64 t y))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 (-.f64 t y)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (neg.f64 (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 t y)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (neg.f64 (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 t) y))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (neg.f64 (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 t)) y)))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (neg.f64 (Rewrite<= +-commutative_binary64 (+.f64 y (neg.f64 t)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (neg.f64 (Rewrite<= sub-neg_binary64 (-.f64 y t))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (Rewrite=> neg-mul-1_binary64 (*.f64 -1 (-.f64 y t))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (Rewrite<= *-commutative_binary64 (*.f64 (-.f64 y t) -1)))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (Rewrite<= *-lft-identity_binary64 (*.f64 1 (/.f64 (/.f64 x (-.f64 y z)) (*.f64 (-.f64 y t) -1))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 1 (/.f64 x (-.f64 y z))) (*.f64 (-.f64 y t) -1)))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (/.f64 (*.f64 1 (/.f64 x (-.f64 y z))) (Rewrite=> *-commutative_binary64 (*.f64 -1 (-.f64 y t))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (Rewrite=> times-frac_binary64 (*.f64 (/.f64 1 -1) (/.f64 (/.f64 x (-.f64 y z)) (-.f64 y t))))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (*.f64 (Rewrite=> metadata-eval -1) (/.f64 (/.f64 x (-.f64 y z)) (-.f64 y t)))): 0 points increase in error, 0 points decrease in error
      (+.f64 1 (*.f64 -1 (Rewrite<= associate-/r*_binary64 (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t)))))): 17 points increase in error, 15 points decrease in error
      (+.f64 1 (Rewrite<= neg-mul-1_binary64 (neg.f64 (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t)))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= sub-neg_binary64 (-.f64 1 (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t))))): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in x around 0 0.8

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

      \[\leadsto 1 + \color{blue}{\frac{\frac{x}{t - y}}{y - z}} \]
      Proof
      (/.f64 (/.f64 x (-.f64 t y)) (-.f64 y z)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/r*_binary64 (/.f64 x (*.f64 (-.f64 t y) (-.f64 y z)))): 43 points increase in error, 47 points decrease in error
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.8955206388738845 \cdot 10^{+139}:\\ \;\;\;\;1 - \frac{x}{z \cdot \left(t - y\right)}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\frac{x}{t - y}}{y - z}\\ \end{array} \]

Alternatives

Alternative 1
Error9.1
Cost1368
\[\begin{array}{l} t_1 := 1 + \frac{\frac{x}{t}}{y - z}\\ \mathbf{if}\;y \leq -3.3001604558687304 \cdot 10^{-75}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -2.8119219213872703 \cdot 10^{-178}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-207}:\\ \;\;\;\;1 - \frac{\frac{x}{z}}{t}\\ \mathbf{elif}\;y \leq 1.972027512676145 \cdot 10^{-25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 240664738218541.6:\\ \;\;\;\;1 + \frac{x}{y \cdot z}\\ \mathbf{elif}\;y \leq 2.612887305784571 \cdot 10^{+27}:\\ \;\;\;\;1 + \frac{x}{y \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1 + x \cdot \frac{-1}{y \cdot y}\\ \end{array} \]
Alternative 2
Error9.1
Cost1240
\[\begin{array}{l} t_1 := 1 + \frac{\frac{x}{t}}{y - z}\\ \mathbf{if}\;y \leq -3.3001604558687304 \cdot 10^{-75}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -2.8119219213872703 \cdot 10^{-178}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-207}:\\ \;\;\;\;1 - \frac{\frac{x}{z}}{t}\\ \mathbf{elif}\;y \leq 1.972027512676145 \cdot 10^{-25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 240664738218541.6:\\ \;\;\;\;1 + \frac{x}{y \cdot z}\\ \mathbf{elif}\;y \leq 2.612887305784571 \cdot 10^{+27}:\\ \;\;\;\;1 + \frac{x}{y \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\frac{x}{y}}{y}\\ \end{array} \]
Alternative 3
Error4.9
Cost1104
\[\begin{array}{l} t_1 := 1 + \frac{\frac{x}{t}}{y - z}\\ \mathbf{if}\;z \leq -2.0325160396737035 \cdot 10^{-84}:\\ \;\;\;\;1 - \frac{x}{z \cdot \left(t - y\right)}\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-115}:\\ \;\;\;\;1 + \frac{x}{y \cdot \left(t - y\right)}\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 10^{-245}:\\ \;\;\;\;1 + \frac{\frac{x}{y}}{t - y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error4.4
Cost1104
\[\begin{array}{l} \mathbf{if}\;z \leq -2.0325160396737035 \cdot 10^{-84}:\\ \;\;\;\;1 - \frac{x}{z \cdot \left(t - y\right)}\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-115}:\\ \;\;\;\;1 + \frac{x}{y \cdot \left(t - y\right)}\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-153}:\\ \;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\ \mathbf{elif}\;z \leq 10^{-153}:\\ \;\;\;\;1 - \frac{\frac{x}{y - t}}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x}{\left(y - z\right) \cdot t}\\ \end{array} \]
Alternative 5
Error10.0
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -5.275037116665123 \cdot 10^{-111}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.1579598471014185 \cdot 10^{-117}:\\ \;\;\;\;1 - \frac{\frac{x}{t}}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Error11.0
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -5.275037116665123 \cdot 10^{-111}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 0.0107208615383555:\\ \;\;\;\;1 - \frac{\frac{x}{t}}{z}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\frac{x}{y}}{y}\\ \end{array} \]
Alternative 7
Error10.9
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -5.275037116665123 \cdot 10^{-111}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 0.0107208615383555:\\ \;\;\;\;1 - \frac{\frac{x}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\frac{x}{y}}{y}\\ \end{array} \]
Alternative 8
Error6.9
Cost708
\[\begin{array}{l} \mathbf{if}\;t \leq 10^{-150}:\\ \;\;\;\;1 - \frac{\frac{x}{y}}{y - z}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\ \end{array} \]
Alternative 9
Error1.1
Cost704
\[1 + \frac{\frac{x}{y - z}}{t - y} \]
Alternative 10
Error13.5
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -1.4 \cdot 10^{-281}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-297}:\\ \;\;\;\;\frac{-x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Error13.2
Cost64
\[1 \]

Error

Reproduce

herbie shell --seed 2022317 
(FPCore (x y z t)
  :name "Data.Random.Distribution.Triangular:triangularCDF from random-fu-0.2.6.2, A"
  :precision binary64
  (- 1.0 (/ x (* (- y z) (- y t)))))