I have an equation and I want to take its derivative with respect to two variables. However, it contains some parameters which need to solve them together to find them (Pn, omega, gamma). These parameters are implicit in each other. I defined first some parameters and I want now to take the partial derivative with respect to rho, x1, x2.

    alpha = sqrt (4*pi*beta*e^2/eps0)
    eta3 = x1*rho*sigma1^3 + x2*rho*sigma2^3
    delta = 1 - pi*eta3/6
    rho1 = x1*rho
    rho2 = x2*rho

     gamma = alpha/
     2*((rho1*(z1 - 
     pi/(2*delta)*sigma1^2*Pn/(1 + gamma*sigma1))) + (rho2*(z2 - 
     pi/(2*delta)*sigma2^2*Pn/(1 + gamma*sigma2))))^0.5

     omega = 1 + 
     pi/(2*delta)*(rho1*sigma1^3*z1/(1 + gamma*sigma1) + 
     rho2*sigma2^3*z2/(1 + gamma*sigma2))

     Pn = 1/omega*(rh1*sigma1*z1/(1 + gamma*sigma1) + 
     rh2*sigma2*z2/(1 + gamma*sigma2))

     f[_rho, _x1, _x2] = -e^2/
     z1^2/(1 + gamma*sigma1) + (rho2*z2^2/(1 + gamma*sigma2)) + 
     pi/(2*delta)*omega*Pn^2)) + gamma^3/(3*pi)

I attached two pictures to illustrate the equations: - I want to take the derivative of the equation 28 with respect to xion, where rho_ion = xion*rho. Keeping in mid the following: The system of equations 29 need to be solved first to get the derivative since they depend on xion and on each other. Also, they are implicit.

enter image description here enter image description here

Could you please help me? I'm new to Mathematica so I will appreciate any help. Thanks in advance.

  • 2
    $\begingroup$ Mathematica is case sensitive. So it thinks pi is a variable and Pi is 3.14..., e is a variable and E is 2.8, sqrt is a variable and Sqrt is the square root function. Next, function arguments are put inside [ and ] while ( and ) group expressions. Next function definitions are f[var_, var_]:= instead of f[_var, _var]=. Next you say you have a set of equations that you want to find the derivative of. I'm guessing you want the derivative of f, but that doesn't seem to be an equation because equations are usually equal to something. That is a lot. Can you edit your question to use this info? $\endgroup$
    – Bill
    Dec 16 '18 at 19:36
  • $\begingroup$ You also have a problem with your definition of gamma. You start by saying gamma= and so Mathematica makes note that gamma is being defined and it starts evaluating the right hand side. During that it looks up the values for alpha, rho1, rho2 and then it finds gamma on the right hand side. So it goes back to the definition of gamma and starts over. And over. And over. Until it has started over 1024 times and bails out. Is that the exactly correct definition of gamma? Can you explain precisely what you mean gamma to be? You also seem to have a missing ) inside your definition of f. $\endgroup$
    – Bill
    Dec 16 '18 at 19:53
  • $\begingroup$ You need to learn the difference between and the appropriate use Set ( = ) and SetDelayed ( := ). There is a discussion of it here $\endgroup$
    – m_goldberg
    Dec 17 '18 at 1:25
  • $\begingroup$ Thanks for the comments. I will fix them. For the gamma, it's implicit function as well as the Pn and the omega. They need to be solved together numerically then substituted in the f function. After that, I need the derivative of f function with respect to the rho $\endgroup$
    – user61943
    Dec 17 '18 at 8:34
  • $\begingroup$ Could you maybe, create a very simple and easily comprehensible example, which would, however, carry features characterizing your real problem. In such a case, we could fast understand your problem and eventually help. $\endgroup$ Dec 17 '18 at 10:07

Your Answer

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

Browse other questions tagged or ask your own question.