Mathematica: Substituting in for integrand

  • Mathematica
  • Thread starter Arijun
  • Start date
  • Tags
    Mathematica
In summary, you are trying to integrate a function that has three integration variables, dθ, dr, and φ. You are using Sequence[] and Integrate to try and integrate the function.
  • #1
Arijun
21
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
  • #2
You can't do that!
 
  • #3
Too bad...
 
  • #4
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:
  • #5
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]
 

Related to Mathematica: Substituting in for integrand

1. What is Mathematica and how does it work?

Mathematica is a computational software program used for mathematical calculations and data analysis. It uses a symbolic language to represent mathematical expressions and can perform a wide range of operations, including solving equations, plotting graphs, and integrating functions.

2. How do I substitute in a specific value for an integrand in Mathematica?

To substitute in a specific value for an integrand in Mathematica, you can use the "ReplaceAll" function (represented by the symbol "/."). For example, if you have an integrand f(x) and you want to substitute in the value x=2, you could write f(x)/.x->2. This will replace all instances of x in the integrand with the value 2, allowing you to evaluate the integral at that specific point.

3. Can Mathematica handle complex integrals?

Yes, Mathematica has the ability to handle complex integrals. It can handle both real and complex variables, and can also handle integrals with multiple variables. It also has built-in functions for evaluating integrals with special functions such as trigonometric, hyperbolic, and exponential functions.

4. How accurate are the results when using Mathematica to evaluate integrals?

The accuracy of the results when using Mathematica to evaluate integrals depends on the complexity of the integrand and the numerical precision specified. By default, Mathematica uses machine precision, but you can specify a higher precision if needed. It is always recommended to check the results and make sure they are reasonable before using them in any applications.

5. Can Mathematica help me with step-by-step solutions for integrals?

Yes, Mathematica has a feature called "Step-by-step Solutions" that can provide a detailed breakdown of how it solved a particular integral. This feature can be accessed by clicking on the "Show Steps" button in the bottom right corner of the result box. It can be helpful for understanding the process of evaluating an integral and can also provide insights for solving similar integrals in the future.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
19
Views
581
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • Calculus and Beyond Homework Help
Replies
4
Views
506
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
Back
Top