Statistics.Math.RootFinding:ridders from math-functions-0.1.5.2

Percentage Accurate: 61.0% → 79.6%
Time: 15.2s
Alternatives: 4
Speedup: 37.7×

Specification

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

\\
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\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 4 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: 61.0% accurate, 1.0× speedup?

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

\\
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\end{array}

Alternative 1: 79.6% accurate, 1.0× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ z_s = \mathsf{copysign}\left(1, z\right) \\ [x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\\\ [x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\ \\ z\_s \cdot \left(y \cdot \frac{x}{\frac{\mathsf{fma}\left(a \cdot \frac{t}{z\_m}, -0.5, z\_m\right)}{z\_m}}\right) \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
(FPCore (z_s x y z_m t a)
 :precision binary64
 (* z_s (* y (/ x (/ (fma (* a (/ t z_m)) -0.5 z_m) z_m)))))
z_m = fabs(z);
z_s = copysign(1.0, z);
assert(x < y && y < z_m && z_m < t && t < a);
assert(x < y && y < z_m && z_m < t && t < a);
double code(double z_s, double x, double y, double z_m, double t, double a) {
	return z_s * (y * (x / (fma((a * (t / z_m)), -0.5, z_m) / z_m)));
}
z_m = abs(z)
z_s = copysign(1.0, z)
x, y, z_m, t, a = sort([x, y, z_m, t, a])
x, y, z_m, t, a = sort([x, y, z_m, t, a])
function code(z_s, x, y, z_m, t, a)
	return Float64(z_s * Float64(y * Float64(x / Float64(fma(Float64(a * Float64(t / z_m)), -0.5, z_m) / z_m))))
end
z_m = N[Abs[z], $MachinePrecision]
z_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
code[z$95$s_, x_, y_, z$95$m_, t_, a_] := N[(z$95$s * N[(y * N[(x / N[(N[(N[(a * N[(t / z$95$m), $MachinePrecision]), $MachinePrecision] * -0.5 + z$95$m), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
[x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\\\
[x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\
\\
z\_s \cdot \left(y \cdot \frac{x}{\frac{\mathsf{fma}\left(a \cdot \frac{t}{z\_m}, -0.5, z\_m\right)}{z\_m}}\right)
\end{array}
Derivation
  1. Initial program 63.7%

    \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
  2. Step-by-step derivation
    1. associate-/l*65.7%

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

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

      \[\leadsto \color{blue}{y \cdot \frac{x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \]
    4. associate-/l*64.0%

      \[\leadsto y \cdot \color{blue}{\frac{x \cdot z}{\sqrt{z \cdot z - t \cdot a}}} \]
  3. Simplified64.0%

    \[\leadsto \color{blue}{y \cdot \frac{x \cdot z}{\sqrt{z \cdot z - t \cdot a}}} \]
  4. Add Preprocessing
  5. Taylor expanded in z around inf 45.1%

    \[\leadsto y \cdot \frac{x \cdot z}{\color{blue}{z + -0.5 \cdot \frac{a \cdot t}{z}}} \]
  6. Step-by-step derivation
    1. associate-/l*45.1%

      \[\leadsto y \cdot \frac{x \cdot z}{z + -0.5 \cdot \color{blue}{\frac{a}{\frac{z}{t}}}} \]
  7. Simplified45.1%

    \[\leadsto y \cdot \frac{x \cdot z}{\color{blue}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}} \]
  8. Step-by-step derivation
    1. associate-/l*49.3%

      \[\leadsto y \cdot \color{blue}{\frac{x}{\frac{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}{z}}} \]
    2. div-inv49.3%

      \[\leadsto y \cdot \color{blue}{\left(x \cdot \frac{1}{\frac{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}{z}}\right)} \]
    3. +-commutative49.3%

      \[\leadsto y \cdot \left(x \cdot \frac{1}{\frac{\color{blue}{-0.5 \cdot \frac{a}{\frac{z}{t}} + z}}{z}}\right) \]
    4. fma-def49.3%

      \[\leadsto y \cdot \left(x \cdot \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(-0.5, \frac{a}{\frac{z}{t}}, z\right)}}{z}}\right) \]
    5. associate-/r/49.3%

      \[\leadsto y \cdot \left(x \cdot \frac{1}{\frac{\mathsf{fma}\left(-0.5, \color{blue}{\frac{a}{z} \cdot t}, z\right)}{z}}\right) \]
  9. Applied egg-rr49.3%

    \[\leadsto y \cdot \color{blue}{\left(x \cdot \frac{1}{\frac{\mathsf{fma}\left(-0.5, \frac{a}{z} \cdot t, z\right)}{z}}\right)} \]
  10. Step-by-step derivation
    1. un-div-inv49.3%

      \[\leadsto y \cdot \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(-0.5, \frac{a}{z} \cdot t, z\right)}{z}}} \]
    2. fma-udef49.3%

      \[\leadsto y \cdot \frac{x}{\frac{\color{blue}{-0.5 \cdot \left(\frac{a}{z} \cdot t\right) + z}}{z}} \]
    3. *-commutative49.3%

      \[\leadsto y \cdot \frac{x}{\frac{\color{blue}{\left(\frac{a}{z} \cdot t\right) \cdot -0.5} + z}{z}} \]
    4. fma-def49.3%

      \[\leadsto y \cdot \frac{x}{\frac{\color{blue}{\mathsf{fma}\left(\frac{a}{z} \cdot t, -0.5, z\right)}}{z}} \]
    5. associate-*l/49.3%

      \[\leadsto y \cdot \frac{x}{\frac{\mathsf{fma}\left(\color{blue}{\frac{a \cdot t}{z}}, -0.5, z\right)}{z}} \]
    6. associate-*r/49.3%

      \[\leadsto y \cdot \frac{x}{\frac{\mathsf{fma}\left(\color{blue}{a \cdot \frac{t}{z}}, -0.5, z\right)}{z}} \]
  11. Applied egg-rr49.3%

    \[\leadsto y \cdot \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(a \cdot \frac{t}{z}, -0.5, z\right)}{z}}} \]
  12. Final simplification49.3%

    \[\leadsto y \cdot \frac{x}{\frac{\mathsf{fma}\left(a \cdot \frac{t}{z}, -0.5, z\right)}{z}} \]
  13. Add Preprocessing

Alternative 2: 69.5% accurate, 7.5× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ z_s = \mathsf{copysign}\left(1, z\right) \\ [x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\\\ [x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\ \\ z\_s \cdot \left(y \cdot \frac{x \cdot z\_m}{z\_m + \left(a \cdot \frac{t}{z\_m}\right) \cdot -0.5}\right) \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
(FPCore (z_s x y z_m t a)
 :precision binary64
 (* z_s (* y (/ (* x z_m) (+ z_m (* (* a (/ t z_m)) -0.5))))))
z_m = fabs(z);
z_s = copysign(1.0, z);
assert(x < y && y < z_m && z_m < t && t < a);
assert(x < y && y < z_m && z_m < t && t < a);
double code(double z_s, double x, double y, double z_m, double t, double a) {
	return z_s * (y * ((x * z_m) / (z_m + ((a * (t / z_m)) * -0.5))));
}
z_m = abs(z)
z_s = copysign(1.0d0, z)
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
real(8) function code(z_s, x, y, z_m, t, a)
    real(8), intent (in) :: z_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = z_s * (y * ((x * z_m) / (z_m + ((a * (t / z_m)) * (-0.5d0)))))
end function
z_m = Math.abs(z);
z_s = Math.copySign(1.0, z);
assert x < y && y < z_m && z_m < t && t < a;
assert x < y && y < z_m && z_m < t && t < a;
public static double code(double z_s, double x, double y, double z_m, double t, double a) {
	return z_s * (y * ((x * z_m) / (z_m + ((a * (t / z_m)) * -0.5))));
}
z_m = math.fabs(z)
z_s = math.copysign(1.0, z)
[x, y, z_m, t, a] = sort([x, y, z_m, t, a])
[x, y, z_m, t, a] = sort([x, y, z_m, t, a])
def code(z_s, x, y, z_m, t, a):
	return z_s * (y * ((x * z_m) / (z_m + ((a * (t / z_m)) * -0.5))))
z_m = abs(z)
z_s = copysign(1.0, z)
x, y, z_m, t, a = sort([x, y, z_m, t, a])
x, y, z_m, t, a = sort([x, y, z_m, t, a])
function code(z_s, x, y, z_m, t, a)
	return Float64(z_s * Float64(y * Float64(Float64(x * z_m) / Float64(z_m + Float64(Float64(a * Float64(t / z_m)) * -0.5)))))
end
z_m = abs(z);
z_s = sign(z) * abs(1.0);
x, y, z_m, t, a = num2cell(sort([x, y, z_m, t, a])){:}
x, y, z_m, t, a = num2cell(sort([x, y, z_m, t, a])){:}
function tmp = code(z_s, x, y, z_m, t, a)
	tmp = z_s * (y * ((x * z_m) / (z_m + ((a * (t / z_m)) * -0.5))));
end
z_m = N[Abs[z], $MachinePrecision]
z_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
code[z$95$s_, x_, y_, z$95$m_, t_, a_] := N[(z$95$s * N[(y * N[(N[(x * z$95$m), $MachinePrecision] / N[(z$95$m + N[(N[(a * N[(t / z$95$m), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
[x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\\\
[x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\
\\
z\_s \cdot \left(y \cdot \frac{x \cdot z\_m}{z\_m + \left(a \cdot \frac{t}{z\_m}\right) \cdot -0.5}\right)
\end{array}
Derivation
  1. Initial program 63.7%

    \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
  2. Step-by-step derivation
    1. associate-/l*65.7%

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

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

      \[\leadsto \color{blue}{y \cdot \frac{x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \]
    4. associate-/l*64.0%

      \[\leadsto y \cdot \color{blue}{\frac{x \cdot z}{\sqrt{z \cdot z - t \cdot a}}} \]
  3. Simplified64.0%

    \[\leadsto \color{blue}{y \cdot \frac{x \cdot z}{\sqrt{z \cdot z - t \cdot a}}} \]
  4. Add Preprocessing
  5. Taylor expanded in z around inf 45.1%

    \[\leadsto y \cdot \frac{x \cdot z}{\color{blue}{z + -0.5 \cdot \frac{a \cdot t}{z}}} \]
  6. Step-by-step derivation
    1. associate-/l*45.1%

      \[\leadsto y \cdot \frac{x \cdot z}{z + -0.5 \cdot \color{blue}{\frac{a}{\frac{z}{t}}}} \]
  7. Simplified45.1%

    \[\leadsto y \cdot \frac{x \cdot z}{\color{blue}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}} \]
  8. Taylor expanded in a around 0 45.1%

    \[\leadsto y \cdot \frac{x \cdot z}{z + -0.5 \cdot \color{blue}{\frac{a \cdot t}{z}}} \]
  9. Step-by-step derivation
    1. associate-*r/45.1%

      \[\leadsto y \cdot \frac{x \cdot z}{z + -0.5 \cdot \color{blue}{\left(a \cdot \frac{t}{z}\right)}} \]
  10. Simplified45.1%

    \[\leadsto y \cdot \frac{x \cdot z}{z + -0.5 \cdot \color{blue}{\left(a \cdot \frac{t}{z}\right)}} \]
  11. Final simplification45.1%

    \[\leadsto y \cdot \frac{x \cdot z}{z + \left(a \cdot \frac{t}{z}\right) \cdot -0.5} \]
  12. Add Preprocessing

Alternative 3: 65.9% accurate, 16.1× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ z_s = \mathsf{copysign}\left(1, z\right) \\ [x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\\\ [x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\ \\ z\_s \cdot \left(y \cdot \frac{x \cdot z\_m}{z\_m}\right) \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
(FPCore (z_s x y z_m t a) :precision binary64 (* z_s (* y (/ (* x z_m) z_m))))
z_m = fabs(z);
z_s = copysign(1.0, z);
assert(x < y && y < z_m && z_m < t && t < a);
assert(x < y && y < z_m && z_m < t && t < a);
double code(double z_s, double x, double y, double z_m, double t, double a) {
	return z_s * (y * ((x * z_m) / z_m));
}
z_m = abs(z)
z_s = copysign(1.0d0, z)
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
real(8) function code(z_s, x, y, z_m, t, a)
    real(8), intent (in) :: z_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = z_s * (y * ((x * z_m) / z_m))
end function
z_m = Math.abs(z);
z_s = Math.copySign(1.0, z);
assert x < y && y < z_m && z_m < t && t < a;
assert x < y && y < z_m && z_m < t && t < a;
public static double code(double z_s, double x, double y, double z_m, double t, double a) {
	return z_s * (y * ((x * z_m) / z_m));
}
z_m = math.fabs(z)
z_s = math.copysign(1.0, z)
[x, y, z_m, t, a] = sort([x, y, z_m, t, a])
[x, y, z_m, t, a] = sort([x, y, z_m, t, a])
def code(z_s, x, y, z_m, t, a):
	return z_s * (y * ((x * z_m) / z_m))
z_m = abs(z)
z_s = copysign(1.0, z)
x, y, z_m, t, a = sort([x, y, z_m, t, a])
x, y, z_m, t, a = sort([x, y, z_m, t, a])
function code(z_s, x, y, z_m, t, a)
	return Float64(z_s * Float64(y * Float64(Float64(x * z_m) / z_m)))
end
z_m = abs(z);
z_s = sign(z) * abs(1.0);
x, y, z_m, t, a = num2cell(sort([x, y, z_m, t, a])){:}
x, y, z_m, t, a = num2cell(sort([x, y, z_m, t, a])){:}
function tmp = code(z_s, x, y, z_m, t, a)
	tmp = z_s * (y * ((x * z_m) / z_m));
end
z_m = N[Abs[z], $MachinePrecision]
z_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
code[z$95$s_, x_, y_, z$95$m_, t_, a_] := N[(z$95$s * N[(y * N[(N[(x * z$95$m), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
[x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\\\
[x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\
\\
z\_s \cdot \left(y \cdot \frac{x \cdot z\_m}{z\_m}\right)
\end{array}
Derivation
  1. Initial program 63.7%

    \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
  2. Step-by-step derivation
    1. associate-/l*65.7%

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

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

      \[\leadsto \color{blue}{y \cdot \frac{x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \]
    4. associate-/l*64.0%

      \[\leadsto y \cdot \color{blue}{\frac{x \cdot z}{\sqrt{z \cdot z - t \cdot a}}} \]
  3. Simplified64.0%

    \[\leadsto \color{blue}{y \cdot \frac{x \cdot z}{\sqrt{z \cdot z - t \cdot a}}} \]
  4. Add Preprocessing
  5. Taylor expanded in z around inf 40.4%

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

    \[\leadsto y \cdot \frac{x \cdot z}{z} \]
  7. Add Preprocessing

Alternative 4: 73.4% accurate, 37.7× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ z_s = \mathsf{copysign}\left(1, z\right) \\ [x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\\\ [x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\ \\ z\_s \cdot \left(y \cdot x\right) \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
(FPCore (z_s x y z_m t a) :precision binary64 (* z_s (* y x)))
z_m = fabs(z);
z_s = copysign(1.0, z);
assert(x < y && y < z_m && z_m < t && t < a);
assert(x < y && y < z_m && z_m < t && t < a);
double code(double z_s, double x, double y, double z_m, double t, double a) {
	return z_s * (y * x);
}
z_m = abs(z)
z_s = copysign(1.0d0, z)
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
real(8) function code(z_s, x, y, z_m, t, a)
    real(8), intent (in) :: z_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = z_s * (y * x)
end function
z_m = Math.abs(z);
z_s = Math.copySign(1.0, z);
assert x < y && y < z_m && z_m < t && t < a;
assert x < y && y < z_m && z_m < t && t < a;
public static double code(double z_s, double x, double y, double z_m, double t, double a) {
	return z_s * (y * x);
}
z_m = math.fabs(z)
z_s = math.copysign(1.0, z)
[x, y, z_m, t, a] = sort([x, y, z_m, t, a])
[x, y, z_m, t, a] = sort([x, y, z_m, t, a])
def code(z_s, x, y, z_m, t, a):
	return z_s * (y * x)
z_m = abs(z)
z_s = copysign(1.0, z)
x, y, z_m, t, a = sort([x, y, z_m, t, a])
x, y, z_m, t, a = sort([x, y, z_m, t, a])
function code(z_s, x, y, z_m, t, a)
	return Float64(z_s * Float64(y * x))
end
z_m = abs(z);
z_s = sign(z) * abs(1.0);
x, y, z_m, t, a = num2cell(sort([x, y, z_m, t, a])){:}
x, y, z_m, t, a = num2cell(sort([x, y, z_m, t, a])){:}
function tmp = code(z_s, x, y, z_m, t, a)
	tmp = z_s * (y * x);
end
z_m = N[Abs[z], $MachinePrecision]
z_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z_m, t, and a should be sorted in increasing order before calling this function.
code[z$95$s_, x_, y_, z$95$m_, t_, a_] := N[(z$95$s * N[(y * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
[x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\\\
[x, y, z_m, t, a] = \mathsf{sort}([x, y, z_m, t, a])\\
\\
z\_s \cdot \left(y \cdot x\right)
\end{array}
Derivation
  1. Initial program 63.7%

    \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
  2. Step-by-step derivation
    1. associate-/l*65.7%

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

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

      \[\leadsto \color{blue}{y \cdot \frac{x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \]
    4. associate-/l*64.0%

      \[\leadsto y \cdot \color{blue}{\frac{x \cdot z}{\sqrt{z \cdot z - t \cdot a}}} \]
  3. Simplified64.0%

    \[\leadsto \color{blue}{y \cdot \frac{x \cdot z}{\sqrt{z \cdot z - t \cdot a}}} \]
  4. Add Preprocessing
  5. Taylor expanded in z around inf 41.7%

    \[\leadsto y \cdot \color{blue}{x} \]
  6. Final simplification41.7%

    \[\leadsto y \cdot x \]
  7. Add Preprocessing

Developer target: 89.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z < -3.1921305903852764 \cdot 10^{+46}:\\ \;\;\;\;-y \cdot x\\ \mathbf{elif}\;z < 5.976268120920894 \cdot 10^{+90}:\\ \;\;\;\;\frac{x \cdot z}{\frac{\sqrt{z \cdot z - a \cdot t}}{y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (< z -3.1921305903852764e+46)
   (- (* y x))
   (if (< z 5.976268120920894e+90)
     (/ (* x z) (/ (sqrt (- (* z z) (* a t))) y))
     (* y x))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (z < -3.1921305903852764e+46) {
		tmp = -(y * x);
	} else if (z < 5.976268120920894e+90) {
		tmp = (x * z) / (sqrt(((z * z) - (a * t))) / y);
	} else {
		tmp = y * x;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: tmp
    if (z < (-3.1921305903852764d+46)) then
        tmp = -(y * x)
    else if (z < 5.976268120920894d+90) then
        tmp = (x * z) / (sqrt(((z * z) - (a * t))) / y)
    else
        tmp = y * x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (z < -3.1921305903852764e+46) {
		tmp = -(y * x);
	} else if (z < 5.976268120920894e+90) {
		tmp = (x * z) / (Math.sqrt(((z * z) - (a * t))) / y);
	} else {
		tmp = y * x;
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if z < -3.1921305903852764e+46:
		tmp = -(y * x)
	elif z < 5.976268120920894e+90:
		tmp = (x * z) / (math.sqrt(((z * z) - (a * t))) / y)
	else:
		tmp = y * x
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if (z < -3.1921305903852764e+46)
		tmp = Float64(-Float64(y * x));
	elseif (z < 5.976268120920894e+90)
		tmp = Float64(Float64(x * z) / Float64(sqrt(Float64(Float64(z * z) - Float64(a * t))) / y));
	else
		tmp = Float64(y * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if (z < -3.1921305903852764e+46)
		tmp = -(y * x);
	elseif (z < 5.976268120920894e+90)
		tmp = (x * z) / (sqrt(((z * z) - (a * t))) / y);
	else
		tmp = y * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := If[Less[z, -3.1921305903852764e+46], (-N[(y * x), $MachinePrecision]), If[Less[z, 5.976268120920894e+90], N[(N[(x * z), $MachinePrecision] / N[(N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(a * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z < -3.1921305903852764 \cdot 10^{+46}:\\
\;\;\;\;-y \cdot x\\

\mathbf{elif}\;z < 5.976268120920894 \cdot 10^{+90}:\\
\;\;\;\;\frac{x \cdot z}{\frac{\sqrt{z \cdot z - a \cdot t}}{y}}\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024033 
(FPCore (x y z t a)
  :name "Statistics.Math.RootFinding:ridders from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (if (< z -3.1921305903852764e+46) (- (* y x)) (if (< z 5.976268120920894e+90) (/ (* x z) (/ (sqrt (- (* z z) (* a t))) y)) (* y x)))

  (/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))