Average Error: 24.5 → 8.3
Time: 5.4s
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 -\infty:\\ \;\;\;\;x + \left(y - z\right) \cdot \frac{t - x}{a - z}\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq -2.1810124009229863 \cdot 10^{-200}:\\ \;\;\;\;x + \left(\left(y - z\right) \cdot \left(t - x\right)\right) \cdot \frac{1}{a - z}\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq 0:\\ \;\;\;\;\left(t + \frac{x \cdot y}{z}\right) - \frac{y \cdot t}{z}\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq 3.6456281701934235 \cdot 10^{+264}:\\ \;\;\;\;x + \left(\left(y - z\right) \cdot \left(t - x\right)\right) \cdot \frac{1}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - z}{\left(a - z\right) \cdot \frac{1}{t - x}}\\ \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 -\infty:\\
\;\;\;\;x + \left(y - z\right) \cdot \frac{t - x}{a - z}\\

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

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

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

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

\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))) (- INFINITY))
   (+ x (* (- y z) (/ (- t x) (- a z))))
   (if (<= (+ x (/ (* (- y z) (- t x)) (- a z))) -2.1810124009229863e-200)
     (+ x (* (* (- y z) (- t x)) (/ 1.0 (- a z))))
     (if (<= (+ x (/ (* (- y z) (- t x)) (- a z))) 0.0)
       (- (+ t (/ (* x y) z)) (/ (* y t) z))
       (if (<= (+ x (/ (* (- y z) (- t x)) (- a z))) 3.6456281701934235e+264)
         (+ x (* (* (- y z) (- t x)) (/ 1.0 (- a z))))
         (+ x (/ (- y z) (* (- a z) (/ 1.0 (- t 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 tmp;
	if ((x + (((y - z) * (t - x)) / (a - z))) <= -((double) INFINITY)) {
		tmp = x + ((y - z) * ((t - x) / (a - z)));
	} else if ((x + (((y - z) * (t - x)) / (a - z))) <= -2.1810124009229863e-200) {
		tmp = x + (((y - z) * (t - x)) * (1.0 / (a - z)));
	} else if ((x + (((y - z) * (t - x)) / (a - z))) <= 0.0) {
		tmp = (t + ((x * y) / z)) - ((y * t) / z);
	} else if ((x + (((y - z) * (t - x)) / (a - z))) <= 3.6456281701934235e+264) {
		tmp = x + (((y - z) * (t - x)) * (1.0 / (a - z)));
	} else {
		tmp = x + ((y - z) / ((a - z) * (1.0 / (t - x))));
	}
	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.5
Target11.8
Herbie8.3
\[\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))) < -inf.0

    1. Initial program 64.0

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

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

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

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

    if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -2.1810124009229863e-200 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 3.64562817019342346e264

    1. Initial program 1.9

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

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

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

    1. Initial program 50.8

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

      \[\leadsto x + \color{blue}{\frac{y - z}{\frac{a - z}{t - x}}}\]
    4. Taylor expanded around inf 24.1

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

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

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

    1. Initial program 57.1

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

      \[\leadsto x + \color{blue}{\frac{y - z}{\frac{a - z}{t - x}}}\]
    4. Using strategy rm
    5. Applied div-inv_binary6416.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq -\infty:\\ \;\;\;\;x + \left(y - z\right) \cdot \frac{t - x}{a - z}\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq -2.1810124009229863 \cdot 10^{-200}:\\ \;\;\;\;x + \left(\left(y - z\right) \cdot \left(t - x\right)\right) \cdot \frac{1}{a - z}\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq 0:\\ \;\;\;\;\left(t + \frac{x \cdot y}{z}\right) - \frac{y \cdot t}{z}\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \leq 3.6456281701934235 \cdot 10^{+264}:\\ \;\;\;\;x + \left(\left(y - z\right) \cdot \left(t - x\right)\right) \cdot \frac{1}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - z}{\left(a - z\right) \cdot \frac{1}{t - x}}\\ \end{array}\]

Reproduce

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