Average Error: 2.1 → 1.5
Time: 3.5s
Precision: binary64
\[\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 -8.451637872316771 \cdot 10^{-106}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 1.418303538573969 \cdot 10^{-267}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z - y}\\ \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 -8.451637872316771e-106)
     t_2
     (if (<= t_1 1.418303538573969e-267) (/ (* (- x y) t) (- z y)) 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 <= -8.451637872316771e-106) {
		tmp = t_2;
	} else if (t_1 <= 1.418303538573969e-267) {
		tmp = ((x - y) * t) / (z - y);
	} 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 <= (-8.451637872316771d-106)) then
        tmp = t_2
    else if (t_1 <= 1.418303538573969d-267) then
        tmp = ((x - y) * t) / (z - y)
    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 <= -8.451637872316771e-106) {
		tmp = t_2;
	} else if (t_1 <= 1.418303538573969e-267) {
		tmp = ((x - y) * t) / (z - y);
	} 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 <= -8.451637872316771e-106:
		tmp = t_2
	elif t_1 <= 1.418303538573969e-267:
		tmp = ((x - y) * t) / (z - y)
	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 <= -8.451637872316771e-106)
		tmp = t_2;
	elseif (t_1 <= 1.418303538573969e-267)
		tmp = Float64(Float64(Float64(x - y) * t) / Float64(z - y));
	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 <= -8.451637872316771e-106)
		tmp = t_2;
	elseif (t_1 <= 1.418303538573969e-267)
		tmp = ((x - y) * t) / (z - y);
	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, -8.451637872316771e-106], t$95$2, If[LessEqual[t$95$1, 1.418303538573969e-267], N[(N[(N[(x - y), $MachinePrecision] * t), $MachinePrecision] / N[(z - y), $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 -8.451637872316771 \cdot 10^{-106}:\\
\;\;\;\;t_2\\

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

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


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 x y) (-.f64 z y)) < -8.45163787231677142e-106 or 1.418303538573969e-267 < (/.f64 (-.f64 x y) (-.f64 z y))

    1. Initial program 1.3

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

    if -8.45163787231677142e-106 < (/.f64 (-.f64 x y) (-.f64 z y)) < 1.418303538573969e-267

    1. Initial program 7.1

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

      \[\leadsto \color{blue}{\frac{t \cdot \left(x - y\right)}{z - y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.5

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

Reproduce

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