?

Average Error: 14.8 → 0.8
Time: 5.3s
Precision: binary64
Cost: 1361

?

\[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq -4 \cdot 10^{-184} \lor \neg \left(\frac{y}{z} \leq 5 \cdot 10^{-109}\right) \land \frac{y}{z} \leq 10^{+165}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
(FPCore (x y z t)
 :precision binary64
 (if (<= (/ y z) (- INFINITY))
   (/ (* y x) z)
   (if (or (<= (/ y z) -4e-184)
           (and (not (<= (/ y z) 5e-109)) (<= (/ y z) 1e+165)))
     (/ x (/ z y))
     (/ y (/ z x)))))
double code(double x, double y, double z, double t) {
	return x * (((y / z) * t) / t);
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y / z) <= -((double) INFINITY)) {
		tmp = (y * x) / z;
	} else if (((y / z) <= -4e-184) || (!((y / z) <= 5e-109) && ((y / z) <= 1e+165))) {
		tmp = x / (z / y);
	} else {
		tmp = y / (z / x);
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	return x * (((y / z) * t) / t);
}
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((y / z) <= -Double.POSITIVE_INFINITY) {
		tmp = (y * x) / z;
	} else if (((y / z) <= -4e-184) || (!((y / z) <= 5e-109) && ((y / z) <= 1e+165))) {
		tmp = x / (z / y);
	} else {
		tmp = y / (z / x);
	}
	return tmp;
}
def code(x, y, z, t):
	return x * (((y / z) * t) / t)
def code(x, y, z, t):
	tmp = 0
	if (y / z) <= -math.inf:
		tmp = (y * x) / z
	elif ((y / z) <= -4e-184) or (not ((y / z) <= 5e-109) and ((y / z) <= 1e+165)):
		tmp = x / (z / y)
	else:
		tmp = y / (z / x)
	return tmp
function code(x, y, z, t)
	return Float64(x * Float64(Float64(Float64(y / z) * t) / t))
end
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(y / z) <= Float64(-Inf))
		tmp = Float64(Float64(y * x) / z);
	elseif ((Float64(y / z) <= -4e-184) || (!(Float64(y / z) <= 5e-109) && (Float64(y / z) <= 1e+165)))
		tmp = Float64(x / Float64(z / y));
	else
		tmp = Float64(y / Float64(z / x));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = x * (((y / z) * t) / t);
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((y / z) <= -Inf)
		tmp = (y * x) / z;
	elseif (((y / z) <= -4e-184) || (~(((y / z) <= 5e-109)) && ((y / z) <= 1e+165)))
		tmp = x / (z / y);
	else
		tmp = y / (z / x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(x * N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[N[(y / z), $MachinePrecision], (-Infinity)], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision], If[Or[LessEqual[N[(y / z), $MachinePrecision], -4e-184], And[N[Not[LessEqual[N[(y / z), $MachinePrecision], 5e-109]], $MachinePrecision], LessEqual[N[(y / z), $MachinePrecision], 1e+165]]], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \leq -\infty:\\
\;\;\;\;\frac{y \cdot x}{z}\\

\mathbf{elif}\;\frac{y}{z} \leq -4 \cdot 10^{-184} \lor \neg \left(\frac{y}{z} \leq 5 \cdot 10^{-109}\right) \land \frac{y}{z} \leq 10^{+165}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.8
Target1.6
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} < -1.20672205123045 \cdot 10^{+245}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} < -5.907522236933906 \cdot 10^{-275}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} < 5.658954423153415 \cdot 10^{-65}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} < 2.0087180502407133 \cdot 10^{+217}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if (/.f64 y z) < -inf.0

    1. Initial program 64.0

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified64.0

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

      [Start]64.0

      \[ x \cdot \frac{\frac{y}{z} \cdot t}{t} \]

      associate-/l* [=>]64.0

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

      *-inverses [=>]64.0

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

      /-rgt-identity [=>]64.0

      \[ x \cdot \color{blue}{\frac{y}{z}} \]
    3. Taylor expanded in x around 0 0.2

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

    if -inf.0 < (/.f64 y z) < -4.0000000000000002e-184 or 5.0000000000000002e-109 < (/.f64 y z) < 9.99999999999999899e164

    1. Initial program 8.6

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified0.2

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

      [Start]8.6

      \[ x \cdot \frac{\frac{y}{z} \cdot t}{t} \]

      associate-/l* [=>]0.2

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

      *-inverses [=>]0.2

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

      /-rgt-identity [=>]0.2

      \[ x \cdot \color{blue}{\frac{y}{z}} \]
    3. Applied egg-rr0.2

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

    if -4.0000000000000002e-184 < (/.f64 y z) < 5.0000000000000002e-109 or 9.99999999999999899e164 < (/.f64 y z)

    1. Initial program 19.7

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified1.6

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

      [Start]19.7

      \[ x \cdot \frac{\frac{y}{z} \cdot t}{t} \]

      associate-/l* [=>]10.8

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

      *-inverses [=>]10.8

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

      /-rgt-identity [=>]10.8

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

      associate-*r/ [=>]1.9

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

      associate-*l/ [<=]1.6

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

      *-commutative [<=]1.6

      \[ \color{blue}{y \cdot \frac{x}{z}} \]
    3. Applied egg-rr1.6

      \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq -4 \cdot 10^{-184} \lor \neg \left(\frac{y}{z} \leq 5 \cdot 10^{-109}\right) \land \frac{y}{z} \leq 10^{+165}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]

Alternatives

Alternative 1
Error0.9
Cost1362
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -1 \cdot 10^{+229} \lor \neg \left(\frac{y}{z} \leq -1 \cdot 10^{-307} \lor \neg \left(\frac{y}{z} \leq 5 \cdot 10^{-166}\right) \land \frac{y}{z} \leq 10^{+99}\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \]
Alternative 2
Error0.3
Cost1362
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty \lor \neg \left(\frac{y}{z} \leq -2 \cdot 10^{-304}\right) \land \left(\frac{y}{z} \leq 10^{-247} \lor \neg \left(\frac{y}{z} \leq 2 \cdot 10^{+168}\right)\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \]
Alternative 3
Error0.8
Cost1361
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq -4 \cdot 10^{-184} \lor \neg \left(\frac{y}{z} \leq 5 \cdot 10^{-109}\right) \land \frac{y}{z} \leq 10^{+165}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]
Alternative 4
Error6.4
Cost320
\[\frac{y}{z} \cdot x \]

Error

Reproduce?

herbie shell --seed 2023060 
(FPCore (x y z t)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, B"
  :precision binary64

  :herbie-target
  (if (< (/ (* (/ y z) t) t) -1.20672205123045e+245) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) -5.907522236933906e-275) (* x (/ y z)) (if (< (/ (* (/ y z) t) t) 5.658954423153415e-65) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) 2.0087180502407133e+217) (* x (/ y z)) (/ (* y x) z)))))

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