Average Error: 2.1 → 1.6
Time: 4.8s
Precision: binary64
\[\frac{x}{y} \cdot \left(z - t\right) + t \]
\[\begin{array}{l} t_1 := t + \frac{z - t}{\frac{y}{x}}\\ \mathbf{if}\;\frac{x}{y} \leq -5.822884373689189 \cdot 10^{-101}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 2.63608031016327 \cdot 10^{-310}:\\ \;\;\;\;t + \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ (* (/ x y) (- z t)) t))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ t (/ (- z t) (/ y x)))))
   (if (<= (/ x y) -5.822884373689189e-101)
     t_1
     (if (<= (/ x y) 2.63608031016327e-310) (+ t (/ (* x z) y)) t_1))))
double code(double x, double y, double z, double t) {
	return ((x / y) * (z - t)) + t;
}
double code(double x, double y, double z, double t) {
	double t_1 = t + ((z - t) / (y / x));
	double tmp;
	if ((x / y) <= -5.822884373689189e-101) {
		tmp = t_1;
	} else if ((x / y) <= 2.63608031016327e-310) {
		tmp = t + ((x * 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 - t)) + 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 = t + ((z - t) / (y / x))
    if ((x / y) <= (-5.822884373689189d-101)) then
        tmp = t_1
    else if ((x / y) <= 2.63608031016327d-310) then
        tmp = t + ((x * 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 - t)) + t;
}
public static double code(double x, double y, double z, double t) {
	double t_1 = t + ((z - t) / (y / x));
	double tmp;
	if ((x / y) <= -5.822884373689189e-101) {
		tmp = t_1;
	} else if ((x / y) <= 2.63608031016327e-310) {
		tmp = t + ((x * z) / y);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	return ((x / y) * (z - t)) + t
def code(x, y, z, t):
	t_1 = t + ((z - t) / (y / x))
	tmp = 0
	if (x / y) <= -5.822884373689189e-101:
		tmp = t_1
	elif (x / y) <= 2.63608031016327e-310:
		tmp = t + ((x * z) / y)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	return Float64(Float64(Float64(x / y) * Float64(z - t)) + t)
end
function code(x, y, z, t)
	t_1 = Float64(t + Float64(Float64(z - t) / Float64(y / x)))
	tmp = 0.0
	if (Float64(x / y) <= -5.822884373689189e-101)
		tmp = t_1;
	elseif (Float64(x / y) <= 2.63608031016327e-310)
		tmp = Float64(t + Float64(Float64(x * z) / y));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = ((x / y) * (z - t)) + t;
end
function tmp_2 = code(x, y, z, t)
	t_1 = t + ((z - t) / (y / x));
	tmp = 0.0;
	if ((x / y) <= -5.822884373689189e-101)
		tmp = t_1;
	elseif ((x / y) <= 2.63608031016327e-310)
		tmp = t + ((x * z) / y);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t + N[(N[(z - t), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -5.822884373689189e-101], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 2.63608031016327e-310], N[(t + N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\frac{x}{y} \cdot \left(z - t\right) + t
\begin{array}{l}
t_1 := t + \frac{z - t}{\frac{y}{x}}\\
\mathbf{if}\;\frac{x}{y} \leq -5.822884373689189 \cdot 10^{-101}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\frac{x}{y} \leq 2.63608031016327 \cdot 10^{-310}:\\
\;\;\;\;t + \frac{x \cdot z}{y}\\

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


\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.4
Herbie1.6
\[\begin{array}{l} \mathbf{if}\;z < 2.759456554562692 \cdot 10^{-282}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \mathbf{elif}\;z < 2.326994450874436 \cdot 10^{-110}:\\ \;\;\;\;x \cdot \frac{z - t}{y} + t\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if (/.f64 x y) < -5.8228843736891887e-101 or 2.63608031016327e-310 < (/.f64 x y)

    1. Initial program 2.1

      \[\frac{x}{y} \cdot \left(z - t\right) + t \]
    2. Applied egg-rr1.9

      \[\leadsto \color{blue}{\frac{z - t}{\frac{y}{x}}} + t \]

    if -5.8228843736891887e-101 < (/.f64 x y) < 2.63608031016327e-310

    1. Initial program 2.2

      \[\frac{x}{y} \cdot \left(z - t\right) + t \]
    2. Taylor expanded in z around inf 0.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -5.822884373689189 \cdot 10^{-101}:\\ \;\;\;\;t + \frac{z - t}{\frac{y}{x}}\\ \mathbf{elif}\;\frac{x}{y} \leq 2.63608031016327 \cdot 10^{-310}:\\ \;\;\;\;t + \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;t + \frac{z - t}{\frac{y}{x}}\\ \end{array} \]

Reproduce

herbie shell --seed 2022153 
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
  :precision binary64

  :herbie-target
  (if (< z 2.759456554562692e-282) (+ (* (/ x y) (- z t)) t) (if (< z 2.326994450874436e-110) (+ (* x (/ (- z t) y)) t) (+ (* (/ x y) (- z t)) t)))

  (+ (* (/ x y) (- z t)) t))