Ask Your Question
0

Access integration constant

asked 2017-02-02 12:10:46 +0200

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!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-02-02 15:37:16 +0200

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
edit flag offensive delete link more
0

answered 2017-02-10 14:52:38 +0200

maaaaaaartin gravatar image

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

edit flag offensive delete link more

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: 2017-02-02 12:10:46 +0200

Seen: 481 times

Last updated: Feb 10 '17