8
$\begingroup$

I would like to calculate a system of two differential equations in Mathematica using DSolve, like:

fx''[x] + a*fx[x] == -I*eta*fy''[x] - b*fy[x], ...

where fx[x] and fy[x] are unknown functions. Using DSolve I can easily find some solutions of the type fx[x] = C[1]*cosh[x/L] + C[2]*a*sinh[x/L], where L is a term of the dimension of x.

The problem is, that the parameters a and b in my equations have physical dimension (e.g. meter). From the analysis of the solution the two terms in the result have different physical dimension, which is nonsensical. Another option is that Mathematica rescaled C[1] so that finally it has dimension of a*C[2].

My question is: Can I somehow control the physical dimensions of the parameters (a,b) in the differential equations or the constants C[1], C[2] in the result?

$\endgroup$

migrated from stackoverflow.com Feb 20 '12 at 17:05

This question came from our site for professional and enthusiast programmers.

  • $\begingroup$ You input appears to have the same issue. If x and a have dimensions of length then f''[x] has dimensions of length^2*f[x] whereas af[x] is only lengthf[x]. $\endgroup$ – Daniel Lichtblau Feb 20 '12 at 23:32
  • 1
    $\begingroup$ @DanielLichtblau: If x has the dimension of length, f''[x] of course has the dimension (dimension of f[x])/length^2. For the equations to be dimensionally correct, a must have the dimension 1/length^2, and b must have the dimension dim(eta)/length^2. $\endgroup$ – celtschk Feb 21 '12 at 9:32
13
$\begingroup$

It is generally better to work in dimensionless units to start with. In your case, your a and b have units of $L^{-2}$, while eta is dimensionless. Taking fx''[x] + a*fx[x] == -I*eta*fy''[x] - b*fy[x] as an example, you could use $\xi=x/L$, $\alpha=a L^2$, $\beta=b L^2$ (all of which are now dimensionless), whereupon your differential equation becomes $L^{-2}\left(\partial_{\xi,\xi}F_x(\xi)+\alpha F_x(\xi)+i\eta \partial_{\xi,\xi}F_y(\xi)+\beta F_y(\xi)\right)=0$, where I have set $F_x(\xi)=f_x(x)$ and similarly for $y$. Solving the equation in the brackets is what you really should do; no problems like you mention above can now arise.

To summarise, one should almost always switch to dimensionless units before numerically solving a problem.

$\endgroup$
  • 1
    $\begingroup$ Your advise remind me an almost forgotten juvenile favorite en.wikipedia.org/wiki/Mr._Tompkins $\endgroup$ – Dr. belisarius Mar 8 '12 at 1:37
  • $\begingroup$ This is useful to know but it still seems very weird that Mathematica would produce a dimensionally inconsistent solution to a dimensionally consistent equation. I'd be interested to know more about this but I can't think of a good way to formulate a question. $\endgroup$ – David Z Jan 4 '16 at 14:11
  • 1
    $\begingroup$ @DavidZ: The use of units in DSolve and allied functions was discussed a bit in this question: DSolve returns a “wrong” solution $\endgroup$ – Michael Seifert Jan 5 '16 at 17:06
  • 1
    $\begingroup$ @MichaelSeifert Thanks, that's useful. Though the manipulation that solves that particular case ($\log A - \log B \to \log\frac{A}{B}$) is standard practice in physics. What motivated my comment was the situation in this question of mine, which doesn't seem to be so easily dealt with. There are no logarithms involved there (unless they're "hidden" somehow). $\endgroup$ – David Z Jan 5 '16 at 17:35

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.