Average Error: 10.5 → 0.2
Time: 2.0s
Precision: 64
\[\frac{x + y \cdot \left(z - x\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.73862281444923593 \cdot 10^{73} \lor \neg \left(z \le 9.2922977956071547 \cdot 10^{-89}\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}\;z \le -2.73862281444923593 \cdot 10^{73} \lor \neg \left(z \le 9.2922977956071547 \cdot 10^{-89}\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 ((double) (((double) (x + ((double) (y * ((double) (z - x)))))) / z));
}
double code(double x, double y, double z) {
	double VAR;
	if (((z <= -2.738622814449236e+73) || !(z <= 9.292297795607155e-89))) {
		VAR = ((double) (((double) (((double) (x / z)) + y)) - ((double) (x / ((double) (z / y))))));
	} else {
		VAR = ((double) (((double) (((double) (x / z)) + y)) - ((double) (((double) (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.5
Target0.0
Herbie0.2
\[\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -2.738622814449236e+73 or 9.292297795607155e-89 < z

    1. Initial program 16.5

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

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

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

    if -2.738622814449236e+73 < z < 9.292297795607155e-89

    1. Initial program 0.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.73862281444923593 \cdot 10^{73} \lor \neg \left(z \le 9.2922977956071547 \cdot 10^{-89}\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 2020124 
(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))