Mathematica Mathematica: Substituting in for integrand

  • Thread starter Thread starter Arijun
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
The discussion centers on the challenges of integrating a complex expression in Mathematica, specifically when trying to define the integrand before the integral for a more compact representation. The user encounters difficulties with substitutions involving differential elements (dq's) and seeks a method to ensure Mathematica evaluates these substitutions prior to performing the integral. The integral in question pertains to calculating the gravitational field outside a uniform sphere.A suggested workaround involves using the Sequence[] function to format the integrand correctly, allowing for a more streamlined input while maintaining the necessary order of variables. This approach, however, does not extend to definite integrals where limits cannot be separated from the integrand. The conversation hints at the potential for more advanced solutions from experienced Mathematica users, encouraging the exploration of alternative forums for further insights on this integration puzzle.
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:
\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}
In case you're wondering, it's the gravitational field outside a uniform sphere.
 
Physics news on Phys.org
You can't do that!
 
Too bad...
 
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]
 

Similar threads

Replies
19
Views
2K
Replies
1
Views
2K
Replies
13
Views
2K
Replies
1
Views
2K
Replies
5
Views
3K
Replies
5
Views
2K
Replies
1
Views
2K
Replies
10
Views
12K
Back
Top