?

Average Error: 7.4 → 7.6
Time: 20.5s
Precision: binary64
Cost: 14216

?

\[ \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} \mathbf{if}\;t \leq 1.08 \cdot 10^{+249}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\ \mathbf{elif}\;t \leq 1.45 \cdot 10^{+261}:\\ \;\;\;\;-\left(\frac{x}{{t}^{2}} + \frac{x \cdot \left(\frac{1}{t} + \frac{y}{{t}^{2}}\right)}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t \cdot \left(y - z\right)}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (/ x (* (- y z) (- t z))))
(FPCore (x y z t)
 :precision binary64
 (if (<= t 1.08e+249)
   (/ x (* (- y z) (- t z)))
   (if (<= t 1.45e+261)
     (- (+ (/ x (pow t 2.0)) (/ (* x (+ (/ 1.0 t) (/ y (pow t 2.0)))) z)))
     (/ x (* t (- y z))))))
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 tmp;
	if (t <= 1.08e+249) {
		tmp = x / ((y - z) * (t - z));
	} else if (t <= 1.45e+261) {
		tmp = -((x / pow(t, 2.0)) + ((x * ((1.0 / t) + (y / pow(t, 2.0)))) / z));
	} else {
		tmp = x / (t * (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 = 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) :: tmp
    if (t <= 1.08d+249) then
        tmp = x / ((y - z) * (t - z))
    else if (t <= 1.45d+261) then
        tmp = -((x / (t ** 2.0d0)) + ((x * ((1.0d0 / t) + (y / (t ** 2.0d0)))) / z))
    else
        tmp = x / (t * (y - z))
    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 tmp;
	if (t <= 1.08e+249) {
		tmp = x / ((y - z) * (t - z));
	} else if (t <= 1.45e+261) {
		tmp = -((x / Math.pow(t, 2.0)) + ((x * ((1.0 / t) + (y / Math.pow(t, 2.0)))) / z));
	} else {
		tmp = x / (t * (y - z));
	}
	return tmp;
}
def code(x, y, z, t):
	return x / ((y - z) * (t - z))
def code(x, y, z, t):
	tmp = 0
	if t <= 1.08e+249:
		tmp = x / ((y - z) * (t - z))
	elif t <= 1.45e+261:
		tmp = -((x / math.pow(t, 2.0)) + ((x * ((1.0 / t) + (y / math.pow(t, 2.0)))) / z))
	else:
		tmp = x / (t * (y - z))
	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)
	tmp = 0.0
	if (t <= 1.08e+249)
		tmp = Float64(x / Float64(Float64(y - z) * Float64(t - z)));
	elseif (t <= 1.45e+261)
		tmp = Float64(-Float64(Float64(x / (t ^ 2.0)) + Float64(Float64(x * Float64(Float64(1.0 / t) + Float64(y / (t ^ 2.0)))) / z)));
	else
		tmp = Float64(x / Float64(t * Float64(y - z)));
	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)
	tmp = 0.0;
	if (t <= 1.08e+249)
		tmp = x / ((y - z) * (t - z));
	elseif (t <= 1.45e+261)
		tmp = -((x / (t ^ 2.0)) + ((x * ((1.0 / t) + (y / (t ^ 2.0)))) / z));
	else
		tmp = x / (t * (y - z));
	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_] := If[LessEqual[t, 1.08e+249], N[(x / N[(N[(y - z), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.45e+261], (-N[(N[(x / N[Power[t, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(x * N[(N[(1.0 / t), $MachinePrecision] + N[(y / N[Power[t, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), N[(x / N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}
\begin{array}{l}
\mathbf{if}\;t \leq 1.08 \cdot 10^{+249}:\\
\;\;\;\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\

\mathbf{elif}\;t \leq 1.45 \cdot 10^{+261}:\\
\;\;\;\;-\left(\frac{x}{{t}^{2}} + \frac{x \cdot \left(\frac{1}{t} + \frac{y}{{t}^{2}}\right)}{z}\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.4
Target8.0
Herbie7.6
\[\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 3 regimes
  2. if t < 1.07999999999999995e249

    1. Initial program 7.0

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

    if 1.07999999999999995e249 < t < 1.45e261

    1. Initial program 11.7

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \]
    2. Taylor expanded in t around inf 12.4

      \[\leadsto \color{blue}{\frac{z \cdot x}{{t}^{2} \cdot \left(y - z\right)} + \frac{x}{t \cdot \left(y - z\right)}} \]
    3. Taylor expanded in x around 0 11.7

      \[\leadsto \color{blue}{\left(\frac{1}{t \cdot \left(y - z\right)} + \frac{z}{{t}^{2} \cdot \left(y - z\right)}\right) \cdot x} \]
    4. Taylor expanded in z around inf 21.6

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{{t}^{2}} + -1 \cdot \frac{\left(\frac{y}{{t}^{2}} + \frac{1}{t}\right) \cdot x}{z}} \]
    5. Simplified21.6

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

      [Start]21.6

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

      rational.json-simplify-1 [=>]21.6

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

      rational.json-simplify-2 [=>]21.6

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

      rational.json-simplify-47 [=>]21.6

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

      rational.json-simplify-2 [=>]21.6

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

      rational.json-simplify-9 [=>]21.6

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

      rational.json-simplify-2 [=>]21.6

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

      rational.json-simplify-1 [=>]21.6

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

    if 1.45e261 < t

    1. Initial program 10.9

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \]
    2. Taylor expanded in t around inf 10.9

      \[\leadsto \color{blue}{\frac{x}{t \cdot \left(y - z\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification7.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 1.08 \cdot 10^{+249}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\ \mathbf{elif}\;t \leq 1.45 \cdot 10^{+261}:\\ \;\;\;\;-\left(\frac{x}{{t}^{2}} + \frac{x \cdot \left(\frac{1}{t} + \frac{y}{{t}^{2}}\right)}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t \cdot \left(y - z\right)}\\ \end{array} \]

Alternatives

Alternative 1
Error33.3
Cost1044
\[\begin{array}{l} t_1 := \frac{\frac{x}{t}}{y}\\ t_2 := \frac{x}{y \cdot \left(-z\right)}\\ \mathbf{if}\;t \leq -1.8 \cdot 10^{-166}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.15 \cdot 10^{-173}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.32 \cdot 10^{-134}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 9.2 \cdot 10^{-46}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 8 \cdot 10^{+238}:\\ \;\;\;\;\frac{x}{z \cdot \left(-t\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error23.6
Cost976
\[\begin{array}{l} t_1 := \frac{\frac{x}{t}}{y}\\ t_2 := \frac{x}{y \cdot \left(-z\right)}\\ \mathbf{if}\;t \leq -3.5 \cdot 10^{-166}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.55 \cdot 10^{-178}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 4.7 \cdot 10^{-136}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.4 \cdot 10^{-89}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t \cdot \left(y - z\right)}\\ \end{array} \]
Alternative 3
Error17.4
Cost976
\[\begin{array}{l} t_1 := \frac{x}{t \cdot \left(y - z\right)}\\ t_2 := \frac{x}{z \cdot \left(z - t\right)}\\ \mathbf{if}\;z \leq -4.1 \cdot 10^{-21}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.35 \cdot 10^{-210}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-267}:\\ \;\;\;\;\frac{\frac{x}{t}}{y}\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-89}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error14.6
Cost976
\[\begin{array}{l} t_1 := \frac{x}{t \cdot \left(y - z\right)}\\ \mathbf{if}\;y \leq -9.6 \cdot 10^{-6}:\\ \;\;\;\;\frac{x}{\left(t - z\right) \cdot y}\\ \mathbf{elif}\;y \leq -8.4 \cdot 10^{-39}:\\ \;\;\;\;\frac{x}{z \cdot \left(z - y\right)}\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-91}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-218}:\\ \;\;\;\;\frac{x}{z \cdot \left(z - t\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error32.1
Cost912
\[\begin{array}{l} t_1 := \frac{\frac{x}{t}}{y}\\ t_2 := \frac{x}{y \cdot \left(-z\right)}\\ \mathbf{if}\;t \leq -2.5 \cdot 10^{-166}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.55 \cdot 10^{-178}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.9 \cdot 10^{-128}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.45 \cdot 10^{-89}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error7.8
Cost840
\[\begin{array}{l} t_1 := \frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\ \mathbf{if}\;z \leq -2.7 \cdot 10^{-210}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{-267}:\\ \;\;\;\;\frac{\frac{x}{t}}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error15.8
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -8.8 \cdot 10^{-54}:\\ \;\;\;\;\frac{\frac{x}{t}}{y}\\ \mathbf{elif}\;t \leq 1.52 \cdot 10^{-89}:\\ \;\;\;\;\frac{x}{z \cdot \left(z - y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t \cdot \left(y - z\right)}\\ \end{array} \]
Alternative 8
Error39.6
Cost320
\[\frac{x}{y \cdot t} \]
Alternative 9
Error37.1
Cost320
\[\frac{\frac{x}{t}}{y} \]

Error

Reproduce?

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