Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following program for computing f(x) =e^(rx)sin(mx)+e6(sx)sin(nx) d

ID: 1278684 • Letter: C

Question

Consider the following program for computing

f(x) =e^(rx)sin(mx)+e6(sx)sin(nx)

def f(x, m, n, r, s):

return expsin(x, r, m) + expsin(x, s, n)

x = 2.5

print f(x, 0.1, 0.2, 1, 1)

from math import exp, sin

def expsin(x, p, q):

return exp(p*x)*sin(q*x)

Find an error in the program and correct the program. The corrected output is?

I am having a hard time with getting the program to run on python. I keep trying to fix the problems in the program, but I must not be doing it correctly. Any help would be much appreciated.

Explanation / Answer

The order you define things matter.. you have to define things before you use them

from math import exp,sin

def expsin(x,p,q):
   return exp(p*x)*sin(q*x)

def f(x,m,n,r,s):
   return expsin(x,r,m) + expsin(x,s,n)

x=2.5

print f(x,0.1,0.2,1,1)