
(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:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(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}
Initial program 97.7%
(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}
if (sqrt.f64 t) < 0.619999999999999996Initial program 97.2%
Taylor expanded in x around 0
Applied rewrites83.9%
Taylor expanded in x around 0
Applied rewrites93.6%
Taylor expanded in x around 0
Applied rewrites47.0%
Taylor expanded in x around 0
Applied rewrites93.8%
if 0.619999999999999996 < (sqrt.f64 t) < 7.5000000000000001e58Initial program 98.4%
Taylor expanded in x around 0
Applied rewrites90.8%
Taylor expanded in x around 0
Applied rewrites23.9%
Taylor expanded in x around 0
Applied rewrites34.2%
if 7.5000000000000001e58 < (sqrt.f64 t) Initial program 98.5%
Taylor expanded in x around 0
Applied rewrites91.0%
Taylor expanded in x around 0
Applied rewrites23.9%
(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}
if (sqrt.f64 t) < 0.28000000000000003Initial program 97.2%
Taylor expanded in x around 0
Applied rewrites83.9%
Taylor expanded in x around 0
Applied rewrites93.6%
if 0.28000000000000003 < (sqrt.f64 t) < 7.5000000000000001e58Initial program 98.4%
Taylor expanded in x around 0
Applied rewrites90.8%
Taylor expanded in x around 0
Applied rewrites23.9%
Taylor expanded in x around 0
Applied rewrites34.2%
if 7.5000000000000001e58 < (sqrt.f64 t) Initial program 98.5%
Taylor expanded in x around 0
Applied rewrites91.0%
Taylor expanded in x around 0
Applied rewrites23.9%
(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}
if (*.f64 y #s(literal 27 binary64)) < -3.50000000000000001e91 or 2.2999999999999999e75 < (*.f64 y #s(literal 27 binary64)) Initial program 98.5%
Taylor expanded in x around 0
Applied rewrites16.9%
Taylor expanded in x around 0
Applied rewrites2.7%
Taylor expanded in t around -inf
Applied rewrites18.0%
Taylor expanded in t around -inf
Applied rewrites19.5%
if -3.50000000000000001e91 < (*.f64 y #s(literal 27 binary64)) < 2.2999999999999999e75Initial program 96.9%
Taylor expanded in x around 0
Applied rewrites82.4%
Taylor expanded in x around 0
Applied rewrites61.2%
Taylor expanded in x around 0
Applied rewrites67.4%
(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}
if (sqrt.f64 t) < 0.28000000000000003Initial program 97.2%
Taylor expanded in x around 0
Applied rewrites83.9%
Taylor expanded in x around 0
Applied rewrites93.6%
if 0.28000000000000003 < (sqrt.f64 t) Initial program 98.5%
Taylor expanded in x around 0
Applied rewrites91.0%
Taylor expanded in x around 0
Applied rewrites23.9%
Taylor expanded in x around 0
Applied rewrites21.9%
(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}
if (*.f64 y #s(literal 27 binary64)) < -0.880000000000000004 or 0.52000000000000002 < (*.f64 y #s(literal 27 binary64)) Initial program 98.5%
Taylor expanded in x around 0
Applied rewrites16.9%
Taylor expanded in x around 0
Applied rewrites3.4%
Taylor expanded in t around -inf
Applied rewrites18.0%
Taylor expanded in t around -inf
Applied rewrites19.5%
if -0.880000000000000004 < (*.f64 y #s(literal 27 binary64)) < 0.52000000000000002Initial program 96.0%
Taylor expanded in x around 0
Applied rewrites81.8%
Taylor expanded in x around 0
Applied rewrites23.9%
Taylor expanded in x around 0
Applied rewrites89.8%
(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}
Initial program 97.7%
Taylor expanded in x around 0
Applied rewrites16.9%
Taylor expanded in x around 0
Applied rewrites3.7%
Taylor expanded in t around -inf
Applied rewrites18.0%
Taylor expanded in t around -inf
Applied rewrites19.5%
(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}
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)))))