Average Error: 12.0 → 2.3
Time: 5.7s
Precision: binary64
\[\frac{x \cdot \left(y - z\right)}{t - z} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -1.5964659875812437 \cdot 10^{-80}:\\ \;\;\;\;x \cdot \left(\frac{y}{t - z} - \frac{z}{t - z}\right)\\ \mathbf{elif}\;z \leq 3.0222555522334117 \cdot 10^{-175}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{t - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{t - z}{y - z}}\\ \end{array} \]
\frac{x \cdot \left(y - z\right)}{t - z}
\begin{array}{l}
\mathbf{if}\;z \leq -1.5964659875812437 \cdot 10^{-80}:\\
\;\;\;\;x \cdot \left(\frac{y}{t - z} - \frac{z}{t - z}\right)\\

\mathbf{elif}\;z \leq 3.0222555522334117 \cdot 10^{-175}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x}{t - z}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{t - z}{y - z}}\\


\end{array}
(FPCore (x y z t) :precision binary64 (/ (* x (- y z)) (- t z)))
(FPCore (x y z t)
 :precision binary64
 (if (<= z -1.5964659875812437e-80)
   (* x (- (/ y (- t z)) (/ z (- t z))))
   (if (<= z 3.0222555522334117e-175)
     (* (- y z) (/ x (- t z)))
     (/ x (/ (- t z) (- y z))))))
double code(double x, double y, double z, double t) {
	return (x * (y - z)) / (t - z);
}
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -1.5964659875812437e-80) {
		tmp = x * ((y / (t - z)) - (z / (t - z)));
	} else if (z <= 3.0222555522334117e-175) {
		tmp = (y - z) * (x / (t - z));
	} else {
		tmp = x / ((t - z) / (y - z));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.0
Target2.2
Herbie2.3
\[\frac{x}{\frac{t - z}{y - z}} \]

Derivation

  1. Split input into 3 regimes
  2. if z < -1.59646598758124371e-80

    1. Initial program 15.0

      \[\frac{x \cdot \left(y - z\right)}{t - z} \]
    2. Applied *-un-lft-identity_binary6415.0

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

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y - z}{t - z}} \]
    4. Simplified0.4

      \[\leadsto \color{blue}{x} \cdot \frac{y - z}{t - z} \]
    5. Taylor expanded in y around 0 0.4

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

    if -1.59646598758124371e-80 < z < 3.0222555522334117e-175

    1. Initial program 6.3

      \[\frac{x \cdot \left(y - z\right)}{t - z} \]
    2. Applied associate-/l*_binary645.6

      \[\leadsto \color{blue}{\frac{x}{\frac{t - z}{y - z}}} \]
    3. Taylor expanded in t around 0 5.6

      \[\leadsto \frac{x}{\color{blue}{\frac{t}{y - z} - \frac{z}{y - z}}} \]
    4. Applied div-inv_binary645.6

      \[\leadsto \frac{x}{\frac{t}{y - z} - \color{blue}{z \cdot \frac{1}{y - z}}} \]
    5. Applied div-inv_binary645.6

      \[\leadsto \frac{x}{\color{blue}{t \cdot \frac{1}{y - z}} - z \cdot \frac{1}{y - z}} \]
    6. Applied distribute-rgt-out--_binary645.6

      \[\leadsto \frac{x}{\color{blue}{\frac{1}{y - z} \cdot \left(t - z\right)}} \]
    7. Applied *-un-lft-identity_binary645.6

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\frac{1}{y - z} \cdot \left(t - z\right)} \]
    8. Applied times-frac_binary645.8

      \[\leadsto \color{blue}{\frac{1}{\frac{1}{y - z}} \cdot \frac{x}{t - z}} \]
    9. Simplified5.7

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

    if 3.0222555522334117e-175 < z

    1. Initial program 13.2

      \[\frac{x \cdot \left(y - z\right)}{t - z} \]
    2. Applied associate-/l*_binary641.6

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

      \[\leadsto \frac{x}{\color{blue}{1 \cdot \frac{t - z}{y - z}}} \]
    4. Applied associate-/r*_binary641.6

      \[\leadsto \color{blue}{\frac{\frac{x}{1}}{\frac{t - z}{y - z}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.5964659875812437 \cdot 10^{-80}:\\ \;\;\;\;x \cdot \left(\frac{y}{t - z} - \frac{z}{t - z}\right)\\ \mathbf{elif}\;z \leq 3.0222555522334117 \cdot 10^{-175}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{t - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{t - z}{y - z}}\\ \end{array} \]

Reproduce

herbie shell --seed 2022081 
(FPCore (x y z t)
  :name "Graphics.Rendering.Chart.Plot.AreaSpots:renderAreaSpots4D from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (/ x (/ (- t z) (- y z)))

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