Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question
1

Substitute variable in differential equation

asked 5 years ago

Emil Widmann gravatar image

updated 4 years ago

I have

m = function('m')(r)
V = function('V')(r)
phi = m(r)/r
V = 4*pi*r^3/3
divG = (diff(phi,r,2)+2/r*diff(phi,r)).full_simplify()

which describes a spherical symmetric source term of a field, nice. Now I want to get this as a function of volume, not of radius and tried:

a=divG.subs(r=V(r))

But it gets me nowhere - It should also substitute the differentials - How to solve this?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 4 years ago

Juanjo gravatar image

If I am right, you want to transform the differential expression d2ϕdr2+2rdϕdr, where ϕ(r)=m(r)r, by changing the independent variable to V. The relation between V and r is V=4π3r3. We can think of m(r) as the result of composing two functions: one that yields V in terms of r and then one that yields m in terms of V. In other words, an abusing a bit of the notation, m(r)=m(V(r)).

We can then transform the given differential expression as follows:

var("r,V")
vol = 4*pi*r^3/3
m(V) = function("m")(V)    # m as function of V
M = m(V.subs(V=vol))       # this is m(r)=m(V(r))
phi = M/r
divG = (diff(phi,r,2) + 2/r*diff(phi,r))
divG = divG.subs(vol==V, r^3==3*V/(4*pi)).full_simplify()
show(divG)

In a Jupyter notebook, one gets

12πV2(V)2m(V)+8πVm(V)

that is, in a more proper mathematical notation,

4π(3Vd2mdV2(V)+2dmdV(V))

I hope this has some meaning for you.

Preview: (hide)
link

Comments

Thanks a lot for showing me. - I got the first term of the solution by hand, but missed the second. The result has a meaning, but what it is I have to figure out, it seems the bracket contains sort of a "density operator".

Emil Widmann gravatar imageEmil Widmann ( 4 years ago )

Just 2 more questions: How do I insert latex code here in this forum? How are the symbols D0 and D0,0 defined (result from show(divG), divG in the first version as function from r)?

Emil Widmann gravatar imageEmil Widmann ( 4 years ago )

1) This forum uses MathJax to render LaTeX code. You just have to write it as you would do in a TeX file. For example, if you write

This is inline math: $V(r)=4\pi r^3/3$. This is display math:
$$V(r)=\frac{4\pi}{3}r^3.$$

you get, as expected,

This is inline math: V(r)=4πr3/3. This is display math: V(r)=4π3r3.

Juanjo gravatar imageJuanjo ( 4 years ago )

2) If you insert print(divG), you will see that those symbols come from D[0,0](m) and D[0](m). For a multivariate function f, D[i,j,k...](f) means the partial derivative of f respect to the i-th variable, then the j-th variable, then the k-th variable and so on. For example, for f(x,y,z), D[2,0,1,2](f) corresponds to 4fzxyz, that is, 4fxyz2 if fC4. Take into account that, in Python, indices start counting in 0.

For a univariate function, D[0](f), D[0,0](f), etc. are just their successive derivatives.

Juanjo gravatar imageJuanjo ( 4 years ago )

Vielen Dank! I would upvote 2 times more if I could ...

Emil Widmann gravatar imageEmil Widmann ( 4 years ago )

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: 5 years ago

Seen: 1,205 times

Last updated: Apr 11 '20