# How to take the derivative of a function w.r.t. just one of the arguments?

When I use

DSolve[
D[v[ω, z, Subscript[k, y], Subscript[k, x]], {z, 1}] ==
-((i*ω)/c)*(Sqrt[1 - (c*Subscript[k, y]/ω)^2] +
Sqrt[1 - (c*Subscript[k, x]/ω)^2])*v[ω, z, Subscript[k, y], Subscript[k, x]],
v, z]


to determine the general solutions of this differential equation, I get an error message which says that the length of the derivative operator is not the same as the number of arguments. However, the derivative on the LHS of the differential equation is only w.r.t. the $z$ argument, so I do not know how to overcome this problem.

• Hi and welcome. As good programming practice, try to avoid using subscripted objects as variables, since they are not always treated as symbols by Mathematica and may lead to unexpected behavior. – QuantumDot Mar 2 '17 at 18:33
• To see such unexpected behaviour, try this: D[f[x, Subscript[x, 1]], x]. As you can see, D treated Subscript as a mathematical function that has x as an argument. – Szabolcs Mar 2 '17 at 18:35
• MMMs answer assumes that i in your equation is the square root of -1. I am guessing that is what you probably meant. That (and dropping the subscript) is the difference between MMMs answer and Fabians. – Jack LaVigne Mar 2 '17 at 19:05

You have to put in the function v with its arguments:

DSolve[D[v[ω, z, Subscript[k, y], Subscript[k, x]], {z,
1}] == -((i*ω)/c)*(Sqrt[
1 - (c*Subscript[k, y]/ω)^2] +
Sqrt[1 - (c*Subscript[k, x]/ω)^2])*
v[ω, z, Subscript[k, y], Subscript[k, x]],
v[ω, z, Subscript[k, y], Subscript[k, x]], z]


Gives:

 {{v[ω, z, Subscript[k, y], Subscript[k, x]] ->
E^((z*(-(i*ω*Sqrt[(ω^2 - c^2*Subscript[k, x]^2)/ω^2]) -
i*ω*Sqrt[(ω^2 - c^2*Subscript[k, y]^2)/ω^2]))/c)*C[1]}}


or as TeX

$$\left\{\left\{v\left(\omega ,z,k_y,k_x\right)\to c_1 \exp \left(\frac{z \left(-i \omega \sqrt{\frac{\omega ^2-c^2 k_x^2}{\omega ^2}}-i \omega \sqrt{\frac{\omega ^2-c^2 k_y^2}{\omega ^2}}\right)}{c}\right)\right\}\right\}$$