f | from math import * | f | from math import * |
| | | |
| | | |
| def ADD(f, g): | | def ADD(f, g): |
n | def H(x): | n | def fun(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 H | | return fun |
| | | |
| | | |
| def SUB(f, g): | | def SUB(f, g): |
n | def H(x): | n | def fun(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 H | | return fun |
| | | |
| | | |
| def MUL(f, g): | | def MUL(f, g): |
n | def H(x): | n | def fun(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 H | | return fun |
| | | |
| | | |
| def DIV(f, g): | | def DIV(f, g): |
n | def H(x): | n | def fun(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 H | | return fun |
| | | |