Why Is My Solve Function Not Working in Mathematica?

  • Context: Graduate 
  • Thread starter Thread starter 215
  • Start date Start date
  • Tags Tags
    Function
Click For Summary

Discussion Overview

The discussion revolves around the challenges of using the Solve function in Mathematica for user-defined functions, particularly those involving summations and multiple variables. Participants explore the feasibility of solving equations that include such functions and share their experiences with different approaches and potential pitfalls.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant inquires about using the Solve function on a user-defined function with multiple constants and a summation.
  • Another participant suggests that the problem may be too complex due to the summation with a variable number of terms and recommends using Nsolve or substituting variables.
  • There are repeated questions about the possibility of solving equations involving user-defined functions, with emphasis on the complexity introduced by summations.
  • One participant points out that a mixture of logical operators (&& and ,) could be causing issues in their equations.
  • Participants share specific examples of equations that are not working as expected, highlighting errors and warnings from Mathematica.
  • There is a discussion about the correct syntax for using the Solve function, with emphasis on how expressions should be structured.

Areas of Agreement / Disagreement

Participants express varying opinions on the capabilities of the Solve function with user-defined functions. There is no consensus on the best approach to take, and multiple competing views remain regarding the use of different functions like Nsolve and FindRoot.

Contextual Notes

Participants note limitations related to the complexity of the functions being solved, including the presence of discontinuities and the need for good initial guesses in numerical methods. There are also references to the challenges posed by inexact coefficients in the equations.

Who May Find This Useful

This discussion may be useful for Mathematica users dealing with complex equations involving user-defined functions, particularly in the context of physics or engineering problems.

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 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K