n | | n | #!/usr/bin/env python2 |
| | | # -*- coding: utf-8 -*- |
| | | from math import * |
| | | |
| | | |
| def SUB(f, g): | | def SUB(a, b): |
| if callable(f) and callable(g): | | if callable(a) and callable(b): |
| def h(x): | | def h(x): |
n | return f(x)-g(x) | n | return a(x) - b(x) |
| if callable(f) and (not callable(g)): | | if callable(a) and not callable(b): |
| def h(x): | | def h(x): |
n | return f(x)-g | n | return a(x) - b |
| if (not callable(f)) and callable(g): | | if not callable(a) and callable(b): |
| def h(x): | | def h(x): |
n | return f-g(x) | n | return a - b(x) |
| if (not callable(f)) and (not callable(g)): | | if not callable(a) and not callable(b): |
| def h(x): | | def h(x): |
n | return f-g | n | return a - b |
| return h | | return h |
| | | |
| | | |
n | def DIV(f, g): | n | def DIV(a, b): |
| if callable(f) and callable(g): | | if callable(a) and callable(b): |
| def h(x): | | def h(x): |
n | return f(x)/g(x) | n | return a(x)/b(x) |
| if callable(f) and not callable(g): | | if callable(a) and not callable(b): |
| def h(x): | | def h(x): |
n | return f(x)/g | n | return a(x)/b |
| if (not callable(f)) and callable(g): | | if not callable(a) and callable(b): |
| def h(x): | | def h(x): |
n | return f/g(x) | n | return a/b(x) |
| if (not callable(f)) and (not callable(g)): | | if not callable(a) and not callable(b): |
| def h(x): | | def h(x): |
n | return f/g | n | return a/b |
| return h | | return h |
| | | |
| | | |
n | def MUL(f, g): | n | def MUL(a, b): |
| if callable(f) and callable(g): | | if callable(a) and callable(b): |
| def h(x): | | def h(x): |
n | return f(x)*g(x) | n | return a(x)*b(x) |
| if callable(f) and not callable(g): | | if callable(a) and not callable(b): |
| def h(x): | | def h(x): |
n | return f(x)*g | n | return a(x)*b |
| if not callable(f) and callable(g): | | if not callable(a) and callable(b): |
| def h(x): | | def h(x): |
n | return f*g(x) | n | return a*b(x) |
| if (not callable(f)) and (not callable(g)): | | if not callable(a) and not callable(b): |
| def h(x): | | def h(x): |
n | return f*g | n | return a*b |
| return h | | return h |
| | | |
| | | |
n | def ADD(f, g): | n | def ADD(a, b): |
| if callable(f) and callable(g): | | if callable(a) and callable(b): |
| def h(x): | | def h(x): |
n | return f(x)+g(x) | n | return a(x)+b(x) |
| if callable(f) and not callable(g): | | if callable(a) and not callable(b): |
| def h(x): | | def h(x): |
n | return f(x)+g | n | return a(x)+b |
| if not callable(f) and callable(g): | | if not callable(a) and callable(b): |
| def h(x): | | def h(x): |
n | return f+g(x) | n | return a+b(x) |
| if (not callable(f)) and (not callable(g)): | | if not callable(a) and not callable(b): |
| def h(x): | | def h(x): |
t | return f+g | t | return a+b |
| return h | | return h |
| | | |