Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Solve function not working why?

  1. May 11, 2013 #1

    215

    User Avatar

    I am trying to solve a function using Solve in mathmatica.
    I am solving for multiple constants.

    Can i use a solve on a function i have made in Mathmatica... I mean
    a function like this
    L2[n_, q_] :=
    Total[(Range[0, IntegerPart[n/((4.1/100)/q)]]*q + 0.0038)*\[Pi]*(4.1/
    100)/q] + (((IntegerPart[n/((4.1/100)/q)] + 1)*q) +
    0.0038)*\[Pi]*(n - IntegerPart[n/((4.1/100)/q)]*(4.1/100)/q)

    And use the solve function like this

    Solve[30 == 0.0175*10^-6*L2[n, q]/((q/2)^2*\[Pi]) &&
    L2[n, q] == 29.918420573509337`, {L, n}]

    Or how should i use it?
     
  2. jcsd
  3. May 12, 2013 #2
    You're really asking something that's too hard here. A function with a summation in it with a variable number of terms. You could try nsolve, but the only thing Mathematica could do with a discontinuous function is trying random values.

    I would substitute r = n/((4.1/100)/q and then try solve for
    0<=k < 1, 1 <=k <2, 2 <= k <3, ....
     
  4. May 12, 2013 #3

    215

    User Avatar

    But is it posible to solve function with solve..

    I mean like
    L[n_,q_,E_]:= ....n.....q...E
    Solve[L[n_,q_,E_]==5444,{n,q,E}]
     
  5. May 12, 2013 #4
    The problem is not the user defined function, but the summation with a variable number of terms. Nsolve won't work either, the only thing that might work is findroot, but you'll have to give a good enough initial quess for n and q.
     
  6. May 12, 2013 #5

    215

    User Avatar

    Hmm... ok why isn't this one working then..
    http://snag.gy/j41zD.jpg

    The bold letters is constant..
     
  7. May 13, 2013 #6
    Probably because you have a mixture of && and ,

    In[1]:= Solve[0.5 == v/R && B == \[Mu]0*v/R*n/(lj/\[Mu]j + 2*x) && 2*B^2/(2 \[Mu]0*a*(4*x/(lj/\[Mu]j + 2 x) - 1)) == 2 && R == 0.0175*10^-6*L/((g/2)^2*Pi), {L, B, v, q, n, R}]

    During evaluation of In[1]:= Solve::ratnz: Solve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result. >>

    During evaluation of In[1]:= Solve::svars: Equations may not give solutions for all "solve" variables. >>

    Out[1]= {{L -> 4.4879895051282756*^7*g^2*R, B -> (-1.4142135623730951*Sqrt[-1.* a*lj*\[Mu]0 + 2.*a*x*\[Mu]0*\[Mu]j])/Sqrt[lj + 2.*x*\[Mu]j], v -> 0.5*R, n -> (2.*((-1.4142135623730951*lj* Sqrt[-1.*a*\[Mu]0*(lj - 2.*x*\[Mu]j)])/Sqrt[lj + 2.*x*\[Mu]j] - (2.8284271247461903*x*\[Mu]j* Sqrt[-1.*a*\[Mu]0*(lj - 2.*x*\[Mu]j)])/Sqrt[lj + 2.*x*\[Mu]j]))/(\[Mu]0*\[Mu]j)},
    {L -> 4.4879895051282756*^7*g^2*R, B -> (1.4142135623730951*Sqrt[-1.* a*lj*\[Mu]0 + 2.*a*x*\[Mu]0*\[Mu]j])/Sqrt[lj + 2.*x*\[Mu]j], v -> 0.5*R, n -> (2.*((1.4142135623730951*lj*Sqrt[-1.* a*\[Mu]0*(lj - 2.*x*\[Mu]j)])/Sqrt[lj + 2.*x*\[Mu]j] + (2.8284271247461903*x*\[Mu]j*Sqrt[-1.* a*\[Mu]0*(lj - 2.*x*\[Mu]j)])/Sqrt[lj + 2.*x*\[Mu]j]))/(\[Mu]0*\[Mu]j)}}

    In[2]:= Reduce[0.5 == v/R && B == \[Mu]0*v/R*n/(lj/\[Mu]j + 2*x) && 2*B^2/(2 \[Mu]0*a*(4*x/(lj/\[Mu]j + 2 x) - 1)) == 2 && R == 0.0175*10^-6*L/((g/2)^2*Pi), {L, B, v, q, n, R}]

    During evaluation of In[2]:= Reduce::ratnz: Reduce was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result. >>

    Out[2]= (x == 0 && (B == (0. - 1.4142135623730951*I)* Sqrt[a]*Sqrt[\[Mu]0] || B == (0. + 1.4142135623730951*I)* Sqrt[a]*Sqrt[\[Mu]0]) && g != 0 && v == (1.1140846016432675*^-8*L)/g^2 && B*\[Mu]j != 0 && n == (-4.*a*lj)/(B*\[Mu]j) && R == 2.*v && L*lj != 0) || (lj + 2.*x*\[Mu]j != 0 && (B == (-1.4142135623730951* Sqrt[-1.*a*lj*\[Mu]0 + 2.*a*x*\[Mu]0*\[Mu]j])/Sqrt[lj + 2.*x*\[Mu]j] || B == (1.4142135623730951* Sqrt[-1.*a*lj*\[Mu]0 + 2.*a*x*\[Mu]0*\[Mu]j])/Sqrt[lj + 2.*x*\[Mu]j]) && g != 0 && v == (1.1140846016432675*^-8* L)/g^2 && B^2 + 2.*a*\[Mu]0 != 0 && n == (16.*a*B*x)/(B^2 + 2.*a*\[Mu]0) && R == 2.*v && L*lj - 2.*L*x*\[Mu]j != 0)
     
  8. May 13, 2013 #7

    215

    User Avatar

    && is just And, it should give a problem?
     
  9. May 13, 2013 #8
    From your picture
    Solve[expression&&expression,expression,{variablelist}]
    which is not
    Solve[expression&&expression&&expression,{variablelist}]
    and is not
    Solve[{expression,expression,expression},{variablelist}]

    Read the Mathematica documentation carefully.
    Mathematica does not have a "figure out what my problem actually is and what I should have asked and do that for me instead of what I actually wrote" button.

    WolframAlpha.com will accept an undocumented sort of more english description of what the problem is and try to figure out what you meant and try to come up with some answer.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Solve function not working why?
  1. Solving for a function (Replies: 1)

Loading...