- #1
MaxManus
- 277
- 1
Homework Statement
The exercise: Make a Python function for computing
g(t) = e**(-a * t**2) and gderiv(t) = -2*a*t*g(t)
Return the function values of g(t) and gderiv(t). Apply the function to write out a result in the format:
g(1, a=0.5)=0.606531, g’(1, a=0.5)=-0.606531 I have made a function g(t, a) and gderiv(t,a), but I don't know how to print t and a so that i can print the result in the format: "g(1, a=0.5)=0.606531, g’(1, a=0.5)=-0.606531"
The Attempt at a Solution
from math import e
def g(t, a):
G = e**(-a*t**2)
Gderiv = -2*a*t*G
return G, Gderiv,
G,Gderiv = g(t = 1, a = 0.5)
print "g(%g, a=%g) = %.6f" % (t, a, G)
Edit: The problem is that t and a are not defined.