Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: math480-2016
Views: 2158

Math 480: Open Source Mathematical Software

2016-04-25

William Stein

Lectures 13: Symbolic Calculus (part 1 of 3)

Today:

  1. (John Jeng) Update on peer grading (due Friday at 6pm)

  2. Turn on screen cast

  3. New homework assignment (due Friday at 6pm)

  4. Today: symbolic calculus (part 1 of 3)

Some Resources for Symbolic Calculus in Sage

Short crash course

  • defining symbolic variables

  • defining symbolic functions

  • plot

  • differente

  • integrate

  • finding zeros

reset()
y + theta
Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> NameError: name 'y' is not defined
# x is predefined; can define other variables... %var y, theta, aleph
show(x+y+theta +aleph)
aleph+θ+x+y\displaystyle \mathit{aleph} + \theta + x + y
var('y, theta')
(y, theta)
f(z, william) = z*(z+1)*william f(10)
110*william
z + william
william + z
type(f)
<type 'sage.symbolic.expression.Expression'>
f.parent()
Callable function ring with argument z
f * f
z |--> (z + 1)^2*z^2
show(f)
z  (z+1)z\displaystyle z \ {\mapsto}\ {\left(z + 1\right)} z
# GOTCHA! z = .5 f(z) = z*(z+1) # this line whacks the previous defn of z!! print z
z
z = .5 def f(z): print z print z
0.500000000000000
f(z) = z*(z+1) g = plot(f, (0, 3), color='chartreuse', thickness=10, zorder=10) # has a bazillion options show(g + text('hi there class!', (2,6), zorder=11))
diff(x^5 + 2*x + pi, x)
5*x^4 + 2
f = sin(x)*cos(x)*tan(x) g = integrate(f, x) show(g)
12x14sin(2x)\displaystyle \frac{1}{2} \, x - \frac{1}{4} \, \sin\left(2 \, x\right)
h = g.differentiate(x) show(h)
12cos(2x)+12\displaystyle -\frac{1}{2} \, \cos\left(2 \, x\right) + \frac{1}{2}
k = h - f show(k)
cos(x)sin(x)tan(x)12cos(2x)+12\displaystyle -\cos\left(x\right) \sin\left(x\right) \tan\left(x\right) - \frac{1}{2} \, \cos\left(2 \, x\right) + \frac{1}{2}
k
-cos(x)*sin(x)*tan(x) - 1/2*cos(2*x) + 1/2
plot(k, 0, 1)
k.si ︠228efa99-f7b6-47c7-9774-eb894d2acffes︠ k.simplify_full()
0
sin(x).find_root(2,5)
3.1415926535898335
N(sin(1/2))
0.479425538604203
complex_plot(x^2, (-1,1), (-1,1))