?

Average Error: 6.2 → 0.7
Time: 4.9s
Precision: binary64
Cost: 1360

?

\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\frac{x \cdot y}{z} \]
\[\begin{array}{l} t_0 := \frac{y}{\frac{z}{x}}\\ \mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+169}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-143}:\\ \;\;\;\;\frac{\frac{1}{z + z}}{\frac{0.5}{y \cdot x}}\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-187}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \leq 10^{+270}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x y) z))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ y (/ z x))))
   (if (<= (* x y) -2e+169)
     t_0
     (if (<= (* x y) -1e-143)
       (/ (/ 1.0 (+ z z)) (/ 0.5 (* y x)))
       (if (<= (* x y) 2e-187)
         (/ x (/ z y))
         (if (<= (* x y) 1e+270) (/ (* x y) z) t_0))))))
double code(double x, double y, double z) {
	return (x * y) / z;
}
double code(double x, double y, double z) {
	double t_0 = y / (z / x);
	double tmp;
	if ((x * y) <= -2e+169) {
		tmp = t_0;
	} else if ((x * y) <= -1e-143) {
		tmp = (1.0 / (z + z)) / (0.5 / (y * x));
	} else if ((x * y) <= 2e-187) {
		tmp = x / (z / y);
	} else if ((x * y) <= 1e+270) {
		tmp = (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
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 = y / (z / x)
    if ((x * y) <= (-2d+169)) then
        tmp = t_0
    else if ((x * y) <= (-1d-143)) then
        tmp = (1.0d0 / (z + z)) / (0.5d0 / (y * x))
    else if ((x * y) <= 2d-187) then
        tmp = x / (z / y)
    else if ((x * y) <= 1d+270) then
        tmp = (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;
}
public static double code(double x, double y, double z) {
	double t_0 = y / (z / x);
	double tmp;
	if ((x * y) <= -2e+169) {
		tmp = t_0;
	} else if ((x * y) <= -1e-143) {
		tmp = (1.0 / (z + z)) / (0.5 / (y * x));
	} else if ((x * y) <= 2e-187) {
		tmp = x / (z / y);
	} else if ((x * y) <= 1e+270) {
		tmp = (x * y) / z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	return (x * y) / z
def code(x, y, z):
	t_0 = y / (z / x)
	tmp = 0
	if (x * y) <= -2e+169:
		tmp = t_0
	elif (x * y) <= -1e-143:
		tmp = (1.0 / (z + z)) / (0.5 / (y * x))
	elif (x * y) <= 2e-187:
		tmp = x / (z / y)
	elif (x * y) <= 1e+270:
		tmp = (x * y) / z
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	return Float64(Float64(x * y) / z)
end
function code(x, y, z)
	t_0 = Float64(y / Float64(z / x))
	tmp = 0.0
	if (Float64(x * y) <= -2e+169)
		tmp = t_0;
	elseif (Float64(x * y) <= -1e-143)
		tmp = Float64(Float64(1.0 / Float64(z + z)) / Float64(0.5 / Float64(y * x)));
	elseif (Float64(x * y) <= 2e-187)
		tmp = Float64(x / Float64(z / y));
	elseif (Float64(x * y) <= 1e+270)
		tmp = Float64(Float64(x * y) / z);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x * y) / z;
end
function tmp_2 = code(x, y, z)
	t_0 = y / (z / x);
	tmp = 0.0;
	if ((x * y) <= -2e+169)
		tmp = t_0;
	elseif ((x * y) <= -1e-143)
		tmp = (1.0 / (z + z)) / (0.5 / (y * x));
	elseif ((x * y) <= 2e-187)
		tmp = x / (z / y);
	elseif ((x * y) <= 1e+270)
		tmp = (x * y) / z;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -2e+169], t$95$0, If[LessEqual[N[(x * y), $MachinePrecision], -1e-143], N[(N[(1.0 / N[(z + z), $MachinePrecision]), $MachinePrecision] / N[(0.5 / N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e-187], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+270], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]]]
\frac{x \cdot y}{z}
\begin{array}{l}
t_0 := \frac{y}{\frac{z}{x}}\\
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+169}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-143}:\\
\;\;\;\;\frac{\frac{1}{z + z}}{\frac{0.5}{y \cdot x}}\\

\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-187}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

\mathbf{elif}\;x \cdot y \leq 10^{+270}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.2
Target6.3
Herbie0.7
\[\begin{array}{l} \mathbf{if}\;z < -4.262230790519429 \cdot 10^{-138}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;z < 1.7042130660650472 \cdot 10^{-164}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \end{array} \]

Derivation?

  1. Split input into 4 regimes
  2. if (*.f64 x y) < -1.99999999999999987e169 or 1e270 < (*.f64 x y)

    1. Initial program 28.2

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

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

      [Start]28.2

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

      rational.json-simplify-50 [=>]28.2

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

      rational.json-simplify-43 [=>]1.7

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

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

    if -1.99999999999999987e169 < (*.f64 x y) < -9.9999999999999995e-144

    1. Initial program 0.2

      \[\frac{x \cdot y}{z} \]
    2. Applied egg-rr11.5

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

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

    if -9.9999999999999995e-144 < (*.f64 x y) < 2e-187

    1. Initial program 9.4

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

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

      [Start]9.4

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

      rational.json-simplify-50 [=>]9.4

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

      rational.json-simplify-43 [=>]1.2

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

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
    4. Simplified1.2

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

      [Start]9.4

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

      rational.json-simplify-43 [=>]1.2

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

      rational.json-simplify-27 [<=]1.2

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

    if 2e-187 < (*.f64 x y) < 1e270

    1. Initial program 0.2

      \[\frac{x \cdot y}{z} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+169}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-143}:\\ \;\;\;\;\frac{\frac{1}{z + z}}{\frac{0.5}{y \cdot x}}\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-187}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \leq 10^{+270}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]

Alternatives

Alternative 1
Error0.6
Cost1360
\[\begin{array}{l} t_0 := \frac{y}{\frac{z}{x}}\\ t_1 := \frac{x \cdot y}{z}\\ \mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+169}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{-170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-187}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \leq 10^{+270}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error6.2
Cost584
\[\begin{array}{l} t_0 := x \cdot \frac{y}{z}\\ \mathbf{if}\;x \leq 1.85 \cdot 10^{-277}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-163}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error6.1
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq 1.45 \cdot 10^{-277}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-162}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \]
Alternative 4
Error6.4
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{+238}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \leq -4.4 \cdot 10^{+54}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \]
Alternative 5
Error6.3
Cost320
\[x \cdot \frac{y}{z} \]

Error

Reproduce?

herbie shell --seed 2023073 
(FPCore (x y z)
  :name "Diagrams.Solve.Tridiagonal:solveCyclicTriDiagonal from diagrams-solve-0.1, A"
  :precision binary64

  :herbie-target
  (if (< z -4.262230790519429e-138) (/ (* x y) z) (if (< z 1.7042130660650472e-164) (/ x (/ z y)) (* (/ x z) y)))

  (/ (* x y) z))