Average Error: 2.2 → 1.6
Time: 23.3s
Precision: binary64
Cost: 1864
\[\frac{x - y}{z - y} \cdot t \]
\[\begin{array}{l} t_1 := \frac{x - y}{z - y}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-81}:\\ \;\;\;\;\frac{t}{\frac{z - y}{x - y}}\\ \mathbf{elif}\;t_1 \leq 10^{-317}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\left(x - y\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(\frac{x}{z - y} - \frac{y}{z - y}\right)\\ \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 (<= t_1 -2e-81)
     (/ t (/ (- z y) (- x y)))
     (if (<= t_1 1e-317)
       (* (/ 1.0 z) (* (- x y) t))
       (* t (- (/ x (- z y)) (/ y (- z y))))))))
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 <= -2e-81) {
		tmp = t / ((z - y) / (x - y));
	} else if (t_1 <= 1e-317) {
		tmp = (1.0 / z) * ((x - y) * t);
	} else {
		tmp = t * ((x / (z - y)) - (y / (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 - 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 <= (-2d-81)) then
        tmp = t / ((z - y) / (x - y))
    else if (t_1 <= 1d-317) then
        tmp = (1.0d0 / z) * ((x - y) * t)
    else
        tmp = t * ((x / (z - y)) - (y / (z - y)))
    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 <= -2e-81) {
		tmp = t / ((z - y) / (x - y));
	} else if (t_1 <= 1e-317) {
		tmp = (1.0 / z) * ((x - y) * t);
	} else {
		tmp = t * ((x / (z - y)) - (y / (z - y)));
	}
	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 <= -2e-81:
		tmp = t / ((z - y) / (x - y))
	elif t_1 <= 1e-317:
		tmp = (1.0 / z) * ((x - y) * t)
	else:
		tmp = t * ((x / (z - y)) - (y / (z - y)))
	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 <= -2e-81)
		tmp = Float64(t / Float64(Float64(z - y) / Float64(x - y)));
	elseif (t_1 <= 1e-317)
		tmp = Float64(Float64(1.0 / z) * Float64(Float64(x - y) * t));
	else
		tmp = Float64(t * Float64(Float64(x / Float64(z - y)) - Float64(y / Float64(z - y))));
	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 <= -2e-81)
		tmp = t / ((z - y) / (x - y));
	elseif (t_1 <= 1e-317)
		tmp = (1.0 / z) * ((x - y) * t);
	else
		tmp = t * ((x / (z - y)) - (y / (z - y)));
	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[LessEqual[t$95$1, -2e-81], N[(t / N[(N[(z - y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-317], N[(N[(1.0 / z), $MachinePrecision] * N[(N[(x - y), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[(t * N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\frac{x - y}{z - y} \cdot t
\begin{array}{l}
t_1 := \frac{x - y}{z - y}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{-81}:\\
\;\;\;\;\frac{t}{\frac{z - y}{x - y}}\\

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

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.2
Target2.1
Herbie1.6
\[\frac{t}{\frac{z - y}{x - y}} \]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 x y) (-.f64 z y)) < -1.9999999999999999e-81

    1. Initial program 3.1

      \[\frac{x - y}{z - y} \cdot t \]
    2. Applied egg-rr2.8

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

    if -1.9999999999999999e-81 < (/.f64 (-.f64 x y) (-.f64 z y)) < 1.00000023e-317

    1. Initial program 7.5

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

      \[\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))): 57 points increase in error, 78 points decrease in error
      (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 (-.f64 x y) (-.f64 z y)) t)): 40 points increase in error, 73 points decrease in error
    3. Taylor expanded in z around inf 3.0

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

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

    if 1.00000023e-317 < (/.f64 (-.f64 x y) (-.f64 z y))

    1. Initial program 0.9

      \[\frac{x - y}{z - y} \cdot t \]
    2. Taylor expanded in x around 0 0.9

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

      \[\leadsto \color{blue}{\left(\frac{x}{z - y} - \frac{y}{z - y}\right)} \cdot t \]
      Proof
      (-.f64 (/.f64 x (-.f64 z y)) (/.f64 y (-.f64 z y))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= unsub-neg_binary64 (+.f64 (/.f64 x (-.f64 z y)) (neg.f64 (/.f64 y (-.f64 z y))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 x (-.f64 z y)) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (/.f64 y (-.f64 z y))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 -1 (/.f64 y (-.f64 z y))) (/.f64 x (-.f64 z y)))): 0 points increase in error, 0 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification1.6

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

Alternatives

Alternative 1
Error1.5
Cost1608
\[\begin{array}{l} t_1 := \frac{x - y}{z - y}\\ t_2 := \frac{t}{\frac{z - y}{x - y}}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-81}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 10^{-317}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\left(x - y\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error1.5
Cost1608
\[\begin{array}{l} t_1 := \frac{x - y}{z - y}\\ t_2 := \frac{t}{\frac{z - y}{x - y}}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-69}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 4 \cdot 10^{-242}:\\ \;\;\;\;\frac{x \cdot t - y \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error20.6
Cost1372
\[\begin{array}{l} t_1 := \frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{if}\;z \leq -2.737477696401444 \cdot 10^{+225}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -6.238027402209409 \cdot 10^{+159}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{elif}\;z \leq -1.4077960024619379 \cdot 10^{+62}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.264608697308068 \cdot 10^{-26}:\\ \;\;\;\;\frac{t}{\frac{z - y}{x}}\\ \mathbf{elif}\;z \leq -4.5722788904218705 \cdot 10^{-95}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \mathbf{elif}\;z \leq 1.5657522371722566 \cdot 10^{-31}:\\ \;\;\;\;t - x \cdot \frac{t}{y}\\ \mathbf{elif}\;z \leq 1.9481579467402142 \cdot 10^{+108}:\\ \;\;\;\;\frac{x}{\frac{z - y}{t}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error19.6
Cost1108
\[\begin{array}{l} t_1 := \frac{x \cdot t}{z - y}\\ t_2 := t - x \cdot \frac{t}{y}\\ \mathbf{if}\;y \leq -1.6556073421447957 \cdot 10^{-5}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -9.163261726011394 \cdot 10^{-24}:\\ \;\;\;\;t \cdot \left(-\frac{y}{z}\right)\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-80}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-290}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 8.398716681117393 \cdot 10^{+37}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error19.7
Cost1108
\[\begin{array}{l} \mathbf{if}\;z \leq -1.4077960024619379 \cdot 10^{+62}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;z \leq -4.264608697308068 \cdot 10^{-26}:\\ \;\;\;\;\frac{t}{\frac{z - y}{x}}\\ \mathbf{elif}\;z \leq -4.5722788904218705 \cdot 10^{-95}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \mathbf{elif}\;z \leq 1.5657522371722566 \cdot 10^{-31}:\\ \;\;\;\;t - x \cdot \frac{t}{y}\\ \mathbf{elif}\;z \leq 1.9481579467402142 \cdot 10^{+108}:\\ \;\;\;\;\frac{x}{\frac{z - y}{t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \end{array} \]
Alternative 6
Error19.1
Cost1108
\[\begin{array}{l} \mathbf{if}\;z \leq -1.4077960024619379 \cdot 10^{+62}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;z \leq -4.264608697308068 \cdot 10^{-26}:\\ \;\;\;\;\frac{t}{\frac{z - y}{x}}\\ \mathbf{elif}\;z \leq -4.5722788904218705 \cdot 10^{-95}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \mathbf{elif}\;z \leq 1.5657522371722566 \cdot 10^{-31}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{elif}\;z \leq 1.9481579467402142 \cdot 10^{+108}:\\ \;\;\;\;\frac{x}{\frac{z - y}{t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \end{array} \]
Alternative 7
Error19.0
Cost1108
\[\begin{array}{l} \mathbf{if}\;z \leq -1.4077960024619379 \cdot 10^{+62}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;z \leq -4.264608697308068 \cdot 10^{-26}:\\ \;\;\;\;\frac{t}{\frac{z - y}{x}}\\ \mathbf{elif}\;z \leq -4.5722788904218705 \cdot 10^{-95}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \mathbf{elif}\;z \leq 1.5657522371722566 \cdot 10^{-31}:\\ \;\;\;\;\frac{t}{\frac{-y}{x - y}}\\ \mathbf{elif}\;z \leq 1.9481579467402142 \cdot 10^{+108}:\\ \;\;\;\;\frac{x}{\frac{z - y}{t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \end{array} \]
Alternative 8
Error23.9
Cost976
\[\begin{array}{l} \mathbf{if}\;y \leq -2.5049267641757172 \cdot 10^{+176}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -8.052504859359161 \cdot 10^{+128}:\\ \;\;\;\;\frac{x}{\frac{z - y}{t}}\\ \mathbf{elif}\;y \leq -0.0018552164268854205:\\ \;\;\;\;t \cdot \left(-\frac{y}{z}\right)\\ \mathbf{elif}\;y \leq 8.398716681117393 \cdot 10^{+37}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 9
Error16.8
Cost976
\[\begin{array}{l} t_1 := \frac{t}{\frac{z - y}{x}}\\ \mathbf{if}\;x \leq -2.2054251411040276 \cdot 10^{+90}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.904129633050657 \cdot 10^{-20}:\\ \;\;\;\;t - x \cdot \frac{t}{y}\\ \mathbf{elif}\;x \leq -1.6862588310172587 \cdot 10^{-43}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{elif}\;x \leq 3.5701403437943013 \cdot 10^{-19}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error25.0
Cost716
\[\begin{array}{l} \mathbf{if}\;y \leq -2.0417525294339973 \cdot 10^{+55}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -9.163261726011394 \cdot 10^{-24}:\\ \;\;\;\;y \cdot \frac{-t}{z}\\ \mathbf{elif}\;y \leq 8.398716681117393 \cdot 10^{+37}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 11
Error25.6
Cost716
\[\begin{array}{l} \mathbf{if}\;y \leq -3.832506018383278 \cdot 10^{+118}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -9.163261726011394 \cdot 10^{-24}:\\ \;\;\;\;t \cdot \left(-\frac{y}{z}\right)\\ \mathbf{elif}\;y \leq 8.398716681117393 \cdot 10^{+37}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 12
Error21.8
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -4.0714734037697075 \cdot 10^{+28}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 8.398716681117393 \cdot 10^{+37}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 13
Error18.1
Cost712
\[\begin{array}{l} t_1 := t - x \cdot \frac{t}{y}\\ \mathbf{if}\;y \leq -1.7927556285365822 \cdot 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8.398716681117393 \cdot 10^{+37}:\\ \;\;\;\;\frac{t}{\frac{z - y}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 14
Error37.6
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -2.85 \cdot 10^{-84}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.06 \cdot 10^{-202}:\\ \;\;\;\;\frac{y \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 15
Error25.0
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.7927556285365822 \cdot 10^{+41}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 8.398716681117393 \cdot 10^{+37}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 16
Error25.1
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.7927556285365822 \cdot 10^{+41}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 8.398716681117393 \cdot 10^{+37}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 17
Error39.6
Cost64
\[t \]

Error

Reproduce

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