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

\mathbf{elif}\;y \leq 5 \cdot 10^{-285}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{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.3
Herbie2.3
\[\frac{t}{\frac{z - y}{x - y}} \]

Derivation

  1. Split input into 2 regimes
  2. if y < -3.00000000000000003e-28 or 5.00000000000000018e-285 < y

    1. Initial program 1.4

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

    if -3.00000000000000003e-28 < y < 5.00000000000000018e-285

    1. Initial program 5.0

      \[\frac{x - y}{z - y} \cdot t \]
    2. Simplified5.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))): 66 points increase in error, 73 points decrease in error
      (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 (-.f64 x y) (-.f64 z y)) t)): 35 points increase in error, 73 points decrease in error
  3. Recombined 2 regimes into one program.
  4. Final simplification2.3

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

Alternatives

Alternative 1
Error19.5
Cost976
\[\begin{array}{l} t_1 := \left(x - y\right) \cdot \frac{t}{z}\\ t_2 := t \cdot \frac{y - x}{y}\\ \mathbf{if}\;y \leq -4.2 \cdot 10^{-105}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{-139}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-102}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+18}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error16.8
Cost976
\[\begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{-41}:\\ \;\;\;\;t \cdot \frac{y}{y - z}\\ \mathbf{elif}\;y \leq 2.45 \cdot 10^{-287}:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{elif}\;y \leq 3.15 \cdot 10^{-80}:\\ \;\;\;\;t \cdot \frac{x}{z - y}\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+17}:\\ \;\;\;\;\frac{t}{\frac{z}{x - y}}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{y - x}{y}\\ \end{array} \]
Alternative 3
Error17.1
Cost976
\[\begin{array}{l} \mathbf{if}\;y \leq -3 \cdot 10^{-45}:\\ \;\;\;\;t \cdot \frac{y}{y - z}\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-282}:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{elif}\;y \leq 3 \cdot 10^{-80}:\\ \;\;\;\;t \cdot \frac{x}{z - y}\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{+21}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{y - x}{y}\\ \end{array} \]
Alternative 4
Error16.8
Cost844
\[\begin{array}{l} \mathbf{if}\;y \leq -5.3 \cdot 10^{-45}:\\ \;\;\;\;t \cdot \frac{y}{y - z}\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-287}:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{+42}:\\ \;\;\;\;t \cdot \frac{x}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{y - x}{y}\\ \end{array} \]
Alternative 5
Error7.2
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{+125}:\\ \;\;\;\;t \cdot \frac{y}{y - z}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{+135}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{-t}{\frac{y}{x - y}}\\ \end{array} \]
Alternative 6
Error25.7
Cost716
\[\begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{+62}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -9.5 \cdot 10^{-52}:\\ \;\;\;\;\frac{t}{z} \cdot \left(-y\right)\\ \mathbf{elif}\;y \leq 1.12 \cdot 10^{+18}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 7
Error20.6
Cost712
\[\begin{array}{l} t_1 := t \cdot \frac{y - x}{y}\\ \mathbf{if}\;y \leq -4.3 \cdot 10^{-105}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{-40}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error17.5
Cost712
\[\begin{array}{l} t_1 := t \cdot \frac{y - x}{y}\\ \mathbf{if}\;y \leq -0.025:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-38}:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error17.3
Cost712
\[\begin{array}{l} t_1 := t \cdot \frac{y - x}{y}\\ \mathbf{if}\;y \leq -33000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{+44}:\\ \;\;\;\;t \cdot \frac{x}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error38.1
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{-126}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-40}:\\ \;\;\;\;t \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 11
Error26.4
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -2.1 \cdot 10^{-28}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 4 \cdot 10^{-38}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 12
Error25.8
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -2.1 \cdot 10^{-28}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{+16}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 13
Error40.1
Cost64
\[t \]

Error

Reproduce

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