?

Average Error: 12.6 → 2.9
Time: 8.1s
Precision: binary64
Cost: 713

?

\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{-40} \lor \neg \left(y \leq 2.7 \cdot 10^{-196}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y - z}{\frac{y}{x}}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -7e-40) (not (<= y 2.7e-196)))
   (- x (/ x (/ y z)))
   (/ (- y z) (/ y x))))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -7e-40) || !(y <= 2.7e-196)) {
		tmp = x - (x / (y / z));
	} else {
		tmp = (y - z) / (y / x);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * (y - z)) / y
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-7d-40)) .or. (.not. (y <= 2.7d-196))) then
        tmp = x - (x / (y / z))
    else
        tmp = (y - z) / (y / x)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -7e-40) || !(y <= 2.7e-196)) {
		tmp = x - (x / (y / z));
	} else {
		tmp = (y - z) / (y / x);
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y - z)) / y
def code(x, y, z):
	tmp = 0
	if (y <= -7e-40) or not (y <= 2.7e-196):
		tmp = x - (x / (y / z))
	else:
		tmp = (y - z) / (y / x)
	return tmp
function code(x, y, z)
	return Float64(Float64(x * Float64(y - z)) / y)
end
function code(x, y, z)
	tmp = 0.0
	if ((y <= -7e-40) || !(y <= 2.7e-196))
		tmp = Float64(x - Float64(x / Float64(y / z)));
	else
		tmp = Float64(Float64(y - z) / Float64(y / x));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x * (y - z)) / y;
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -7e-40) || ~((y <= 2.7e-196)))
		tmp = x - (x / (y / z));
	else
		tmp = (y - z) / (y / x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_] := If[Or[LessEqual[y, -7e-40], N[Not[LessEqual[y, 2.7e-196]], $MachinePrecision]], N[(x - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{-40} \lor \neg \left(y \leq 2.7 \cdot 10^{-196}\right):\\
\;\;\;\;x - \frac{x}{\frac{y}{z}}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.6
Target3.3
Herbie2.9
\[\begin{array}{l} \mathbf{if}\;z < -2.060202331921739 \cdot 10^{+104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z < 1.6939766013828526 \cdot 10^{+213}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if y < -7.0000000000000003e-40 or 2.69999999999999982e-196 < y

    1. Initial program 13.8

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Simplified0.9

      \[\leadsto \color{blue}{x - \frac{x}{\frac{y}{z}}} \]
      Proof

      [Start]13.8

      \[ \frac{x \cdot \left(y - z\right)}{y} \]

      associate-*r/ [<=]1.1

      \[ \color{blue}{x \cdot \frac{y - z}{y}} \]

      div-sub [=>]1.1

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

      distribute-rgt-out-- [<=]1.1

      \[ \color{blue}{\frac{y}{y} \cdot x - \frac{z}{y} \cdot x} \]

      *-inverses [=>]1.1

      \[ \color{blue}{1} \cdot x - \frac{z}{y} \cdot x \]

      *-lft-identity [=>]1.1

      \[ \color{blue}{x} - \frac{z}{y} \cdot x \]

      associate-*l/ [=>]4.4

      \[ x - \color{blue}{\frac{z \cdot x}{y}} \]

      *-commutative [<=]4.4

      \[ x - \frac{\color{blue}{x \cdot z}}{y} \]

      associate-/l* [=>]0.9

      \[ x - \color{blue}{\frac{x}{\frac{y}{z}}} \]

    if -7.0000000000000003e-40 < y < 2.69999999999999982e-196

    1. Initial program 8.8

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Simplified8.8

      \[\leadsto \color{blue}{\frac{y - z}{\frac{y}{x}}} \]
      Proof

      [Start]8.8

      \[ \frac{x \cdot \left(y - z\right)}{y} \]

      *-commutative [=>]8.8

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

      associate-/l* [=>]8.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{-40} \lor \neg \left(y \leq 2.7 \cdot 10^{-196}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y - z}{\frac{y}{x}}\\ \end{array} \]

Alternatives

Alternative 1
Error21.2
Cost1179
\[\begin{array}{l} \mathbf{if}\;z \leq -2.85 \cdot 10^{+200} \lor \neg \left(z \leq -7.5 \cdot 10^{+111}\right) \land \left(z \leq -7 \cdot 10^{-45} \lor \neg \left(z \leq 4.5 \cdot 10^{-82}\right) \land \left(z \leq 3.55 \cdot 10^{-17} \lor \neg \left(z \leq 1.15 \cdot 10^{+20}\right)\right)\right):\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error21.5
Cost1178
\[\begin{array}{l} \mathbf{if}\;z \leq -2.6 \cdot 10^{+200}:\\ \;\;\;\;x \cdot \frac{-z}{y}\\ \mathbf{elif}\;z \leq -3.4 \cdot 10^{+115}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -8.8 \cdot 10^{-45} \lor \neg \left(z \leq 1.12 \cdot 10^{-81}\right) \land \left(z \leq 3.3 \cdot 10^{-17} \lor \neg \left(z \leq 9 \cdot 10^{+18}\right)\right):\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error21.4
Cost1176
\[\begin{array}{l} t_0 := z \cdot \frac{-x}{y}\\ \mathbf{if}\;z \leq -2.6 \cdot 10^{+200}:\\ \;\;\;\;x \cdot \frac{-z}{y}\\ \mathbf{elif}\;z \leq -1.86 \cdot 10^{+115}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-45}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.05 \cdot 10^{-81}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{-17}:\\ \;\;\;\;\frac{x}{\frac{-y}{z}}\\ \mathbf{elif}\;z \leq 21000000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error21.4
Cost1176
\[\begin{array}{l} \mathbf{if}\;z \leq -2.6 \cdot 10^{+200}:\\ \;\;\;\;x \cdot \frac{-z}{y}\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{+112}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -5.2 \cdot 10^{-45}:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-81}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-17}:\\ \;\;\;\;\frac{x}{\frac{-y}{z}}\\ \mathbf{elif}\;z \leq 3.9 \cdot 10^{+15}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \end{array} \]
Alternative 5
Error21.4
Cost1176
\[\begin{array}{l} \mathbf{if}\;z \leq -2.65 \cdot 10^{+200}:\\ \;\;\;\;x \cdot \frac{-z}{y}\\ \mathbf{elif}\;z \leq -1.95 \cdot 10^{+115}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{-45}:\\ \;\;\;\;\frac{x \cdot \left(-z\right)}{y}\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{-81}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-17}:\\ \;\;\;\;\frac{x}{\frac{-y}{z}}\\ \mathbf{elif}\;z \leq 80000000000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \end{array} \]
Alternative 6
Error3.1
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -4 \cdot 10^{-120} \lor \neg \left(y \leq 2.5 \cdot 10^{-196}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array} \]
Alternative 7
Error7.9
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -2.8 \cdot 10^{+85}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.1 \cdot 10^{+184}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error25.5
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023060 
(FPCore (x y z)
  :name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))

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