# Using physical dimensions in Mathematica DSolve

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*cosh[x/L] + C*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 so that finally it has dimension of a*C.

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

## migrated from stackoverflow.comFeb 20 '12 at 17:05

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

• 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]. – Daniel Lichtblau Feb 20 '12 at 23:32
• @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. – celtschk Feb 21 '12 at 9:32

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.
• @DavidZ: The use of units in DSolve and allied functions was discussed a bit in this question: DSolve returns a “wrong” solution – Michael Seifert Jan 5 '16 at 17:06
• @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). – David Z Jan 5 '16 at 17:35