?

Average Error: 3.4% → 2.87%
Time: 12.1s
Precision: binary64
Cost: 1609

?

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.4%
Target3.39%
Herbie2.87%
\[\frac{t}{\frac{z - y}{x - y}} \]

Derivation?

  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 x y) (-.f64 z y)) < -4.99999999999999991e-200 or 4e-82 < (/.f64 (-.f64 x y) (-.f64 z y))

    1. Initial program 2.3

      \[\frac{x - y}{z - y} \cdot t \]

    if -4.99999999999999991e-200 < (/.f64 (-.f64 x y) (-.f64 z y)) < 4e-82

    1. Initial program 8.59

      \[\frac{x - y}{z - y} \cdot t \]
    2. Simplified3.26

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

      [Start]8.59

      \[ \frac{x - y}{z - y} \cdot t \]

      associate-*l/ [=>]5.6

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

      associate-*r/ [<=]3.26

      \[ \color{blue}{\left(x - y\right) \cdot \frac{t}{z - y}} \]
    3. Taylor expanded in z around inf 5.6

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

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

Alternatives

Alternative 1
Error12.28%
Cost1104
\[\begin{array}{l} t_1 := \left(x - y\right) \cdot \frac{t}{z - y}\\ \mathbf{if}\;y \leq -2.4 \cdot 10^{+145}:\\ \;\;\;\;t \cdot \frac{y - x}{y}\\ \mathbf{elif}\;y \leq -4.8 \cdot 10^{-139}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{-196}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+188}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \end{array} \]
Alternative 2
Error33.31%
Cost976
\[\begin{array}{l} t_1 := t \cdot \frac{x}{z - y}\\ \mathbf{if}\;y \leq -4.6 \cdot 10^{+78}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{-98}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{-56}:\\ \;\;\;\;\frac{-y}{\frac{z}{t}}\\ \mathbf{elif}\;y \leq 32000000000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 3
Error32.49%
Cost976
\[\begin{array}{l} t_1 := t \cdot \frac{x}{z - y}\\ \mathbf{if}\;y \leq -7 \cdot 10^{+78}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{-135}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-55}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{elif}\;y \leq 31500000000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 4
Error25.62%
Cost976
\[\begin{array}{l} t_1 := t \cdot \frac{y - x}{y}\\ \mathbf{if}\;y \leq -3.2 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-135}:\\ \;\;\;\;t \cdot \frac{x}{z - y}\\ \mathbf{elif}\;y \leq 11400000000:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{+51}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{y}{y - z}\\ \end{array} \]
Alternative 5
Error39.62%
Cost848
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-12}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-100}:\\ \;\;\;\;\frac{x \cdot t}{z}\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-54}:\\ \;\;\;\;\frac{-y}{\frac{z}{t}}\\ \mathbf{elif}\;y \leq 390000000:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 6
Error25.4%
Cost844
\[\begin{array}{l} \mathbf{if}\;y \leq -1.1 \cdot 10^{-7}:\\ \;\;\;\;t \cdot \frac{y - x}{y}\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{-136}:\\ \;\;\;\;t \cdot \frac{x}{z - y}\\ \mathbf{elif}\;y \leq 480000:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \end{array} \]
Alternative 7
Error25.92%
Cost844
\[\begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{-6}:\\ \;\;\;\;t \cdot \frac{y - x}{y}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-135}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{elif}\;y \leq 450000:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \end{array} \]
Alternative 8
Error25.23%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -5.8 \cdot 10^{+78} \lor \neg \left(y \leq 1.6 \cdot 10^{-100}\right):\\ \;\;\;\;t \cdot \frac{y}{y - z}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{x}{z - y}\\ \end{array} \]
Alternative 9
Error39.21%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.1 \cdot 10^{-12}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 7900000:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 10
Error38.08%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -5.6 \cdot 10^{-11}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 850000:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 11
Error61.94%
Cost64
\[t \]

Error

Reproduce?

herbie shell --seed 2023090 
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cput from hsignal-0.2.7.1"
  :precision binary64

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

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