-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Currently (from the demo):
h(x)=x^2+3x+7
h(x)
derivative(h,"x")
TypeError: Unexpected type of argument in function derivative
(expected: string or Node or number or boolean,
actual: function, index: 0)
It would seem reasonable to extend derivative
to apply to a "function" since it is not doing anything on such an argument now. Moreover, it would seem good when the argument is "function" for the return type to be "function" as well, so that one could do hypothetically:
h(x) = x^2+3x+7
h(x)
dh = derivative(h, "x")
dh(x)
dh(1)
5 // 2x+3 evaluated at 1
Additionally, do you see any problem with making derivative
take rawArgs so that e.g. derivative(x^2+3x+2,x)
[Note: no quotes] would work as well? Are there cases when the user would want there to be evaluation in either argument that derivative
couldn't figure out that it should do, or where the meaning would be ambiguous depending on whether derivative
decided to do evaluation ?
Finally, is there any reason why the second argument, giving the variable, shouldn't be optional, and default to the lexicographically first free variable that appears in the first argument? With all of these changes, we could write derivative(x^2+3x+2)
and get back 2*x+3
which would seem very reasonable.