# adapted from file without sum of Bernstein Polynomials by Kilom691# http://commons.wikimedia.org/wiki/File:Bernstein_poly_4.svgN=4rnb=rainbow(N+1)pt1=sum(plot(binomial(N,i)*x**i*(1-x)**(N-i),0,1,legend_label=r'$B^{}_{}(u)$'.format(N,i),color=rnb[i],thickness=3,aspect_ratio=1)foriinrange(N+1))almostOne=0.99999# bug in sagemath, put it to 1.0 and BSum plot will vanishvar('i')BSum=sum(binomial(N,i)*x**i*(1-x)**(N-i),i,0,3) \
+binomial(N,4)*x**4*(1-x)**(N-4)*almostOnept2=plot(BSum,0,1,legend_label='$\sum_{i=0}^{4} \, B^{4}_{i}(u)$',# code between $ .. $ uses LaTeX math commands to format equationcolor='orange',thickness=3)pt2.set_legend_options(loc=(0.37,0.5))show(pt1+pt2,figsize=6)
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
to share – to copy, distribute and transmit the work
to remix – to adapt the work
Under the following conditions:
attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.