Anaconda Python in Euler Math Toolbox

Instead of the usual separate installation of Python and its packages, you can install Anaconda for Euler Math Toolbox (EMT). You can use Anaconda on its own, of course. Start a program called „Spyder“ and enter the code at the bottom of this page into the editor, then press the green arrow to run this code. You get the following graph.

a

But you can also run this from EMT directly. The following will open a Python window with this plot.

>function python ...
$from pylab import *
$from matplotlib.patches import Polygon
$def func(x):
$    return (x-3)*(x-5)*(x-7)+85
$ax = subplot(111)
$a, b = 2, 9 # integral area
$x = arange(0, 10, 0.01)
$y = func(x)
$plot(x, y, linewidth=1)
$# make the shaded region
$ix = arange(a, b, 0.01)
$iy = func(ix)
$verts = [(a,0)] + list(zip(ix,iy)) + [(b,0)]
$poly = Polygon(verts, facecolor='0.8', edgecolor='k')
$ax.add_patch(poly)
$text(0.5 * (a + b), 30,
$     r"$\int_a^b f(x)\mathrm{d}x$", horizontalalignment='center',
$     fontsize=20)
$axis([0,10, 0, 180])
$figtext(0.9, 0.05, 'x')
$figtext(0.1, 0.9, 'y')
$ax.set_xticks((a,b))
$ax.set_xticklabels(('a','b'))
$ax.set_yticks([])
$show()
$endfunction

If you omit the show() command, pyins() will insert the graphics into the EMT notebook.

Just to show you that this plot can be done in EMT too.

>function f(x) := (x-3)*(x-5)*(x-7)+85;
>plot2d("f",0,10,xl="x",yl="y",frame);
>plot2d("f",2,9,>filled,>add,fillcolor=lightgray);
>xaxis(0,[2,9],["a","b"]); yaxis(0);
>label(latex("\int_a^b f(x) \, dx",factor=1.3),5,50):

b

 

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.