Finding Numerically the solution line for an equation

  • Context: Graduate 
  • Thread starter Thread starter LayMuon
  • Start date Start date
  • Tags Tags
    Line
Click For Summary

Discussion Overview

The discussion revolves around finding a numerical solution line y(x) for the equation f(x,y) = 0, where the function f may yield complex values. Participants explore methods for efficiently locating this solution line without exhaustively scanning the entire region of {x,y}.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant seeks a numerically efficient method to find the solution line y(x) for f(x,y) = 0, emphasizing the need for the imaginary part to be zero.
  • Another participant questions whether f(x,y) is differentiable analytically, assuming it is continuous, and suggests using a binary search method if a feasible range for y(x0) is provided.
  • A participant asks for clarification on the term "binary chop," leading to an explanation that it resembles a "binary search" method based on the continuity of f.
  • Concerns are raised regarding the definition of positive and negative values when f(x,y) may be complex, with some arguing that the modulus can be used instead.
  • Participants discuss the implications of using local minima of |f| to find zeros, noting that while every zero is a local minimum, not all local minima correspond to zeros.
  • There is a suggestion that scanning all x values is problematic, and a more efficient approach is desired to avoid this exhaustive search.

Areas of Agreement / Disagreement

Participants express differing views on the best approach to finding the solution line, with some advocating for binary search methods and others questioning the applicability of these methods given the potential complexity of f. The discussion remains unresolved regarding the most effective numerical strategy.

Contextual Notes

Participants note limitations related to the complexity of f(x,y) and the challenges of defining positive and negative values in the context of complex numbers. There is also an acknowledgment that not all local minima correspond to zeros of the function.

LayMuon
Messages
149
Reaction score
1
I have a function which depends say upon two variables: [itex]f(x,y)[/itex].

I need to find numerically the solution line [itex]y(x)[/itex] of the equation [itex]f(x,y) = 0[/itex]. The function itself for arbitrary set of {x,y} may evaluate to some complex number (it involves lots of square roots) but for the solution I am seeking the imaginary part on the solution line should be zero. I understand that one in principal can scan through the whole region of {x,y} to get the curve but I need numerically efficient way to write the code.

Thanks.
 
Physics news on Phys.org
Is f(x,y) differentiable analytically? I'll assume not, but I will assume it's continuous.
If you can feed in a feasible range for y(x0) then you could program a binary chop on the values. (Do I need to explain that?) Having found one point on the line, (x0, y0), you could then search for solutions of f(x,y) = 0 where the |(x,y)-(x0, y0)| = some small r. Again, you could do a binary chop on the direction from (x0, y0) to (x,y).
 
What is "binary chop"?
 
If [itex]f(x_0, y_0)> 0[/itex] and [itex]f(x_1, y_1)< 0[/itex] then, because f is continuous, there must be a point between [itex](x_0, y_0)[/itex] and [itex](x_1, y_1)[/itex] where f is 0. We have no idea where so checking one point is as good as another- use the midpoint, [itex](x_2, y_2)= ((x_0+ x_1)/2, (y_0+ y_1)/2)[/itex]. Now look at [itex]f(x_2, y_2)[/itex]. If it is 0, we are done! If not, it is either positive or negative. If it is positive, then, since [itex]f(x_1, y_1)< 0[/itex], there must be a solution between them. If it is negative, then, since [itex]f(x_0, y_0)> 0[/itex], there be a solution between them. In either case, define [itex](x_3, y_3)[/itex] to be the mid point of that interval.

That is, I think, what haruspex is calling a "binary chop". I would call it a "binary search".
 
Last edited by a moderator:
My concern is that f(x,y) does not evaluate necessarily to real value, it might as well be complex, so it being positive or negative is not well defined.
 
LayMuon said:
My concern is that f(x,y) does not evaluate necessarily to real value, it might as well be complex, so it being positive or negative is not well defined.
That's not a problem. 0 is 0, and the modulus of f is zero if and only if f is 0.
 
haruspex said:
That's not a problem. 0 is 0, and the modulus of f is zero if and only if f is 0.

But then if you are taking |f(x,y)| how do you implement the comparisons of where it is positive and where negative?
 
LayMuon said:
But then if you are taking |f(x,y)| how do you implement the comparisons of where it is positive and where negative?
Ooops! Yes, you're right, sorry. Let me think some more.
 
OK, instead of doing the binary chop based on the sign of f, you can look for local minima of |f|. This is a bit trickier because you need to track three 'current' points. E.g. if |f(x,y0)| > |f(x,y1)| < |f(x,y2)|, y0 < y1 < y2, then you know there is a min between y0 and y2. So next pick y3 = (y0 + y2). If |f(x,y3)| > |f(x,y1)| then you know there's one between y3 and y2. But it might turn out to be > 0, and there could be a min between y0 and y3.
 
  • #10
haruspex said:
OK, instead of doing the binary chop based on the sign of f, you can look for local minima of |f|. This is a bit trickier because you need to track three 'current' points. E.g. if |f(x,y0)| > |f(x,y1)| < |f(x,y2)|, y0 < y1 < y2, then you know there is a min between y0 and y2. So next pick y3 = (y0 + y2). If |f(x,y3)| > |f(x,y1)| then you know there's one between y3 and y2. But it might turn out to be > 0, and there could be a min between y0 and y3.

but in that case you would just find local minima of the function, not zeros.
 
  • #11
LayMuon said:
but in that case you would just find local minima of the function, not zeros.
Since |f| ≥ 0, every zero will be a local minimum. So if you find all the minima you will find all the zeroes.
 
  • #12
But not all local minima are the zeros
 
  • #13
And another problematic thing with what you suggest is that you have to literally scan all x values, the problem is like for single variable case. I was more looking to be able to dispense with scanning x fully.
 
  • #14
LayMuon said:
But not all local minima are the zeros
Quite so.
And another problematic thing with what you suggest is that you have to literally scan all x values, the problem is like for single variable case. I was more looking to be able to dispense with scanning x fully.
As I understood it, you want to plot y as a function of x. So you would choose whatever set of x values then for each one try to find that y for which f(x,y)=0. All I can offer is some way to find those corresponding y values.
 

Similar threads

  • · Replies 17 ·
Replies
17
Views
4K
Replies
3
Views
2K
  • · Replies 20 ·
Replies
20
Views
4K
  • · Replies 8 ·
Replies
8
Views
1K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
982