f | from math import * | f | from math import * |
| | | |
| | | |
| def ADD(f, g): | | def ADD(f, g): |
n | def fun(x): | n | def H(x): |
| if callable(f) and callable(g): | | if callable(f) and callable(g): |
n | return f(x)+g(x) | n | return f(x) + g(x) |
| elif callable(f): | | elif callable(f): |
n | return f(x)+g | n | return f(x) + g |
| elif callable(g): | | elif callable(g): |
n | return f+g(x) | n | return f + g(x) |
| else: | | else: |
n | return f+g | n | return f + g |
| return fun | | return H |
| | | |
| | | |
| def SUB(f, g): | | def SUB(f, g): |
n | def fun(x): | n | def H(x): |
| if callable(f) and callable(g): | | if callable(f) and callable(g): |
n | return f(x)-g(x) | n | return f(x) - g(x) |
| elif callable(f): | | elif callable(f): |
n | return f(x)-g | n | return f(x) - g |
| elif callable(g): | | elif callable(g): |
n | return f-g(x) | n | return f - g(x) |
| else: | | else: |
n | return f-g | n | return f - g |
| return fun | | return H |
| | | |
| | | |
| def MUL(f, g): | | def MUL(f, g): |
n | def fun(x): | n | def H(x): |
| if callable(f) and callable(g): | | if callable(f) and callable(g): |
n | return f(x)*g(x) | n | return f(x) * g(x) |
| elif callable(f): | | elif callable(f): |
n | return f(x)*g | n | return f(x) * g |
| elif callable(g): | | elif callable(g): |
n | return f*g(x) | n | return f * g(x) |
| else: | | else: |
n | return f*g | n | return f * g |
| return fun | | return H |
| | | |
| | | |
| def DIV(f, g): | | def DIV(f, g): |
n | def fun(x): | n | def H(x): |
| if callable(f) and callable(g): | | if callable(f) and callable(g): |
n | return f(x)/g(x) | n | return f(x) / g(x) |
| elif callable(f): | | elif callable(f): |
n | return f(x)/g | n | return f(x) / g |
| elif callable(g): | | elif callable(g): |
n | return f/g(x) | n | return f / g(x) |
| else: | | else: |
t | return f/g | t | return f / g |
| return fun | | return H |
| | | |