Finding Numerically the solution line for an equation

  • Thread starter LayMuon
  • Start date
  • Tags
    Line
In summary, the conversation discusses finding a solution line y(x) for the equation f(x,y) = 0, where the function itself can evaluate to a complex number for arbitrary sets of {x,y}, but the imaginary part of the solution must be zero. The suggested approach is to use a numerically efficient way to write the code, such as programming a binary chop or binary search on the values of y(x0). However, this approach may be tricky as the function may not evaluate to a real value, making it difficult to compare positive and negative values. Another approach suggested is to look for local minima of |f|, but this also has limitations as not all local minima are zeros.
  • #1
LayMuon
149
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
  • #2
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).
 
  • #3
What is "binary chop"?
 
  • #4
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:
  • #5
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.
 
  • #6
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.
 
  • #7
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?
 
  • #8
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.
 
  • #9
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.
 

1. How do I find the numerical solution line for an equation?

To find the numerical solution line for an equation, you will need to use a graphing calculator or a computer program. Simply enter the equation into the calculator or program, and it will graph the solution line for you.

2. Can I find the numerical solution line by hand?

In most cases, it is not possible to find the numerical solution line by hand. This is because the solution line involves plotting multiple points and connecting them to create a line, which can be time-consuming and prone to human error. It is best to use a graphing calculator or computer program for accuracy.

3. What is the purpose of finding the numerical solution line?

The numerical solution line helps us visualize and understand the behavior of an equation. It can also be used to solve systems of equations, find intersections, and make predictions about the behavior of a system.

4. Is there a difference between the solution line and the graph of an equation?

Yes, there is a difference between the solution line and the graph of an equation. The solution line only shows the specific points that satisfy the equation, while the graph of an equation shows all possible points. The solution line is a smaller subset of the graph.

5. Can the numerical solution line be used to solve any type of equation?

The numerical solution line can be used to solve linear equations, quadratic equations, and other types of equations. However, it may not be the most efficient method for every type of equation. Other methods, such as substitution or elimination, may be more suitable for certain types of equations.

Similar threads

Replies
20
Views
2K
Replies
1
Views
811
Replies
3
Views
934
Replies
4
Views
902
Replies
12
Views
1K
Replies
1
Views
1K
  • Calculus
Replies
4
Views
1K
Replies
3
Views
1K
Replies
10
Views
1K
Replies
5
Views
1K
Back
Top