Average Error: 2.3 → 1.9
Time: 11.5s
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 -5 \cdot 10^{-69}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{-179}:\\ \;\;\;\;\frac{x - y}{\frac{z}{t}}\\ \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 -5e-69) t_2 (if (<= t_1 5e-179) (/ (- x y) (/ z t)) 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 <= -5e-69) {
		tmp = t_2;
	} else if (t_1 <= 5e-179) {
		tmp = (x - y) / (z / t);
	} 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 <= (-5d-69)) then
        tmp = t_2
    else if (t_1 <= 5d-179) then
        tmp = (x - y) / (z / t)
    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 <= -5e-69) {
		tmp = t_2;
	} else if (t_1 <= 5e-179) {
		tmp = (x - y) / (z / t);
	} 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 <= -5e-69:
		tmp = t_2
	elif t_1 <= 5e-179:
		tmp = (x - y) / (z / t)
	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 <= -5e-69)
		tmp = t_2;
	elseif (t_1 <= 5e-179)
		tmp = Float64(Float64(x - y) / Float64(z / t));
	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 <= -5e-69)
		tmp = t_2;
	elseif (t_1 <= 5e-179)
		tmp = (x - y) / (z / t);
	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, -5e-69], t$95$2, If[LessEqual[t$95$1, 5e-179], N[(N[(x - y), $MachinePrecision] / N[(z / t), $MachinePrecision]), $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 -5 \cdot 10^{-69}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-179}:\\
\;\;\;\;\frac{x - y}{\frac{z}{t}}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 x y) (-.f64 z y)) < -5.00000000000000033e-69 or 4.9999999999999998e-179 < (/.f64 (-.f64 x y) (-.f64 z y))

    1. Initial program 1.6

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

    if -5.00000000000000033e-69 < (/.f64 (-.f64 x y) (-.f64 z y)) < 4.9999999999999998e-179

    1. Initial program 5.1

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

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

      \[\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)))): 0 points increase in error, 0 points decrease in error
      (-.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 x t) (-.f64 z y))) (/.f64 y (/.f64 (-.f64 z y) t))): 28 points increase in error, 28 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)))): 28 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
    4. Taylor expanded in z around inf 3.2

      \[\leadsto \frac{x - y}{\color{blue}{\frac{z}{t}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.9

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

Alternatives

Alternative 1
Error16.9
Cost1040
\[\begin{array}{l} t_1 := \frac{-t}{\frac{z}{y} + -1}\\ \mathbf{if}\;y \leq -1.9665455536500962 \cdot 10^{+58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.4907080149248054 \cdot 10^{-112}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;y \leq 1.4091167942023565 \cdot 10^{-70}:\\ \;\;\;\;t - x \cdot \frac{t}{y}\\ \mathbf{elif}\;y \leq 8.544618162396167 \cdot 10^{-27}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error16.9
Cost1040
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9665455536500962 \cdot 10^{+58}:\\ \;\;\;\;\frac{-t}{\frac{z}{y} + -1}\\ \mathbf{elif}\;y \leq 1.4907080149248054 \cdot 10^{-112}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;y \leq 1.4091167942023565 \cdot 10^{-70}:\\ \;\;\;\;t - x \cdot \frac{t}{y}\\ \mathbf{elif}\;y \leq 8.544618162396167 \cdot 10^{-27}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{-y}{z - y}\\ \end{array} \]
Alternative 3
Error22.3
Cost976
\[\begin{array}{l} t_1 := t - x \cdot \frac{t}{y}\\ \mathbf{if}\;y \leq -3.951910519723787 \cdot 10^{+40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.4907080149248054 \cdot 10^{-112}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 1.4091167942023565 \cdot 10^{-70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8.544618162396167 \cdot 10^{-27}:\\ \;\;\;\;\frac{t \cdot \left(-y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error19.6
Cost976
\[\begin{array}{l} t_1 := \frac{x - y}{\frac{z}{t}}\\ t_2 := t - x \cdot \frac{t}{y}\\ \mathbf{if}\;y \leq -1.3999240943638444 \cdot 10^{+64}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.4907080149248054 \cdot 10^{-112}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.4091167942023565 \cdot 10^{-70}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 8.544618162396167 \cdot 10^{-27}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error19.1
Cost976
\[\begin{array}{l} t_1 := t - x \cdot \frac{t}{y}\\ \mathbf{if}\;y \leq -1.3999240943638444 \cdot 10^{+64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.4907080149248054 \cdot 10^{-112}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;y \leq 1.4091167942023565 \cdot 10^{-70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8.544618162396167 \cdot 10^{-27}:\\ \;\;\;\;\frac{x - y}{\frac{z}{t}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error18.3
Cost976
\[\begin{array}{l} t_1 := t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{if}\;y \leq -1.3999240943638444 \cdot 10^{+64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.4907080149248054 \cdot 10^{-112}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;y \leq 1.4091167942023565 \cdot 10^{-70}:\\ \;\;\;\;t - x \cdot \frac{t}{y}\\ \mathbf{elif}\;y \leq 8.544618162396167 \cdot 10^{-27}:\\ \;\;\;\;\frac{x - y}{\frac{z}{t}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error18.3
Cost976
\[\begin{array}{l} t_1 := t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{if}\;y \leq -1.3999240943638444 \cdot 10^{+64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.4907080149248054 \cdot 10^{-112}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;y \leq 1.4091167942023565 \cdot 10^{-70}:\\ \;\;\;\;t - x \cdot \frac{t}{y}\\ \mathbf{elif}\;y \leq 8.544618162396167 \cdot 10^{-27}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error26.3
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9665455536500962 \cdot 10^{+58}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.4907080149248054 \cdot 10^{-112}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 1.4091167942023565 \cdot 10^{-70}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 8.544618162396167 \cdot 10^{-27}:\\ \;\;\;\;\left(-t\right) \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 9
Error26.3
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9665455536500962 \cdot 10^{+58}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.4907080149248054 \cdot 10^{-112}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 1.4091167942023565 \cdot 10^{-70}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 8.544618162396167 \cdot 10^{-27}:\\ \;\;\;\;\frac{t \cdot \left(-y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 10
Error7.3
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -2.0213621790732382 \cdot 10^{+114}:\\ \;\;\;\;\frac{-t}{\frac{z}{y} + -1}\\ \mathbf{elif}\;y \leq 1.3245532083494473 \cdot 10^{+110}:\\ \;\;\;\;\frac{x - y}{\frac{z - y}{t}}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \end{array} \]
Alternative 11
Error7.1
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -2.0213621790732382 \cdot 10^{+114}:\\ \;\;\;\;\frac{-t}{\frac{z}{y} + -1}\\ \mathbf{elif}\;y \leq 1.3245532083494473 \cdot 10^{+110}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \end{array} \]
Alternative 12
Error37.6
Cost584
\[\begin{array}{l} t_1 := \frac{y}{\frac{z}{t}}\\ \mathbf{if}\;z \leq -2.0991322973598582 \cdot 10^{+167}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.3571282871967747 \cdot 10^{+178}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error37.6
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -2.0991322973598582 \cdot 10^{+167}:\\ \;\;\;\;t \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 1.3571282871967747 \cdot 10^{+178}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{t}}\\ \end{array} \]
Alternative 14
Error27.0
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -6.927453959493339 \cdot 10^{+45}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.2327130281375111 \cdot 10^{-105}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 15
Error27.0
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -6.927453959493339 \cdot 10^{+45}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.2327130281375111 \cdot 10^{-105}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 16
Error26.5
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9665455536500962 \cdot 10^{+58}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.4907080149248054 \cdot 10^{-112}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 17
Error39.6
Cost64
\[t \]

Error

Reproduce

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