Average Error: 2.3 → 1.8
Time: 20.6s
Precision: binary64
Cost: 1092
\[\frac{x - y}{z - y} \cdot t \]
\[\begin{array}{l} \mathbf{if}\;\frac{x - y}{z - y} \leq 5 \cdot 10^{+196}:\\ \;\;\;\;\frac{t}{\frac{z - y}{x - y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{\frac{z - y}{t}}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (* (/ (- x y) (- z y)) t))
(FPCore (x y z t)
 :precision binary64
 (if (<= (/ (- x y) (- z y)) 5e+196)
   (/ t (/ (- z y) (- x y)))
   (/ (- x y) (/ (- z y) t))))
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 tmp;
	if (((x - y) / (z - y)) <= 5e+196) {
		tmp = t / ((z - y) / (x - y));
	} else {
		tmp = (x - y) / ((z - y) / t);
	}
	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) :: tmp
    if (((x - y) / (z - y)) <= 5d+196) then
        tmp = t / ((z - y) / (x - y))
    else
        tmp = (x - y) / ((z - y) / t)
    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 tmp;
	if (((x - y) / (z - y)) <= 5e+196) {
		tmp = t / ((z - y) / (x - y));
	} else {
		tmp = (x - y) / ((z - y) / t);
	}
	return tmp;
}
def code(x, y, z, t):
	return ((x - y) / (z - y)) * t
def code(x, y, z, t):
	tmp = 0
	if ((x - y) / (z - y)) <= 5e+196:
		tmp = t / ((z - y) / (x - y))
	else:
		tmp = (x - y) / ((z - y) / t)
	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)
	tmp = 0.0
	if (Float64(Float64(x - y) / Float64(z - y)) <= 5e+196)
		tmp = Float64(t / Float64(Float64(z - y) / Float64(x - y)));
	else
		tmp = Float64(Float64(x - y) / Float64(Float64(z - y) / t));
	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)
	tmp = 0.0;
	if (((x - y) / (z - y)) <= 5e+196)
		tmp = t / ((z - y) / (x - y));
	else
		tmp = (x - y) / ((z - y) / t);
	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_] := If[LessEqual[N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision], 5e+196], N[(t / N[(N[(z - y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\frac{x - y}{z - y} \cdot t
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{z - y} \leq 5 \cdot 10^{+196}:\\
\;\;\;\;\frac{t}{\frac{z - y}{x - y}}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.3
Target2.3
Herbie1.8
\[\frac{t}{\frac{z - y}{x - y}} \]

Derivation

  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 x y) (-.f64 z y)) < 4.9999999999999998e196

    1. Initial program 1.7

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

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

    if 4.9999999999999998e196 < (/.f64 (-.f64 x y) (-.f64 z y))

    1. Initial program 20.7

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

      \[\leadsto \color{blue}{\frac{t \cdot x}{z - y} + -1 \cdot \frac{y \cdot t}{z - y}} \]
    3. Simplified0.8

      \[\leadsto \color{blue}{\frac{x - y}{\frac{z - y}{t}}} \]
      Proof
      (/.f64 (-.f64 x y) (/.f64 (-.f64 z y) t)): 0 points increase in error, 0 points decrease in error
      (Rewrite=> div-sub_binary64 (-.f64 (/.f64 x (/.f64 (-.f64 z y) t)) (/.f64 y (/.f64 (-.f64 z y) t)))): 2 points increase in error, 1 points decrease in error
      (-.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 x t) (-.f64 z y))) (/.f64 y (/.f64 (-.f64 z y) t))): 34 points increase in error, 23 points decrease in error
      (-.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 t x)) (-.f64 z y)) (/.f64 y (/.f64 (-.f64 z y) t))): 0 points increase in error, 0 points decrease in error
      (-.f64 (/.f64 (*.f64 t x) (-.f64 z y)) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 y t) (-.f64 z y)))): 37 points increase in error, 49 points decrease in error
      (Rewrite<= unsub-neg_binary64 (+.f64 (/.f64 (*.f64 t x) (-.f64 z y)) (neg.f64 (/.f64 (*.f64 y t) (-.f64 z y))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (*.f64 t x) (-.f64 z y)) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (/.f64 (*.f64 y t) (-.f64 z y))))): 0 points increase in error, 0 points decrease in error
  3. Recombined 2 regimes into one program.
  4. Final simplification1.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y}{z - y} \leq 5 \cdot 10^{+196}:\\ \;\;\;\;\frac{t}{\frac{z - y}{x - y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{\frac{z - y}{t}}\\ \end{array} \]

Alternatives

Alternative 1
Error18.7
Cost1900
\[\begin{array}{l} t_1 := \frac{t}{1 - \frac{z}{y}}\\ t_2 := \frac{x \cdot t}{z - y}\\ \mathbf{if}\;y \leq -1.1853730568411693 \cdot 10^{+151}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.2499008283210632 \cdot 10^{+69}:\\ \;\;\;\;\frac{t}{y} \cdot \left(y - x\right)\\ \mathbf{elif}\;y \leq -1.2175832040871328 \cdot 10^{+52}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -4.004287262295165 \cdot 10^{+23}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -8.736991470857088 \cdot 10^{-42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-280}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 10^{-117}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 1.8727658710291317 \cdot 10^{-72}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 41522124.350205414:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.0592641300444866 \cdot 10^{+29}:\\ \;\;\;\;\frac{x \cdot t}{z}\\ \mathbf{elif}\;y \leq 2.2074554634308328 \cdot 10^{+182}:\\ \;\;\;\;t - \frac{x \cdot t}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error17.5
Cost1504
\[\begin{array}{l} t_1 := \frac{t}{1 - \frac{z}{y}}\\ t_2 := \frac{x \cdot t}{z - y}\\ \mathbf{if}\;y \leq -1.1853730568411693 \cdot 10^{+151}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.2499008283210632 \cdot 10^{+69}:\\ \;\;\;\;\frac{t}{y} \cdot \left(y - x\right)\\ \mathbf{elif}\;y \leq -1.2175832040871328 \cdot 10^{+52}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -4.004287262295165 \cdot 10^{+23}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -8.736991470857088 \cdot 10^{-42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-280}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 10^{-117}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 1.8727658710291317 \cdot 10^{-72}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error18.1
Cost1372
\[\begin{array}{l} t_1 := \frac{t}{1 - \frac{z}{y}}\\ \mathbf{if}\;y \leq -1.1853730568411693 \cdot 10^{+151}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.2499008283210632 \cdot 10^{+69}:\\ \;\;\;\;\frac{t}{y} \cdot \left(y - x\right)\\ \mathbf{elif}\;y \leq -1.2175832040871328 \cdot 10^{+52}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -4.004287262295165 \cdot 10^{+23}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{elif}\;y \leq -8.736991470857088 \cdot 10^{-42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.0592641300444866 \cdot 10^{+29}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{elif}\;y \leq 2.2074554634308328 \cdot 10^{+182}:\\ \;\;\;\;t - \frac{x \cdot t}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error17.4
Cost1372
\[\begin{array}{l} t_1 := t \cdot \left(1 - \frac{x}{y}\right)\\ t_2 := \frac{t}{1 - \frac{z}{y}}\\ \mathbf{if}\;y \leq -1.1853730568411693 \cdot 10^{+151}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -2.2499008283210632 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.2175832040871328 \cdot 10^{+52}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -4.004287262295165 \cdot 10^{+23}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{elif}\;y \leq -8.736991470857088 \cdot 10^{-42}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2.0592641300444866 \cdot 10^{+29}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{elif}\;y \leq 2.2074554634308328 \cdot 10^{+182}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error17.2
Cost1372
\[\begin{array}{l} t_1 := t \cdot \left(1 - \frac{x}{y}\right)\\ t_2 := \frac{t}{1 - \frac{z}{y}}\\ \mathbf{if}\;y \leq -1.1853730568411693 \cdot 10^{+151}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -2.2499008283210632 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.2175832040871328 \cdot 10^{+52}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -4.004287262295165 \cdot 10^{+23}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{elif}\;y \leq -8.736991470857088 \cdot 10^{-42}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2.0592641300444866 \cdot 10^{+29}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{elif}\;y \leq 2.2074554634308328 \cdot 10^{+182}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error17.3
Cost1372
\[\begin{array}{l} t_1 := t \cdot \left(1 - \frac{x}{y}\right)\\ t_2 := \frac{t}{1 - \frac{z}{y}}\\ \mathbf{if}\;y \leq -1.1853730568411693 \cdot 10^{+151}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -2.2499008283210632 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.2175832040871328 \cdot 10^{+52}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -28820054475941090:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{elif}\;y \leq -8.736991470857088 \cdot 10^{-42}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2.0592641300444866 \cdot 10^{+29}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{elif}\;y \leq 2.2074554634308328 \cdot 10^{+182}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error17.3
Cost1372
\[\begin{array}{l} t_1 := t \cdot \left(1 - \frac{x}{y}\right)\\ t_2 := t \cdot \frac{-y}{z - y}\\ t_3 := \frac{t}{1 - \frac{z}{y}}\\ \mathbf{if}\;y \leq -1.1853730568411693 \cdot 10^{+151}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -2.2499008283210632 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.2175832040871328 \cdot 10^{+52}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -28820054475941090:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{elif}\;y \leq -8.736991470857088 \cdot 10^{-42}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2.0592641300444866 \cdot 10^{+29}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{elif}\;y \leq 2.2074554634308328 \cdot 10^{+182}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 8
Error21.9
Cost1108
\[\begin{array}{l} t_1 := \frac{t}{y} \cdot \left(y - x\right)\\ \mathbf{if}\;y \leq -2.486254514671021 \cdot 10^{+198}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -6.710197819819423 \cdot 10^{-15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-280}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{elif}\;y \leq 2.0592641300444866 \cdot 10^{+29}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 2.257391513162288 \cdot 10^{+176}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 9
Error23.2
Cost976
\[\begin{array}{l} t_1 := \frac{t}{y} \cdot \left(y - x\right)\\ \mathbf{if}\;y \leq -2.486254514671021 \cdot 10^{+198}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -6.710197819819423 \cdot 10^{-15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.0592641300444866 \cdot 10^{+29}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 2.257391513162288 \cdot 10^{+176}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 10
Error39.7
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-136}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-243}:\\ \;\;\;\;\frac{x \cdot t}{y}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 11
Error38.3
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -2.744971928024563 \cdot 10^{-72}:\\ \;\;\;\;t\\ \mathbf{elif}\;t \leq 4.87650530160613 \cdot 10^{-113}:\\ \;\;\;\;\frac{y \cdot t}{y}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 12
Error26.1
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -6.710197819819423 \cdot 10^{-15}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 2.0592641300444866 \cdot 10^{+29}:\\ \;\;\;\;\frac{x \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 13
Error26.2
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.976115100776652 \cdot 10^{+46}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 2.0592641300444866 \cdot 10^{+29}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 14
Error25.3
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.976115100776652 \cdot 10^{+46}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 2.0592641300444866 \cdot 10^{+29}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 15
Error2.3
Cost576
\[\frac{t}{\frac{z - y}{x - y}} \]
Alternative 16
Error40.3
Cost64
\[t \]

Error

Reproduce

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