
(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 7 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 (let* ((t_0 (sin (* x 0.5)))) (/ t_0 (/ 0.375 (/ t_0 (sin x))))))
double code(double x) {
double t_0 = sin((x * 0.5));
return t_0 / (0.375 / (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 = t_0 / (0.375d0 / (t_0 / sin(x)))
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return t_0 / (0.375 / (t_0 / Math.sin(x)));
}
def code(x): t_0 = math.sin((x * 0.5)) return t_0 / (0.375 / (t_0 / math.sin(x)))
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(t_0 / Float64(0.375 / Float64(t_0 / sin(x)))) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = t_0 / (0.375 / (t_0 / sin(x))); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(t$95$0 / N[(0.375 / N[(t$95$0 / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{t_0}{\frac{0.375}{\frac{t_0}{\sin x}}}
\end{array}
\end{array}
Initial program 75.3%
associate-*r/99.2%
associate-*l*99.3%
metadata-eval99.3%
Simplified99.3%
associate-*r*99.2%
metadata-eval99.2%
associate-*r/75.3%
associate-/l*99.2%
metadata-eval99.2%
*-commutative99.2%
associate-/l*99.5%
Applied egg-rr99.5%
Taylor expanded in x around inf 99.5%
associate-*r/99.4%
*-commutative99.4%
associate-/l*99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x) :precision binary64 (let* ((t_0 (sin (* x 0.5)))) (/ t_0 (* (sin x) (/ 0.375 t_0)))))
double code(double x) {
double t_0 = sin((x * 0.5));
return t_0 / (sin(x) * (0.375 / t_0));
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sin((x * 0.5d0))
code = t_0 / (sin(x) * (0.375d0 / t_0))
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return t_0 / (Math.sin(x) * (0.375 / t_0));
}
def code(x): t_0 = math.sin((x * 0.5)) return t_0 / (math.sin(x) * (0.375 / t_0))
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(t_0 / Float64(sin(x) * Float64(0.375 / t_0))) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = t_0 / (sin(x) * (0.375 / t_0)); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(t$95$0 / N[(N[Sin[x], $MachinePrecision] * N[(0.375 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{t_0}{\sin x \cdot \frac{0.375}{t_0}}
\end{array}
\end{array}
Initial program 75.3%
associate-*r/99.2%
associate-*l*99.3%
metadata-eval99.3%
Simplified99.3%
associate-*r*99.2%
metadata-eval99.2%
associate-*r/75.3%
associate-/l*99.2%
metadata-eval99.2%
*-commutative99.2%
associate-/l*99.5%
Applied egg-rr99.5%
Taylor expanded in x around inf 99.5%
associate-*r/99.4%
*-commutative99.4%
associate-/l*99.6%
Simplified99.6%
associate-/r/99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x) :precision binary64 (let* ((t_0 (sin (* x 0.5)))) (/ t_0 (* 0.375 (/ (sin x) t_0)))))
double code(double x) {
double t_0 = sin((x * 0.5));
return t_0 / (0.375 * (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 = t_0 / (0.375d0 * (sin(x) / t_0))
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return t_0 / (0.375 * (Math.sin(x) / t_0));
}
def code(x): t_0 = math.sin((x * 0.5)) return t_0 / (0.375 * (math.sin(x) / t_0))
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(t_0 / Float64(0.375 * Float64(sin(x) / t_0))) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = t_0 / (0.375 * (sin(x) / t_0)); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(t$95$0 / N[(0.375 * N[(N[Sin[x], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{t_0}{0.375 \cdot \frac{\sin x}{t_0}}
\end{array}
\end{array}
Initial program 75.3%
associate-*r/99.2%
associate-*l*99.3%
metadata-eval99.3%
Simplified99.3%
associate-*r*99.2%
metadata-eval99.2%
associate-*r/75.3%
associate-/l*99.2%
metadata-eval99.2%
*-commutative99.2%
associate-/l*99.5%
Applied egg-rr99.5%
div-inv99.5%
metadata-eval99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x) :precision binary64 (* 1.3333333333333333 (tan (/ x 2.0))))
double code(double x) {
return 1.3333333333333333 * tan((x / 2.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.3333333333333333d0 * tan((x / 2.0d0))
end function
public static double code(double x) {
return 1.3333333333333333 * Math.tan((x / 2.0));
}
def code(x): return 1.3333333333333333 * math.tan((x / 2.0))
function code(x) return Float64(1.3333333333333333 * tan(Float64(x / 2.0))) end
function tmp = code(x) tmp = 1.3333333333333333 * tan((x / 2.0)); end
code[x_] := N[(1.3333333333333333 * N[Tan[N[(x / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1.3333333333333333 \cdot \tan \left(\frac{x}{2}\right)
\end{array}
Initial program 75.3%
associate-*r/99.2%
associate-*l*99.3%
metadata-eval99.3%
Simplified99.3%
associate-*r/75.4%
associate-*r/75.3%
expm1-log1p-u59.0%
associate-*l/59.1%
expm1-udef35.6%
Applied egg-rr35.1%
expm1-def35.1%
expm1-log1p51.4%
associate-*r/51.4%
associate-*l/51.4%
metadata-eval51.4%
metadata-eval51.4%
distribute-lft-neg-in51.4%
distribute-rgt-neg-in51.4%
distribute-lft-in51.4%
metadata-eval51.4%
sub-neg51.4%
cos-051.4%
associate-/r/51.3%
associate-/l*51.4%
*-lft-identity51.4%
times-frac51.4%
*-commutative51.4%
times-frac51.4%
metadata-eval51.4%
cos-051.4%
hang-p0-tan99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x) :precision binary64 (/ 2.6666666666666665 (+ (* x -0.3333333333333333) (* 4.0 (/ 1.0 x)))))
double code(double x) {
return 2.6666666666666665 / ((x * -0.3333333333333333) + (4.0 * (1.0 / x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 2.6666666666666665d0 / ((x * (-0.3333333333333333d0)) + (4.0d0 * (1.0d0 / x)))
end function
public static double code(double x) {
return 2.6666666666666665 / ((x * -0.3333333333333333) + (4.0 * (1.0 / x)));
}
def code(x): return 2.6666666666666665 / ((x * -0.3333333333333333) + (4.0 * (1.0 / x)))
function code(x) return Float64(2.6666666666666665 / Float64(Float64(x * -0.3333333333333333) + Float64(4.0 * Float64(1.0 / x)))) end
function tmp = code(x) tmp = 2.6666666666666665 / ((x * -0.3333333333333333) + (4.0 * (1.0 / x))); end
code[x_] := N[(2.6666666666666665 / N[(N[(x * -0.3333333333333333), $MachinePrecision] + N[(4.0 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2.6666666666666665}{x \cdot -0.3333333333333333 + 4 \cdot \frac{1}{x}}
\end{array}
Initial program 75.3%
associate-*r/99.2%
associate-*l*99.3%
metadata-eval99.3%
Simplified99.3%
associate-*r/75.4%
associate-*r/75.3%
associate-/l*75.4%
sqr-sin-a51.3%
cancel-sign-sub-inv51.3%
metadata-eval51.3%
*-commutative51.3%
associate-*r*51.3%
metadata-eval51.3%
*-un-lft-identity51.3%
Applied egg-rr51.3%
Taylor expanded in x around 0 52.6%
Final simplification52.6%
(FPCore (x) :precision binary64 (/ 1.0 (/ 1.5 x)))
double code(double x) {
return 1.0 / (1.5 / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (1.5d0 / x)
end function
public static double code(double x) {
return 1.0 / (1.5 / x);
}
def code(x): return 1.0 / (1.5 / x)
function code(x) return Float64(1.0 / Float64(1.5 / x)) end
function tmp = code(x) tmp = 1.0 / (1.5 / x); end
code[x_] := N[(1.0 / N[(1.5 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1.5}{x}}
\end{array}
Initial program 75.3%
associate-*l*75.3%
metadata-eval75.3%
Simplified75.3%
sin-mult51.4%
associate-*r/51.4%
+-inverses51.4%
cos-sum51.1%
cos-251.4%
*-commutative51.4%
associate-*r*51.4%
metadata-eval51.4%
*-un-lft-identity51.4%
Applied egg-rr51.4%
*-commutative51.4%
associate-/l*51.4%
cos-051.4%
metadata-eval51.4%
metadata-eval51.4%
div-sub51.3%
metadata-eval51.3%
metadata-eval51.3%
metadata-eval51.3%
Simplified51.3%
clear-num51.3%
inv-pow51.3%
div-inv51.3%
metadata-eval51.3%
Applied egg-rr51.3%
Taylor expanded in x around 0 52.2%
unpow-152.2%
Applied egg-rr52.2%
Final simplification52.2%
(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 75.3%
associate-*r/99.2%
associate-*l*99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around 0 52.1%
Final simplification52.1%
(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 2023240
(FPCore (x)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, A"
:precision binary64
:herbie-target
(/ (/ (* 8.0 (sin (* x 0.5))) 3.0) (/ (sin x) (sin (* x 0.5))))
(/ (* (* (/ 8.0 3.0) (sin (* x 0.5))) (sin (* x 0.5))) (sin x)))