
(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 5 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 (* (/ (sin x) t_0) 0.375))))
double code(double x) {
double t_0 = sin((x * 0.5));
return t_0 / ((sin(x) / t_0) * 0.375);
}
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) / t_0) * 0.375d0)
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return t_0 / ((Math.sin(x) / t_0) * 0.375);
}
def code(x): t_0 = math.sin((x * 0.5)) return t_0 / ((math.sin(x) / t_0) * 0.375)
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(t_0 / Float64(Float64(sin(x) / t_0) * 0.375)) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = t_0 / ((sin(x) / t_0) * 0.375); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(t$95$0 / N[(N[(N[Sin[x], $MachinePrecision] / t$95$0), $MachinePrecision] * 0.375), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{t_0}{\frac{\sin x}{t_0} \cdot 0.375}
\end{array}
\end{array}
Initial program 75.5%
associate-*r/99.3%
associate-*l*99.3%
metadata-eval99.3%
Simplified99.3%
associate-*r*99.3%
metadata-eval99.3%
associate-*r/75.5%
associate-/l*99.3%
metadata-eval99.3%
*-commutative99.3%
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 (* (sin (* x 0.5)) (/ 1.0 (cos (* x 0.5))))))
double code(double x) {
return 1.3333333333333333 * (sin((x * 0.5)) * (1.0 / cos((x * 0.5))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.3333333333333333d0 * (sin((x * 0.5d0)) * (1.0d0 / cos((x * 0.5d0))))
end function
public static double code(double x) {
return 1.3333333333333333 * (Math.sin((x * 0.5)) * (1.0 / Math.cos((x * 0.5))));
}
def code(x): return 1.3333333333333333 * (math.sin((x * 0.5)) * (1.0 / math.cos((x * 0.5))))
function code(x) return Float64(1.3333333333333333 * Float64(sin(Float64(x * 0.5)) * Float64(1.0 / cos(Float64(x * 0.5))))) end
function tmp = code(x) tmp = 1.3333333333333333 * (sin((x * 0.5)) * (1.0 / cos((x * 0.5)))); end
code[x_] := N[(1.3333333333333333 * N[(N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Cos[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1.3333333333333333 \cdot \left(\sin \left(x \cdot 0.5\right) \cdot \frac{1}{\cos \left(x \cdot 0.5\right)}\right)
\end{array}
Initial program 75.5%
associate-*l*75.4%
metadata-eval75.4%
Simplified75.4%
sin-mult53.3%
associate-*r/53.3%
+-inverses53.3%
cos-sum53.0%
cos-253.3%
*-commutative53.3%
associate-*r*53.3%
metadata-eval53.3%
*-un-lft-identity53.3%
Applied egg-rr53.3%
associate-/l*53.2%
associate-/r/53.3%
metadata-eval53.3%
cos-053.3%
Simplified53.3%
Taylor expanded in x around inf 53.2%
add-cube-cbrt52.8%
pow352.8%
hang-p0-tan97.8%
div-inv97.8%
metadata-eval97.8%
Applied egg-rr97.8%
rem-cube-cbrt99.4%
tan-quot99.4%
metadata-eval99.4%
div-inv99.4%
div-inv99.4%
div-inv99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x) :precision binary64 (/ (* (sin (* x 0.5)) 1.3333333333333333) (cos (* x 0.5))))
double code(double x) {
return (sin((x * 0.5)) * 1.3333333333333333) / cos((x * 0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (sin((x * 0.5d0)) * 1.3333333333333333d0) / cos((x * 0.5d0))
end function
public static double code(double x) {
return (Math.sin((x * 0.5)) * 1.3333333333333333) / Math.cos((x * 0.5));
}
def code(x): return (math.sin((x * 0.5)) * 1.3333333333333333) / math.cos((x * 0.5))
function code(x) return Float64(Float64(sin(Float64(x * 0.5)) * 1.3333333333333333) / cos(Float64(x * 0.5))) end
function tmp = code(x) tmp = (sin((x * 0.5)) * 1.3333333333333333) / cos((x * 0.5)); end
code[x_] := N[(N[(N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision] * 1.3333333333333333), $MachinePrecision] / N[Cos[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin \left(x \cdot 0.5\right) \cdot 1.3333333333333333}{\cos \left(x \cdot 0.5\right)}
\end{array}
Initial program 75.5%
associate-*r/99.3%
associate-*l*99.3%
metadata-eval99.3%
Simplified99.3%
associate-*r/75.4%
associate-*r/75.4%
expm1-log1p-u59.9%
associate-*l/59.9%
expm1-udef38.4%
Applied egg-rr37.6%
expm1-def37.7%
expm1-log1p53.2%
associate-*r/53.3%
metadata-eval53.3%
metadata-eval53.3%
distribute-lft-neg-in53.3%
distribute-rgt-neg-in53.3%
distribute-lft-in53.3%
sub-neg53.3%
cos-053.3%
metadata-eval53.3%
associate-/r/53.2%
associate-/l*53.3%
*-lft-identity53.3%
associate-*l/53.2%
times-frac53.3%
*-commutative53.3%
times-frac53.2%
Simplified99.4%
Taylor expanded in x around inf 99.4%
*-commutative99.4%
*-commutative99.4%
associate-*r/99.4%
Simplified99.4%
Final simplification99.4%
(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.5%
associate-*r/99.3%
associate-*l*99.3%
metadata-eval99.3%
Simplified99.3%
associate-*r/75.4%
associate-*r/75.4%
expm1-log1p-u59.9%
associate-*l/59.9%
expm1-udef38.4%
Applied egg-rr37.6%
expm1-def37.7%
expm1-log1p53.2%
associate-*r/53.3%
metadata-eval53.3%
metadata-eval53.3%
distribute-lft-neg-in53.3%
distribute-rgt-neg-in53.3%
distribute-lft-in53.3%
sub-neg53.3%
cos-053.3%
metadata-eval53.3%
associate-/r/53.2%
associate-/l*53.3%
*-lft-identity53.3%
associate-*l/53.2%
times-frac53.3%
*-commutative53.3%
times-frac53.2%
Simplified99.4%
Final simplification99.4%
(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.5%
associate-*r/99.3%
associate-*l*99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around 0 50.2%
Final simplification50.2%
(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 2023199
(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)))