Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Using Mathematica I want to solve an integral over a function that contains both determined and undetermined parts which looks like this:

r[\[Theta], z] = Sqrt[(h/2)^2 - z^2] + g[\[Theta]] - h/2

As you can see the h/2 and root terms are determined, but g remains an undetermined function of $\theta$. Now I take an integral over this function to both z and theta:

V = Integrate[[Integrate[1/2 r[\[Theta], z]^2, {z, -h/2, h/2}], {\[Theta], 0, 2 \[Pi]}]

which results in:

$$V= \int_0^{2 \pi } \left(\frac{1}{8} (\pi -4) h^2 g(\theta )+\frac{1}{2} h g(\theta )^2+\frac{1}{48} (10-3 \pi ) h^3\right) \, d\theta$$

As you can see, the last term contains no dependence on $\theta$ and therefore I would like that part of the integral solved. In particular I would like my result to look like this $$V=\frac{1}{24} (10-3 \pi )\pi h^3 + \frac{1}{8} (\pi -4) h^2 \int_0^{2 \pi }g(\theta )\, d\theta+\frac{1}{2} h \int_0^{2 \pi }g(\theta )^2 \, d\theta$$

Is there some way to force mathematica to solve the parts of the function that are not dependent (or with known dependence) on the variable towards which I integrate?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Yes, there is such a way. Try this, for example. First define a function to integrate;

int[expr_] := Integrate[expr, {z, -h/2, h/2}, {\[Theta], 0, 2 \[Pi]}]

Then map this function onto the terms of your expression:

r[\[Theta], z] = Sqrt[(h/2)^2 - z^2] + g[\[Theta]] - h/2;

Map[int, Expand[1/2 r[\[Theta], z]^2]]

This results in:

$$\int_0^{2 \pi } -\frac{1}{2} h^2 g(\theta ) \, d\theta +\int_0^{2 \pi } \frac{1}{8} \pi h^2 g(\theta ) \, d\theta +\int_0^{2 \pi } \frac{1}{2} h g(\theta )^2 \, d\theta +\frac{1}{24} \pi (10-3 \pi ) h^3 $$

share|improve this answer
    
Great, thanks! Quick comment: did you know that you can copy the output of mathemetica directly as latex by right-clicking on the equation and selecting "Copy as -> Latex"? –  Michiel Jul 4 at 12:12
    
@Michiel No, I did not. –  Alexei Boulbitch Jul 4 at 14:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.