Skip to content

Instantly share code, notes, and snippets.

@tell
Last active September 27, 2015 15:28
Show Gist options
  • Save tell/1291649 to your computer and use it in GitHub Desktop.
Save tell/1291649 to your computer and use it in GitHub Desktop.
Symbolic calculation on Sage 4.7.1 using Napier's constant
## Problem: Do not use symbol 'e'.
## see http://homepage1.nifty.com/herumi/diary/1110.html#14
var('x t a b c d g') # we can not use symbol 'e' instead of 'g'.
assume(t > 0)
f = ((exp(x) - (a + b*x + c*x^2 + d*x^3 + g*x^4))^2).integral(x,0,t)
ans = solve([f.diff(a), f.diff(b), f.diff(c), f.diff(d), f.diff(g)], [a,b,c,d,g])
## work around
ans1 = [eq.subs(e=exp(1)) for eq in ans[0]]
## check, limit to 0
for eq in ans1:
print eq.limit(t=0)
for eq in ans1:
print eq.left(), '=', eq.right().subs(t=log(2)/4096).n(500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment