Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, B

Percentage Accurate: 81.1% → 97.7%
Time: 3.7s
Alternatives: 6
Speedup: 1.8×

Specification

?
\[\begin{array}{l} \\ x \cdot \frac{\frac{y}{z} \cdot t}{t} \end{array} \]
(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
double code(double x, double y, double z, double t) {
	return x * (((y / z) * t) / t);
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x * (((y / z) * t) / t)
end function
public static double code(double x, double y, double z, double t) {
	return x * (((y / z) * t) / t);
}
def code(x, y, z, t):
	return x * (((y / z) * t) / t)
function code(x, y, z, t)
	return Float64(x * Float64(Float64(Float64(y / z) * t) / t))
end
function tmp = code(x, y, z, t)
	tmp = x * (((y / z) * t) / t);
end
code[x_, y_, z_, t_] := N[(x * N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 81.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \frac{\frac{y}{z} \cdot t}{t} \end{array} \]
(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
double code(double x, double y, double z, double t) {
	return x * (((y / z) * t) / t);
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x * (((y / z) * t) / t)
end function
public static double code(double x, double y, double z, double t) {
	return x * (((y / z) * t) / t);
}
def code(x, y, z, t):
	return x * (((y / z) * t) / t)
function code(x, y, z, t)
	return Float64(x * Float64(Float64(Float64(y / z) * t) / t))
end
function tmp = code(x, y, z, t)
	tmp = x * (((y / z) * t) / t);
end
code[x_, y_, z_, t_] := N[(x * N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\end{array}

Alternative 1: 97.7% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -5 \cdot 10^{+123}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq -5 \cdot 10^{-296} \lor \neg \left(\frac{y}{z} \leq 10^{-259}\right):\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{1}{z}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= (/ y z) -5e+123)
   (/ (* y x) z)
   (if (or (<= (/ y z) -5e-296) (not (<= (/ y z) 1e-259)))
     (/ x (/ z y))
     (* (* y x) (/ 1.0 z)))))
assert(x < y);
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y / z) <= -5e+123) {
		tmp = (y * x) / z;
	} else if (((y / z) <= -5e-296) || !((y / z) <= 1e-259)) {
		tmp = x / (z / y);
	} else {
		tmp = (y * x) * (1.0 / z);
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((y / z) <= (-5d+123)) then
        tmp = (y * x) / z
    else if (((y / z) <= (-5d-296)) .or. (.not. ((y / z) <= 1d-259))) then
        tmp = x / (z / y)
    else
        tmp = (y * x) * (1.0d0 / z)
    end if
    code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((y / z) <= -5e+123) {
		tmp = (y * x) / z;
	} else if (((y / z) <= -5e-296) || !((y / z) <= 1e-259)) {
		tmp = x / (z / y);
	} else {
		tmp = (y * x) * (1.0 / z);
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z, t):
	tmp = 0
	if (y / z) <= -5e+123:
		tmp = (y * x) / z
	elif ((y / z) <= -5e-296) or not ((y / z) <= 1e-259):
		tmp = x / (z / y)
	else:
		tmp = (y * x) * (1.0 / z)
	return tmp
x, y = sort([x, y])
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(y / z) <= -5e+123)
		tmp = Float64(Float64(y * x) / z);
	elseif ((Float64(y / z) <= -5e-296) || !(Float64(y / z) <= 1e-259))
		tmp = Float64(x / Float64(z / y));
	else
		tmp = Float64(Float64(y * x) * Float64(1.0 / z));
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((y / z) <= -5e+123)
		tmp = (y * x) / z;
	elseif (((y / z) <= -5e-296) || ~(((y / z) <= 1e-259)))
		tmp = x / (z / y);
	else
		tmp = (y * x) * (1.0 / z);
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[N[(y / z), $MachinePrecision], -5e+123], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision], If[Or[LessEqual[N[(y / z), $MachinePrecision], -5e-296], N[Not[LessEqual[N[(y / z), $MachinePrecision], 1e-259]], $MachinePrecision]], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \leq -5 \cdot 10^{+123}:\\
\;\;\;\;\frac{y \cdot x}{z}\\

\mathbf{elif}\;\frac{y}{z} \leq -5 \cdot 10^{-296} \lor \neg \left(\frac{y}{z} \leq 10^{-259}\right):\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

\mathbf{else}:\\
\;\;\;\;\left(y \cdot x\right) \cdot \frac{1}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 y z) < -4.99999999999999974e123

    1. Initial program 83.7%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Taylor expanded in x around 0 99.9%

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

    if -4.99999999999999974e123 < (/.f64 y z) < -5.0000000000000003e-296 or 1.0000000000000001e-259 < (/.f64 y z)

    1. Initial program 87.6%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Step-by-step derivation
      1. clear-num87.4%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{t}{\frac{y}{z} \cdot t}}} \]
      2. un-div-inv87.5%

        \[\leadsto \color{blue}{\frac{x}{\frac{t}{\frac{y}{z} \cdot t}}} \]
      3. *-commutative87.5%

        \[\leadsto \frac{x}{\frac{t}{\color{blue}{t \cdot \frac{y}{z}}}} \]
      4. associate-/r*98.6%

        \[\leadsto \frac{x}{\color{blue}{\frac{\frac{t}{t}}{\frac{y}{z}}}} \]
      5. *-inverses98.6%

        \[\leadsto \frac{x}{\frac{\color{blue}{1}}{\frac{y}{z}}} \]
      6. clear-num98.7%

        \[\leadsto \frac{x}{\color{blue}{\frac{z}{y}}} \]
    3. Applied egg-rr98.7%

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

    if -5.0000000000000003e-296 < (/.f64 y z) < 1.0000000000000001e-259

    1. Initial program 75.5%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Taylor expanded in x around 0 99.9%

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
    3. Step-by-step derivation
      1. div-inv99.9%

        \[\leadsto \color{blue}{\left(y \cdot x\right) \cdot \frac{1}{z}} \]
      2. *-commutative99.9%

        \[\leadsto \color{blue}{\frac{1}{z} \cdot \left(y \cdot x\right)} \]
    4. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\frac{1}{z} \cdot \left(y \cdot x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.0%

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

Alternative 2: 97.7% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty \lor \neg \left(\frac{y}{z} \leq -1 \cdot 10^{-140}\right) \land \frac{y}{z} \leq 2 \cdot 10^{-310}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (or (<= (/ y z) (- INFINITY))
         (and (not (<= (/ y z) -1e-140)) (<= (/ y z) 2e-310)))
   (* y (/ x z))
   (* (/ y z) x)))
assert(x < y);
double code(double x, double y, double z, double t) {
	double tmp;
	if (((y / z) <= -((double) INFINITY)) || (!((y / z) <= -1e-140) && ((y / z) <= 2e-310))) {
		tmp = y * (x / z);
	} else {
		tmp = (y / z) * x;
	}
	return tmp;
}
assert x < y;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (((y / z) <= -Double.POSITIVE_INFINITY) || (!((y / z) <= -1e-140) && ((y / z) <= 2e-310))) {
		tmp = y * (x / z);
	} else {
		tmp = (y / z) * x;
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z, t):
	tmp = 0
	if ((y / z) <= -math.inf) or (not ((y / z) <= -1e-140) and ((y / z) <= 2e-310)):
		tmp = y * (x / z)
	else:
		tmp = (y / z) * x
	return tmp
x, y = sort([x, y])
function code(x, y, z, t)
	tmp = 0.0
	if ((Float64(y / z) <= Float64(-Inf)) || (!(Float64(y / z) <= -1e-140) && (Float64(y / z) <= 2e-310)))
		tmp = Float64(y * Float64(x / z));
	else
		tmp = Float64(Float64(y / z) * x);
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (((y / z) <= -Inf) || (~(((y / z) <= -1e-140)) && ((y / z) <= 2e-310)))
		tmp = y * (x / z);
	else
		tmp = (y / z) * x;
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(y / z), $MachinePrecision], (-Infinity)], And[N[Not[LessEqual[N[(y / z), $MachinePrecision], -1e-140]], $MachinePrecision], LessEqual[N[(y / z), $MachinePrecision], 2e-310]]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \leq -\infty \lor \neg \left(\frac{y}{z} \leq -1 \cdot 10^{-140}\right) \land \frac{y}{z} \leq 2 \cdot 10^{-310}:\\
\;\;\;\;y \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 y z) < -inf.0 or -9.9999999999999998e-141 < (/.f64 y z) < 1.999999999999994e-310

    1. Initial program 78.8%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Taylor expanded in x around 0 98.6%

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
    3. Step-by-step derivation
      1. *-commutative98.6%

        \[\leadsto \frac{\color{blue}{x \cdot y}}{z} \]
      2. associate-*l/99.5%

        \[\leadsto \color{blue}{\frac{x}{z} \cdot y} \]
    4. Applied egg-rr99.5%

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

    if -inf.0 < (/.f64 y z) < -9.9999999999999998e-141 or 1.999999999999994e-310 < (/.f64 y z)

    1. Initial program 87.9%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Taylor expanded in x around 0 90.7%

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
    3. Step-by-step derivation
      1. associate-*l/98.7%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x} \]
    4. Simplified98.7%

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty \lor \neg \left(\frac{y}{z} \leq -1 \cdot 10^{-140}\right) \land \frac{y}{z} \leq 2 \cdot 10^{-310}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \]

Alternative 3: 98.0% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -1 \cdot 10^{+298} \lor \neg \left(\frac{y}{z} \leq -2 \cdot 10^{-278}\right) \land \frac{y}{z} \leq 2 \cdot 10^{-176}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (or (<= (/ y z) -1e+298)
         (and (not (<= (/ y z) -2e-278)) (<= (/ y z) 2e-176)))
   (* y (/ x z))
   (/ x (/ z y))))
assert(x < y);
double code(double x, double y, double z, double t) {
	double tmp;
	if (((y / z) <= -1e+298) || (!((y / z) <= -2e-278) && ((y / z) <= 2e-176))) {
		tmp = y * (x / z);
	} else {
		tmp = x / (z / y);
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (((y / z) <= (-1d+298)) .or. (.not. ((y / z) <= (-2d-278))) .and. ((y / z) <= 2d-176)) then
        tmp = y * (x / z)
    else
        tmp = x / (z / y)
    end if
    code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (((y / z) <= -1e+298) || (!((y / z) <= -2e-278) && ((y / z) <= 2e-176))) {
		tmp = y * (x / z);
	} else {
		tmp = x / (z / y);
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z, t):
	tmp = 0
	if ((y / z) <= -1e+298) or (not ((y / z) <= -2e-278) and ((y / z) <= 2e-176)):
		tmp = y * (x / z)
	else:
		tmp = x / (z / y)
	return tmp
x, y = sort([x, y])
function code(x, y, z, t)
	tmp = 0.0
	if ((Float64(y / z) <= -1e+298) || (!(Float64(y / z) <= -2e-278) && (Float64(y / z) <= 2e-176)))
		tmp = Float64(y * Float64(x / z));
	else
		tmp = Float64(x / Float64(z / y));
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (((y / z) <= -1e+298) || (~(((y / z) <= -2e-278)) && ((y / z) <= 2e-176)))
		tmp = y * (x / z);
	else
		tmp = x / (z / y);
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(y / z), $MachinePrecision], -1e+298], And[N[Not[LessEqual[N[(y / z), $MachinePrecision], -2e-278]], $MachinePrecision], LessEqual[N[(y / z), $MachinePrecision], 2e-176]]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \leq -1 \cdot 10^{+298} \lor \neg \left(\frac{y}{z} \leq -2 \cdot 10^{-278}\right) \land \frac{y}{z} \leq 2 \cdot 10^{-176}:\\
\;\;\;\;y \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 y z) < -9.9999999999999996e297 or -1.99999999999999988e-278 < (/.f64 y z) < 2e-176

    1. Initial program 75.4%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Taylor expanded in x around 0 99.9%

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
    3. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \frac{\color{blue}{x \cdot y}}{z} \]
      2. associate-*l/99.9%

        \[\leadsto \color{blue}{\frac{x}{z} \cdot y} \]
    4. Applied egg-rr99.9%

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

    if -9.9999999999999996e297 < (/.f64 y z) < -1.99999999999999988e-278 or 2e-176 < (/.f64 y z)

    1. Initial program 88.3%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Step-by-step derivation
      1. clear-num88.2%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{t}{\frac{y}{z} \cdot t}}} \]
      2. un-div-inv88.2%

        \[\leadsto \color{blue}{\frac{x}{\frac{t}{\frac{y}{z} \cdot t}}} \]
      3. *-commutative88.2%

        \[\leadsto \frac{x}{\frac{t}{\color{blue}{t \cdot \frac{y}{z}}}} \]
      4. associate-/r*98.7%

        \[\leadsto \frac{x}{\color{blue}{\frac{\frac{t}{t}}{\frac{y}{z}}}} \]
      5. *-inverses98.7%

        \[\leadsto \frac{x}{\frac{\color{blue}{1}}{\frac{y}{z}}} \]
      6. clear-num98.8%

        \[\leadsto \frac{x}{\color{blue}{\frac{z}{y}}} \]
    3. Applied egg-rr98.8%

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -1 \cdot 10^{+298} \lor \neg \left(\frac{y}{z} \leq -2 \cdot 10^{-278}\right) \land \frac{y}{z} \leq 2 \cdot 10^{-176}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \]

Alternative 4: 98.1% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -1 \cdot 10^{+298} \lor \neg \left(\frac{y}{z} \leq -2 \cdot 10^{-278}\right) \land \frac{y}{z} \leq 5 \cdot 10^{-193}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (or (<= (/ y z) -1e+298)
         (and (not (<= (/ y z) -2e-278)) (<= (/ y z) 5e-193)))
   (/ y (/ z x))
   (/ x (/ z y))))
assert(x < y);
double code(double x, double y, double z, double t) {
	double tmp;
	if (((y / z) <= -1e+298) || (!((y / z) <= -2e-278) && ((y / z) <= 5e-193))) {
		tmp = y / (z / x);
	} else {
		tmp = x / (z / y);
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (((y / z) <= (-1d+298)) .or. (.not. ((y / z) <= (-2d-278))) .and. ((y / z) <= 5d-193)) then
        tmp = y / (z / x)
    else
        tmp = x / (z / y)
    end if
    code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (((y / z) <= -1e+298) || (!((y / z) <= -2e-278) && ((y / z) <= 5e-193))) {
		tmp = y / (z / x);
	} else {
		tmp = x / (z / y);
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z, t):
	tmp = 0
	if ((y / z) <= -1e+298) or (not ((y / z) <= -2e-278) and ((y / z) <= 5e-193)):
		tmp = y / (z / x)
	else:
		tmp = x / (z / y)
	return tmp
x, y = sort([x, y])
function code(x, y, z, t)
	tmp = 0.0
	if ((Float64(y / z) <= -1e+298) || (!(Float64(y / z) <= -2e-278) && (Float64(y / z) <= 5e-193)))
		tmp = Float64(y / Float64(z / x));
	else
		tmp = Float64(x / Float64(z / y));
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (((y / z) <= -1e+298) || (~(((y / z) <= -2e-278)) && ((y / z) <= 5e-193)))
		tmp = y / (z / x);
	else
		tmp = x / (z / y);
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(y / z), $MachinePrecision], -1e+298], And[N[Not[LessEqual[N[(y / z), $MachinePrecision], -2e-278]], $MachinePrecision], LessEqual[N[(y / z), $MachinePrecision], 5e-193]]], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \leq -1 \cdot 10^{+298} \lor \neg \left(\frac{y}{z} \leq -2 \cdot 10^{-278}\right) \land \frac{y}{z} \leq 5 \cdot 10^{-193}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 y z) < -9.9999999999999996e297 or -1.99999999999999988e-278 < (/.f64 y z) < 5.0000000000000005e-193

    1. Initial program 75.0%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Taylor expanded in x around 0 99.9%

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
    3. Step-by-step derivation
      1. associate-*l/81.5%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x} \]
    4. Simplified81.5%

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x} \]
    5. Step-by-step derivation
      1. associate-/r/99.9%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
    6. Applied egg-rr99.9%

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

    if -9.9999999999999996e297 < (/.f64 y z) < -1.99999999999999988e-278 or 5.0000000000000005e-193 < (/.f64 y z)

    1. Initial program 88.4%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Step-by-step derivation
      1. clear-num88.2%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{t}{\frac{y}{z} \cdot t}}} \]
      2. un-div-inv88.3%

        \[\leadsto \color{blue}{\frac{x}{\frac{t}{\frac{y}{z} \cdot t}}} \]
      3. *-commutative88.3%

        \[\leadsto \frac{x}{\frac{t}{\color{blue}{t \cdot \frac{y}{z}}}} \]
      4. associate-/r*98.7%

        \[\leadsto \frac{x}{\color{blue}{\frac{\frac{t}{t}}{\frac{y}{z}}}} \]
      5. *-inverses98.7%

        \[\leadsto \frac{x}{\frac{\color{blue}{1}}{\frac{y}{z}}} \]
      6. clear-num98.8%

        \[\leadsto \frac{x}{\color{blue}{\frac{z}{y}}} \]
    3. Applied egg-rr98.8%

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.0%

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

Alternative 5: 97.7% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -5 \cdot 10^{+123}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq -2 \cdot 10^{-278} \lor \neg \left(\frac{y}{z} \leq 5 \cdot 10^{-193}\right):\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= (/ y z) -5e+123)
   (/ (* y x) z)
   (if (or (<= (/ y z) -2e-278) (not (<= (/ y z) 5e-193)))
     (/ x (/ z y))
     (/ y (/ z x)))))
assert(x < y);
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y / z) <= -5e+123) {
		tmp = (y * x) / z;
	} else if (((y / z) <= -2e-278) || !((y / z) <= 5e-193)) {
		tmp = x / (z / y);
	} else {
		tmp = y / (z / x);
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((y / z) <= (-5d+123)) then
        tmp = (y * x) / z
    else if (((y / z) <= (-2d-278)) .or. (.not. ((y / z) <= 5d-193))) then
        tmp = x / (z / y)
    else
        tmp = y / (z / x)
    end if
    code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((y / z) <= -5e+123) {
		tmp = (y * x) / z;
	} else if (((y / z) <= -2e-278) || !((y / z) <= 5e-193)) {
		tmp = x / (z / y);
	} else {
		tmp = y / (z / x);
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z, t):
	tmp = 0
	if (y / z) <= -5e+123:
		tmp = (y * x) / z
	elif ((y / z) <= -2e-278) or not ((y / z) <= 5e-193):
		tmp = x / (z / y)
	else:
		tmp = y / (z / x)
	return tmp
x, y = sort([x, y])
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(y / z) <= -5e+123)
		tmp = Float64(Float64(y * x) / z);
	elseif ((Float64(y / z) <= -2e-278) || !(Float64(y / z) <= 5e-193))
		tmp = Float64(x / Float64(z / y));
	else
		tmp = Float64(y / Float64(z / x));
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((y / z) <= -5e+123)
		tmp = (y * x) / z;
	elseif (((y / z) <= -2e-278) || ~(((y / z) <= 5e-193)))
		tmp = x / (z / y);
	else
		tmp = y / (z / x);
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[N[(y / z), $MachinePrecision], -5e+123], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision], If[Or[LessEqual[N[(y / z), $MachinePrecision], -2e-278], N[Not[LessEqual[N[(y / z), $MachinePrecision], 5e-193]], $MachinePrecision]], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \leq -5 \cdot 10^{+123}:\\
\;\;\;\;\frac{y \cdot x}{z}\\

\mathbf{elif}\;\frac{y}{z} \leq -2 \cdot 10^{-278} \lor \neg \left(\frac{y}{z} \leq 5 \cdot 10^{-193}\right):\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 y z) < -4.99999999999999974e123

    1. Initial program 83.7%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Taylor expanded in x around 0 99.9%

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

    if -4.99999999999999974e123 < (/.f64 y z) < -1.99999999999999988e-278 or 5.0000000000000005e-193 < (/.f64 y z)

    1. Initial program 87.7%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Step-by-step derivation
      1. clear-num87.6%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{t}{\frac{y}{z} \cdot t}}} \]
      2. un-div-inv87.6%

        \[\leadsto \color{blue}{\frac{x}{\frac{t}{\frac{y}{z} \cdot t}}} \]
      3. *-commutative87.6%

        \[\leadsto \frac{x}{\frac{t}{\color{blue}{t \cdot \frac{y}{z}}}} \]
      4. associate-/r*98.6%

        \[\leadsto \frac{x}{\color{blue}{\frac{\frac{t}{t}}{\frac{y}{z}}}} \]
      5. *-inverses98.6%

        \[\leadsto \frac{x}{\frac{\color{blue}{1}}{\frac{y}{z}}} \]
      6. clear-num98.7%

        \[\leadsto \frac{x}{\color{blue}{\frac{z}{y}}} \]
    3. Applied egg-rr98.7%

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

    if -1.99999999999999988e-278 < (/.f64 y z) < 5.0000000000000005e-193

    1. Initial program 76.7%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Taylor expanded in x around 0 99.9%

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
    3. Step-by-step derivation
      1. associate-*l/83.4%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x} \]
    4. Simplified83.4%

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x} \]
    5. Step-by-step derivation
      1. associate-/r/99.9%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
    6. Applied egg-rr99.9%

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

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

Alternative 6: 92.3% accurate, 1.8× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ y \cdot \frac{x}{z} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t) :precision binary64 (* y (/ x z)))
assert(x < y);
double code(double x, double y, double z, double t) {
	return y * (x / z);
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = y * (x / z)
end function
assert x < y;
public static double code(double x, double y, double z, double t) {
	return y * (x / z);
}
[x, y] = sort([x, y])
def code(x, y, z, t):
	return y * (x / z)
x, y = sort([x, y])
function code(x, y, z, t)
	return Float64(y * Float64(x / z))
end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z, t)
	tmp = y * (x / z);
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
y \cdot \frac{x}{z}
\end{array}
Derivation
  1. Initial program 85.3%

    \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
  2. Taylor expanded in x around 0 92.9%

    \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
  3. Step-by-step derivation
    1. *-commutative92.9%

      \[\leadsto \frac{\color{blue}{x \cdot y}}{z} \]
    2. associate-*l/89.8%

      \[\leadsto \color{blue}{\frac{x}{z} \cdot y} \]
  4. Applied egg-rr89.8%

    \[\leadsto \color{blue}{\frac{x}{z} \cdot y} \]
  5. Final simplification89.8%

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

Developer target: 97.8% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \frac{y}{z}\\ t_2 := \frac{\frac{y}{z} \cdot t}{t}\\ t_3 := \frac{y}{\frac{z}{x}}\\ \mathbf{if}\;t_2 < -1.20672205123045 \cdot 10^{+245}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 < -5.907522236933906 \cdot 10^{-275}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 < 5.658954423153415 \cdot 10^{-65}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 < 2.0087180502407133 \cdot 10^{+217}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (/ y z))) (t_2 (/ (* (/ y z) t) t)) (t_3 (/ y (/ z x))))
   (if (< t_2 -1.20672205123045e+245)
     t_3
     (if (< t_2 -5.907522236933906e-275)
       t_1
       (if (< t_2 5.658954423153415e-65)
         t_3
         (if (< t_2 2.0087180502407133e+217) t_1 (/ (* y x) z)))))))
double code(double x, double y, double z, double t) {
	double t_1 = x * (y / z);
	double t_2 = ((y / z) * t) / t;
	double t_3 = y / (z / x);
	double tmp;
	if (t_2 < -1.20672205123045e+245) {
		tmp = t_3;
	} else if (t_2 < -5.907522236933906e-275) {
		tmp = t_1;
	} else if (t_2 < 5.658954423153415e-65) {
		tmp = t_3;
	} else if (t_2 < 2.0087180502407133e+217) {
		tmp = t_1;
	} else {
		tmp = (y * x) / z;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_1 = x * (y / z)
    t_2 = ((y / z) * t) / t
    t_3 = y / (z / x)
    if (t_2 < (-1.20672205123045d+245)) then
        tmp = t_3
    else if (t_2 < (-5.907522236933906d-275)) then
        tmp = t_1
    else if (t_2 < 5.658954423153415d-65) then
        tmp = t_3
    else if (t_2 < 2.0087180502407133d+217) then
        tmp = t_1
    else
        tmp = (y * x) / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * (y / z);
	double t_2 = ((y / z) * t) / t;
	double t_3 = y / (z / x);
	double tmp;
	if (t_2 < -1.20672205123045e+245) {
		tmp = t_3;
	} else if (t_2 < -5.907522236933906e-275) {
		tmp = t_1;
	} else if (t_2 < 5.658954423153415e-65) {
		tmp = t_3;
	} else if (t_2 < 2.0087180502407133e+217) {
		tmp = t_1;
	} else {
		tmp = (y * x) / z;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * (y / z)
	t_2 = ((y / z) * t) / t
	t_3 = y / (z / x)
	tmp = 0
	if t_2 < -1.20672205123045e+245:
		tmp = t_3
	elif t_2 < -5.907522236933906e-275:
		tmp = t_1
	elif t_2 < 5.658954423153415e-65:
		tmp = t_3
	elif t_2 < 2.0087180502407133e+217:
		tmp = t_1
	else:
		tmp = (y * x) / z
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * Float64(y / z))
	t_2 = Float64(Float64(Float64(y / z) * t) / t)
	t_3 = Float64(y / Float64(z / x))
	tmp = 0.0
	if (t_2 < -1.20672205123045e+245)
		tmp = t_3;
	elseif (t_2 < -5.907522236933906e-275)
		tmp = t_1;
	elseif (t_2 < 5.658954423153415e-65)
		tmp = t_3;
	elseif (t_2 < 2.0087180502407133e+217)
		tmp = t_1;
	else
		tmp = Float64(Float64(y * x) / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * (y / z);
	t_2 = ((y / z) * t) / t;
	t_3 = y / (z / x);
	tmp = 0.0;
	if (t_2 < -1.20672205123045e+245)
		tmp = t_3;
	elseif (t_2 < -5.907522236933906e-275)
		tmp = t_1;
	elseif (t_2 < 5.658954423153415e-65)
		tmp = t_3;
	elseif (t_2 < 2.0087180502407133e+217)
		tmp = t_1;
	else
		tmp = (y * x) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]}, Block[{t$95$3 = N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$2, -1.20672205123045e+245], t$95$3, If[Less[t$95$2, -5.907522236933906e-275], t$95$1, If[Less[t$95$2, 5.658954423153415e-65], t$95$3, If[Less[t$95$2, 2.0087180502407133e+217], t$95$1, N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \frac{y}{z}\\
t_2 := \frac{\frac{y}{z} \cdot t}{t}\\
t_3 := \frac{y}{\frac{z}{x}}\\
\mathbf{if}\;t_2 < -1.20672205123045 \cdot 10^{+245}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_2 < -5.907522236933906 \cdot 10^{-275}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 < 5.658954423153415 \cdot 10^{-65}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_2 < 2.0087180502407133 \cdot 10^{+217}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}

Reproduce

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