Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, J

Percentage Accurate: 79.5% → 88.2%
Time: 15.9s
Alternatives: 16
Speedup: 0.7×

Specification

?
\[\begin{array}{l} \\ \frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))
double code(double x, double y, double z, double t, double a, double b, double c) {
	return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
real(8) function code(x, y, z, t, a, b, c)
    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), intent (in) :: b
    real(8), intent (in) :: c
    code = ((((x * 9.0d0) * y) - (((z * 4.0d0) * t) * a)) + b) / (z * c)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
	return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
def code(x, y, z, t, a, b, c):
	return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c)
function code(x, y, z, t, a, b, c)
	return Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c))
end
function tmp = code(x, y, z, t, a, b, c)
	tmp = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\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 16 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: 79.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))
double code(double x, double y, double z, double t, double a, double b, double c) {
	return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
real(8) function code(x, y, z, t, a, b, c)
    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), intent (in) :: b
    real(8), intent (in) :: c
    code = ((((x * 9.0d0) * y) - (((z * 4.0d0) * t) * a)) + b) / (z * c)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
	return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
def code(x, y, z, t, a, b, c):
	return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c)
function code(x, y, z, t, a, b, c)
	return Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c))
end
function tmp = code(x, y, z, t, a, b, c)
	tmp = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\end{array}

Alternative 1: 88.2% accurate, 0.2× speedup?

\[\begin{array}{l} [x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\\\ [x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\ \\ \begin{array}{l} t_1 := \frac{b + \left(y \cdot \left(9 \cdot x\right) - a \cdot \left(t \cdot \left(4 \cdot z\right)\right)\right)}{z \cdot c}\\ \mathbf{if}\;t\_1 \leq -5 \cdot 10^{-193}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_1 \leq 0:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(-4 \cdot t\right) \cdot a, z, \mathsf{fma}\left(9 \cdot x, y, b\right)\right)}{c}}{z}\\ \mathbf{elif}\;t\_1 \leq \infty:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{-4}{c} \cdot t\right) \cdot a\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c)
 :precision binary64
 (let* ((t_1 (/ (+ b (- (* y (* 9.0 x)) (* a (* t (* 4.0 z))))) (* z c))))
   (if (<= t_1 -5e-193)
     t_1
     (if (<= t_1 0.0)
       (/ (/ (fma (* (* -4.0 t) a) z (fma (* 9.0 x) y b)) c) z)
       (if (<= t_1 INFINITY) t_1 (* (* (/ -4.0 c) t) a))))))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
	double t_1 = (b + ((y * (9.0 * x)) - (a * (t * (4.0 * z))))) / (z * c);
	double tmp;
	if (t_1 <= -5e-193) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = (fma(((-4.0 * t) * a), z, fma((9.0 * x), y, b)) / c) / z;
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = ((-4.0 / c) * t) * a;
	}
	return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c])
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c])
function code(x, y, z, t, a, b, c)
	t_1 = Float64(Float64(b + Float64(Float64(y * Float64(9.0 * x)) - Float64(a * Float64(t * Float64(4.0 * z))))) / Float64(z * c))
	tmp = 0.0
	if (t_1 <= -5e-193)
		tmp = t_1;
	elseif (t_1 <= 0.0)
		tmp = Float64(Float64(fma(Float64(Float64(-4.0 * t) * a), z, fma(Float64(9.0 * x), y, b)) / c) / z);
	elseif (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = Float64(Float64(Float64(-4.0 / c) * t) * a);
	end
	return tmp
end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(b + N[(N[(y * N[(9.0 * x), $MachinePrecision]), $MachinePrecision] - N[(a * N[(t * N[(4.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-193], t$95$1, If[LessEqual[t$95$1, 0.0], N[(N[(N[(N[(N[(-4.0 * t), $MachinePrecision] * a), $MachinePrecision] * z + N[(N[(9.0 * x), $MachinePrecision] * y + b), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$1, N[(N[(N[(-4.0 / c), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\\\
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
t_1 := \frac{b + \left(y \cdot \left(9 \cdot x\right) - a \cdot \left(t \cdot \left(4 \cdot z\right)\right)\right)}{z \cdot c}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-193}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(-4 \cdot t\right) \cdot a, z, \mathsf{fma}\left(9 \cdot x, y, b\right)\right)}{c}}{z}\\

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{-4}{c} \cdot t\right) \cdot a\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < -5.0000000000000005e-193 or 0.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < +inf.0

    1. Initial program 90.0%

      \[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \]
    2. Add Preprocessing

    if -5.0000000000000005e-193 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < 0.0

    1. Initial program 23.4%

      \[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0

      \[\leadsto \color{blue}{\frac{-4 \cdot \frac{a \cdot \left(t \cdot z\right)}{c} + \left(9 \cdot \frac{x \cdot y}{c} + \frac{b}{c}\right)}{z}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{-4 \cdot \frac{a \cdot \left(t \cdot z\right)}{c} + \left(9 \cdot \frac{x \cdot y}{c} + \frac{b}{c}\right)}{z}} \]
    5. Applied rewrites99.4%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{y \cdot x}{c}, 9, \frac{\mathsf{fma}\left(-4 \cdot a, z \cdot t, b\right)}{c}\right)}{z}} \]
    6. Taylor expanded in c around 0

      \[\leadsto \frac{\frac{b + \left(-4 \cdot \left(a \cdot \left(t \cdot z\right)\right) + 9 \cdot \left(x \cdot y\right)\right)}{c}}{z} \]
    7. Step-by-step derivation
      1. Applied rewrites99.6%

        \[\leadsto \frac{\frac{\mathsf{fma}\left(a \cdot \left(-4 \cdot t\right), z, \mathsf{fma}\left(x \cdot 9, y, b\right)\right)}{c}}{z} \]

      if +inf.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c))

      1. Initial program 0.0%

        \[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \]
      2. Add Preprocessing
      3. Taylor expanded in z around inf

        \[\leadsto \color{blue}{-4 \cdot \frac{a \cdot t}{c}} \]
      4. Step-by-step derivation
        1. associate-*l/N/A

          \[\leadsto -4 \cdot \color{blue}{\left(\frac{a}{c} \cdot t\right)} \]
        2. associate-*l*N/A

          \[\leadsto \color{blue}{\left(-4 \cdot \frac{a}{c}\right) \cdot t} \]
        3. lower-*.f64N/A

          \[\leadsto \color{blue}{\left(-4 \cdot \frac{a}{c}\right) \cdot t} \]
        4. *-commutativeN/A

          \[\leadsto \color{blue}{\left(\frac{a}{c} \cdot -4\right)} \cdot t \]
        5. lower-*.f64N/A

          \[\leadsto \color{blue}{\left(\frac{a}{c} \cdot -4\right)} \cdot t \]
        6. lower-/.f6465.3

          \[\leadsto \left(\color{blue}{\frac{a}{c}} \cdot -4\right) \cdot t \]
      5. Applied rewrites65.3%

        \[\leadsto \color{blue}{\left(\frac{a}{c} \cdot -4\right) \cdot t} \]
      6. Step-by-step derivation
        1. Applied rewrites80.3%

          \[\leadsto a \cdot \color{blue}{\left(\frac{1}{c} \cdot \left(-4 \cdot t\right)\right)} \]
        2. Step-by-step derivation
          1. Applied rewrites80.3%

            \[\leadsto a \cdot \left(\frac{-4}{c} \cdot \color{blue}{t}\right) \]
        3. Recombined 3 regimes into one program.
        4. Final simplification90.4%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{b + \left(y \cdot \left(9 \cdot x\right) - a \cdot \left(t \cdot \left(4 \cdot z\right)\right)\right)}{z \cdot c} \leq -5 \cdot 10^{-193}:\\ \;\;\;\;\frac{b + \left(y \cdot \left(9 \cdot x\right) - a \cdot \left(t \cdot \left(4 \cdot z\right)\right)\right)}{z \cdot c}\\ \mathbf{elif}\;\frac{b + \left(y \cdot \left(9 \cdot x\right) - a \cdot \left(t \cdot \left(4 \cdot z\right)\right)\right)}{z \cdot c} \leq 0:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(-4 \cdot t\right) \cdot a, z, \mathsf{fma}\left(9 \cdot x, y, b\right)\right)}{c}}{z}\\ \mathbf{elif}\;\frac{b + \left(y \cdot \left(9 \cdot x\right) - a \cdot \left(t \cdot \left(4 \cdot z\right)\right)\right)}{z \cdot c} \leq \infty:\\ \;\;\;\;\frac{b + \left(y \cdot \left(9 \cdot x\right) - a \cdot \left(t \cdot \left(4 \cdot z\right)\right)\right)}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{-4}{c} \cdot t\right) \cdot a\\ \end{array} \]
        5. Add Preprocessing

        Alternative 2: 86.8% accurate, 0.2× speedup?

        \[\begin{array}{l} [x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\\\ [x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\ \\ \begin{array}{l} t_1 := y \cdot \left(9 \cdot x\right)\\ t_2 := \frac{b + \left(t\_1 - a \cdot \left(t \cdot \left(4 \cdot z\right)\right)\right)}{z \cdot c}\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-193}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_2 \leq 0:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(-4 \cdot t\right) \cdot a, z, t\_1\right)}{c}}{z}\\ \mathbf{elif}\;t\_2 \leq \infty:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{-4}{c} \cdot t\right) \cdot a\\ \end{array} \end{array} \]
        NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
        NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
        (FPCore (x y z t a b c)
         :precision binary64
         (let* ((t_1 (* y (* 9.0 x)))
                (t_2 (/ (+ b (- t_1 (* a (* t (* 4.0 z))))) (* z c))))
           (if (<= t_2 -5e-193)
             t_2
             (if (<= t_2 0.0)
               (/ (/ (fma (* (* -4.0 t) a) z t_1) c) z)
               (if (<= t_2 INFINITY) t_2 (* (* (/ -4.0 c) t) a))))))
        assert(x < y && y < z && z < t && t < a && a < b && b < c);
        assert(x < y && y < z && z < t && t < a && a < b && b < c);
        double code(double x, double y, double z, double t, double a, double b, double c) {
        	double t_1 = y * (9.0 * x);
        	double t_2 = (b + (t_1 - (a * (t * (4.0 * z))))) / (z * c);
        	double tmp;
        	if (t_2 <= -5e-193) {
        		tmp = t_2;
        	} else if (t_2 <= 0.0) {
        		tmp = (fma(((-4.0 * t) * a), z, t_1) / c) / z;
        	} else if (t_2 <= ((double) INFINITY)) {
        		tmp = t_2;
        	} else {
        		tmp = ((-4.0 / c) * t) * a;
        	}
        	return tmp;
        }
        
        x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c])
        x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c])
        function code(x, y, z, t, a, b, c)
        	t_1 = Float64(y * Float64(9.0 * x))
        	t_2 = Float64(Float64(b + Float64(t_1 - Float64(a * Float64(t * Float64(4.0 * z))))) / Float64(z * c))
        	tmp = 0.0
        	if (t_2 <= -5e-193)
        		tmp = t_2;
        	elseif (t_2 <= 0.0)
        		tmp = Float64(Float64(fma(Float64(Float64(-4.0 * t) * a), z, t_1) / c) / z);
        	elseif (t_2 <= Inf)
        		tmp = t_2;
        	else
        		tmp = Float64(Float64(Float64(-4.0 / c) * t) * a);
        	end
        	return tmp
        end
        
        NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
        NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
        code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(y * N[(9.0 * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(b + N[(t$95$1 - N[(a * N[(t * N[(4.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e-193], t$95$2, If[LessEqual[t$95$2, 0.0], N[(N[(N[(N[(N[(-4.0 * t), $MachinePrecision] * a), $MachinePrecision] * z + t$95$1), $MachinePrecision] / c), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$2, Infinity], t$95$2, N[(N[(N[(-4.0 / c), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]]]]]]
        
        \begin{array}{l}
        [x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\\\
        [x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
        \\
        \begin{array}{l}
        t_1 := y \cdot \left(9 \cdot x\right)\\
        t_2 := \frac{b + \left(t\_1 - a \cdot \left(t \cdot \left(4 \cdot z\right)\right)\right)}{z \cdot c}\\
        \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-193}:\\
        \;\;\;\;t\_2\\
        
        \mathbf{elif}\;t\_2 \leq 0:\\
        \;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(-4 \cdot t\right) \cdot a, z, t\_1\right)}{c}}{z}\\
        
        \mathbf{elif}\;t\_2 \leq \infty:\\
        \;\;\;\;t\_2\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(\frac{-4}{c} \cdot t\right) \cdot a\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < -5.0000000000000005e-193 or 0.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < +inf.0

          1. Initial program 89.4%

            \[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \]
          2. Add Preprocessing

          if -5.0000000000000005e-193 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < 0.0

          1. Initial program 50.6%

            \[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \]
          2. Add Preprocessing
          3. Taylor expanded in z around 0

            \[\leadsto \color{blue}{\frac{-4 \cdot \frac{a \cdot \left(t \cdot z\right)}{c} + \left(9 \cdot \frac{x \cdot y}{c} + \frac{b}{c}\right)}{z}} \]
          4. Step-by-step derivation
            1. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{-4 \cdot \frac{a \cdot \left(t \cdot z\right)}{c} + \left(9 \cdot \frac{x \cdot y}{c} + \frac{b}{c}\right)}{z}} \]
          5. Applied rewrites96.7%

            \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{y \cdot x}{c}, 9, \frac{\mathsf{fma}\left(-4 \cdot a, z \cdot t, b\right)}{c}\right)}{z}} \]
          6. Taylor expanded in c around 0

            \[\leadsto \frac{\frac{b + \left(-4 \cdot \left(a \cdot \left(t \cdot z\right)\right) + 9 \cdot \left(x \cdot y\right)\right)}{c}}{z} \]
          7. Step-by-step derivation
            1. Applied rewrites96.2%

              \[\leadsto \frac{\frac{\mathsf{fma}\left(a \cdot \left(-4 \cdot t\right), z, \mathsf{fma}\left(x \cdot 9, y, b\right)\right)}{c}}{z} \]
            2. Taylor expanded in x around inf

              \[\leadsto \frac{\frac{\mathsf{fma}\left(a \cdot \left(-4 \cdot t\right), z, 9 \cdot \left(x \cdot y\right)\right)}{c}}{z} \]
            3. Step-by-step derivation
              1. Applied rewrites76.0%

                \[\leadsto \frac{\frac{\mathsf{fma}\left(a \cdot \left(-4 \cdot t\right), z, \left(x \cdot 9\right) \cdot y\right)}{c}}{z} \]

              if +inf.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c))

              1. Initial program 0.0%

                \[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \]
              2. Add Preprocessing
              3. Taylor expanded in z around inf

                \[\leadsto \color{blue}{-4 \cdot \frac{a \cdot t}{c}} \]
              4. Step-by-step derivation
                1. associate-*l/N/A

                  \[\leadsto -4 \cdot \color{blue}{\left(\frac{a}{c} \cdot t\right)} \]
                2. associate-*l*N/A

                  \[\leadsto \color{blue}{\left(-4 \cdot \frac{a}{c}\right) \cdot t} \]
                3. lower-*.f64N/A

                  \[\leadsto \color{blue}{\left(-4 \cdot \frac{a}{c}\right) \cdot t} \]
                4. *-commutativeN/A

                  \[\leadsto \color{blue}{\left(\frac{a}{c} \cdot -4\right)} \cdot t \]
                5. lower-*.f64N/A

                  \[\leadsto \color{blue}{\left(\frac{a}{c} \cdot -4\right)} \cdot t \]
                6. lower-/.f6462.6

                  \[\leadsto \left(\color{blue}{\frac{a}{c}} \cdot -4\right) \cdot t \]
              5. Applied rewrites62.6%

                \[\leadsto \color{blue}{\left(\frac{a}{c} \cdot -4\right) \cdot t} \]
              6. Step-by-step derivation
                1. Applied rewrites67.9%

                  \[\leadsto a \cdot \color{blue}{\left(\frac{1}{c} \cdot \left(-4 \cdot t\right)\right)} \]
                2. Step-by-step derivation
                  1. Applied rewrites68.3%

                    \[\leadsto a \cdot \left(\frac{-4}{c} \cdot \color{blue}{t}\right) \]
                3. Recombined 3 regimes into one program.
                4. Final simplification86.8%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{b + \left(y \cdot \left(9 \cdot x\right) - a \cdot \left(t \cdot \left(4 \cdot z\right)\right)\right)}{z \cdot c} \leq -5 \cdot 10^{-193}:\\ \;\;\;\;\frac{b + \left(y \cdot \left(9 \cdot x\right) - a \cdot \left(t \cdot \left(4 \cdot z\right)\right)\right)}{z \cdot c}\\ \mathbf{elif}\;\frac{b + \left(y \cdot \left(9 \cdot x\right) - a \cdot \left(t \cdot \left(4 \cdot z\right)\right)\right)}{z \cdot c} \leq 0:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(-4 \cdot t\right) \cdot a, z, y \cdot \left(9 \cdot x\right)\right)}{c}}{z}\\ \mathbf{elif}\;\frac{b + \left(y \cdot \left(9 \cdot x\right) - a \cdot \left(t \cdot \left(4 \cdot z\right)\right)\right)}{z \cdot c} \leq \infty:\\ \;\;\;\;\frac{b + \left(y \cdot \left(9 \cdot x\right) - a \cdot \left(t \cdot \left(4 \cdot z\right)\right)\right)}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{-4}{c} \cdot t\right) \cdot a\\ \end{array} \]
                5. Add Preprocessing

                Developer Target 1: 80.8% accurate, 0.1× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{b}{c \cdot z}\\ t_2 := 4 \cdot \frac{a \cdot t}{c}\\ t_3 := \left(x \cdot 9\right) \cdot y\\ t_4 := \left(t\_3 - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b\\ t_5 := \frac{t\_4}{z \cdot c}\\ t_6 := \frac{\left(t\_3 - \left(z \cdot 4\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{if}\;t\_5 < -1.100156740804105 \cdot 10^{-171}:\\ \;\;\;\;t\_6\\ \mathbf{elif}\;t\_5 < 0:\\ \;\;\;\;\frac{\frac{t\_4}{z}}{c}\\ \mathbf{elif}\;t\_5 < 1.1708877911747488 \cdot 10^{-53}:\\ \;\;\;\;t\_6\\ \mathbf{elif}\;t\_5 < 2.876823679546137 \cdot 10^{+130}:\\ \;\;\;\;\left(\left(9 \cdot \frac{y}{c}\right) \cdot \frac{x}{z} + t\_1\right) - t\_2\\ \mathbf{elif}\;t\_5 < 1.3838515042456319 \cdot 10^{+158}:\\ \;\;\;\;t\_6\\ \mathbf{else}:\\ \;\;\;\;\left(9 \cdot \left(\frac{y}{c \cdot z} \cdot x\right) + t\_1\right) - t\_2\\ \end{array} \end{array} \]
                (FPCore (x y z t a b c)
                 :precision binary64
                 (let* ((t_1 (/ b (* c z)))
                        (t_2 (* 4.0 (/ (* a t) c)))
                        (t_3 (* (* x 9.0) y))
                        (t_4 (+ (- t_3 (* (* (* z 4.0) t) a)) b))
                        (t_5 (/ t_4 (* z c)))
                        (t_6 (/ (+ (- t_3 (* (* z 4.0) (* t a))) b) (* z c))))
                   (if (< t_5 -1.100156740804105e-171)
                     t_6
                     (if (< t_5 0.0)
                       (/ (/ t_4 z) c)
                       (if (< t_5 1.1708877911747488e-53)
                         t_6
                         (if (< t_5 2.876823679546137e+130)
                           (- (+ (* (* 9.0 (/ y c)) (/ x z)) t_1) t_2)
                           (if (< t_5 1.3838515042456319e+158)
                             t_6
                             (- (+ (* 9.0 (* (/ y (* c z)) x)) t_1) t_2))))))))
                double code(double x, double y, double z, double t, double a, double b, double c) {
                	double t_1 = b / (c * z);
                	double t_2 = 4.0 * ((a * t) / c);
                	double t_3 = (x * 9.0) * y;
                	double t_4 = (t_3 - (((z * 4.0) * t) * a)) + b;
                	double t_5 = t_4 / (z * c);
                	double t_6 = ((t_3 - ((z * 4.0) * (t * a))) + b) / (z * c);
                	double tmp;
                	if (t_5 < -1.100156740804105e-171) {
                		tmp = t_6;
                	} else if (t_5 < 0.0) {
                		tmp = (t_4 / z) / c;
                	} else if (t_5 < 1.1708877911747488e-53) {
                		tmp = t_6;
                	} else if (t_5 < 2.876823679546137e+130) {
                		tmp = (((9.0 * (y / c)) * (x / z)) + t_1) - t_2;
                	} else if (t_5 < 1.3838515042456319e+158) {
                		tmp = t_6;
                	} else {
                		tmp = ((9.0 * ((y / (c * z)) * x)) + t_1) - t_2;
                	}
                	return tmp;
                }
                
                real(8) function code(x, y, z, t, a, b, c)
                    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), intent (in) :: b
                    real(8), intent (in) :: c
                    real(8) :: t_1
                    real(8) :: t_2
                    real(8) :: t_3
                    real(8) :: t_4
                    real(8) :: t_5
                    real(8) :: t_6
                    real(8) :: tmp
                    t_1 = b / (c * z)
                    t_2 = 4.0d0 * ((a * t) / c)
                    t_3 = (x * 9.0d0) * y
                    t_4 = (t_3 - (((z * 4.0d0) * t) * a)) + b
                    t_5 = t_4 / (z * c)
                    t_6 = ((t_3 - ((z * 4.0d0) * (t * a))) + b) / (z * c)
                    if (t_5 < (-1.100156740804105d-171)) then
                        tmp = t_6
                    else if (t_5 < 0.0d0) then
                        tmp = (t_4 / z) / c
                    else if (t_5 < 1.1708877911747488d-53) then
                        tmp = t_6
                    else if (t_5 < 2.876823679546137d+130) then
                        tmp = (((9.0d0 * (y / c)) * (x / z)) + t_1) - t_2
                    else if (t_5 < 1.3838515042456319d+158) then
                        tmp = t_6
                    else
                        tmp = ((9.0d0 * ((y / (c * z)) * x)) + t_1) - t_2
                    end if
                    code = tmp
                end function
                
                public static double code(double x, double y, double z, double t, double a, double b, double c) {
                	double t_1 = b / (c * z);
                	double t_2 = 4.0 * ((a * t) / c);
                	double t_3 = (x * 9.0) * y;
                	double t_4 = (t_3 - (((z * 4.0) * t) * a)) + b;
                	double t_5 = t_4 / (z * c);
                	double t_6 = ((t_3 - ((z * 4.0) * (t * a))) + b) / (z * c);
                	double tmp;
                	if (t_5 < -1.100156740804105e-171) {
                		tmp = t_6;
                	} else if (t_5 < 0.0) {
                		tmp = (t_4 / z) / c;
                	} else if (t_5 < 1.1708877911747488e-53) {
                		tmp = t_6;
                	} else if (t_5 < 2.876823679546137e+130) {
                		tmp = (((9.0 * (y / c)) * (x / z)) + t_1) - t_2;
                	} else if (t_5 < 1.3838515042456319e+158) {
                		tmp = t_6;
                	} else {
                		tmp = ((9.0 * ((y / (c * z)) * x)) + t_1) - t_2;
                	}
                	return tmp;
                }
                
                def code(x, y, z, t, a, b, c):
                	t_1 = b / (c * z)
                	t_2 = 4.0 * ((a * t) / c)
                	t_3 = (x * 9.0) * y
                	t_4 = (t_3 - (((z * 4.0) * t) * a)) + b
                	t_5 = t_4 / (z * c)
                	t_6 = ((t_3 - ((z * 4.0) * (t * a))) + b) / (z * c)
                	tmp = 0
                	if t_5 < -1.100156740804105e-171:
                		tmp = t_6
                	elif t_5 < 0.0:
                		tmp = (t_4 / z) / c
                	elif t_5 < 1.1708877911747488e-53:
                		tmp = t_6
                	elif t_5 < 2.876823679546137e+130:
                		tmp = (((9.0 * (y / c)) * (x / z)) + t_1) - t_2
                	elif t_5 < 1.3838515042456319e+158:
                		tmp = t_6
                	else:
                		tmp = ((9.0 * ((y / (c * z)) * x)) + t_1) - t_2
                	return tmp
                
                function code(x, y, z, t, a, b, c)
                	t_1 = Float64(b / Float64(c * z))
                	t_2 = Float64(4.0 * Float64(Float64(a * t) / c))
                	t_3 = Float64(Float64(x * 9.0) * y)
                	t_4 = Float64(Float64(t_3 - Float64(Float64(Float64(z * 4.0) * t) * a)) + b)
                	t_5 = Float64(t_4 / Float64(z * c))
                	t_6 = Float64(Float64(Float64(t_3 - Float64(Float64(z * 4.0) * Float64(t * a))) + b) / Float64(z * c))
                	tmp = 0.0
                	if (t_5 < -1.100156740804105e-171)
                		tmp = t_6;
                	elseif (t_5 < 0.0)
                		tmp = Float64(Float64(t_4 / z) / c);
                	elseif (t_5 < 1.1708877911747488e-53)
                		tmp = t_6;
                	elseif (t_5 < 2.876823679546137e+130)
                		tmp = Float64(Float64(Float64(Float64(9.0 * Float64(y / c)) * Float64(x / z)) + t_1) - t_2);
                	elseif (t_5 < 1.3838515042456319e+158)
                		tmp = t_6;
                	else
                		tmp = Float64(Float64(Float64(9.0 * Float64(Float64(y / Float64(c * z)) * x)) + t_1) - t_2);
                	end
                	return tmp
                end
                
                function tmp_2 = code(x, y, z, t, a, b, c)
                	t_1 = b / (c * z);
                	t_2 = 4.0 * ((a * t) / c);
                	t_3 = (x * 9.0) * y;
                	t_4 = (t_3 - (((z * 4.0) * t) * a)) + b;
                	t_5 = t_4 / (z * c);
                	t_6 = ((t_3 - ((z * 4.0) * (t * a))) + b) / (z * c);
                	tmp = 0.0;
                	if (t_5 < -1.100156740804105e-171)
                		tmp = t_6;
                	elseif (t_5 < 0.0)
                		tmp = (t_4 / z) / c;
                	elseif (t_5 < 1.1708877911747488e-53)
                		tmp = t_6;
                	elseif (t_5 < 2.876823679546137e+130)
                		tmp = (((9.0 * (y / c)) * (x / z)) + t_1) - t_2;
                	elseif (t_5 < 1.3838515042456319e+158)
                		tmp = t_6;
                	else
                		tmp = ((9.0 * ((y / (c * z)) * x)) + t_1) - t_2;
                	end
                	tmp_2 = tmp;
                end
                
                code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(b / N[(c * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(4.0 * N[(N[(a * t), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$4 = N[(N[(t$95$3 - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 / N[(z * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(N[(N[(t$95$3 - N[(N[(z * 4.0), $MachinePrecision] * N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$5, -1.100156740804105e-171], t$95$6, If[Less[t$95$5, 0.0], N[(N[(t$95$4 / z), $MachinePrecision] / c), $MachinePrecision], If[Less[t$95$5, 1.1708877911747488e-53], t$95$6, If[Less[t$95$5, 2.876823679546137e+130], N[(N[(N[(N[(9.0 * N[(y / c), $MachinePrecision]), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision], If[Less[t$95$5, 1.3838515042456319e+158], t$95$6, N[(N[(N[(9.0 * N[(N[(y / N[(c * z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision]]]]]]]]]]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                t_1 := \frac{b}{c \cdot z}\\
                t_2 := 4 \cdot \frac{a \cdot t}{c}\\
                t_3 := \left(x \cdot 9\right) \cdot y\\
                t_4 := \left(t\_3 - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b\\
                t_5 := \frac{t\_4}{z \cdot c}\\
                t_6 := \frac{\left(t\_3 - \left(z \cdot 4\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\
                \mathbf{if}\;t\_5 < -1.100156740804105 \cdot 10^{-171}:\\
                \;\;\;\;t\_6\\
                
                \mathbf{elif}\;t\_5 < 0:\\
                \;\;\;\;\frac{\frac{t\_4}{z}}{c}\\
                
                \mathbf{elif}\;t\_5 < 1.1708877911747488 \cdot 10^{-53}:\\
                \;\;\;\;t\_6\\
                
                \mathbf{elif}\;t\_5 < 2.876823679546137 \cdot 10^{+130}:\\
                \;\;\;\;\left(\left(9 \cdot \frac{y}{c}\right) \cdot \frac{x}{z} + t\_1\right) - t\_2\\
                
                \mathbf{elif}\;t\_5 < 1.3838515042456319 \cdot 10^{+158}:\\
                \;\;\;\;t\_6\\
                
                \mathbf{else}:\\
                \;\;\;\;\left(9 \cdot \left(\frac{y}{c \cdot z} \cdot x\right) + t\_1\right) - t\_2\\
                
                
                \end{array}
                \end{array}
                

                Reproduce

                ?
                herbie shell --seed 2024230 
                (FPCore (x y z t a b c)
                  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, J"
                  :precision binary64
                
                  :alt
                  (! :herbie-platform default (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) -220031348160821/200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 0) (/ (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) z) c) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 365902434742109/31250000000000000000000000000000000000000000000000000000000000000000) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 28768236795461370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (+ (* (* 9 (/ y c)) (/ x z)) (/ b (* c z))) (* 4 (/ (* a t) c))) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 138385150424563190000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (- (+ (* 9 (* (/ y (* c z)) x)) (/ b (* c z))) (* 4 (/ (* a t) c)))))))))
                
                  (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))