Average Error: 24.3 → 6.2
Time: 35.1s
Precision: binary64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \]
\[\begin{array}{l} t_1 := x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\ t_2 := \mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_3 := \left(\frac{x \cdot z}{a - z} + \left(x + \frac{y \cdot t}{a - z}\right)\right) - \left(\frac{x \cdot y}{a - z} + \frac{z \cdot t}{a - z}\right)\\ \mathbf{if}\;t_1 \leq -1.6488828562436782 \cdot 10^{-298}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\left(\frac{x \cdot y}{z} + \left(t + \frac{t \cdot a}{z}\right)\right) - \left(\frac{y \cdot t}{z} + \frac{x \cdot a}{z}\right)\\ \mathbf{elif}\;t_1 \leq 2.8498496972131763 \cdot 10^{+278}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array}\\ \end{array} \]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
t_1 := x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\
t_2 := \mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := \left(\frac{x \cdot z}{a - z} + \left(x + \frac{y \cdot t}{a - z}\right)\right) - \left(\frac{x \cdot y}{a - z} + \frac{z \cdot t}{a - z}\right)\\
\mathbf{if}\;t_1 \leq -1.6488828562436782 \cdot 10^{-298}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\left(\frac{x \cdot y}{z} + \left(t + \frac{t \cdot a}{z}\right)\right) - \left(\frac{y \cdot t}{z} + \frac{x \cdot a}{z}\right)\\

\mathbf{elif}\;t_1 \leq 2.8498496972131763 \cdot 10^{+278}:\\
\;\;\;\;t_3\\

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


\end{array}\\


\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
 (let* ((t_1 (+ x (/ (* (- y z) (- t x)) (- a z))))
        (t_2 (fma (- y z) (/ (- t x) (- a z)) x)))
   (if (<= t_1 (- INFINITY))
     t_2
     (let* ((t_3
             (-
              (+ (/ (* x z) (- a z)) (+ x (/ (* y t) (- a z))))
              (+ (/ (* x y) (- a z)) (/ (* z t) (- a z))))))
       (if (<= t_1 -1.6488828562436782e-298)
         t_3
         (if (<= t_1 0.0)
           (-
            (+ (/ (* x y) z) (+ t (/ (* t a) z)))
            (+ (/ (* y t) z) (/ (* x a) z)))
           (if (<= t_1 2.8498496972131763e+278) t_3 t_2)))))))
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 t_1 = x + (((y - z) * (t - x)) / (a - z));
	double t_2 = fma((y - z), ((t - x) / (a - z)), x);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = t_2;
	} else {
		double t_3 = (((x * z) / (a - z)) + (x + ((y * t) / (a - z)))) - (((x * y) / (a - z)) + ((z * t) / (a - z)));
		double tmp_1;
		if (t_1 <= -1.6488828562436782e-298) {
			tmp_1 = t_3;
		} else if (t_1 <= 0.0) {
			tmp_1 = (((x * y) / z) + (t + ((t * a) / z))) - (((y * t) / z) + ((x * a) / z));
		} else if (t_1 <= 2.8498496972131763e+278) {
			tmp_1 = t_3;
		} else {
			tmp_1 = t_2;
		}
		tmp = tmp_1;
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.3
Target12.0
Herbie6.2
\[\begin{array}{l} \mathbf{if}\;z < -1.2536131056095036 \cdot 10^{+188}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{elif}\;z < 4.446702369113811 \cdot 10^{+64}:\\ \;\;\;\;x + \frac{y - z}{\frac{a - z}{t - x}}\\ \mathbf{else}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -inf.0 or 2.84984969721317632e278 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z)))

    1. Initial program 61.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)} \]
    3. Applied add-cube-cbrt_binary6418.0

      \[\leadsto \color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)} \cdot \sqrt[3]{\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)}} \]
    4. Applied pow1/3_binary6440.7

      \[\leadsto \left(\sqrt[3]{\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)} \cdot \sqrt[3]{\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)}\right) \cdot \color{blue}{{\left(\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\right)}^{0.3333333333333333}} \]
    5. Applied pow1/3_binary6441.1

      \[\leadsto \left(\sqrt[3]{\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)} \cdot \color{blue}{{\left(\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\right)}^{0.3333333333333333}}\right) \cdot {\left(\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\right)}^{0.3333333333333333} \]
    6. Applied pow1/3_binary6441.3

      \[\leadsto \left(\color{blue}{{\left(\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\right)}^{0.3333333333333333}} \cdot {\left(\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\right)}^{0.3333333333333333}\right) \cdot {\left(\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\right)}^{0.3333333333333333} \]
    7. Applied pow-sqr_binary6441.3

      \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\right)}^{\left(2 \cdot 0.3333333333333333\right)}} \cdot {\left(\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\right)}^{0.3333333333333333} \]
    8. Applied pow-prod-up_binary6417.2

      \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\right)}^{\left(2 \cdot 0.3333333333333333 + 0.3333333333333333\right)}} \]

    if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -1.6488828562436782e-298 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 2.84984969721317632e278

    1. Initial program 2.1

      \[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \]
    2. Simplified7.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)} \]
    3. Taylor expanded in y around 0 1.7

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

    if -1.6488828562436782e-298 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 0.0

    1. Initial program 60.5

      \[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \]
    2. Simplified60.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)} \]
    3. Taylor expanded in z around inf 1.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq -\infty:\\ \;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq -1.6488828562436782 \cdot 10^{-298}:\\ \;\;\;\;\left(\frac{x \cdot z}{a - z} + \left(x + \frac{y \cdot t}{a - z}\right)\right) - \left(\frac{x \cdot y}{a - z} + \frac{z \cdot t}{a - z}\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq 0:\\ \;\;\;\;\left(\frac{x \cdot y}{z} + \left(t + \frac{t \cdot a}{z}\right)\right) - \left(\frac{y \cdot t}{z} + \frac{x \cdot a}{z}\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq 2.8498496972131763 \cdot 10^{+278}:\\ \;\;\;\;\left(\frac{x \cdot z}{a - z} + \left(x + \frac{y \cdot t}{a - z}\right)\right) - \left(\frac{x \cdot y}{a - z} + \frac{z \cdot t}{a - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022117 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (if (< z -1.2536131056095036e+188) (- t (* (/ y z) (- t x))) (if (< z 4.446702369113811e+64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))

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