Week 7 - Defining Functions

Question 1

a) Define the function f(x)=cos(x).

b) Plot the function over the range 0 to 2π

c) Evaluate the function at x=0. Does it give the expected value?

Question 2

a) Define the function g(x) as the derivative of x^2 with respect to x using either ‘:=’ or ‘=’

b) Evalutate g(3)

Does this give the correct answer? Explain your choice of ‘:=’ or ‘=’.

Question 3

a) Define a function h(y)=(d/dy)cos(y)

b) Evaluate h(((3π)/2))

c) Plot the function h(y) for y from -3π to 3π