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

\mathbf{elif}\;x \leq 1.5069737614011972 \cdot 10^{-298}:\\
\;\;\;\;x + \left(\frac{y}{t} - \frac{x}{t}\right) \cdot z\\

\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.3
Target2.4
Herbie2.4
\[\begin{array}{l} \mathbf{if}\;\left(y - x\right) \cdot \frac{z}{t} < -1013646692435.8867:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{elif}\;\left(y - x\right) \cdot \frac{z}{t} < 0:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if x < -1.53495703455770257e-128 or 1.50697376140119718e-298 < x

    1. Initial program 1.6

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

    if -1.53495703455770257e-128 < x < 1.50697376140119718e-298

    1. Initial program 5.3

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

      \[\leadsto x + \color{blue}{\left(\frac{y \cdot z}{t} - \frac{z \cdot x}{t}\right)} \]
    3. Taylor expanded in z around 0 5.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5349570345577026 \cdot 10^{-128}:\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq 1.5069737614011972 \cdot 10^{-298}:\\ \;\;\;\;x + \left(\frac{y}{t} - \frac{x}{t}\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \end{array} \]

Reproduce

herbie shell --seed 2022152 
(FPCore (x y z t)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:tickPosition from plot-0.2.3.4"
  :precision binary64

  :herbie-target
  (if (< (* (- y x) (/ z t)) -1013646692435.8867) (+ x (/ (- y x) (/ t z))) (if (< (* (- y x) (/ z t)) 0.0) (+ x (/ (* (- y x) z) t)) (+ x (/ (- y x) (/ t z)))))

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