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

Percentage Accurate: 98.0% → 98.0%
Time: 5.0s
Alternatives: 7
Speedup: 1.0×

Specification

?
\[\mathsf{TRUE}\left(\right)\]
\[\begin{array}{l} \\ \frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (* (/ 1.0 3.0) (acos (* (/ (* 3.0 (/ x (* y 27.0))) (* z 2.0)) (sqrt t)))))
double code(double x, double y, double z, double t) {
	return (1.0 / 3.0) * acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * sqrt(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 = (1.0d0 / 3.0d0) * acos((((3.0d0 * (x / (y * 27.0d0))) / (z * 2.0d0)) * sqrt(t)))
end function
public static double code(double x, double y, double z, double t) {
	return (1.0 / 3.0) * Math.acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * Math.sqrt(t)));
}
def code(x, y, z, t):
	return (1.0 / 3.0) * math.acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * math.sqrt(t)))
function code(x, y, z, t)
	return Float64(Float64(1.0 / 3.0) * acos(Float64(Float64(Float64(3.0 * Float64(x / Float64(y * 27.0))) / Float64(z * 2.0)) * sqrt(t))))
end
function tmp = code(x, y, z, t)
	tmp = (1.0 / 3.0) * acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * sqrt(t)));
end
code[x_, y_, z_, t_] := N[(N[(1.0 / 3.0), $MachinePrecision] * N[ArcCos[N[(N[(N[(3.0 * N[(x / N[(y * 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z * 2.0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right)
\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 7 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: 98.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (* (/ 1.0 3.0) (acos (* (/ (* 3.0 (/ x (* y 27.0))) (* z 2.0)) (sqrt t)))))
double code(double x, double y, double z, double t) {
	return (1.0 / 3.0) * acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * sqrt(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 = (1.0d0 / 3.0d0) * acos((((3.0d0 * (x / (y * 27.0d0))) / (z * 2.0d0)) * sqrt(t)))
end function
public static double code(double x, double y, double z, double t) {
	return (1.0 / 3.0) * Math.acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * Math.sqrt(t)));
}
def code(x, y, z, t):
	return (1.0 / 3.0) * math.acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * math.sqrt(t)))
function code(x, y, z, t)
	return Float64(Float64(1.0 / 3.0) * acos(Float64(Float64(Float64(3.0 * Float64(x / Float64(y * 27.0))) / Float64(z * 2.0)) * sqrt(t))))
end
function tmp = code(x, y, z, t)
	tmp = (1.0 / 3.0) * acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * sqrt(t)));
end
code[x_, y_, z_, t_] := N[(N[(1.0 / 3.0), $MachinePrecision] * N[ArcCos[N[(N[(N[(3.0 * N[(x / N[(y * 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z * 2.0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right)
\end{array}

Alternative 1: 98.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (* (/ 1.0 3.0) (acos (* (/ (* 3.0 (/ x (* y 27.0))) (* z 2.0)) (sqrt t)))))
double code(double x, double y, double z, double t) {
	return (1.0 / 3.0) * acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * sqrt(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 = (1.0d0 / 3.0d0) * acos((((3.0d0 * (x / (y * 27.0d0))) / (z * 2.0d0)) * sqrt(t)))
end function
public static double code(double x, double y, double z, double t) {
	return (1.0 / 3.0) * Math.acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * Math.sqrt(t)));
}
def code(x, y, z, t):
	return (1.0 / 3.0) * math.acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * math.sqrt(t)))
function code(x, y, z, t)
	return Float64(Float64(1.0 / 3.0) * acos(Float64(Float64(Float64(3.0 * Float64(x / Float64(y * 27.0))) / Float64(z * 2.0)) * sqrt(t))))
end
function tmp = code(x, y, z, t)
	tmp = (1.0 / 3.0) * acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * sqrt(t)));
end
code[x_, y_, z_, t_] := N[(N[(1.0 / 3.0), $MachinePrecision] * N[ArcCos[N[(N[(N[(3.0 * N[(x / N[(y * 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z * 2.0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right)
\end{array}
Derivation
  1. Initial program 97.7%

    \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 66.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{1}{3} \cdot \frac{1}{3}\\ \mathbf{if}\;\sqrt{t} \leq 0.62:\\ \;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(t\_1 \cdot \sqrt{t}\right)\\ \mathbf{elif}\;\sqrt{t} \leq 7.5 \cdot 10^{+58}:\\ \;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(y \cdot 27\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{3} \cdot \cos^{-1} t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* (/ 1.0 3.0) (/ 1.0 3.0))))
   (if (<= (sqrt t) 0.62)
     (* (/ 1.0 3.0) (acos (* t_1 (sqrt t))))
     (if (<= (sqrt t) 7.5e+58)
       (* (/ 1.0 3.0) (acos (* y 27.0)))
       (* (/ 1.0 3.0) (acos t_1))))))
double code(double x, double y, double z, double t) {
	double t_1 = (1.0 / 3.0) * (1.0 / 3.0);
	double tmp;
	if (sqrt(t) <= 0.62) {
		tmp = (1.0 / 3.0) * acos((t_1 * sqrt(t)));
	} else if (sqrt(t) <= 7.5e+58) {
		tmp = (1.0 / 3.0) * acos((y * 27.0));
	} else {
		tmp = (1.0 / 3.0) * acos(t_1);
	}
	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) :: tmp
    t_1 = (1.0d0 / 3.0d0) * (1.0d0 / 3.0d0)
    if (sqrt(t) <= 0.62d0) then
        tmp = (1.0d0 / 3.0d0) * acos((t_1 * sqrt(t)))
    else if (sqrt(t) <= 7.5d+58) then
        tmp = (1.0d0 / 3.0d0) * acos((y * 27.0d0))
    else
        tmp = (1.0d0 / 3.0d0) * acos(t_1)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = (1.0 / 3.0) * (1.0 / 3.0);
	double tmp;
	if (Math.sqrt(t) <= 0.62) {
		tmp = (1.0 / 3.0) * Math.acos((t_1 * Math.sqrt(t)));
	} else if (Math.sqrt(t) <= 7.5e+58) {
		tmp = (1.0 / 3.0) * Math.acos((y * 27.0));
	} else {
		tmp = (1.0 / 3.0) * Math.acos(t_1);
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = (1.0 / 3.0) * (1.0 / 3.0)
	tmp = 0
	if math.sqrt(t) <= 0.62:
		tmp = (1.0 / 3.0) * math.acos((t_1 * math.sqrt(t)))
	elif math.sqrt(t) <= 7.5e+58:
		tmp = (1.0 / 3.0) * math.acos((y * 27.0))
	else:
		tmp = (1.0 / 3.0) * math.acos(t_1)
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(1.0 / 3.0) * Float64(1.0 / 3.0))
	tmp = 0.0
	if (sqrt(t) <= 0.62)
		tmp = Float64(Float64(1.0 / 3.0) * acos(Float64(t_1 * sqrt(t))));
	elseif (sqrt(t) <= 7.5e+58)
		tmp = Float64(Float64(1.0 / 3.0) * acos(Float64(y * 27.0)));
	else
		tmp = Float64(Float64(1.0 / 3.0) * acos(t_1));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = (1.0 / 3.0) * (1.0 / 3.0);
	tmp = 0.0;
	if (sqrt(t) <= 0.62)
		tmp = (1.0 / 3.0) * acos((t_1 * sqrt(t)));
	elseif (sqrt(t) <= 7.5e+58)
		tmp = (1.0 / 3.0) * acos((y * 27.0));
	else
		tmp = (1.0 / 3.0) * acos(t_1);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(1.0 / 3.0), $MachinePrecision] * N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sqrt[t], $MachinePrecision], 0.62], N[(N[(1.0 / 3.0), $MachinePrecision] * N[ArcCos[N[(t$95$1 * N[Sqrt[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sqrt[t], $MachinePrecision], 7.5e+58], N[(N[(1.0 / 3.0), $MachinePrecision] * N[ArcCos[N[(y * 27.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / 3.0), $MachinePrecision] * N[ArcCos[t$95$1], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{1}{3} \cdot \frac{1}{3}\\
\mathbf{if}\;\sqrt{t} \leq 0.62:\\
\;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(t\_1 \cdot \sqrt{t}\right)\\

\mathbf{elif}\;\sqrt{t} \leq 7.5 \cdot 10^{+58}:\\
\;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(y \cdot 27\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{3} \cdot \cos^{-1} t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (sqrt.f64 t) < 0.619999999999999996

    1. Initial program 97.2%

      \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{1}{9} \cdot \frac{x}{y}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    4. Applied rewrites83.9%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    5. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\color{blue}{\left(\frac{1}{18} \cdot \frac{x}{y \cdot z}\right)} \cdot \sqrt{t}\right) \]
    6. Applied rewrites93.6%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\color{blue}{\frac{1}{3}} \cdot \sqrt{t}\right) \]
    7. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\color{blue}{\left(\frac{1}{18} \cdot \frac{x}{y \cdot z}\right)} \cdot \sqrt{t}\right) \]
    8. Applied rewrites47.0%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\color{blue}{\left(y \cdot 27\right)} \cdot \sqrt{t}\right) \]
    9. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\color{blue}{\left(\frac{1}{18} \cdot \frac{x}{y \cdot z}\right)} \cdot \sqrt{t}\right) \]
    10. Applied rewrites93.8%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\color{blue}{\left(\frac{1}{3} \cdot \frac{1}{3}\right)} \cdot \sqrt{t}\right) \]

    if 0.619999999999999996 < (sqrt.f64 t) < 7.5000000000000001e58

    1. Initial program 98.4%

      \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{1}{9} \cdot \frac{x}{y}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    4. Applied rewrites90.8%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    5. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
    6. Applied rewrites23.9%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{3} \cdot \frac{1}{3}\right)} \]
    7. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
    8. Applied rewrites34.2%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(y \cdot 27\right)} \]

    if 7.5000000000000001e58 < (sqrt.f64 t)

    1. Initial program 98.5%

      \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{1}{9} \cdot \frac{x}{y}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    4. Applied rewrites91.0%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    5. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
    6. Applied rewrites23.9%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{3} \cdot \frac{1}{3}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 65.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sqrt{t} \leq 0.28:\\ \;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(\frac{1}{3} \cdot \sqrt{t}\right)\\ \mathbf{elif}\;\sqrt{t} \leq 7.5 \cdot 10^{+58}:\\ \;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(y \cdot 27\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(\frac{1}{3} \cdot \frac{1}{3}\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (sqrt t) 0.28)
   (* (/ 1.0 3.0) (acos (* (/ 1.0 3.0) (sqrt t))))
   (if (<= (sqrt t) 7.5e+58)
     (* (/ 1.0 3.0) (acos (* y 27.0)))
     (* (/ 1.0 3.0) (acos (* (/ 1.0 3.0) (/ 1.0 3.0)))))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (sqrt(t) <= 0.28) {
		tmp = (1.0 / 3.0) * acos(((1.0 / 3.0) * sqrt(t)));
	} else if (sqrt(t) <= 7.5e+58) {
		tmp = (1.0 / 3.0) * acos((y * 27.0));
	} else {
		tmp = (1.0 / 3.0) * acos(((1.0 / 3.0) * (1.0 / 3.0)));
	}
	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) :: tmp
    if (sqrt(t) <= 0.28d0) then
        tmp = (1.0d0 / 3.0d0) * acos(((1.0d0 / 3.0d0) * sqrt(t)))
    else if (sqrt(t) <= 7.5d+58) then
        tmp = (1.0d0 / 3.0d0) * acos((y * 27.0d0))
    else
        tmp = (1.0d0 / 3.0d0) * acos(((1.0d0 / 3.0d0) * (1.0d0 / 3.0d0)))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (Math.sqrt(t) <= 0.28) {
		tmp = (1.0 / 3.0) * Math.acos(((1.0 / 3.0) * Math.sqrt(t)));
	} else if (Math.sqrt(t) <= 7.5e+58) {
		tmp = (1.0 / 3.0) * Math.acos((y * 27.0));
	} else {
		tmp = (1.0 / 3.0) * Math.acos(((1.0 / 3.0) * (1.0 / 3.0)));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if math.sqrt(t) <= 0.28:
		tmp = (1.0 / 3.0) * math.acos(((1.0 / 3.0) * math.sqrt(t)))
	elif math.sqrt(t) <= 7.5e+58:
		tmp = (1.0 / 3.0) * math.acos((y * 27.0))
	else:
		tmp = (1.0 / 3.0) * math.acos(((1.0 / 3.0) * (1.0 / 3.0)))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (sqrt(t) <= 0.28)
		tmp = Float64(Float64(1.0 / 3.0) * acos(Float64(Float64(1.0 / 3.0) * sqrt(t))));
	elseif (sqrt(t) <= 7.5e+58)
		tmp = Float64(Float64(1.0 / 3.0) * acos(Float64(y * 27.0)));
	else
		tmp = Float64(Float64(1.0 / 3.0) * acos(Float64(Float64(1.0 / 3.0) * Float64(1.0 / 3.0))));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (sqrt(t) <= 0.28)
		tmp = (1.0 / 3.0) * acos(((1.0 / 3.0) * sqrt(t)));
	elseif (sqrt(t) <= 7.5e+58)
		tmp = (1.0 / 3.0) * acos((y * 27.0));
	else
		tmp = (1.0 / 3.0) * acos(((1.0 / 3.0) * (1.0 / 3.0)));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[N[Sqrt[t], $MachinePrecision], 0.28], N[(N[(1.0 / 3.0), $MachinePrecision] * N[ArcCos[N[(N[(1.0 / 3.0), $MachinePrecision] * N[Sqrt[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sqrt[t], $MachinePrecision], 7.5e+58], N[(N[(1.0 / 3.0), $MachinePrecision] * N[ArcCos[N[(y * 27.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / 3.0), $MachinePrecision] * N[ArcCos[N[(N[(1.0 / 3.0), $MachinePrecision] * N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\sqrt{t} \leq 0.28:\\
\;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(\frac{1}{3} \cdot \sqrt{t}\right)\\

\mathbf{elif}\;\sqrt{t} \leq 7.5 \cdot 10^{+58}:\\
\;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(y \cdot 27\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(\frac{1}{3} \cdot \frac{1}{3}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (sqrt.f64 t) < 0.28000000000000003

    1. Initial program 97.2%

      \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{1}{9} \cdot \frac{x}{y}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    4. Applied rewrites83.9%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    5. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\color{blue}{\left(\frac{1}{18} \cdot \frac{x}{y \cdot z}\right)} \cdot \sqrt{t}\right) \]
    6. Applied rewrites93.6%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\color{blue}{\frac{1}{3}} \cdot \sqrt{t}\right) \]

    if 0.28000000000000003 < (sqrt.f64 t) < 7.5000000000000001e58

    1. Initial program 98.4%

      \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{1}{9} \cdot \frac{x}{y}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    4. Applied rewrites90.8%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    5. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
    6. Applied rewrites23.9%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{3} \cdot \frac{1}{3}\right)} \]
    7. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
    8. Applied rewrites34.2%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(y \cdot 27\right)} \]

    if 7.5000000000000001e58 < (sqrt.f64 t)

    1. Initial program 98.5%

      \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{1}{9} \cdot \frac{x}{y}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    4. Applied rewrites91.0%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    5. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
    6. Applied rewrites23.9%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{3} \cdot \frac{1}{3}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 41.9% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \cdot 27 \leq -3.5 \cdot 10^{+91}:\\ \;\;\;\;\frac{1}{3}\\ \mathbf{elif}\;y \cdot 27 \leq 2.3 \cdot 10^{+75}:\\ \;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(\left(y \cdot 27\right) \cdot \sqrt{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{3}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (* y 27.0) -3.5e+91)
   (/ 1.0 3.0)
   (if (<= (* y 27.0) 2.3e+75)
     (* (/ 1.0 3.0) (acos (* (* y 27.0) (sqrt t))))
     (/ 1.0 3.0))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y * 27.0) <= -3.5e+91) {
		tmp = 1.0 / 3.0;
	} else if ((y * 27.0) <= 2.3e+75) {
		tmp = (1.0 / 3.0) * acos(((y * 27.0) * sqrt(t)));
	} else {
		tmp = 1.0 / 3.0;
	}
	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) :: tmp
    if ((y * 27.0d0) <= (-3.5d+91)) then
        tmp = 1.0d0 / 3.0d0
    else if ((y * 27.0d0) <= 2.3d+75) then
        tmp = (1.0d0 / 3.0d0) * acos(((y * 27.0d0) * sqrt(t)))
    else
        tmp = 1.0d0 / 3.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((y * 27.0) <= -3.5e+91) {
		tmp = 1.0 / 3.0;
	} else if ((y * 27.0) <= 2.3e+75) {
		tmp = (1.0 / 3.0) * Math.acos(((y * 27.0) * Math.sqrt(t)));
	} else {
		tmp = 1.0 / 3.0;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (y * 27.0) <= -3.5e+91:
		tmp = 1.0 / 3.0
	elif (y * 27.0) <= 2.3e+75:
		tmp = (1.0 / 3.0) * math.acos(((y * 27.0) * math.sqrt(t)))
	else:
		tmp = 1.0 / 3.0
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(y * 27.0) <= -3.5e+91)
		tmp = Float64(1.0 / 3.0);
	elseif (Float64(y * 27.0) <= 2.3e+75)
		tmp = Float64(Float64(1.0 / 3.0) * acos(Float64(Float64(y * 27.0) * sqrt(t))));
	else
		tmp = Float64(1.0 / 3.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((y * 27.0) <= -3.5e+91)
		tmp = 1.0 / 3.0;
	elseif ((y * 27.0) <= 2.3e+75)
		tmp = (1.0 / 3.0) * acos(((y * 27.0) * sqrt(t)));
	else
		tmp = 1.0 / 3.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[N[(y * 27.0), $MachinePrecision], -3.5e+91], N[(1.0 / 3.0), $MachinePrecision], If[LessEqual[N[(y * 27.0), $MachinePrecision], 2.3e+75], N[(N[(1.0 / 3.0), $MachinePrecision] * N[ArcCos[N[(N[(y * 27.0), $MachinePrecision] * N[Sqrt[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / 3.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \cdot 27 \leq -3.5 \cdot 10^{+91}:\\
\;\;\;\;\frac{1}{3}\\

\mathbf{elif}\;y \cdot 27 \leq 2.3 \cdot 10^{+75}:\\
\;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(\left(y \cdot 27\right) \cdot \sqrt{t}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y #s(literal 27 binary64)) < -3.50000000000000001e91 or 2.2999999999999999e75 < (*.f64 y #s(literal 27 binary64))

    1. Initial program 98.5%

      \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \color{blue}{\cos^{-1} \left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
    4. Applied rewrites16.9%

      \[\leadsto \frac{1}{3} \cdot \color{blue}{\frac{1}{3}} \]
    5. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \color{blue}{\cos^{-1} \left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
    6. Applied rewrites2.7%

      \[\leadsto \frac{1}{3} \cdot \color{blue}{\left(y \cdot 27\right)} \]
    7. Taylor expanded in t around -inf

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \cos^{-1} \left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x \cdot {\left(\sqrt{-1}\right)}^{2}}{y \cdot z}\right)\right)} \]
    8. Applied rewrites18.0%

      \[\leadsto \color{blue}{\cos^{-1} \left(\frac{1}{3} \cdot \frac{1}{3}\right)} \]
    9. Taylor expanded in t around -inf

      \[\leadsto \cos^{-1} \left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x \cdot {\left(\sqrt{-1}\right)}^{2}}{y \cdot z}\right)\right) \]
    10. Applied rewrites19.5%

      \[\leadsto \frac{1}{\color{blue}{3}} \]

    if -3.50000000000000001e91 < (*.f64 y #s(literal 27 binary64)) < 2.2999999999999999e75

    1. Initial program 96.9%

      \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{1}{9} \cdot \frac{x}{y}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    4. Applied rewrites82.4%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    5. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\color{blue}{\left(\frac{1}{18} \cdot \frac{x}{y \cdot z}\right)} \cdot \sqrt{t}\right) \]
    6. Applied rewrites61.2%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\color{blue}{\frac{1}{3}} \cdot \sqrt{t}\right) \]
    7. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\color{blue}{\left(\frac{1}{18} \cdot \frac{x}{y \cdot z}\right)} \cdot \sqrt{t}\right) \]
    8. Applied rewrites67.4%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\color{blue}{\left(y \cdot 27\right)} \cdot \sqrt{t}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 65.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sqrt{t} \leq 0.28:\\ \;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(\frac{1}{3} \cdot \sqrt{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(y \cdot 27\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (sqrt t) 0.28)
   (* (/ 1.0 3.0) (acos (* (/ 1.0 3.0) (sqrt t))))
   (* (/ 1.0 3.0) (acos (* y 27.0)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (sqrt(t) <= 0.28) {
		tmp = (1.0 / 3.0) * acos(((1.0 / 3.0) * sqrt(t)));
	} else {
		tmp = (1.0 / 3.0) * acos((y * 27.0));
	}
	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) :: tmp
    if (sqrt(t) <= 0.28d0) then
        tmp = (1.0d0 / 3.0d0) * acos(((1.0d0 / 3.0d0) * sqrt(t)))
    else
        tmp = (1.0d0 / 3.0d0) * acos((y * 27.0d0))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (Math.sqrt(t) <= 0.28) {
		tmp = (1.0 / 3.0) * Math.acos(((1.0 / 3.0) * Math.sqrt(t)));
	} else {
		tmp = (1.0 / 3.0) * Math.acos((y * 27.0));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if math.sqrt(t) <= 0.28:
		tmp = (1.0 / 3.0) * math.acos(((1.0 / 3.0) * math.sqrt(t)))
	else:
		tmp = (1.0 / 3.0) * math.acos((y * 27.0))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (sqrt(t) <= 0.28)
		tmp = Float64(Float64(1.0 / 3.0) * acos(Float64(Float64(1.0 / 3.0) * sqrt(t))));
	else
		tmp = Float64(Float64(1.0 / 3.0) * acos(Float64(y * 27.0)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (sqrt(t) <= 0.28)
		tmp = (1.0 / 3.0) * acos(((1.0 / 3.0) * sqrt(t)));
	else
		tmp = (1.0 / 3.0) * acos((y * 27.0));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[N[Sqrt[t], $MachinePrecision], 0.28], N[(N[(1.0 / 3.0), $MachinePrecision] * N[ArcCos[N[(N[(1.0 / 3.0), $MachinePrecision] * N[Sqrt[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / 3.0), $MachinePrecision] * N[ArcCos[N[(y * 27.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\sqrt{t} \leq 0.28:\\
\;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(\frac{1}{3} \cdot \sqrt{t}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(y \cdot 27\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sqrt.f64 t) < 0.28000000000000003

    1. Initial program 97.2%

      \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{1}{9} \cdot \frac{x}{y}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    4. Applied rewrites83.9%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    5. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\color{blue}{\left(\frac{1}{18} \cdot \frac{x}{y \cdot z}\right)} \cdot \sqrt{t}\right) \]
    6. Applied rewrites93.6%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\color{blue}{\frac{1}{3}} \cdot \sqrt{t}\right) \]

    if 0.28000000000000003 < (sqrt.f64 t)

    1. Initial program 98.5%

      \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{1}{9} \cdot \frac{x}{y}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    4. Applied rewrites91.0%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    5. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
    6. Applied rewrites23.9%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{3} \cdot \frac{1}{3}\right)} \]
    7. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
    8. Applied rewrites21.9%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(y \cdot 27\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 41.4% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \cdot 27 \leq -0.88:\\ \;\;\;\;\frac{1}{3}\\ \mathbf{elif}\;y \cdot 27 \leq 0.52:\\ \;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(y \cdot 27\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{3}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (* y 27.0) -0.88)
   (/ 1.0 3.0)
   (if (<= (* y 27.0) 0.52) (* (/ 1.0 3.0) (acos (* y 27.0))) (/ 1.0 3.0))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y * 27.0) <= -0.88) {
		tmp = 1.0 / 3.0;
	} else if ((y * 27.0) <= 0.52) {
		tmp = (1.0 / 3.0) * acos((y * 27.0));
	} else {
		tmp = 1.0 / 3.0;
	}
	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) :: tmp
    if ((y * 27.0d0) <= (-0.88d0)) then
        tmp = 1.0d0 / 3.0d0
    else if ((y * 27.0d0) <= 0.52d0) then
        tmp = (1.0d0 / 3.0d0) * acos((y * 27.0d0))
    else
        tmp = 1.0d0 / 3.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((y * 27.0) <= -0.88) {
		tmp = 1.0 / 3.0;
	} else if ((y * 27.0) <= 0.52) {
		tmp = (1.0 / 3.0) * Math.acos((y * 27.0));
	} else {
		tmp = 1.0 / 3.0;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (y * 27.0) <= -0.88:
		tmp = 1.0 / 3.0
	elif (y * 27.0) <= 0.52:
		tmp = (1.0 / 3.0) * math.acos((y * 27.0))
	else:
		tmp = 1.0 / 3.0
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(y * 27.0) <= -0.88)
		tmp = Float64(1.0 / 3.0);
	elseif (Float64(y * 27.0) <= 0.52)
		tmp = Float64(Float64(1.0 / 3.0) * acos(Float64(y * 27.0)));
	else
		tmp = Float64(1.0 / 3.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((y * 27.0) <= -0.88)
		tmp = 1.0 / 3.0;
	elseif ((y * 27.0) <= 0.52)
		tmp = (1.0 / 3.0) * acos((y * 27.0));
	else
		tmp = 1.0 / 3.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[N[(y * 27.0), $MachinePrecision], -0.88], N[(1.0 / 3.0), $MachinePrecision], If[LessEqual[N[(y * 27.0), $MachinePrecision], 0.52], N[(N[(1.0 / 3.0), $MachinePrecision] * N[ArcCos[N[(y * 27.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / 3.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \cdot 27 \leq -0.88:\\
\;\;\;\;\frac{1}{3}\\

\mathbf{elif}\;y \cdot 27 \leq 0.52:\\
\;\;\;\;\frac{1}{3} \cdot \cos^{-1} \left(y \cdot 27\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y #s(literal 27 binary64)) < -0.880000000000000004 or 0.52000000000000002 < (*.f64 y #s(literal 27 binary64))

    1. Initial program 98.5%

      \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \color{blue}{\cos^{-1} \left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
    4. Applied rewrites16.9%

      \[\leadsto \frac{1}{3} \cdot \color{blue}{\frac{1}{3}} \]
    5. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \color{blue}{\cos^{-1} \left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
    6. Applied rewrites3.4%

      \[\leadsto \frac{1}{3} \cdot \color{blue}{\left(y \cdot 27\right)} \]
    7. Taylor expanded in t around -inf

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \cos^{-1} \left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x \cdot {\left(\sqrt{-1}\right)}^{2}}{y \cdot z}\right)\right)} \]
    8. Applied rewrites18.0%

      \[\leadsto \color{blue}{\cos^{-1} \left(\frac{1}{3} \cdot \frac{1}{3}\right)} \]
    9. Taylor expanded in t around -inf

      \[\leadsto \cos^{-1} \left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x \cdot {\left(\sqrt{-1}\right)}^{2}}{y \cdot z}\right)\right) \]
    10. Applied rewrites19.5%

      \[\leadsto \frac{1}{\color{blue}{3}} \]

    if -0.880000000000000004 < (*.f64 y #s(literal 27 binary64)) < 0.52000000000000002

    1. Initial program 96.0%

      \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{1}{9} \cdot \frac{x}{y}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    4. Applied rewrites81.8%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2}}}{z \cdot 2} \cdot \sqrt{t}\right) \]
    5. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
    6. Applied rewrites23.9%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{3} \cdot \frac{1}{3}\right)} \]
    7. Taylor expanded in x around 0

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
    8. Applied rewrites89.8%

      \[\leadsto \frac{1}{3} \cdot \cos^{-1} \color{blue}{\left(y \cdot 27\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 19.5% accurate, 14.1× speedup?

\[\begin{array}{l} \\ \frac{1}{3} \end{array} \]
(FPCore (x y z t) :precision binary64 (/ 1.0 3.0))
double code(double x, double y, double z, double t) {
	return 1.0 / 3.0;
}
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 = 1.0d0 / 3.0d0
end function
public static double code(double x, double y, double z, double t) {
	return 1.0 / 3.0;
}
def code(x, y, z, t):
	return 1.0 / 3.0
function code(x, y, z, t)
	return Float64(1.0 / 3.0)
end
function tmp = code(x, y, z, t)
	tmp = 1.0 / 3.0;
end
code[x_, y_, z_, t_] := N[(1.0 / 3.0), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{3}
\end{array}
Derivation
  1. Initial program 97.7%

    \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \frac{1}{3} \cdot \color{blue}{\cos^{-1} \left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
  4. Applied rewrites16.9%

    \[\leadsto \frac{1}{3} \cdot \color{blue}{\frac{1}{3}} \]
  5. Taylor expanded in x around 0

    \[\leadsto \frac{1}{3} \cdot \color{blue}{\cos^{-1} \left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x}{y \cdot z}\right)\right)} \]
  6. Applied rewrites3.7%

    \[\leadsto \frac{1}{3} \cdot \color{blue}{\left(y \cdot 27\right)} \]
  7. Taylor expanded in t around -inf

    \[\leadsto \color{blue}{\frac{1}{3} \cdot \cos^{-1} \left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x \cdot {\left(\sqrt{-1}\right)}^{2}}{y \cdot z}\right)\right)} \]
  8. Applied rewrites18.0%

    \[\leadsto \color{blue}{\cos^{-1} \left(\frac{1}{3} \cdot \frac{1}{3}\right)} \]
  9. Taylor expanded in t around -inf

    \[\leadsto \cos^{-1} \left(\frac{1}{18} \cdot \left(\sqrt{t} \cdot \frac{x \cdot {\left(\sqrt{-1}\right)}^{2}}{y \cdot z}\right)\right) \]
  10. Applied rewrites19.5%

    \[\leadsto \frac{1}{\color{blue}{3}} \]
  11. Add Preprocessing

Developer Target 1: 98.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\cos^{-1} \left(\frac{\frac{x}{27}}{y \cdot z} \cdot \frac{\sqrt{t}}{\frac{2}{3}}\right)}{3} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (/ (acos (* (/ (/ x 27.0) (* y z)) (/ (sqrt t) (/ 2.0 3.0)))) 3.0))
double code(double x, double y, double z, double t) {
	return acos((((x / 27.0) / (y * z)) * (sqrt(t) / (2.0 / 3.0)))) / 3.0;
}
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 = acos((((x / 27.0d0) / (y * z)) * (sqrt(t) / (2.0d0 / 3.0d0)))) / 3.0d0
end function
public static double code(double x, double y, double z, double t) {
	return Math.acos((((x / 27.0) / (y * z)) * (Math.sqrt(t) / (2.0 / 3.0)))) / 3.0;
}
def code(x, y, z, t):
	return math.acos((((x / 27.0) / (y * z)) * (math.sqrt(t) / (2.0 / 3.0)))) / 3.0
function code(x, y, z, t)
	return Float64(acos(Float64(Float64(Float64(x / 27.0) / Float64(y * z)) * Float64(sqrt(t) / Float64(2.0 / 3.0)))) / 3.0)
end
function tmp = code(x, y, z, t)
	tmp = acos((((x / 27.0) / (y * z)) * (sqrt(t) / (2.0 / 3.0)))) / 3.0;
end
code[x_, y_, z_, t_] := N[(N[ArcCos[N[(N[(N[(x / 27.0), $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[t], $MachinePrecision] / N[(2.0 / 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 3.0), $MachinePrecision]
\begin{array}{l}

\\
\frac{\cos^{-1} \left(\frac{\frac{x}{27}}{y \cdot z} \cdot \frac{\sqrt{t}}{\frac{2}{3}}\right)}{3}
\end{array}

Reproduce

?
herbie shell --seed 2024321 
(FPCore (x y z t)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, D"
  :precision binary64
  :pre (TRUE)

  :alt
  (! :herbie-platform default (/ (acos (* (/ (/ x 27) (* y z)) (/ (sqrt t) (/ 2 3)))) 3))

  (* (/ 1.0 3.0) (acos (* (/ (* 3.0 (/ x (* y 27.0))) (* z 2.0)) (sqrt t)))))