Average Error: 2.1 → 2.0
Time: 10.8s
Precision: binary64
Cost: 1608
\[\frac{x - y}{z - y} \cdot t \]
\[\begin{array}{l} t_1 := \frac{x - y}{z - y}\\ t_2 := t_1 \cdot t\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{-320}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \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))) (t_2 (* t_1 t)))
   (if (<= t_1 -2e-53) t_2 (if (<= t_1 2e-320) (/ (* (- x y) t) z) t_2))))
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 t_2 = t_1 * t;
	double tmp;
	if (t_1 <= -2e-53) {
		tmp = t_2;
	} else if (t_1 <= 2e-320) {
		tmp = ((x - y) * t) / z;
	} else {
		tmp = t_2;
	}
	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) :: t_2
    real(8) :: tmp
    t_1 = (x - y) / (z - y)
    t_2 = t_1 * t
    if (t_1 <= (-2d-53)) then
        tmp = t_2
    else if (t_1 <= 2d-320) then
        tmp = ((x - y) * t) / z
    else
        tmp = t_2
    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 t_2 = t_1 * t;
	double tmp;
	if (t_1 <= -2e-53) {
		tmp = t_2;
	} else if (t_1 <= 2e-320) {
		tmp = ((x - y) * t) / z;
	} else {
		tmp = t_2;
	}
	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)
	t_2 = t_1 * t
	tmp = 0
	if t_1 <= -2e-53:
		tmp = t_2
	elif t_1 <= 2e-320:
		tmp = ((x - y) * t) / z
	else:
		tmp = t_2
	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))
	t_2 = Float64(t_1 * t)
	tmp = 0.0
	if (t_1 <= -2e-53)
		tmp = t_2;
	elseif (t_1 <= 2e-320)
		tmp = Float64(Float64(Float64(x - y) * t) / z);
	else
		tmp = t_2;
	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);
	t_2 = t_1 * t;
	tmp = 0.0;
	if (t_1 <= -2e-53)
		tmp = t_2;
	elseif (t_1 <= 2e-320)
		tmp = ((x - y) * t) / z;
	else
		tmp = t_2;
	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]}, Block[{t$95$2 = N[(t$95$1 * t), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-53], t$95$2, If[LessEqual[t$95$1, 2e-320], N[(N[(N[(x - y), $MachinePrecision] * t), $MachinePrecision] / z), $MachinePrecision], t$95$2]]]]
\frac{x - y}{z - y} \cdot t
\begin{array}{l}
t_1 := \frac{x - y}{z - y}\\
t_2 := t_1 \cdot t\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{-53}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{-320}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.1
Target2.1
Herbie2.0
\[\frac{t}{\frac{z - y}{x - y}} \]

Derivation

  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 x y) (-.f64 z y)) < -2.00000000000000006e-53 or 1.99998e-320 < (/.f64 (-.f64 x y) (-.f64 z y))

    1. Initial program 1.5

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

    if -2.00000000000000006e-53 < (/.f64 (-.f64 x y) (-.f64 z y)) < 1.99998e-320

    1. Initial program 5.5

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

      \[\leadsto \color{blue}{\left(x - y\right) \cdot \frac{t}{z - y}} \]
      Proof
      (*.f64 (-.f64 x y) (/.f64 t (-.f64 z y))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 (-.f64 x y) t) (-.f64 z y))): 64 points increase in error, 73 points decrease in error
      (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 (-.f64 x y) (-.f64 z y)) t)): 20 points increase in error, 68 points decrease in error
    3. Taylor expanded in z around inf 4.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y}{z - y} \leq -2 \cdot 10^{-53}:\\ \;\;\;\;\frac{x - y}{z - y} \cdot t\\ \mathbf{elif}\;\frac{x - y}{z - y} \leq 2 \cdot 10^{-320}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{z - y} \cdot t\\ \end{array} \]

Alternatives

Alternative 1
Error17.3
Cost976
\[\begin{array}{l} t_1 := t - \frac{t}{\frac{y}{x}}\\ t_2 := t \cdot \frac{x - y}{z}\\ \mathbf{if}\;z \leq -4.8 \cdot 10^{+15}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -7.2 \cdot 10^{-99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.22 \cdot 10^{-116}:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error16.6
Cost976
\[\begin{array}{l} t_1 := t \cdot \frac{y}{y - z}\\ \mathbf{if}\;y \leq -3.4 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{-176}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-110}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{-77}:\\ \;\;\;\;t \cdot \frac{x}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error18.4
Cost976
\[\begin{array}{l} t_1 := t - \frac{t}{\frac{y}{x}}\\ \mathbf{if}\;z \leq -1.7 \cdot 10^{+17}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;z \leq -5.4 \cdot 10^{-99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.22 \cdot 10^{-116}:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{+32}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \end{array} \]
Alternative 4
Error21.2
Cost844
\[\begin{array}{l} \mathbf{if}\;y \leq -4.3 \cdot 10^{+117}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-127}:\\ \;\;\;\;t \cdot \frac{x}{z - y}\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{+95}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 5
Error6.9
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -7.4 \cdot 10^{+169}:\\ \;\;\;\;t \cdot \frac{y}{y - z}\\ \mathbf{elif}\;y \leq 1.14 \cdot 10^{+157}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t - \frac{t}{\frac{y}{x}}\\ \end{array} \]
Alternative 6
Error26.5
Cost780
\[\begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+23}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{-145}:\\ \;\;\;\;\frac{x \cdot t}{z}\\ \mathbf{elif}\;y \leq 5.1 \cdot 10^{-51}:\\ \;\;\;\;y \cdot \left(-\frac{t}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 7
Error26.4
Cost780
\[\begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{+23}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-145}:\\ \;\;\;\;\frac{x \cdot t}{z}\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-54}:\\ \;\;\;\;\frac{t \cdot \left(-y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 8
Error21.4
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{+23}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{+84}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 9
Error16.6
Cost712
\[\begin{array}{l} t_1 := t \cdot \frac{y}{y - z}\\ \mathbf{if}\;y \leq -3.4 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-113}:\\ \;\;\;\;t \cdot \frac{x}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error25.5
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -2.9 \cdot 10^{+23}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-54}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 11
Error24.7
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{+23}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-36}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 12
Error25.4
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -2.85 \cdot 10^{+23}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 7 \cdot 10^{-36}:\\ \;\;\;\;\frac{x \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 13
Error39.7
Cost64
\[t \]

Error

Reproduce

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