Average Error: 24.9 → 5.0
Time: 7.2s
Precision: binary64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
\[\begin{array}{l} \mathbf{if}\;\begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\ t_1 \leq -3.9403966779596214 \cdot 10^{-278} \lor \neg \left(t_1 \leq 0\right) \end{array}:\\ \;\;\;\;\begin{array}{l} t_2 := \frac{a - t}{z - t}\\ \frac{y}{t_2} - \left(\frac{x}{t_2} - x\right) \end{array}\\ \mathbf{else}:\\ \;\;\;\;\left(y + \left(\frac{x \cdot z}{t} + \frac{y \cdot a}{t}\right)\right) - \left(\frac{x \cdot a}{t} + \frac{y \cdot z}{t}\right)\\ \end{array} \]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
t_1 \leq -3.9403966779596214 \cdot 10^{-278} \lor \neg \left(t_1 \leq 0\right)
\end{array}:\\
\;\;\;\;\begin{array}{l}
t_2 := \frac{a - t}{z - t}\\
\frac{y}{t_2} - \left(\frac{x}{t_2} - x\right)
\end{array}\\

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


\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y x) (- z t)) (- a t))))
(FPCore (x y z t a)
 :precision binary64
 (if (let* ((t_1 (+ x (/ (* (- y x) (- z t)) (- a t)))))
       (or (<= t_1 -3.9403966779596214e-278) (not (<= t_1 0.0))))
   (let* ((t_2 (/ (- a t) (- z t)))) (- (/ y t_2) (- (/ x t_2) x)))
   (- (+ y (+ (/ (* x z) t) (/ (* y a) t))) (+ (/ (* x a) t) (/ (* y z) t)))))
double code(double x, double y, double z, double t, double a) {
	return x + (((y - x) * (z - t)) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = x + (((y - x) * (z - t)) / (a - t));
	double tmp;
	if ((t_1 <= -3.9403966779596214e-278) || !(t_1 <= 0.0)) {
		double t_2_1 = (a - t) / (z - t);
		tmp = (y / t_2_1) - ((x / t_2_1) - x);
	} else {
		tmp = (y + (((x * z) / t) + ((y * a) / t))) - (((x * a) / t) + ((y * z) / t));
	}
	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.9
Target9.5
Herbie5.0
\[\begin{array}{l} \mathbf{if}\;a < -1.6153062845442575 \cdot 10^{-142}:\\ \;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;a < 3.774403170083174 \cdot 10^{-182}:\\ \;\;\;\;y - \frac{z}{t} \cdot \left(y - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -3.9403966779596214e-278 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t)))

    1. Initial program 21.6

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

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

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

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

      \[\leadsto \color{blue}{\frac{y - x}{\frac{a - t}{z - t}}} + x \]
    6. Applied div-sub_binary647.3

      \[\leadsto \color{blue}{\left(\frac{y}{\frac{a - t}{z - t}} - \frac{x}{\frac{a - t}{z - t}}\right)} + x \]
    7. Applied associate-+l-_binary645.2

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

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

    1. Initial program 58.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \leq -3.9403966779596214 \cdot 10^{-278} \lor \neg \left(x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \leq 0\right):\\ \;\;\;\;\frac{y}{\frac{a - t}{z - t}} - \left(\frac{x}{\frac{a - t}{z - t}} - x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y + \left(\frac{x \cdot z}{t} + \frac{y \cdot a}{t}\right)\right) - \left(\frac{x \cdot a}{t} + \frac{y \cdot z}{t}\right)\\ \end{array} \]

Reproduce

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

  :herbie-target
  (if (< a -1.6153062845442575e-142) (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t)))) (if (< a 3.774403170083174e-182) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t))))))

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