
(FPCore (x) :precision binary64 (let* ((t_0 (sin (* x 0.5)))) (/ (* (* (/ 8.0 3.0) t_0) t_0) (sin x))))
double code(double x) {
double t_0 = sin((x * 0.5));
return (((8.0 / 3.0) * t_0) * t_0) / sin(x);
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sin((x * 0.5d0))
code = (((8.0d0 / 3.0d0) * t_0) * t_0) / sin(x)
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return (((8.0 / 3.0) * t_0) * t_0) / Math.sin(x);
}
def code(x): t_0 = math.sin((x * 0.5)) return (((8.0 / 3.0) * t_0) * t_0) / math.sin(x)
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(Float64(Float64(Float64(8.0 / 3.0) * t_0) * t_0) / sin(x)) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = (((8.0 / 3.0) * t_0) * t_0) / sin(x); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(8.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (let* ((t_0 (sin (* x 0.5)))) (/ (* (* (/ 8.0 3.0) t_0) t_0) (sin x))))
double code(double x) {
double t_0 = sin((x * 0.5));
return (((8.0 / 3.0) * t_0) * t_0) / sin(x);
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sin((x * 0.5d0))
code = (((8.0d0 / 3.0d0) * t_0) * t_0) / sin(x)
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return (((8.0 / 3.0) * t_0) * t_0) / Math.sin(x);
}
def code(x): t_0 = math.sin((x * 0.5)) return (((8.0 / 3.0) * t_0) * t_0) / math.sin(x)
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(Float64(Float64(Float64(8.0 / 3.0) * t_0) * t_0) / sin(x)) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = (((8.0 / 3.0) * t_0) * t_0) / sin(x); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(8.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x}
\end{array}
\end{array}
(FPCore (x) :precision binary64 (/ (tan (/ x 2.0)) 0.75))
double code(double x) {
return tan((x / 2.0)) / 0.75;
}
real(8) function code(x)
real(8), intent (in) :: x
code = tan((x / 2.0d0)) / 0.75d0
end function
public static double code(double x) {
return Math.tan((x / 2.0)) / 0.75;
}
def code(x): return math.tan((x / 2.0)) / 0.75
function code(x) return Float64(tan(Float64(x / 2.0)) / 0.75) end
function tmp = code(x) tmp = tan((x / 2.0)) / 0.75; end
code[x_] := N[(N[Tan[N[(x / 2.0), $MachinePrecision]], $MachinePrecision] / 0.75), $MachinePrecision]
\begin{array}{l}
\\
\frac{\tan \left(\frac{x}{2}\right)}{0.75}
\end{array}
Initial program 78.7%
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
metadata-evalN/A
sin-lowering-sin.f6499.3%
Simplified99.3%
Applied egg-rr99.8%
(FPCore (x) :precision binary64 (* (tan (/ x 2.0)) 1.3333333333333333))
double code(double x) {
return tan((x / 2.0)) * 1.3333333333333333;
}
real(8) function code(x)
real(8), intent (in) :: x
code = tan((x / 2.0d0)) * 1.3333333333333333d0
end function
public static double code(double x) {
return Math.tan((x / 2.0)) * 1.3333333333333333;
}
def code(x): return math.tan((x / 2.0)) * 1.3333333333333333
function code(x) return Float64(tan(Float64(x / 2.0)) * 1.3333333333333333) end
function tmp = code(x) tmp = tan((x / 2.0)) * 1.3333333333333333; end
code[x_] := N[(N[Tan[N[(x / 2.0), $MachinePrecision]], $MachinePrecision] * 1.3333333333333333), $MachinePrecision]
\begin{array}{l}
\\
\tan \left(\frac{x}{2}\right) \cdot 1.3333333333333333
\end{array}
Initial program 78.7%
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
metadata-evalN/A
sin-lowering-sin.f6499.3%
Simplified99.3%
Applied egg-rr99.5%
(FPCore (x) :precision binary64 (/ (/ x (- -0.75 (* (* x x) -0.0625))) -2.0))
double code(double x) {
return (x / (-0.75 - ((x * x) * -0.0625))) / -2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x / ((-0.75d0) - ((x * x) * (-0.0625d0)))) / (-2.0d0)
end function
public static double code(double x) {
return (x / (-0.75 - ((x * x) * -0.0625))) / -2.0;
}
def code(x): return (x / (-0.75 - ((x * x) * -0.0625))) / -2.0
function code(x) return Float64(Float64(x / Float64(-0.75 - Float64(Float64(x * x) * -0.0625))) / -2.0) end
function tmp = code(x) tmp = (x / (-0.75 - ((x * x) * -0.0625))) / -2.0; end
code[x_] := N[(N[(x / N[(-0.75 - N[(N[(x * x), $MachinePrecision] * -0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{x}{-0.75 - \left(x \cdot x\right) \cdot -0.0625}}{-2}
\end{array}
Initial program 78.7%
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
metadata-evalN/A
sin-lowering-sin.f6499.3%
Simplified99.3%
Applied egg-rr99.6%
Taylor expanded in x around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6449.4%
Simplified49.4%
frac-2negN/A
/-lowering-/.f64N/A
clear-numN/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
distribute-neg-inN/A
unsub-negN/A
--lowering--.f64N/A
metadata-evalN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-eval49.6%
Applied egg-rr49.6%
(FPCore (x) :precision binary64 (* x (/ 0.5 (+ 0.75 (* (* x x) -0.0625)))))
double code(double x) {
return x * (0.5 / (0.75 + ((x * x) * -0.0625)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (0.5d0 / (0.75d0 + ((x * x) * (-0.0625d0))))
end function
public static double code(double x) {
return x * (0.5 / (0.75 + ((x * x) * -0.0625)));
}
def code(x): return x * (0.5 / (0.75 + ((x * x) * -0.0625)))
function code(x) return Float64(x * Float64(0.5 / Float64(0.75 + Float64(Float64(x * x) * -0.0625)))) end
function tmp = code(x) tmp = x * (0.5 / (0.75 + ((x * x) * -0.0625))); end
code[x_] := N[(x * N[(0.5 / N[(0.75 + N[(N[(x * x), $MachinePrecision] * -0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{0.5}{0.75 + \left(x \cdot x\right) \cdot -0.0625}
\end{array}
Initial program 78.7%
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
metadata-evalN/A
sin-lowering-sin.f6499.3%
Simplified99.3%
Applied egg-rr99.6%
Taylor expanded in x around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6449.4%
Simplified49.4%
associate-/l/N/A
associate-/r*N/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
metadata-evalN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6449.4%
Applied egg-rr49.4%
Final simplification49.4%
(FPCore (x) :precision binary64 (/ x 1.5))
double code(double x) {
return x / 1.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = x / 1.5d0
end function
public static double code(double x) {
return x / 1.5;
}
def code(x): return x / 1.5
function code(x) return Float64(x / 1.5) end
function tmp = code(x) tmp = x / 1.5; end
code[x_] := N[(x / 1.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1.5}
\end{array}
Initial program 78.7%
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
metadata-evalN/A
sin-lowering-sin.f6499.3%
Simplified99.3%
Applied egg-rr99.8%
Taylor expanded in x around 0
*-commutativeN/A
metadata-evalN/A
associate-/l*N/A
*-rgt-identityN/A
/-lowering-/.f6448.9%
Simplified48.9%
associate-/l/N/A
/-lowering-/.f64N/A
metadata-eval48.9%
Applied egg-rr48.9%
(FPCore (x) :precision binary64 (* x 0.6666666666666666))
double code(double x) {
return x * 0.6666666666666666;
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * 0.6666666666666666d0
end function
public static double code(double x) {
return x * 0.6666666666666666;
}
def code(x): return x * 0.6666666666666666
function code(x) return Float64(x * 0.6666666666666666) end
function tmp = code(x) tmp = x * 0.6666666666666666; end
code[x_] := N[(x * 0.6666666666666666), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.6666666666666666
\end{array}
Initial program 78.7%
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
metadata-evalN/A
sin-lowering-sin.f6499.3%
Simplified99.3%
Taylor expanded in x around 0
*-lowering-*.f6448.6%
Simplified48.6%
Final simplification48.6%
(FPCore (x) :precision binary64 (let* ((t_0 (sin (* x 0.5)))) (/ (/ (* 8.0 t_0) 3.0) (/ (sin x) t_0))))
double code(double x) {
double t_0 = sin((x * 0.5));
return ((8.0 * t_0) / 3.0) / (sin(x) / t_0);
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sin((x * 0.5d0))
code = ((8.0d0 * t_0) / 3.0d0) / (sin(x) / t_0)
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return ((8.0 * t_0) / 3.0) / (Math.sin(x) / t_0);
}
def code(x): t_0 = math.sin((x * 0.5)) return ((8.0 * t_0) / 3.0) / (math.sin(x) / t_0)
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(Float64(Float64(8.0 * t_0) / 3.0) / Float64(sin(x) / t_0)) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = ((8.0 * t_0) / 3.0) / (sin(x) / t_0); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(8.0 * t$95$0), $MachinePrecision] / 3.0), $MachinePrecision] / N[(N[Sin[x], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{\frac{8 \cdot t\_0}{3}}{\frac{\sin x}{t\_0}}
\end{array}
\end{array}
herbie shell --seed 2024138
(FPCore (x)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, A"
:precision binary64
:alt
(! :herbie-platform default (/ (/ (* 8 (sin (* x 1/2))) 3) (/ (sin x) (sin (* x 1/2)))))
(/ (* (* (/ 8.0 3.0) (sin (* x 0.5))) (sin (* x 0.5))) (sin x)))