Why Is My Solve Function Not Working in Mathematica?

  • Thread starter Thread starter 215
  • Start date Start date
  • Tags Tags
    Function
Click For Summary
The discussion revolves around difficulties in using the Solve function in Mathematica for a user-defined function involving summation with a variable number of terms. Users suggest that the issue may stem from the complexity of the function rather than the function itself, recommending alternatives like Nsolve or FindRoot, but noting that these require good initial guesses. There is also confusion regarding the correct syntax for combining equations, with a warning that mixing logical operators can lead to errors. The importance of consulting Mathematica documentation for proper usage is emphasized. Ultimately, the challenges arise from the nature of the equations and the specific implementation in Mathematica.
215
Messages
39
Reaction score
0
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?
 
Physics news on Phys.org
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, ...
 
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}]
 
215 said:
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}]

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.
 
Hmm... ok why isn't this one working then..
http://snag.gy/j41zD.jpg

The bold letters is constant..
 
215 said:
Hmm... ok why isn't this one working then..

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)
 
&& is just And, it should give a problem?
 
215 said:
&& is just And, it should give a problem?

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.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
449
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K