Kernel: Python 3 (Ubuntu Linux)
In [2]:
Elementary operations
We will frequently be computing with arrays of numbers, so let's see how various elementary computations are defined
In [13]:
[1 2 3 4]
In [14]:
[ 6 8 10 12]
Exercise
Try various elementary operations (+
,-
,*
,/
). What do the operations x**2
and x**y
produce? And how about x^2
?
Univariate functions
To plot a function we first need to evaluate it at a number of points and subsequently produce a plot.
In [4]:
[<matplotlib.lines.Line2D at 0x7f3e41edacc0>,
<matplotlib.lines.Line2D at 0x7f3e41edaeb8>]
We can add labels, a legend and change the linestyle of the plots:
In [9]:
<matplotlib.legend.Legend at 0x7f3e18119f60>
Defining your own functions
We can define our own functions as follows
In [24]:
[<matplotlib.lines.Line2D at 0x7f3e115b0908>,
<matplotlib.lines.Line2D at 0x7f3e115b0a90>]
Exercise
Define the function ParseError: KaTeX parse error: Unknown column alignment: - at position 29: …{\begin{array} -̲-x & x < -1 \\ …
and plot it.
Multivariate functions
When plotting a function of two variables, we need to define a grid first:
In [11]:
(0.0, 1.0, 0.0, 1.0)
In [0]: