Mathematica taking a long time to solve

In summary, it seems that when Solve is given "complicated equations" that the size of the expression has a serious effect on the run time. Doing what is possible to reduce the size of the expressions seems to help. Notice that gam always appears as (gam + 1)/2 in your expression. Substituting using expression/.(gam + 1)/2->g will reduce the size and not change the results.
  • #1
haihek
3
0
Hi everyone,

I am trying to solve this complicated two simultaneous equations, and it has been taking more than 2 hours to solve .. and it is still running... can anyone tell me what is wrong .. thanks

Solve[{((((1 - xr)/xr)^(1/2) (M2^2 xr - 1)/(
1 + (gam + 1)/2 M2^2 - M2^2 xr)) - (((1 - xm)/xm)^(1/2) (
M1^2 xm - 1)/(1 + (gam + 1)/2 M1^2 - M1^2 xm)))/(
1 + (((1 - xr)/xr)^(1/2) (M2^2 xr - 1)/(
1 + (gam + 1)/2 M2^2 - M2^2 xr)) (((1 - xm)/xm)^(1/2) (
M1^2 xm - 1)/(1 + (gam + 1)/2 M1^2 - M1^2 xm))) == tanthi,
xm - a xr == b}, {xm, xr}]
 
Physics news on Phys.org
  • #2
Try to solve xm in terms of xr from
xm - a xr == b
then place it in the other equation, then solve just for xm.
It may do the job.
 
  • #3
implicitnone said:
Try to solve xm in terms of xr from
xm - a xr == b
then place it in the other equation, then solve just for xm.
It may do the job.

Thank you for you reply, although it looked like it may do the job, but nope.. still facing the same waiting time. I don't know if it is normal to take that long (6 hours now), because i never faced this type of run before. Should i just keep it running? or is it a sign of calculation failure??
 
  • #4
Disclaimer: This is somewhat user superstition.

It seems that when Solve is given "complicated equations" that the size of the expression has a serious effect on the run time. Doing what is possible to reduce the size of the expressions seems to help.

Notice that gam always appears as (gam + 1)/2 in your expression. Substituting using
expression/.(gam + 1)/2->g
will reduce the size and not change the results.

If I have not made any mistake then the smallest I have been able to make your expression is
(-(Sqrt[-1 + 1/xm]*(-1 + M1^2*xm)*(1 + M2^2*(g - xr))) + (1 + M1^2*(g -
xm))*Sqrt[-1 + 1/xr]*(-1 + M2^2*xr))/((1 + M1^2*(g - xm))*(1 + M2^2*(g -
xr)) - Sqrt[-1 + 1/xm]*(-1 + M1^2*xm)*Sqrt[-1 + 1/xr]*(-1 + M2^2*xr))

That is about 2/3 the size of your original and does not incorporate the other
suggestion of substituting for one of the xm or xr.
 
  • #5
Its a sign of the solution probably having no analytic form, or at least a really crazy one.
It helps to assign some assumptions sometimes, especially when sqrts are involved. Are the M's or xm's or a/b positive? real? less than/gt one? These things can help speed things up:

$Assumptions = b>0&&a>0&&0<=xm<=1

etc.
 
  • #6
thank you guys for your replies
 

1. Why is Mathematica taking a long time to solve my equation?

There are several factors that can contribute to Mathematica taking a long time to solve an equation. It could be due to the complexity of the equation, the size of the data being used, or the efficiency of your computer's processor. Additionally, if you are using certain functions or algorithms in Mathematica, they may inherently take longer to compute.

2. How can I speed up Mathematica's solving process?

There are a few ways to potentially speed up the solving process in Mathematica. One option is to simplify your equation or data as much as possible before inputting it into Mathematica. Additionally, you can try using parallel computing, which allows Mathematica to utilize multiple processors on your computer to solve equations faster. You can also check for any updates or patches for Mathematica, as they may include performance improvements.

3. Is there a limit to the size or complexity of equations Mathematica can solve?

Mathematica has the capability to solve very large and complex equations, but there are practical limits that can depend on your computer's memory and processing power. If you are encountering issues with Mathematica taking a long time to solve your equation, it may be helpful to break it down into smaller, more manageable parts.

4. Can the type of data used affect how long it takes Mathematica to solve an equation?

Yes, the type and size of data being used can impact the solving time in Mathematica. For example, if you are working with large datasets or using symbolic variables, it can take longer for Mathematica to compute the solution. In some cases, converting data to a simpler form or using specific data types in Mathematica can help improve solving time.

5. Are there any common mistakes that can cause Mathematica to take a long time to solve?

One common mistake that can contribute to longer solving time in Mathematica is using inefficient or unnecessary functions. For example, using a function that iterates over a large dataset when a simpler function could achieve the same result. It's also important to check for any syntax errors or typos in your equation, as these can cause Mathematica to take longer to solve or produce incorrect results.

Similar threads

  • Introductory Physics Homework Help
Replies
4
Views
880
  • Introductory Physics Homework Help
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • Introductory Physics Homework Help
Replies
3
Views
2K
Replies
5
Views
931
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • Introductory Physics Homework Help
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
Back
Top