Average Error: 25.1 → 7.1
Time: 11.8s
Precision: binary64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \]
\[\begin{array}{l} t_1 := \sqrt[3]{y - z}\\ t_2 := t_1 \cdot t_1\\ t_3 := \sqrt[3]{a - z}\\ t_4 := t_3 \cdot t_3\\ t_5 := x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\ \mathbf{if}\;t_5 \leq -8.939814919119468 \cdot 10^{-296}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t_2}{t_4}, \frac{t_1}{\frac{t_3}{t - x}}, x\right)\\ \mathbf{elif}\;t_5 \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{else}:\\ \;\;\;\;\begin{array}{l} t_6 := \sqrt[3]{t - x}\\ \mathsf{fma}\left(\frac{t_2}{\frac{t_4}{t_6 \cdot t_6}}, \frac{t_1}{\frac{t_3}{t_6}}, x\right) \end{array}\\ \end{array} \]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
t_1 := \sqrt[3]{y - z}\\
t_2 := t_1 \cdot t_1\\
t_3 := \sqrt[3]{a - z}\\
t_4 := t_3 \cdot t_3\\
t_5 := x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\
\mathbf{if}\;t_5 \leq -8.939814919119468 \cdot 10^{-296}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t_2}{t_4}, \frac{t_1}{\frac{t_3}{t - x}}, x\right)\\

\mathbf{elif}\;t_5 \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{else}:\\
\;\;\;\;\begin{array}{l}
t_6 := \sqrt[3]{t - x}\\
\mathsf{fma}\left(\frac{t_2}{\frac{t_4}{t_6 \cdot t_6}}, \frac{t_1}{\frac{t_3}{t_6}}, x\right)
\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 (cbrt (- y z)))
        (t_2 (* t_1 t_1))
        (t_3 (cbrt (- a z)))
        (t_4 (* t_3 t_3))
        (t_5 (+ x (/ (* (- y z) (- t x)) (- a z)))))
   (if (<= t_5 -8.939814919119468e-296)
     (fma (/ t_2 t_4) (/ t_1 (/ t_3 (- t x))) x)
     (if (<= t_5 0.0)
       (-
        (+ (/ (* x y) z) (+ t (/ (* t a) z)))
        (+ (/ (* y t) z) (/ (* x a) z)))
       (let* ((t_6 (cbrt (- t x))))
         (fma (/ t_2 (/ t_4 (* t_6 t_6))) (/ t_1 (/ t_3 t_6)) x))))))
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 = cbrt(y - z);
	double t_2 = t_1 * t_1;
	double t_3 = cbrt(a - z);
	double t_4 = t_3 * t_3;
	double t_5 = x + (((y - z) * (t - x)) / (a - z));
	double tmp;
	if (t_5 <= -8.939814919119468e-296) {
		tmp = fma((t_2 / t_4), (t_1 / (t_3 / (t - x))), x);
	} else if (t_5 <= 0.0) {
		tmp = (((x * y) / z) + (t + ((t * a) / z))) - (((y * t) / z) + ((x * a) / z));
	} else {
		double t_6 = cbrt(t - x);
		tmp = fma((t_2 / (t_4 / (t_6 * t_6))), (t_1 / (t_3 / t_6)), x);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original25.1
Target11.8
Herbie7.1
\[\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))) < -8.9398149191194679e-296

    1. Initial program 21.7

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)} \]
    3. Applied clear-num_binary6410.6

      \[\leadsto \mathsf{fma}\left(y - z, \color{blue}{\frac{1}{\frac{a - z}{t - x}}}, x\right) \]
    4. Applied fma-udef_binary6410.6

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

      \[\leadsto \color{blue}{\frac{y - z}{\frac{a - z}{t - x}}} + x \]
    6. Applied *-un-lft-identity_binary6410.3

      \[\leadsto \frac{y - z}{\frac{a - z}{\color{blue}{1 \cdot \left(t - x\right)}}} + x \]
    7. Applied add-cube-cbrt_binary6410.9

      \[\leadsto \frac{y - z}{\frac{\color{blue}{\left(\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}\right) \cdot \sqrt[3]{a - z}}}{1 \cdot \left(t - x\right)}} + x \]
    8. Applied times-frac_binary6410.9

      \[\leadsto \frac{y - z}{\color{blue}{\frac{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}{1} \cdot \frac{\sqrt[3]{a - z}}{t - x}}} + x \]
    9. Applied add-cube-cbrt_binary6410.9

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{y - z} \cdot \sqrt[3]{y - z}\right) \cdot \sqrt[3]{y - z}}}{\frac{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}{1} \cdot \frac{\sqrt[3]{a - z}}{t - x}} + x \]
    10. Applied times-frac_binary647.6

      \[\leadsto \color{blue}{\frac{\sqrt[3]{y - z} \cdot \sqrt[3]{y - z}}{\frac{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}{1}} \cdot \frac{\sqrt[3]{y - z}}{\frac{\sqrt[3]{a - z}}{t - x}}} + x \]
    11. Applied fma-def_binary647.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\sqrt[3]{y - z} \cdot \sqrt[3]{y - z}}{\frac{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}{1}}, \frac{\sqrt[3]{y - z}}{\frac{\sqrt[3]{a - z}}{t - x}}, x\right)} \]

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

    1. Initial program 60.4

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

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

      \[\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)} \]

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

    1. Initial program 22.0

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)} \]
    3. Applied clear-num_binary6410.7

      \[\leadsto \mathsf{fma}\left(y - z, \color{blue}{\frac{1}{\frac{a - z}{t - x}}}, x\right) \]
    4. Applied fma-udef_binary6410.7

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

      \[\leadsto \color{blue}{\frac{y - z}{\frac{a - z}{t - x}}} + x \]
    6. Applied add-cube-cbrt_binary6411.1

      \[\leadsto \frac{y - z}{\frac{a - z}{\color{blue}{\left(\sqrt[3]{t - x} \cdot \sqrt[3]{t - x}\right) \cdot \sqrt[3]{t - x}}}} + x \]
    7. Applied add-cube-cbrt_binary6411.2

      \[\leadsto \frac{y - z}{\frac{\color{blue}{\left(\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}\right) \cdot \sqrt[3]{a - z}}}{\left(\sqrt[3]{t - x} \cdot \sqrt[3]{t - x}\right) \cdot \sqrt[3]{t - x}}} + x \]
    8. Applied times-frac_binary6411.2

      \[\leadsto \frac{y - z}{\color{blue}{\frac{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}{\sqrt[3]{t - x} \cdot \sqrt[3]{t - x}} \cdot \frac{\sqrt[3]{a - z}}{\sqrt[3]{t - x}}}} + x \]
    9. Applied add-cube-cbrt_binary6411.3

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{y - z} \cdot \sqrt[3]{y - z}\right) \cdot \sqrt[3]{y - z}}}{\frac{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}{\sqrt[3]{t - x} \cdot \sqrt[3]{t - x}} \cdot \frac{\sqrt[3]{a - z}}{\sqrt[3]{t - x}}} + x \]
    10. Applied times-frac_binary647.7

      \[\leadsto \color{blue}{\frac{\sqrt[3]{y - z} \cdot \sqrt[3]{y - z}}{\frac{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}{\sqrt[3]{t - x} \cdot \sqrt[3]{t - x}}} \cdot \frac{\sqrt[3]{y - z}}{\frac{\sqrt[3]{a - z}}{\sqrt[3]{t - x}}}} + x \]
    11. Applied fma-def_binary647.7

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\sqrt[3]{y - z} \cdot \sqrt[3]{y - z}}{\frac{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}{\sqrt[3]{t - x} \cdot \sqrt[3]{t - x}}}, \frac{\sqrt[3]{y - z}}{\frac{\sqrt[3]{a - z}}{\sqrt[3]{t - x}}}, x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification7.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq -8.939814919119468 \cdot 10^{-296}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\sqrt[3]{y - z} \cdot \sqrt[3]{y - z}}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}, \frac{\sqrt[3]{y - z}}{\frac{\sqrt[3]{a - z}}{t - x}}, x\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{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\sqrt[3]{y - z} \cdot \sqrt[3]{y - z}}{\frac{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}{\sqrt[3]{t - x} \cdot \sqrt[3]{t - x}}}, \frac{\sqrt[3]{y - z}}{\frac{\sqrt[3]{a - z}}{\sqrt[3]{t - x}}}, x\right)\\ \end{array} \]

Reproduce

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