Average Error: 14.5 → 5.6
Time: 10.1s
Precision: binary64
\[x + \left(y - z\right) \cdot \frac{t - x}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;x + \left(y - z\right) \cdot \frac{t - x}{a - z} \leq -2.4909642387543203 \cdot 10^{-274}:\\ \;\;\;\;x + \frac{t - x}{\frac{a - z}{y - z}}\\ \mathbf{elif}\;x + \left(y - z\right) \cdot \frac{t - x}{a - z} \leq 9.958656639636994 \cdot 10^{-250}:\\ \;\;\;\;\left(t + \left(\frac{x \cdot y}{z} + \frac{t \cdot a}{z}\right)\right) - \left(\frac{x \cdot a}{z} + \frac{y \cdot t}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(t - x\right) \cdot \frac{y - z}{a - z}\\ \end{array}\]
x + \left(y - z\right) \cdot \frac{t - x}{a - z}
\begin{array}{l}
\mathbf{if}\;x + \left(y - z\right) \cdot \frac{t - x}{a - z} \leq -2.4909642387543203 \cdot 10^{-274}:\\
\;\;\;\;x + \frac{t - x}{\frac{a - z}{y - z}}\\

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

\mathbf{else}:\\
\;\;\;\;x + \left(t - x\right) \cdot \frac{y - z}{a - z}\\

\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (* (- y z) (/ (- t x) (- a z)))))
(FPCore (x y z t a)
 :precision binary64
 (if (<= (+ x (* (- y z) (/ (- t x) (- a z)))) -2.4909642387543203e-274)
   (+ x (/ (- t x) (/ (- a z) (- y z))))
   (if (<= (+ x (* (- y z) (/ (- t x) (- a z)))) 9.958656639636994e-250)
     (- (+ t (+ (/ (* x y) z) (/ (* t a) z))) (+ (/ (* x a) z) (/ (* y t) z)))
     (+ x (* (- t x) (/ (- y z) (- a z)))))))
double code(double x, double y, double z, double t, double a) {
	return x + ((y - z) * ((t - x) / (a - z)));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((x + ((y - z) * ((t - x) / (a - z)))) <= -2.4909642387543203e-274) {
		tmp = x + ((t - x) / ((a - z) / (y - z)));
	} else if ((x + ((y - z) * ((t - x) / (a - z)))) <= 9.958656639636994e-250) {
		tmp = (t + (((x * y) / z) + ((t * a) / z))) - (((x * a) / z) + ((y * t) / z));
	} else {
		tmp = x + ((t - x) * ((y - z) / (a - z)));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -2.4909642387543203e-274

    1. Initial program 6.8

      \[x + \left(y - z\right) \cdot \frac{t - x}{a - z}\]
    2. Using strategy rm
    3. Applied associate-*r/_binary6419.4

      \[\leadsto x + \color{blue}{\frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}}\]
    4. Simplified19.4

      \[\leadsto x + \frac{\color{blue}{\left(t - x\right) \cdot \left(y - z\right)}}{a - z}\]
    5. Using strategy rm
    6. Applied associate-/l*_binary644.2

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

    if -2.4909642387543203e-274 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 9.9586566396369937e-250

    1. Initial program 58.9

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

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

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

    if 9.9586566396369937e-250 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z))))

    1. Initial program 5.9

      \[x + \left(y - z\right) \cdot \frac{t - x}{a - z}\]
    2. Using strategy rm
    3. Applied div-inv_binary646.0

      \[\leadsto x + \left(y - z\right) \cdot \color{blue}{\left(\left(t - x\right) \cdot \frac{1}{a - z}\right)}\]
    4. Applied associate-*r*_binary6419.8

      \[\leadsto x + \color{blue}{\left(\left(y - z\right) \cdot \left(t - x\right)\right) \cdot \frac{1}{a - z}}\]
    5. Simplified19.8

      \[\leadsto x + \color{blue}{\left(\left(t - x\right) \cdot \left(y - z\right)\right)} \cdot \frac{1}{a - z}\]
    6. Using strategy rm
    7. Applied associate-*l*_binary643.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \left(y - z\right) \cdot \frac{t - x}{a - z} \leq -2.4909642387543203 \cdot 10^{-274}:\\ \;\;\;\;x + \frac{t - x}{\frac{a - z}{y - z}}\\ \mathbf{elif}\;x + \left(y - z\right) \cdot \frac{t - x}{a - z} \leq 9.958656639636994 \cdot 10^{-250}:\\ \;\;\;\;\left(t + \left(\frac{x \cdot y}{z} + \frac{t \cdot a}{z}\right)\right) - \left(\frac{x \cdot a}{z} + \frac{y \cdot t}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(t - x\right) \cdot \frac{y - z}{a - z}\\ \end{array}\]

Alternatives

Reproduce

herbie shell --seed 2021118 
(FPCore (x y z t a)
  :name "Numeric.Signal:interpolate   from hsignal-0.2.7.1"
  :precision binary64
  (+ x (* (- y z) (/ (- t x) (- a z)))))