Ask Your Question
0

Access integration constant

asked 8 years ago

maaaaaaartin gravatar image

Hi,

Consider the following code:

x = var('x')

f = function('f')(x)

sol = desolve(diff(f,x), [f,x])

print "sol =", sol

solve(sol, _C)

For which I'm getting NameError: name '_C' is not defined. What would be the right way to set the integration constant after the resolution of the differential equation?

Thanks!

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 8 years ago

eric_g gravatar image

Like this (for instance setting the integration constant to 2):

sage: sol2 = sol.subs({SR.var('_C'): 2})
sage: print("sol = {}".format(sol2))
sol = 2
Preview: (hide)
link
0

answered 8 years ago

maaaaaaartin gravatar image

For the record, a workaround is to declare var('_C')right before solve(sol, _C).

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 8 years ago

Seen: 905 times

Last updated: Feb 10 '17