# begin-grid-area
!bslidecell 00
...
!eslidecell
!bslidecell 01
...
!eslidecell
!bslidecell 02
...
!eslidecell
# end-grid-area
Mathematics. Given a function
$$ f(x) = e^{-ax}\sin wx\thinspace .$$ Write a program for evaluating \( f(x) \), and test the program for the value of \( f(0) \).Implementation. The Python implementation reads
from math import exp, sin
def f(x):
return exp(-a*x)*sin(w*x)
a
and w
must be global variables, initialized in the
main program.
Computational experiment. With a main program
a = 1
from math import pi
w = pi
print(f(0))
Terminal> python prog.py
0
from math import exp, sin
def f(x):
return exp(-a*x)*sin(w*x)
a
and w
must be global variables, initialized in the
main program.
a = 1
from math import pi
w = pi
print(f(0))
Terminal> python prog.py
0