2
$\begingroup$
NSolve[ - 8 a^2 x + 9 x^2 -12 x^3 + 4 x^4 == 0, x];
Plot[Evaluate[  x   /.   %  ],    {a, -0.6, 0.6}]

How can I show only positive roots in this plot?

This equation is one of the case of Equation (32) given in this paper.

$\endgroup$
2
  • $\begingroup$ Hello again. It's really a good ideas to start by taking the tour now and learning about asking and what's on-topic. Always edit if improvable, show due diligence, give brief context, include minimal working example of your code and data in formatted form. By doing all this you help us to help you and likely you will inspire great answers. I have edited your question for you this time. $\endgroup$
    – rhermans
    Commented Aug 21, 2018 at 18:29
  • $\begingroup$ If you want to clarify the question, please edit the original question, not one of the answers. If you want to ask about a new problem (even if related to this one), please ask a new question. $\endgroup$
    – Szabolcs
    Commented Aug 24, 2018 at 9:58

2 Answers 2

1
$\begingroup$

NSolve is for finding numerical solutions and is not appropriate when there are non-numerical parameters, such as a in your example. Use Solve instead.

If you only need a plot, an alterative approach to solve-and-plot is to plot the implicit equation directly using ContourPlot.

ContourPlot[-8 a^2 x + 9 x^2 - 12 x^3 + 4 x^4 == 0,
 {a, -.6, .6}, {x, -1, 3},
 FrameLabel -> Automatic,
 MaxRecursion -> 4, PlotPoints -> 100, 
 RegionFunction -> Function[{a, x}, x > 1*^-16]]

enter image description here

MaxRecursion and PlotPoints are used to increase accuracy. RegionFunction is to eliminate non-positive solutions. Since x == 0 is always a solution, I needed to use a value marginally higher than 0 to define the region and exclude the x == 0 line.

$\endgroup$
0
$\begingroup$
Plot[
 Evaluate[
  x /. NSolve[
    {
     -8 a^2 x + 9 x^2 - 12 x^3 + 4 x^4 == 0
     , x > 0
     }
    , x
    , Reals
    ]
  ]
 , {a, -0.6, 0.6}
 , PlotTheme -> "Scientific"
 ]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ Thank you for this help. $\endgroup$
    – Emma
    Commented Aug 21, 2018 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.