[Solved] How to design mathematical program which calculate the derivative of a function using python? [closed]


Taking a function is easy… it’s just like any other argument.

def example(somefunc):
  somefunc() 

example(someFunction)
example(lambda x: x ** 2)

Returning one is a little trickier, but not much.

You can return a lambda:

def example2():
  return lambda x: x + 1

Or you can build an inner function, and return that

def example3():
  def rf(x):
    return x + 2
  return rf

myfunc = example3()
myfunc(2) #returns 4

solved How to design mathematical program which calculate the derivative of a function using python? [closed]