0
$\begingroup$

Why isnt my mathematica code integrating the second integral? Fairly lost as to why it will not. Trying to find an E field for an electromagnetism problem. There is a closed formed, I've seen it in the problem booklet. I was just trying to speed up my computations by learning mathematica.

input

f[r_] = Subscript[\[Sigma], o]/(4*Pi*Subscript[\[Epsilon], o])*
Integrate[
Integrate[(z*OverHat[z] - s*OverHat[s])/Sqrt[z^2 + s^2], {\[Phi], 
0, 2*\[Pi]}], {s, 0, R}]

output

stuck with the second integral not integrating

$\endgroup$
3
  • $\begingroup$ Questions like "Why won't Mathematica compute this integral analytically?" aren't really appropriate here unless there is at least some minimal justification of why you think a closed form result exists, and why Mathematica should be expected to find it. $\endgroup$
    – Szabolcs
    Sep 13, 2017 at 10:23
  • $\begingroup$ (Please add this justification even if you think that it is obvious—it takes time for people to look at your integral and decide this.) $\endgroup$
    – Szabolcs
    Sep 13, 2017 at 10:38
  • $\begingroup$ Ill take care of that, I apologize. $\endgroup$ Sep 13, 2017 at 19:38

1 Answer 1

4
$\begingroup$

There are two problems:

You are using OverHat[s] and treating it as a separate variable. Mathematica does not know that this is how it's supposed to be interpreted. It thinks that OverHat is a function/operator and won't be able to carry out the integral because it does not know the definition of this function. It is generally best to avoid things like Subscript, OverHat, etc. and use plain symbols.

The other problem is that you have lots of parameters, which in general can be any complex number. Help Mathematica out by providing Assumptions.

Integrate[(2 π (-s hs + z hz))/Sqrt[
 s^2 + z^2] , {s, 0, R}, Assumptions -> (R > 0)]
(* ConditionalExpression[π (2 hs Sqrt[z^2] - 
    2 hs Sqrt[R^2 + z^2] - hz z Log[z^2] + 
    2 hz z Log[R + Sqrt[R^2 + z^2]]), 
 R < Im[z] || R + Im[z] < 0 || Re[z] != 0] *)

Integrate[(2 π (-s hs + z hz))/Sqrt[
 s^2 + z^2] , {s, 0, R}, 
 Assumptions -> (Element[hs | hz | z, Reals] && R > 0)]
(* ConditionalExpression[
 2 π (-hs Sqrt[R^2 + z^2] + hs Abs[z] + 
    hz z Log[(R + Sqrt[R^2 + z^2])/Abs[z]]), z != 0] *)

Integrate[(2 π (-s hs + z hz))/Sqrt[
 s^2 + z^2] , {s, 0, R}, 
 Assumptions -> (Element[hs | hz, Reals] && z > 0 && R > 0)]
(* 2 π (hs (z - Sqrt[R^2 + z^2]) + 
   hz z Log[(R + Sqrt[R^2 + z^2])/z]) *)
$\endgroup$
2
  • $\begingroup$ The only necessary assumptions appear to be R > 0 && Re[z] != 0. $\endgroup$ Sep 13, 2017 at 11:17
  • 1
    $\begingroup$ @aardvark2012 That's true, but as this is a physics problem, it was reasonable to assume that all parameters are real. $\endgroup$
    – Szabolcs
    Sep 13, 2017 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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