## plotting – Using NSolve and ContourPlot

Problem 6 a: Solve the equations x^2/9+y^2 /4=1, x^2-y^2=1 for {x,y}. b: Use NSolve to find approximate solutions to this set of equations. c: Now use 2-dimensional zooming and ContourPlot to find an approximation rounded to two places after the decimal point to this pair of equations.

## plotting – Seamless ContourPlot for a conditional function

When I try to create a ContourPlot of a continuous conditional function, Mathematica leaves a “seam” in between the two regions demarcated by the conditional. How do I fill this seam?

``````fn(x_, y_) := If(x < 2, y/x^2, y/(2 x))
ContourPlot(fn(x, y), {x, 1.5, 2.5}, {y, 0, 2})
``````

## plotting – Cannot make ContourPlot work

Trying to run the following:

``````f(x_, y_) := x^2 + 2 y^2 - 2;
g(x_, y_) := -4 x^2 + 3 y^2;
(*find critical points*)
critPts = Solve ({f(x, y) == 0, g(x, y) == 0}) // N
(*find jacobian to categorise critical points*)
jacob(f_, g_) := ( {
{!(
*SubscriptBox(((PartialD)), (x))f), !(
*SubscriptBox(((PartialD)), (y))f)},
{!(
*SubscriptBox(((PartialD)), (x))g), !(
*SubscriptBox(((PartialD)), (y))g)}
} )
jacob(f(x, y), g(x, y))
(*find eigne value for each critical point*)

(* 1st point*)
jacob(f(x, y), g(x, y)) /. critPts((1)) // MatrixForm
Eigenvalues(jacob(f(x, y), g(x, y))) /. critPts((1))
(* now instead do this for all of them*)
Eigenvalues(jacob(f(x, y), g(x, y))) /. critPts // TableForm

vField = VectorPlot({f(x, y), g(x, y)}, {x, -2, 2}, {y, -2, 2})
(* now plot critical plots*)
critPtsPlot = ListPlot({x, y} /. critPts)
(* now the null clines*)
nullClines = {f(x, y) == 0, g(x, y) == 0}
nullClinePlot =
ContourPlot ( nullClines, {x, -2, 2}, {y, -2, 2},
PlotStyle -> {Blue, Yellow}, PlotPoints -> 100)
Show(vField, nullClinePlot, critPtsPlot)
``````

The first two plots work (vField and critPtsPlot) but the last, nullClinePlot is blank. I’m expecting to see an oval around the origin and two diagonal lines (also passing through the origin).
Any thoughts?

Thanks,

Kevin

## plotting – Is it needed to increase the precision of ContourPlot in this case?

I have this function and I want to see where it is zero.
$$frac{1}{16} left(sinh (pi x) left(64 left(x^2-4right) cosh left(frac{2 pi x}{3}right) cos (y)+left(x^2+4right)^2+256 x sinh left(frac{2 pi x}{3}right) sin (y)right)+left(x^2-12right)^2 sinh left(frac{7 pi x}{3}right)-2 left(x^2+4right)^2 sinh left(frac{5 pi x}{3}right)right)+2 left(x^2-4right) sinh left(frac{pi x}{3}right)$$
I use ContourPlot

``````f(x_, y_) :=
2 (-4 + x^2) Sinh((π x)/3) +
1/16 (((4 + x^2)^2 + 64 (-4 + x^2) Cos(y) Cosh((2 π x)/3) +
256 x Sin(y) Sinh((2 π x)/3)) Sinh(π x) -
2 (4 + x^2)^2 Sinh((5 π x)/3) + (-12 + x^2)^2 Sinh((
7 π x)/3));

ContourPlot(
f(x, y) == 0, {x, 3.465728, 3.465729}, {y, 1.046786, 1.046795},
PlotPoints -> 500)

``````

and I obtain this plot

Now, my question is that can I trust this plot and conclude that the curves do not cross?

Or, I should increase the precision of the plot? And if so, how can I ask Mathematica to give higher precision for the axis in ContourPlot?

## plotting – ContourPlot for a certain value

Consider this example:

``````f[x_] := -I*2*x + 3*x^2
``````

which is a complex function defined on a complex plane $$x=x_r+ix_i$$

It is convenient to plot the contour of its real part Re[f] with

``````ListContourPlot[Re[Table[ComplexExpand[f[xr + I*xi]], {xr, 0, 0.2, 0.01}, {xi, -0.05,
0.05, 0.001}]]]
``````

But sometimes we want to only show the contour for a certain value with a legend for the specific value. For example, how can I only plot the contour for Re[f]=0 with a legend for it?

I naively tried as follows, but it didn’t work.

``````ListContourPlot[Re[Table[ComplexExpand[f[xr + I*xi]], {xr, 0, 0.2, 0.01}, {xi, -0.05,
0.05, 0.001}]] == 0]
``````

Thank you for any help.

## plotting – Two-dimensional Contour-Plot – Mathematica Stack Exchange

I have a quick question:

In a Solid-state Physics lecture, we discussed the so-called tight-binding model.
For that, we had the dispersion-relation (which gives us the dependence of the energy $$E$$ wrt $$vec k$$)
$$E(vec{k}) = E_{text{at}} – S – 2Acdot left(cos left( k_x aright) + cosleft( k_y aright)right).$$

Now, the professor plots the relation (I think only the part in the ()-brackets) in Mathematica and apparently obtains the following result:

Now, this is what I tried so far:

``````ContourPlot(-Cos(x) - Cos(y) , {x, -1/2, 1/2}, {y, -1/2, 1/2})
``````

with the following result:

Unfortunately, I neither reproduce the behavior at the edges of the plot,
nor the square. Any hint would be deeply appreciated!

(Please don’t get confused about the x- and y-label of the first plot; I think all the professor wants to say is that we don’t plot $$k_x$$ and $$k_y$$, but rather $$vec kappa$$, which is related to $$vec k$$ with a factor of $$frac{2pi}{a}$$.)

## plotting – How to mark a specific line in ContourPlot

I have the next differential equation

`sol = ParametricNDSolve[{y'`

``` And a Contour Plot of this equation ContourPlot[y[a][x] /. sol, {x, 0, 0.1}, {a, 0, 4}, PlotLegends -> BarLegend[Automatic, LegendMarkerSize -> 180, LegendFunction -> "Frame", LegendMargins -> 5, LegendLabel -> "y[a][x]"], Frame -> True, FrameLabel -> {{"a", ""}, {"x", ""}}, BaseStyle -> {FontWeight -> "Bold", FontSize -> 14}] With this code, I obtain the next image I would like to mark the line of constant value $$1.5$$. To mark this line I click on the line, but I would like to obtain something more "elegant" ```
``` ```
``` Author AdminPosted on May 18, 2020Categories ArticlesTags ContourPlot, line, mark, Plotting, specific ```
``` Plotting – How can you reverse both axes in ContourPlot? How can I reverse the X and Y axes in ContourPlot? I have tried many times and only reversed one axis, the other has not changed. The X axis is correct, but Y is wrong. I want the values ​​on the Y axis to be greater than 0. Is that possible? I used ContourPlot because a has functions like F (x, y) = x ^ 2 + y ^ 2 Author AdminPosted on April 24, 2020Categories ArticlesTags axes, ContourPlot, Plotting, Reverse Plotting – ContourPlot does not show the correct relationship between two functions I use ContourPlot to compare the norm of the two vector fields, $$|| boldsymbol {f} || / || boldsymbol {g} ||$$, the outline should be on $$(x, y)$$ Plane. Consider the following PDEs $$u (x, y, t)$$ and $$v (x, y, t)$$, L = 4; solu = NDSolveValue({D(u(t, x, y), t, t) == D(u(t, x, y), x, x) + D(u(t, x, y), y, y) + Sin(u(t, x, y)), u(t, -L, y) == u(t, L, y), u(t, x, -L) == u(t, x, L), u(0, x, y) == Exp(-(x^2 + y^2)), Derivative(1, 0, 0)(u)(0, x, y) == 0}, u, {t, 0, 4}, {x, -L, L}, {y, -L, L}) solv = NDSolveValue({D(v(t, x, y), t, t) == D(v(t, x, y), x, x) + D(v(t, x, y), y, y)/2 + (1 - v(t, x, y)^2) (1 + 2 v(t, x, y)), v(0, x, y) == E^-(x^2 + y^2), v(t, -L, y) == v(t, L, y), v(t, x, -L) == v(t, x, L), Derivative(1, 0, 0)(v)(0, x, y) == 0}, v, {t, 0, 4}, {x, -L, L}, {y, -L, L}) and these two vector fields f(x_, y_, t_) = solu(t, x, y)*Grad(solv(t, x, y), {x, y}) + Grad(solu(t, x, y), {x, y}); g(x_, y_, t_) = Grad(solu(t, x, y), {x, y})*solu(t, x, y); I can draw the respective contours {ContourPlot(Norm(f(x, y, 1)), {x, 0, L}, {y, 0, L}, PlotRange -> All, ColorFunction -> "Rainbow", Contours -> 10, PlotLegends -> BarLegend(Automatic, All), FrameLabel -> {x, y}), ContourPlot(Norm(g(x, y, 1)), {x, 0, L}, {y, 0, L}, PlotRange -> All, ColorFunction -> "Rainbow", Contours -> 10, PlotLegends -> BarLegend(Automatic, All), FrameLabel -> {x, y})} But if I have their relationship, d. H. Record the relationship of the norms of the two vector fields, ContourPlot produces a strange result that doesn't look correct. ContourPlot(Norm(f(x, y, 1))/Norm(g(x, y, 1)), {x, 0, L}, {y, 0, L}, PlotRange -> All, ColorFunction -> "Rainbow", Contours -> 10, PlotLegends -> BarLegend(Automatic, All), FrameLabel -> {x,y}) A quick review: Norm(f(1.6, 0.5, 1))/Norm(g(1.6, 0.5, 1)) (*4.72938*) This does not match the last contour diagram. What am I doing wrong? Thank you in advance. Author AdminPosted on April 14, 2020Categories ArticlesTags ContourPlot, correct, functions, Plotting, relationship, Show Draw a piecewise function that returns implicit equations using ContourPlot I use ContourPlot to draw implicit equations. Drawing separate implicit equations seems okay, but I can't get ContourPlot to draw a piecewise function that returns implicit equations. ClearAll("Global`*"); a(p1_,p2_):=(p1-30)^2+(2p2-60)^2==250 b(p1_,p2_):=(p1-20)^2+(5p2-40)^2==300 pw(p1_,p2_):=Piecewise({{a(p1,p2),{p1>p2}}},b(p1,p2)) Grid({{ ContourPlot(Evaluate@a(p1,p2),{p1,0,50},{p2,0,50}), ContourPlot(Evaluate@b(p1,p2),{p1,0,50},{p2,0,50}), ContourPlot(Evaluate@pw(p1_,p2_),{p1,0,50},{p2,0,50}) }}) I expect the third figure to have two diagonal cutting circles as follows: Author AdminPosted on January 5, 2020Categories ArticlesTags ContourPlot, draw, equations, function, implicit, piecewise, returns Posts navigation Page 1 Page 2 Next page ```