What is the best way to check if a parameter increase in a mathematical expression increases or decreases the expression as a whole (in Python, preferably SymPy)?
Assumptions: all parameters are positive (i.e. > 0).
Example A*B/(A+C)
: A
should be found as proportional to the expressio开发者_开发技巧n and C
should be found as inverse proportional.
One obvious solution would be to assign 1 to all parameters, 1 and 100 to C respectively and apply eval()
, but that is very crude and might yield errors (e.g. with (A-B)/C
where the best case would be to give an error instead of a wrong result).
I don't believe this can be solved in the general case. A simple counter-example is sin(A)
, which could be both proportional and inverse proportional, depending on what value of A you are evaluating it at.
However, you could use an automatic differentiation tool, such as PyDX or Theano, to compute the derivative of functions at various parameter values.
精彩评论