?

Average Error: 12.0 → 2.0
Time: 6.0s
Precision: binary64
Cost: 1481

?

\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} t_0 := \frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{if}\;t_0 \leq 5 \cdot 10^{+82} \lor \neg \left(t_0 \leq 10^{+232}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* x (- y z)) y)))
   (if (or (<= t_0 5e+82) (not (<= t_0 1e+232))) (- x (/ x (/ y z))) t_0)))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
	double t_0 = (x * (y - z)) / y;
	double tmp;
	if ((t_0 <= 5e+82) || !(t_0 <= 1e+232)) {
		tmp = x - (x / (y / z));
	} else {
		tmp = t_0;
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = (x * (y - z)) / y
    if ((t_0 <= 5d+82) .or. (.not. (t_0 <= 1d+232))) then
        tmp = x - (x / (y / z))
    else
        tmp = t_0
    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 t_0 = (x * (y - z)) / y;
	double tmp;
	if ((t_0 <= 5e+82) || !(t_0 <= 1e+232)) {
		tmp = x - (x / (y / z));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y - z)) / y
def code(x, y, z):
	t_0 = (x * (y - z)) / y
	tmp = 0
	if (t_0 <= 5e+82) or not (t_0 <= 1e+232):
		tmp = x - (x / (y / z))
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	return Float64(Float64(x * Float64(y - z)) / y)
end
function code(x, y, z)
	t_0 = Float64(Float64(x * Float64(y - z)) / y)
	tmp = 0.0
	if ((t_0 <= 5e+82) || !(t_0 <= 1e+232))
		tmp = Float64(x - Float64(x / Float64(y / z)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x * (y - z)) / y;
end
function tmp_2 = code(x, y, z)
	t_0 = (x * (y - z)) / y;
	tmp = 0.0;
	if ((t_0 <= 5e+82) || ~((t_0 <= 1e+232)))
		tmp = x - (x / (y / z));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, If[Or[LessEqual[t$95$0, 5e+82], N[Not[LessEqual[t$95$0, 1e+232]], $MachinePrecision]], N[(x - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y - z\right)}{y}\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{+82} \lor \neg \left(t_0 \leq 10^{+232}\right):\\
\;\;\;\;x - \frac{x}{\frac{y}{z}}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.0
Target3.0
Herbie2.0
\[\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 (/.f64 (*.f64 x (-.f64 y z)) y) < 5.00000000000000015e82 or 1.00000000000000006e232 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 13.3

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

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

      [Start]13.3

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

      associate-*r/ [<=]2.4

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

      div-sub [=>]2.4

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

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

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

      *-inverses [=>]2.4

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

      *-lft-identity [=>]2.4

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

      associate-*l/ [=>]5.1

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

      *-commutative [<=]5.1

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

      associate-/l* [=>]2.2

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

    if 5.00000000000000015e82 < (/.f64 (*.f64 x (-.f64 y z)) y) < 1.00000000000000006e232

    1. Initial program 0.2

      \[\frac{x \cdot \left(y - z\right)}{y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq 5 \cdot 10^{+82} \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \leq 10^{+232}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \end{array} \]

Alternatives

Alternative 1
Error19.7
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{-115}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.15 \cdot 10^{-137}:\\ \;\;\;\;x \cdot \frac{-z}{y}\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{-183}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 9 \cdot 10^{-52}:\\ \;\;\;\;\frac{x}{y} \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error19.5
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -7.4 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -6.9 \cdot 10^{-137}:\\ \;\;\;\;x \cdot \frac{-z}{y}\\ \mathbf{elif}\;y \leq -2.1 \cdot 10^{-183}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{-53}:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error2.7
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -2.8 \cdot 10^{-158} \lor \neg \left(y \leq -1.3 \cdot 10^{-259}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array} \]
Alternative 4
Error7.4
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -3.1 \cdot 10^{+190}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+148}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error19.9
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -2.05 \cdot 10^{-183}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-54}:\\ \;\;\;\;\frac{x}{y} \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error25.3
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023073 
(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))