Processing math: 100%
Ask Your Question
1

Defining constants after solving ODE/PDE

asked 10 years ago

Marios Papachristou gravatar image

Hello

Solving the differential equation f(x)=f(x) the answer leads to f(x)=cex where c is a constant. How can I generically solve this ODE in SAGE and define c afterwards (I don't want to use ics)?

Consider this script

x = var('x')
f = function('f',x)
f = desolve(diff(f,x) == f(x), f, ival=x)
print str(f(x))
>> ce^x
#I want to define c afterwards

A method I found:

#continue the previous prompt
f(x,c) = f(x)
h(x) = f(x,10)

Is there something else that I can do?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 10 years ago

rws gravatar image

updated 10 years ago

First, although you set f to be a function, you later overwrite it with the result of desolve which is a symbolic expression. You can, instead of using it as function, simply substitute any other expression for c:

f = desolve(diff(f,x) == f(x), f, ival=x)
sage: f
c*e^x                                                                                  
sage: f.subs(c=10)
10*e^x                                                                                 
sage: f.subs(c=sin(x))
e^x*sin(x)

If you want that in function notation, assign the expression to a function call:

sage: f(x,c)=f
sage: f
(x, c) |--> c*e^x
sage: f(x,10)
10*e^x
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

1 follower

Stats

Asked: 10 years ago

Seen: 650 times

Last updated: Jan 02 '15