Skip to content

Instantly share code, notes, and snippets.

@MechCoder
Last active December 19, 2015 11:58
Show Gist options
  • Save MechCoder/5951408 to your computer and use it in GitHub Desktop.
Save MechCoder/5951408 to your computer and use it in GitHub Desktop.
Which one is better?
chi = Function('chi')(x, y)
chix = chi.diff(x)
chiy = chi.diff(y)
cpde = chix + h*chiy - hy*chi
chieq = Symbol("chi")
for i in range(1, deg + 1):
chieq += Add(*[
Symbol("chi_" + str(power) + "_" + str(i - power))*x**power*y**(i - power)
for power in range(i + 1)])
cnum, cden = cancel(chieq.diff(x) + h*chieq.diff(y)
- hy*chieq).as_numer_denom() # Is this better
cnum, cden = cancel(cpde.subs({chi : chieq}).doit()).as_numer_denom() ## Or this?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment