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.

Is it possible for Mathematica to solve an equation like $\nabla f(\mathbf{r}) = - \mathbf{E}(\mathbf{r})$ for $f(\mathbf{r})$?

I tried Reduce[Grad[f[x,y,z],{x,y,z}]== -{ex,ey,ez}, f] but that does not work.

share|improve this question
    
Could you please provide a complete code snippet ? Something that we could copy paste into our notebooks and see the actual error ? –  Zet Nov 12 '13 at 17:32
4  
What for? You need not playing with Mathematica for this: $$ f(\mathbf{r}) = f(\mathbf{r_0})- \int \mathbf{E}(\mathbf{r}) d\mathbf{r}$$ –  Artes Nov 12 '13 at 17:35
    
It's a differential equation so you need to use DSolve –  Simon Woods Nov 12 '13 at 18:53

1 Answer 1

up vote 3 down vote accepted

I'll try to combine Artes and Simon Woods comments in an answer.

Given is the electric field as el = {ex, ey, ez} = {er, e\[Theta], ez} in Cartesian and Cylindrical coordinates, respectively.

Solving the differential equation can be done in Cartesian coordinates with

DSolve[Grad[f[x, y, z], {x, y, z}] == {ex, ey, ez}, 
 f[x, y, z], {x, y, z}]

{{f[x, y, z] -> ex x + ey y + ez z + C[1]}}

Or simply by integration, where one has to parametrize the integration variable

Integrate[{ex, ey, ez}.{x t, y t, z t}, {t, 0, Sqrt[2]}]

ex x + ey y + ez z

Remember the constant integration factor, which is set to zero here.

Integration is also easily done in different coordinate systems, such as cylindrical ones

Integrate[{er, e\[Theta], ez}.{r t, r \[Theta] t, z t}, {t, 0, 
  Sqrt[2]}]

er r + ez z + e\[Theta] r \[Theta]

How to use DSolve[] in this case I don't know yet, as

DSolve[Grad[f[r, \[Theta], z], {r, \[Theta], z}, 
   "Cylindrical"] == {er, e\[Theta], ez}, 
 f[r, \[Theta], z], {r, \[Theta], z}]

does not work.

I know this is pretty elementary, but maybe it can help others. Please help to further improve this answer!

share|improve this answer
    
It is about solving of a system consisting of three time-independent partial differential equations, each of the first order. As much as I know neither DSolve, not NDSolve can do this. Please correct me if I missed something. –  Alexei Boulbitch Nov 13 '13 at 12:17
    
@AlexeiBoulbitch Works for me: DSolve[{D[F[x, y, z], {{x, y, z}}] == D[x + x y + z y + x y z, {{x, y, z}}]}, F, {x, y, z}] (V9.0.1). Of course the system is integrable only if the curl of the vector field is zero. –  Michael E2 Nov 13 '13 at 13:19

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.