2
$\begingroup$

I have a mathematical function $f(p,q)=10^{-10}\frac{p^4}{q^2}$. I want to make a contour plot within the region where $10^{-3}<f(p,q)<10^{+3}$. I have tried the following three codes (one is similar to this one), but their outputs are different. Could you suggest me a better way to draw the contour plot of that function?

ContourPlot[{If[
   10^-3 < (10^-10* (x^4)/y^2) < 10^3, (10^-10* (x^4)/y^2)]}, {x, 
  10^-3, 10^3}, {y, -1, 1}, FrameLabel -> {"p", "q"}, 
 ContourLabels -> True, PlotLegends -> Automatic]

ContourPlot[{ConditionalExpression[(10^-10* (x^4)/y^2), 
   10^-3 < (10^-10* (x^4)/y^2) < 10^3]}, {x, 10^-3, 10^3}, {y, -1, 1},
  FrameLabel -> {"p", "q"}, ContourLabels -> True, 
 PlotLegends -> Automatic]

RegionPlot[{10^-3 < (10^-10* (x^4)/y^2) < 10^3}, {x, 10^-3, 
  10^3}, {y, -1, 1}, FrameLabel -> {"p", "q"}, 
 PlotLegends -> Automatic]
$\endgroup$
5
  • $\begingroup$ Try the option RegionFunction $\endgroup$ Sep 1, 2022 at 13:59
  • $\begingroup$ RegionPlot[{10^-3 <= (10^-10*(x^4)/y^2) <= 10^3}, {x, 10^-3, 10^3}, {y, -1, 1}, PlotPoints -> 150, MaxRecursion -> 4, FrameLabel -> {"p", "q"}, PlotLegends -> Automatic] $\endgroup$
    – cvgmt
    Sep 1, 2022 at 14:04
  • $\begingroup$ @ulrich-neumann ``` ContourPlot[(10^-10*(x^4)/y^2), {x, 1, 100}, {y, -1, 1}, RegionFunction -> Function[{x, y, z}, 10^-3 < (10^-10*(x^4)/y^2) < 10^3]] ``` But, I have found a point {{"57.45", "-0.07952"}} which is not within the region. However, at {{"57.45", "-0.07952"}}, the value of the function is 0.172269. $\endgroup$
    – PoreyS
    Sep 1, 2022 at 14:19
  • $\begingroup$ @cvgmt I need contour plot. Thanks. $\endgroup$
    – PoreyS
    Sep 1, 2022 at 14:24
  • $\begingroup$ @PoreyS I t looks like a scaling problem. $\endgroup$ Sep 1, 2022 at 14:29

1 Answer 1

3
$\begingroup$

Something happens near y==0...

As a workaround try

 Show[{ContourPlot[(10^-10*(x^4)/y^2), {x, 10^-3, 1000}, {y, 10^-3, 1},
    PlotPoints -> 100 , 
   RegionFunction -> 
    Function[{x, y, z}, 10^-3 < (10^-10*(x^4)/y^2) < 10^3]],
  ContourPlot[(10^-10*(x^4)/y^2), {x, 10^-3, 1000}, {y, -1, -10^-3 }, 
   PlotPoints -> 100 , 
   RegionFunction -> 
    Function[{x, y, z}, 10^-3 < (10^-10*(x^4)/y^2) < 10^3]]}, 
 PlotRange -> All]

enter image description here Hope it helps!

$\endgroup$

Your Answer

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

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