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

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 3 regimes
  2. if (*.f64 (/.f64 (-.f64 x y) (-.f64 z y)) t) < -0.20000000000000001

    1. Initial program 2.7

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

      \[\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))): 68 points increase in error, 62 points decrease in error
      (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 (-.f64 x y) (-.f64 z y)) t)): 33 points increase in error, 76 points decrease in error

    if -0.20000000000000001 < (*.f64 (/.f64 (-.f64 x y) (-.f64 z y)) t) < 3.9999999999999999e-197

    1. Initial program 2.3

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

      \[\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))): 68 points increase in error, 62 points decrease in error
      (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 (-.f64 x y) (-.f64 z y)) t)): 33 points increase in error, 76 points decrease in error
    3. Applied egg-rr2.4

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

    if 3.9999999999999999e-197 < (*.f64 (/.f64 (-.f64 x y) (-.f64 z y)) t)

    1. Initial program 1.7

      \[\frac{x - y}{z - y} \cdot t \]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.2

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

Alternatives

Alternative 1
Error1.6
Cost1608
\[\begin{array}{l} t_1 := \frac{x - y}{z - y}\\ t_2 := t_1 \cdot t\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 10^{-296}:\\ \;\;\;\;\frac{x - y}{\frac{z}{t}}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error17.6
Cost1372
\[\begin{array}{l} t_1 := \frac{t}{\frac{z - y}{x}}\\ t_2 := t - \frac{t}{\frac{y}{x}}\\ t_3 := \frac{t}{1 - \frac{z}{y}}\\ \mathbf{if}\;y \leq -1.56 \cdot 10^{+108}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -7 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{+20}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-159}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-50}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{+33}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+62}:\\ \;\;\;\;\frac{t}{\frac{z}{x - y}}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error26.9
Cost1308
\[\begin{array}{l} t_1 := \frac{t}{\frac{z}{x}}\\ \mathbf{if}\;y \leq -8.5 \cdot 10^{+134}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -3.9 \cdot 10^{+90}:\\ \;\;\;\;\frac{t}{\frac{z}{-y}}\\ \mathbf{elif}\;y \leq -2.25 \cdot 10^{+20}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 3.05 \cdot 10^{-201}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.45 \cdot 10^{-155}:\\ \;\;\;\;\frac{y \cdot \left(-t\right)}{z}\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{-21}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{+85}:\\ \;\;\;\;\frac{-t}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 4
Error17.6
Cost1304
\[\begin{array}{l} t_1 := \frac{t}{\frac{z - y}{x}}\\ t_2 := \frac{t}{1 - \frac{z}{y}}\\ \mathbf{if}\;y \leq -1.56 \cdot 10^{+108}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -7 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.1 \cdot 10^{+20}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -7.2 \cdot 10^{-161}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-50}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+129}:\\ \;\;\;\;\frac{x - y}{\frac{y}{-t}}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{y}{y - z}\\ \end{array} \]
Alternative 5
Error23.2
Cost1240
\[\begin{array}{l} t_1 := x \cdot \frac{t}{z - y}\\ \mathbf{if}\;y \leq -1.56 \cdot 10^{+108}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -1 \cdot 10^{+62}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.85 \cdot 10^{+21}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-195}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-155}:\\ \;\;\;\;\frac{y \cdot \left(-t\right)}{z}\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{+102}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 6
Error17.4
Cost1240
\[\begin{array}{l} t_1 := t \cdot \frac{y}{y - z}\\ t_2 := \frac{t}{\frac{z}{x - y}}\\ \mathbf{if}\;z \leq -1.1 \cdot 10^{+85}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.95 \cdot 10^{+17}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{-6}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{-52}:\\ \;\;\;\;t - \frac{t}{\frac{y}{x}}\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{+48}:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+105}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error17.2
Cost1240
\[\begin{array}{l} t_1 := \frac{t}{\frac{z - y}{x}}\\ t_2 := \frac{t}{1 - \frac{z}{y}}\\ \mathbf{if}\;y \leq -1.56 \cdot 10^{+108}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -7 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.55 \cdot 10^{+20}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -2.7 \cdot 10^{-163}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-48}:\\ \;\;\;\;\frac{t}{\frac{z}{x - y}}\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{+142}:\\ \;\;\;\;t - \frac{t}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{y}{y - z}\\ \end{array} \]
Alternative 8
Error25.6
Cost1044
\[\begin{array}{l} t_1 := t \cdot \frac{-x}{y}\\ \mathbf{if}\;y \leq -1.86 \cdot 10^{+108}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -3.8 \cdot 10^{+90}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.6 \cdot 10^{+20}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 3.35 \cdot 10^{-21}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{elif}\;y \leq 2.65 \cdot 10^{+85}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 9
Error26.1
Cost1044
\[\begin{array}{l} \mathbf{if}\;y \leq -9.6 \cdot 10^{+134}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -3 \cdot 10^{+90}:\\ \;\;\;\;t \cdot \frac{-y}{z}\\ \mathbf{elif}\;y \leq -1.1 \cdot 10^{+21}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{-21}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{+85}:\\ \;\;\;\;t \cdot \frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 10
Error26.1
Cost1044
\[\begin{array}{l} \mathbf{if}\;y \leq -8.8 \cdot 10^{+134}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -3.9 \cdot 10^{+90}:\\ \;\;\;\;\frac{t}{\frac{z}{-y}}\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{+20}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{-22}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{+85}:\\ \;\;\;\;t \cdot \frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 11
Error26.1
Cost1044
\[\begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{+134}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -3.9 \cdot 10^{+90}:\\ \;\;\;\;\frac{t}{\frac{z}{-y}}\\ \mathbf{elif}\;y \leq -1 \cdot 10^{+21}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 3.35 \cdot 10^{-21}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{+85}:\\ \;\;\;\;\frac{-t}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 12
Error18.8
Cost976
\[\begin{array}{l} t_1 := x \cdot \frac{t}{z - y}\\ t_2 := t \cdot \frac{y}{y - z}\\ \mathbf{if}\;y \leq -3.5 \cdot 10^{+20}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-195}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-155}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{+102}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 13
Error18.8
Cost976
\[\begin{array}{l} t_1 := x \cdot \frac{t}{z - y}\\ t_2 := t \cdot \frac{y}{y - z}\\ \mathbf{if}\;y \leq -2.3 \cdot 10^{+20}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-195}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-155}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{+102}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 14
Error25.7
Cost848
\[\begin{array}{l} t_1 := t \cdot \frac{x}{z}\\ \mathbf{if}\;y \leq -2.55 \cdot 10^{+107}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -4.1 \cdot 10^{+62}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.25 \cdot 10^{+20}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{+54}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 15
Error25.7
Cost848
\[\begin{array}{l} t_1 := \frac{t}{\frac{z}{x}}\\ \mathbf{if}\;y \leq -2.55 \cdot 10^{+107}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -3.6 \cdot 10^{+62}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{+21}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+55}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 16
Error7.0
Cost840
\[\begin{array}{l} t_1 := t \cdot \frac{y}{y - z}\\ \mathbf{if}\;y \leq -2 \cdot 10^{+125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{+185}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 17
Error26.0
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{+20}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.12 \cdot 10^{+60}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 18
Error40.0
Cost64
\[t \]

Error

Reproduce

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