Mathematica: Substituting in for integrand

  • Context: Mathematica 
  • Thread starter Thread starter Arijun
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary

Discussion Overview

The discussion revolves around the use of Mathematica for integrating a complex expression involving multiple variables and substitutions. Participants explore how to structure the integrand and the integration variables to achieve a more compact representation while maintaining the correct evaluation order.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant expresses a desire to write the integrand separately from the integral and questions how to ensure Mathematica evaluates substitutions before the integral.
  • Another participant asserts that the proposed method is not feasible.
  • A different participant suggests that while the approach may seem problematic, it is not entirely hopeless and offers an alternative method using Sequence[] to structure the integrand.
  • Another participant proposes defining each integration variable separately to facilitate the integration process, presenting a different structure for the integrand.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the feasibility of the original approach. There are competing views regarding the best method to structure the integrand and the integration variables.

Contextual Notes

Some limitations are noted, such as the challenge of separating the limits of integration from the integrand and the variable of integration in definite integrals.

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 ·
Replies
19
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 10 ·
Replies
10
Views
13K