Average Error: 10.4 → 0.3
Time: 2.3s
Precision: 64
\[\frac{x + y \cdot \left(z - x\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -86.3371335760888456 \lor \neg \left(x \le 7.7200267136732314 \cdot 10^{-131}\right):\\ \;\;\;\;\left(\frac{x}{z} + y\right) - \frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{x}{z} + y\right) - \frac{x \cdot y}{z}\\ \end{array}\]
\frac{x + y \cdot \left(z - x\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \le -86.3371335760888456 \lor \neg \left(x \le 7.7200267136732314 \cdot 10^{-131}\right):\\
\;\;\;\;\left(\frac{x}{z} + y\right) - \frac{x}{\frac{z}{y}}\\

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

\end{array}
double code(double x, double y, double z) {
	return ((x + (y * (z - x))) / z);
}
double code(double x, double y, double z) {
	double VAR;
	if (((x <= -86.33713357608885) || !(x <= 7.720026713673231e-131))) {
		VAR = (((x / z) + y) - (x / (z / y)));
	} else {
		VAR = (((x / z) + y) - ((x * y) / z));
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.4
Target0.0
Herbie0.3
\[\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -86.33713357608885 or 7.720026713673231e-131 < x

    1. Initial program 12.2

      \[\frac{x + y \cdot \left(z - x\right)}{z}\]
    2. Taylor expanded around 0 6.6

      \[\leadsto \color{blue}{\left(\frac{x}{z} + y\right) - \frac{x \cdot y}{z}}\]
    3. Using strategy rm
    4. Applied associate-/l*0.6

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

    if -86.33713357608885 < x < 7.720026713673231e-131

    1. Initial program 8.4

      \[\frac{x + y \cdot \left(z - x\right)}{z}\]
    2. Taylor expanded around 0 0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -86.3371335760888456 \lor \neg \left(x \le 7.7200267136732314 \cdot 10^{-131}\right):\\ \;\;\;\;\left(\frac{x}{z} + y\right) - \frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{x}{z} + y\right) - \frac{x \cdot y}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2020103 
(FPCore (x y z)
  :name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
  :precision binary64

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

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