Skip to content

Instantly share code, notes, and snippets.

@MechCoder
Created August 20, 2013 04:58
Show Gist options
  • Save MechCoder/6277258 to your computer and use it in GitHub Desktop.
Save MechCoder/6277258 to your computer and use it in GitHub Desktop.
Rules for integration
Indefinite integrals:
1. If old is an integration variable, and new is a Symbol that is not present in expr, then expr.subs({old: new}), should xreplace old with new.
Example:
expr = Integral(f(x), x)
expr.subs(x, y) // should give
⎮ f(y) dy
since dx = dy
However
expr = Integral(f(y), x)
expr.subs(x, y) should NOT give
⎮ f(y) dy
2. If old is an integration variable and new is anything, then it should give a definite integral with new as the upper bound.
expr = Integral(f(x), x)
expr.subs(x, exp(x)) should give
x
⎮ f(x) dx
expr.subs(x, exp(y)) should give
y
⎮ f(x) dx
3. If old is a function of the integration variable and new is also a function of the integration variable.
expr = Integral(exp(x)*log(x), x)
expr.subs(expr.subs(log(x), exp(x)) // What should this return?
Definite integrals:
1. If old is an integration variable, and new is a Symbol that is not present in expr, then expr.subs({old: new}), should xreplace old with new. // Same as above
Example:
expr = Integral(f(x), (x, 1, 2))
expr.subs(x, y) // should give
2
⎮ f(y) dy
1
since dx = dy
However
expr = Integral(f(y), (x, 1, 2))
expr.subs(x, y) should NOT give
2
⎮ f(y) dy
1
2. If old is an integration variable and new is anything, should it return a ValueError?
3. If old is a function of the integration variable and new is also a function of the integration variable, what should it do? Value Error?
According to me, any other case should return a ValueError/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment