Finding Numerically the solution line for an equationby LayMuon Tags: equation, line, numerically, solution 

#1
Dec1012, 07:03 PM

P: 146

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. 



#2
Dec1112, 03:21 AM

Homework
Sci Advisor
HW Helper
Thanks ∞
P: 9,205

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(x_{0}) then you could program a binary chop on the values. (Do I need to explain that?) Having found one point on the line, (x_{0}, y_{0}), you could then search for solutions of f(x,y) = 0 where the (x,y)(x_{0}, y_{0}) = some small r. Again, you could do a binary chop on the direction from (x_{0}, y_{0}) to (x,y). 



#3
Dec1112, 12:35 PM

P: 146

What is "binary chop"?




#4
Dec1112, 07:56 PM

Math
Emeritus
Sci Advisor
Thanks
PF Gold
P: 38,894

Finding Numerically the solution line for an equation
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". 



#5
Dec1112, 08:17 PM

P: 146

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
Dec1112, 08:36 PM

Homework
Sci Advisor
HW Helper
Thanks ∞
P: 9,205





#7
Dec1112, 08:44 PM

P: 146





#8
Dec1112, 08:54 PM

Homework
Sci Advisor
HW Helper
Thanks ∞
P: 9,205





#9
Dec1112, 09:11 PM

Homework
Sci Advisor
HW Helper
Thanks ∞
P: 9,205

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,y_{0}) > f(x,y_{1}) < f(x,y_{2}), y_{0} < y_{1} < y_{2}, then you know there is a min between y_{0} and y_{2}. So next pick y_{3} = (y_{0} + y_{2}). If f(x,y_{3}) > f(x,y_{1}) then you know there's one between y_{3} and y_{2}. But it might turn out to be > 0, and there could be a min between y_{0} and y_{3}.




#10
Dec1112, 09:15 PM

P: 146





#11
Dec1112, 10:25 PM

Homework
Sci Advisor
HW Helper
Thanks ∞
P: 9,205





#12
Dec1112, 11:44 PM

P: 146

But not all local minima are the zeros




#13
Dec1212, 12:16 AM

P: 146

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
Dec1212, 12:23 AM

Homework
Sci Advisor
HW Helper
Thanks ∞
P: 9,205




Register to reply 
Related Discussions  
Finding Equation of an Orthogonal Line  Calculus & Beyond Homework  3  
finding the equation for the tangent line.  Calculus & Beyond Homework  6  
Finding the equation of a line  Calculus  3  
Finding equation of a line  Precalculus Mathematics Homework  3 