Mathematica: Substituting in for integrand

  • Context: Mathematica 
  • Thread starter Thread starter Arijun
  • Start date Start date
  • Tags Tags
    Mathematica
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 3K views
Arijun
Messages
21
Reaction score
1
I would like to be able to write my integrand before my integral and then have my integral be more compact. However Mathematica does not seem to like when I try and substitute in my dq's. Is there a way to tell mathematica to evaluate the substitution before evaluating the integral?(and, I guess, maintaining the order of my dq's, since I think mathematica would have a hard time parsing the integral if it assumes the dq's commute with the rest of the integrand)

This is what I'm trying to integrate:
[tex]\text{dg}\text{:=}G \rho /r`^2\ \text{dVol};\ \text{dVol}\text{:=}\sin [\theta ]\ r^2\ d\phi \ d\theta \ dr; \\g=\int _0^R\int _0^{\pi }\int _0^{2\pi }\text{dg}[/tex]
In case you're wondering, it's the gravitational field outside a uniform sphere.
 
Physics news on Phys.org
I'm not convinced it is completely hopeless.

But what you are trying to do is subvert the usual evaluation process and that is almost always problematic.

While it isn't "desktop publishing" your input, which is what I suspect you REALLY want, this does work:

In[1]:= dg=Sequence[Sin[θ]r^2,θ,r];

In[2]:= Integrate[dg]

Out[2]= -1/3 r^3 Cos[θ]

Other than inserting that Sequence[] and writing θ,r instead of dθ,dr that is close to what you wrote.

Sequence[] allows you to enter a bare collection of comma separated items and Integrate is looking for an integrand separated by a comma from the variable of integration.

Unfortunately at the moment I don't see a way to do definite integrals where the limits of integration are separated from the integrand and variable of integration.

But I would not be too surprised if some much brighter person who really understands the depths of MMA evaluation could come up with some way of doing what you want. You might try asking your question in a couple of other places where a few of the really skilled folks will take the time to answer interesting puzzles.
 
Last edited:
What about something like defining each integration variable separate?d\[Phi] = {\[Phi], 0, 2 \[Pi]};
d\[Theta] = {\[Theta], 0, \[Pi]};
dr = {r, 0, R};
POT = G \[Rho]/r^2;
dVol = Sequence[POT Sin[\[Theta]] r^2 , d\[Phi], d\[Theta], dr]
Integrate[dVol]