Defining Functions
It is often useful to define your own functions within a python program. A function can run any lines of code you desire, in addition to manipulating inputs and outputs. For the first example, we'll stick to a simple mathematical function.
Here we define a function of two inputs, then call it, save the output in a new variable, and print the output:
Plotting Complex Functions
Python has a built in syntax for manipulating complex numbers, using \(j = \sqrt{-1}\). It also lets you easily identify the magnitude, phase, and real and imaginary parts.
In order to visualize complex functions of a single real variable, we need to use two plots. This might be magnitude and phase, or real and imaginary part. In this example, we define the complex function \(z(s) = 2+e^{i s}\), then plot its magnitude and phase:
No comments:
Post a Comment