Part of complex plot disappears [mathematica]

In summary, the two methods give different results due to the use of different optimization techniques and may not always produce the same output.
  • #1
illuminates
26
0
I have a very large expression:

Code:
    j - Sqrt[q^2 + qp^2 -
       2 q qp Cos[\[Theta]]] - \[Sqrt](qp^2 +
         1/2 (16 m5^2 + ma^2 + mp^2 -
            Sqrt[(-(16 m5^2) - ma^2 - mp^2)^2 -
             4 (ma^2 mp^2 - 16 m5^2 qp^2)])) == 0
where
Code:
    \[Theta] = Pi/6; ma = 980; mp = 139;
     j = \[Sqrt](q^2 +
        1/2 (16 m5^2 + ma^2 + mp^2 +
           Sqrt[(-(16 m5^2) - ma^2 - mp^2)^2 -
            4 (ma^2 mp^2 - 16 m5^2 q^2)]))
And qp, m5, q is real and positive.There is two method to solve it, but they give some different result.
Namely, let's look at both methods

First solution

Code:
    eqn = j -
        Sqrt[q^2 + qp^2 -
          2 q qp Cos[\[Theta]]] - \[Sqrt](qp^2 +
           1/2 (16 m5^2 + ma^2 + mp^2 -
              Sqrt[(-(16 m5^2) - ma^2 - mp^2)^2 -
                4 (ma^2 mp^2 - 16 m5^2 qp^2)])) == 0;
    With[{gensol = Solve[eqn , qp]},
      Block[{\[Theta] = Pi/6, ma = 980, mp = 139,
        j},(*subs vals when gensol is evaluated*)
       j = \[Sqrt](q^2 +
           1/2 (16 m5^2 + ma^2 + mp^2 +
              Sqrt[(-(16 m5^2) - ma^2 - mp^2)^2 -
                4 (ma^2 mp^2 - 16 m5^2 q^2)]));
       sols = gensol]];
    qpC13 = Compile[{{q, _Complex}, {m5, _Complex}},
       Evaluate[qp /. sols[[3]]],
       RuntimeOptions -> "EvaluateSymbolically" -> False] ;
       Plot3D[Re@qpC13[q, m5], {q, 0, 10000}, {m5, 0, 2000},
     AxesLabel -> Automatic]
1.jpg


Second solution
Code:
    eqn = j -
        Sqrt[q^2 + qp^2 -
          q qp Cos[\[Theta]]] - \[Sqrt](qp^2 +
           1/2 (16 m5^2 + ma^2 + mp^2 -
              Sqrt[(-(16 m5^2) - ma^2 - mp^2)^2 -
                4 (ma^2 mp^2 - 16 m5^2 qp^2)])) == 0;
 
    With[{gensol = Solve[eqn, qp]},
      Block[{\[Theta] = Pi/6, ma = 980, mp = 139, j},
       j = \[Sqrt](q^2 +
           1/2 (16 m5^2 + ma^2 + mp^2 +
              Sqrt[(-(16 m5^2) - ma^2 - mp^2)^2 -
                4 (ma^2 mp^2 - 16 m5^2 q^2)]));
       sols = gensol]];
    opt = Experimental`OptimizeExpression[qp /. sols[[3]]];
    Block[{\[Theta] = Pi/6, f},
     f[q0_, m50_] :=
      Block[{q = SetPrecision[q0, 40], m5 = SetPrecision[m50, 40], qp},
       qp = First@opt;
       Re@qp /; Im@qp == 0];
     Plot3D[f[q, m5], {q, 0, 10000}, {m5, 0, 1000}, MaxRecursion -> 3,
      AxesLabel -> Automatic]]
2.jpg
The part of plot disappears in second solution! Why is this happening?
 
Last edited:
Physics news on Phys.org
  • #2
The reason is that the second solution uses the Experimental`OptimizeExpression function, which attempts to optimize the expression by performing numerical approximations. As a result, some of the values in the expression may be rounded off, or even set to zero in some cases. This can lead to a plot that does not display correctly, as part of the data is missing or incorrect.
 

Related to Part of complex plot disappears [mathematica]

1. What does it mean when part of a complex plot disappears in Mathematica?

When part of a complex plot disappears in Mathematica, it means that the function or data that was originally included in the plot is no longer present or has been modified in some way. This can happen if the function or data was accidentally deleted, modified, or if there was an error in the code used to generate the plot.

2. How can I fix a complex plot that has disappeared in Mathematica?

To fix a complex plot that has disappeared in Mathematica, you will need to identify the source of the issue. This could involve checking your code for errors, making sure all necessary functions and data are included, and ensuring that the plot settings are correct. If you are unable to identify the issue, you may need to consult with a more experienced Mathematica user or seek help from the Mathematica community.

3. Can a complex plot disappear if my Mathematica version is outdated?

Yes, it is possible for a complex plot to disappear if your Mathematica version is outdated. Newer versions of Mathematica often have bug fixes and updates that can affect how functions and data are displayed in plots. It is recommended to regularly update your Mathematica software to avoid any potential issues with complex plots disappearing.

4. What should I do if part of a complex plot disappears while I am working on it?

If part of a complex plot disappears while you are working on it, the first thing you should do is save your work. This will prevent any further changes from causing more of the plot to disappear. Then, carefully review your code and plot settings to identify the source of the issue. If you are unable to fix the problem, you may need to start over or seek help from others.

5. Is there a way to recover a complex plot that has disappeared in Mathematica?

If you have saved your work regularly while creating the complex plot, you may be able to recover it by reopening an earlier version of the file. However, if you did not save your work or if the plot disappeared due to a technical issue, it may not be possible to recover it. It is always a good idea to save your work frequently to avoid losing any progress.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
324
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • High Energy, Nuclear, Particle Physics
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
Replies
4
Views
569
  • Calculus and Beyond Homework Help
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top