Group Abstract Group Abstract

Message Boards Message Boards

0
|
38.5K Views
|
20 Replies
|
8 Total Likes
View groups...
Share
Share this post:

How to plot the graph of the equation F[x,y]=0 ?

Posted 11 years ago

I have an equation F(x,y;a,b,c,...)=0, where x and y are variables, a,b,c,... - parameters. y is a real number, x - complex. For every given y I need to solve this equation, i.e. to find Im(x) and Re(x) (this equation may have many solutions). After solving this equation I need to plot two graphs: the dependense of y from Im(x) and y from Re(x).

For example, F(x,y)=x^2 + sin(xy).

If y and x were real numbers, it would be possible to use ContourPlot. However, as my variables are complex, I have to solve this equation numerically and after that plot my graphs.

I have never come across such a problem (and also to date I have a little experience in Mathematica), so could anyone tell me how to solve this problem?

POSTED BY: Artem Strashko
20 Replies

Use ContourPlot3D, it should give you your result; a 3d surface.

POSTED BY: Sander Huisman
Posted 11 years ago

Thank you. But can I further extract two 2D graphs from this 3D graph? I mean I can plot F[Re[x],Im[x],y]=0, but I would like to get two projections of this graph: Re[x],y and Im[x],y.

POSTED BY: Artem Strashko
Posted 11 years ago

Dear Sander, I try to use ContourPlot3D for a very simple problem, but it doesn't give a right answer.enter image description here

Attachments:
POSTED BY: Artem Strashko
Posted 11 years ago

Dear Daniel, thank you so much for your help! Hovewer, I am not sure that this is exactly what I need, because I don't quietly understand how it works.

I can explain what I need in other words. I need the graph of the equation F[x,y]=0, x is a complex number, y is a real number, {y,0,8}. The graph of this equation is 3D, because we have 3 variables Re[x], Im[x], y. I need two 2D graphs y as a function of Re[x] and Im[x], I mean that I need two projection of this 3D graph.I mean smth like that

POSTED BY: Artem Strashko

You might do better to define a root-finding function that, given a value for y, finds Re[x] and Im[x]. Using the redefined form I showed earlier, with s and t as variables for the real and imaginary parts of x respectively, this might be done as below. I use random starting points so as to have a chance at sampling from different branches of the solution curve.

root[yval_?NumericQ] := {s, t} /. 
  FindRoot[{re == 0, im == 0} /. y -> yval, {s, 
    RandomReal[{-5, 5}]}, {t, RandomReal[{-5, 5}]}]

Here is how it looks.

pts = Quiet[Table[root[j], {j, .01, 8, .01}]];
ListPlot[pts]

enter image description here

POSTED BY: Daniel Lichtblau
Posted 11 years ago

Dear Daniel, could you clarify how do you do this? I try to use your code, but I don't get a result.g = 1/10; expr = x - Sqrt[y^2 + I*y]; e2 = expr /. x -> s + I*t; {re, im} = ComplexExpand[{Re[e2], Im[e2]}]; root[yval_?NumericQ] := {s, t} /. FindRoot[{re == 0, im == 0} /. y -> yval, {s, RandomReal[{-5, 5}]}, {t, RandomReal[{-5, 5}]}] pts = Quiet[Table[root[j], {j, .01, 8, .01}]]; ListPlot[pts]

Attachments:
POSTED BY: Artem Strashko
POSTED BY: Daniel Lichtblau
Posted 11 years ago
Attachments:
POSTED BY: Artem Strashko
Posted 11 years ago
Attachments:
POSTED BY: Artem Strashko
POSTED BY: Daniel Lichtblau
Posted 11 years ago
Attachments:
POSTED BY: Artem Strashko
POSTED BY: Daniel Lichtblau
Posted 11 years ago
POSTED BY: Artem Strashko

I'm using version 10.1. You can do similarly with NDSolve if you solve for both {y[rex],imx[rex]}.

POSTED BY: Daniel Lichtblau
Posted 11 years ago
POSTED BY: Artem Strashko
Posted 11 years ago
Attachments:
POSTED BY: Artem Strashko
POSTED BY: Daniel Lichtblau

This might be a start. Define the expression, then use ComplexExpand to form explicit real and imaginary parts.

g = 1/10;
expr = 
  Tanh[Sqrt[-x^2 - y^2]*3/10] (y^2 + I*g*y - 4) Sqrt[-x^2 - 
      y^2] + (y^2 + I*g*y) Sqrt[-x^2 - 
      y^2 ((y^2 + I*g*y - 4)/(y^2 + I*g*y))];

e2 = expr /. x -> s + I*t;
{re, im} = ComplexExpand[{Re[e2], Im[e2]}];

 ContourPlot[(re /. y -> 0.7) == 0, {s, -10, 10}, {t, -10, 10}]

enter image description here

ContourPlot[(im /. y -> 0.7) == 0, {s, -10, 10}, {t, -10, 10}]

enter image description here

POSTED BY: Daniel Lichtblau
Posted 11 years ago
POSTED BY: Artem Strashko

You will get better answers if you give a complete, very specific example of what you want.

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard