Average Error: 24.7 → 9.2
Time: 5.5s
Precision: binary64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq -1.2635250176906057 \cdot 10^{-246}:\\ \;\;\;\;x + \frac{y - z}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \frac{t - x}{\sqrt[3]{a - z}}\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq 0:\\ \;\;\;\;t + y \cdot \left(\frac{x}{z} - \frac{t}{z}\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq 5.045411824196673 \cdot 10^{+299}:\\ \;\;\;\;x + \left(\left(y - z\right) \cdot \left(t - x\right)\right) \cdot \frac{1}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - z\right) \cdot \left(\left(t - x\right) \cdot \frac{1}{a - z}\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq -1.2635250176906057 \cdot 10^{-246}:\\
\;\;\;\;x + \frac{y - z}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \frac{t - x}{\sqrt[3]{a - z}}\\

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

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

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

\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))) -1.2635250176906057e-246)
   (+
    x
    (*
     (/ (- y z) (* (cbrt (- a z)) (cbrt (- a z))))
     (/ (- t x) (cbrt (- a z)))))
   (if (<= (+ x (/ (* (- y z) (- t x)) (- a z))) 0.0)
     (+ t (* y (- (/ x z) (/ t z))))
     (if (<= (+ x (/ (* (- y z) (- t x)) (- a z))) 5.045411824196673e+299)
       (+ x (* (* (- y z) (- t x)) (/ 1.0 (- a z))))
       (+ x (* (- y z) (* (- t x) (/ 1.0 (- 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))) <= -1.2635250176906057e-246) {
		tmp = x + (((y - z) / (cbrt(a - z) * cbrt(a - z))) * ((t - x) / cbrt(a - z)));
	} else if ((x + (((y - z) * (t - x)) / (a - z))) <= 0.0) {
		tmp = t + (y * ((x / z) - (t / z)));
	} else if ((x + (((y - z) * (t - x)) / (a - z))) <= 5.045411824196673e+299) {
		tmp = x + (((y - z) * (t - x)) * (1.0 / (a - z)));
	} else {
		tmp = x + ((y - z) * ((t - x) * (1.0 / (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

Target

Original24.7
Target11.9
Herbie9.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 4 regimes
  2. if (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -1.263525017690606e-246

    1. Initial program 22.3

      \[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt_binary6422.8

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

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

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

    1. Initial program 57.1

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

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

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

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

    1. Initial program 2.0

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

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

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

    1. Initial program 62.3

      \[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity_binary6462.3

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

      \[\leadsto x + \color{blue}{\frac{y - z}{1} \cdot \frac{t - x}{a - z}}\]
    5. Simplified17.1

      \[\leadsto x + \color{blue}{\left(y - z\right)} \cdot \frac{t - x}{a - z}\]
    6. Using strategy rm
    7. Applied div-inv_binary6417.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq -1.2635250176906057 \cdot 10^{-246}:\\ \;\;\;\;x + \frac{y - z}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \frac{t - x}{\sqrt[3]{a - z}}\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq 0:\\ \;\;\;\;t + y \cdot \left(\frac{x}{z} - \frac{t}{z}\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq 5.045411824196673 \cdot 10^{+299}:\\ \;\;\;\;x + \left(\left(y - z\right) \cdot \left(t - x\right)\right) \cdot \frac{1}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - z\right) \cdot \left(\left(t - x\right) \cdot \frac{1}{a - z}\right)\\ \end{array}\]

Reproduce

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