Average Error: 2.1 → 2.1
Time: 15.2s
Precision: binary64
Cost: 832
\[\frac{x - y}{z - y} \cdot t \]
\[\left(\frac{x}{z - y} - \frac{y}{z - y}\right) \cdot t \]
(FPCore (x y z t) :precision binary64 (* (/ (- x y) (- z y)) t))
(FPCore (x y z t) :precision binary64 (* (- (/ x (- z y)) (/ 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) {
	return ((x / (z - y)) - (y / (z - y))) * t;
}
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
    code = ((x / (z - y)) - (y / (z - y))) * t
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) {
	return ((x / (z - y)) - (y / (z - y))) * t;
}
def code(x, y, z, t):
	return ((x - y) / (z - y)) * t
def code(x, y, z, t):
	return ((x / (z - y)) - (y / (z - y))) * t
function code(x, y, z, t)
	return Float64(Float64(Float64(x - y) / Float64(z - y)) * t)
end
function code(x, y, z, t)
	return Float64(Float64(Float64(x / Float64(z - y)) - Float64(y / Float64(z - y))) * t)
end
function tmp = code(x, y, z, t)
	tmp = ((x - y) / (z - y)) * t;
end
function tmp = code(x, y, z, t)
	tmp = ((x / (z - y)) - (y / (z - y))) * t;
end
code[x_, y_, z_, t_] := N[(N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\frac{x - y}{z - y} \cdot t
\left(\frac{x}{z - y} - \frac{y}{z - y}\right) \cdot t

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 2.1

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

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

    \[\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
  4. Final simplification2.1

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

Alternatives

Alternative 1
Error17.4
Cost1372
\[\begin{array}{l} t_1 := \frac{x \cdot t}{z - y}\\ t_2 := \frac{t}{1 - \frac{z}{y}}\\ \mathbf{if}\;y \leq -528656.50836667:\\ \;\;\;\;t - t \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-220}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-211}:\\ \;\;\;\;\frac{t}{\frac{z}{x - y}}\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6.1 \cdot 10^{-86}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2.2106170112505563 \cdot 10^{-39}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;y \leq 1.5501571577518913 \cdot 10^{+40}:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error22.5
Cost1240
\[\begin{array}{l} t_1 := \frac{t}{1 - \frac{z}{y}}\\ t_2 := t - \frac{t}{\frac{y}{x}}\\ \mathbf{if}\;x \leq -864703.6015258852:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.5171712718939628 \cdot 10^{-28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.0545156011738281 \cdot 10^{+71}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{elif}\;x \leq 4.6022571870485146 \cdot 10^{+91}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 10^{+230}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 10^{+284}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error22.5
Cost1240
\[\begin{array}{l} t_1 := \frac{t}{1 - \frac{z}{y}}\\ t_2 := t - t \cdot \frac{x}{y}\\ \mathbf{if}\;x \leq -864703.6015258852:\\ \;\;\;\;t - \frac{t}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq 1.5171712718939628 \cdot 10^{-28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.0545156011738281 \cdot 10^{+71}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{elif}\;x \leq 4.6022571870485146 \cdot 10^{+91}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 10^{+230}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 10^{+284}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error19.4
Cost1240
\[\begin{array}{l} t_1 := x \cdot \frac{t}{z - y}\\ \mathbf{if}\;x \leq -1 \cdot 10^{+180}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1 \cdot 10^{+134}:\\ \;\;\;\;t - \frac{t}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq -1.7546384515413547 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.5171712718939628 \cdot 10^{-28}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \mathbf{elif}\;x \leq 1.0545156011738281 \cdot 10^{+71}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 10^{+190}:\\ \;\;\;\;t - t \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error19.2
Cost976
\[\begin{array}{l} t_1 := \frac{x - y}{\frac{z}{t}}\\ \mathbf{if}\;y \leq -528656.50836667:\\ \;\;\;\;t - t \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq -5.524026512589545 \cdot 10^{-28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-150}:\\ \;\;\;\;t - \frac{x \cdot t}{y}\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-148}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \end{array} \]
Alternative 6
Error17.7
Cost976
\[\begin{array}{l} \mathbf{if}\;y \leq -528656.50836667:\\ \;\;\;\;t - t \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq -5.524026512589545 \cdot 10^{-28}:\\ \;\;\;\;\frac{x - y}{\frac{z}{t}}\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-80}:\\ \;\;\;\;t - \frac{x \cdot t}{y}\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-148}:\\ \;\;\;\;\frac{t}{\frac{z}{x - y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \end{array} \]
Alternative 7
Error16.5
Cost976
\[\begin{array}{l} \mathbf{if}\;y \leq -528656.50836667:\\ \;\;\;\;t - t \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq -5.524026512589545 \cdot 10^{-28}:\\ \;\;\;\;\frac{x - y}{\frac{z}{t}}\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-80}:\\ \;\;\;\;t - \frac{x \cdot t}{y}\\ \mathbf{elif}\;y \leq 2.2106170112505563 \cdot 10^{-39}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \end{array} \]
Alternative 8
Error17.0
Cost976
\[\begin{array}{l} \mathbf{if}\;y \leq -528656.50836667:\\ \;\;\;\;t - t \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-110}:\\ \;\;\;\;\frac{t \cdot \left(x - y\right)}{z}\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-150}:\\ \;\;\;\;t - \frac{x \cdot t}{y}\\ \mathbf{elif}\;y \leq 2.2106170112505563 \cdot 10^{-39}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \end{array} \]
Alternative 9
Error20.3
Cost844
\[\begin{array}{l} t_1 := \frac{t}{1 - \frac{z}{y}}\\ \mathbf{if}\;y \leq -5.003889687346537 \cdot 10^{+89}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-150}:\\ \;\;\;\;t - \frac{x \cdot t}{y}\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-148}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error23.1
Cost712
\[\begin{array}{l} t_1 := t - \frac{x \cdot t}{y}\\ \mathbf{if}\;y \leq -1 \cdot 10^{-150}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-72}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error37.1
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.25 \cdot 10^{-146}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{-72}:\\ \;\;\;\;\frac{y \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 12
Error25.4
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -15499320245395444:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 6.82623852688651 \cdot 10^{-14}:\\ \;\;\;\;\frac{x \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 13
Error25.7
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -15499320245395444:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{-72}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 14
Error24.5
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -15499320245395444:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 6.82623852688651 \cdot 10^{-14}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 15
Error24.6
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -15499320245395444:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 6.82623852688651 \cdot 10^{-14}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 16
Error2.0
Cost576
\[\frac{t}{\frac{z - y}{x - y}} \]
Alternative 17
Error2.1
Cost576
\[t \cdot \frac{x - y}{z - y} \]
Alternative 18
Error39.3
Cost64
\[t \]

Error

Reproduce

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