Average Error: 10.5 → 0.9
Time: 20.8s
Precision: binary64
\[x + \frac{\left(y - z\right) \cdot t}{a - z} \]
\[\begin{array}{l} \mathbf{if}\;t \leq -5.615091370569311 \cdot 10^{-59}:\\ \;\;\;\;t \cdot \left(\frac{y - z}{a - z} + \frac{z - z}{a - z}\right) + x\\ \mathbf{elif}\;t \leq 1.0616679928509863 \cdot 10^{-130}:\\ \;\;\;\;\begin{array}{l} t_1 := \sqrt[3]{a - z}\\ x + \frac{t \cdot \left(\frac{y}{t_1} - \frac{z}{t_1}\right)}{t_1 \cdot t_1} \end{array}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t, \frac{y}{a - z} - \frac{z}{a - z}, x\right)\\ \end{array} \]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\begin{array}{l}
\mathbf{if}\;t \leq -5.615091370569311 \cdot 10^{-59}:\\
\;\;\;\;t \cdot \left(\frac{y - z}{a - z} + \frac{z - z}{a - z}\right) + x\\

\mathbf{elif}\;t \leq 1.0616679928509863 \cdot 10^{-130}:\\
\;\;\;\;\begin{array}{l}
t_1 := \sqrt[3]{a - z}\\
x + \frac{t \cdot \left(\frac{y}{t_1} - \frac{z}{t_1}\right)}{t_1 \cdot t_1}
\end{array}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y}{a - z} - \frac{z}{a - z}, x\right)\\


\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) t) (- a z))))
(FPCore (x y z t a)
 :precision binary64
 (if (<= t -5.615091370569311e-59)
   (+ (* t (+ (/ (- y z) (- a z)) (/ (- z z) (- a z)))) x)
   (if (<= t 1.0616679928509863e-130)
     (let* ((t_1 (cbrt (- a z))))
       (+ x (/ (* t (- (/ y t_1) (/ z t_1))) (* t_1 t_1))))
     (fma t (- (/ y (- a z)) (/ z (- a z))) x))))
double code(double x, double y, double z, double t, double a) {
	return x + (((y - z) * t) / (a - z));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (t <= -5.615091370569311e-59) {
		tmp = (t * (((y - z) / (a - z)) + ((z - z) / (a - z)))) + x;
	} else if (t <= 1.0616679928509863e-130) {
		double t_1 = cbrt(a - z);
		tmp = x + ((t * ((y / t_1) - (z / t_1))) / (t_1 * t_1));
	} else {
		tmp = fma(t, ((y / (a - z)) - (z / (a - z))), 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

Original10.5
Target0.6
Herbie0.9
\[\begin{array}{l} \mathbf{if}\;t < -1.0682974490174067 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \mathbf{elif}\;t < 3.9110949887586375 \cdot 10^{-141}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if t < -5.6150913705693108e-59

    1. Initial program 18.8

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

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

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

      \[\leadsto \color{blue}{t \cdot \left(\frac{y}{a - z} - \frac{z}{a - z}\right)} + x \]
    5. Applied div-inv_binary640.6

      \[\leadsto t \cdot \left(\frac{y}{a - z} - \color{blue}{z \cdot \frac{1}{a - z}}\right) + x \]
    6. Applied div-inv_binary640.6

      \[\leadsto t \cdot \left(\color{blue}{y \cdot \frac{1}{a - z}} - z \cdot \frac{1}{a - z}\right) + x \]
    7. Applied distribute-rgt-out--_binary640.6

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

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

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

      \[\leadsto t \cdot \left(\frac{1}{a - z} \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, -\sqrt[3]{z} \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{z}, \sqrt[3]{z} \cdot \sqrt[3]{z}, \sqrt[3]{z} \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)\right)\right)}\right) + x \]
    11. Applied distribute-rgt-in_binary641.3

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

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

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

    if -5.6150913705693108e-59 < t < 1.06166799285098628e-130

    1. Initial program 0.5

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

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

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

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

      \[\leadsto t \cdot \left(\frac{y}{a - z} - \frac{z}{\color{blue}{\left(\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}\right) \cdot \sqrt[3]{a - z}}}\right) + x \]
    6. Applied *-un-lft-identity_binary643.1

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

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

      \[\leadsto t \cdot \left(\frac{y}{\color{blue}{\left(\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}\right) \cdot \sqrt[3]{a - z}}} - \frac{1}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \frac{z}{\sqrt[3]{a - z}}\right) + x \]
    9. Applied *-un-lft-identity_binary643.2

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

      \[\leadsto t \cdot \left(\color{blue}{\frac{1}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \frac{y}{\sqrt[3]{a - z}}} - \frac{1}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \frac{z}{\sqrt[3]{a - z}}\right) + x \]
    11. Applied distribute-lft-out--_binary643.2

      \[\leadsto t \cdot \color{blue}{\left(\frac{1}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \left(\frac{y}{\sqrt[3]{a - z}} - \frac{z}{\sqrt[3]{a - z}}\right)\right)} + x \]
    12. Applied associate-*r*_binary643.2

      \[\leadsto \color{blue}{\left(t \cdot \frac{1}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}\right) \cdot \left(\frac{y}{\sqrt[3]{a - z}} - \frac{z}{\sqrt[3]{a - z}}\right)} + x \]
    13. Applied un-div-inv_binary643.2

      \[\leadsto \color{blue}{\frac{t}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}} \cdot \left(\frac{y}{\sqrt[3]{a - z}} - \frac{z}{\sqrt[3]{a - z}}\right) + x \]
    14. Applied associate-*l/_binary641.3

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

    if 1.06166799285098628e-130 < t

    1. Initial program 14.9

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -5.615091370569311 \cdot 10^{-59}:\\ \;\;\;\;t \cdot \left(\frac{y - z}{a - z} + \frac{z - z}{a - z}\right) + x\\ \mathbf{elif}\;t \leq 1.0616679928509863 \cdot 10^{-130}:\\ \;\;\;\;x + \frac{t \cdot \left(\frac{y}{\sqrt[3]{a - z}} - \frac{z}{\sqrt[3]{a - z}}\right)}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t, \frac{y}{a - z} - \frac{z}{a - z}, x\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2021313 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, A"
  :precision binary64

  :herbie-target
  (if (< t -1.0682974490174067e-39) (+ x (* (/ (- y z) (- a z)) t)) (if (< t 3.9110949887586375e-141) (+ x (/ (* (- y z) t) (- a z))) (+ x (* (/ (- y z) (- a z)) t))))

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