Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2007-09-06 12:58:16

arina
Member
Registered: 2007-09-06
Posts: 15

Non-linear Simultaneous Equations problem.

Hallo,

I'd like to request a little help with this perplexing problem. I have three equations with two unknowns but so far I haven't been able to solve for exact values of x and y....

I haven't figured it out using log or any numerical method so far.  dizzy 

A solution or even some advice would be much appreciated. 

Thanx.

Offline

#2 2007-09-06 17:19:52

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: Non-linear Simultaneous Equations problem.

After playing with "pythagorean triples for over an hour", I bet the answer is not integral whole numbers.  But I might be wrong easily...


igloo myrtilles fourmis

Offline

#3 2007-09-09 13:52:10

arina
Member
Registered: 2007-09-06
Posts: 15

Re: Non-linear Simultaneous Equations problem.

Oops, I've made a terrible, terrible mistake. I somehow left out the negative signs in the left side of the equation. Here's the correct ones:

I'm really, terribly sorry for the error. eek

Actually, the answer is integral whole numbers. For the above set the correct answer is

You might have noticed that these are the standard distance equations used for Cartesian coordinate geometry. Actually my original distance values were different. I thought maybe I had the wrong distance values. So I chose these coordinates myself by measuring the distance. What I really need is a method to solve these equations repeatedly for different distance values. I gotta code a program that does it automatically. Don't ask me why they keep telling us to write new programs when there are so many maths software available already. But my deadline is fast approaching and I'm out of ideas. dunno

Could anyone please help me out, give me some guidance? Please?

Offline

#4 2007-09-09 17:00:46

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: Non-linear Simultaneous Equations problem.

I've got your answer!!!
It's all in the hyperbolas!!!!
http://www.physicsinsights.org/hyperbola_focus.html
See how the difference of the distance from both foci are always the same...


igloo myrtilles fourmis

Offline

#5 2007-09-10 16:06:03

arina
Member
Registered: 2007-09-06
Posts: 15

Re: Non-linear Simultaneous Equations problem.

Wow, that was fast. Thank you for your help, John. I really appreciate it.

I've spent 4-5 hours trying to work my equations like that but whenever I've replaced the real values of x and y into the equations i get absurd values. In theory the final result should be equal in both sides like

But for my own equations i got strange values in every attempt. Some results for your entertianment:

Finally I used the equation given under the subtopic An Equation for a Hyperbola.
I drew the points on a piece of paper with the middle being

.
was at
and f2 at
so that
.

I selected a random coordinate

as the
that had to be found. Difference in distance:
. (Here the distance and coordinates are in milimeters)

Working the values into equation (8) of the webpage you pointed out, I got this result:

I am absolutely baffled by what I'm doing wrong.

I know your time is very precious. I am deeply humbled by the help you have given so far. But could you help me out a little and maybe point my mistake here? I'll be grateful for any pointers. Thanx.

Last edited by arina (2007-09-10 16:08:40)

Offline

#6 2007-09-10 20:59:32

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: Non-linear Simultaneous Equations problem.

I'm sorry this is getting so hard.
I've never done this before, I was just pointing out
a page that had pictures that might help.
I've been googling around on these topics so far:
   1.  simultaneous hyperbolas
   2.  hyperbolic positioning systems
             I guess if the timing signals in the satellites differ by certain
  amounts, then positioning is figured with hyperbolas!!
  I have a hiking GPS, so this is very interesting to me.
  I'll read more, and if I can help, I'll try later...
  When the hyperbola is on a funny angle, and then you have another
   hyperbola that is smaller on a different angle or something, then
   we have to find the intersection I guess.  I have a lot of research to do...


igloo myrtilles fourmis

Offline

#7 2007-09-10 23:40:15

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: Non-linear Simultaneous Equations problem.

Since these equations are implicit (not explicit in terms of y) equation that are not solved for x or y, then I've been graphing them with a double loop and using different colors to show how close I am to the right answer with colored regions on the graph.

The double loop is like:
  for x = -15 to 15 step 0.1
    for y = -15 to 15 step 0.1
       Check equation in here...
    next y
  next x

I've got to tell you though, the weird thing so far I found is
that none of my hyperbolas have two sections going in two
opposite directions, and I'm perplexed as to why.
I get hyperbolas at all angles going everywhere when I
fiddle with the numbers in an equation of the form:
0 = (x^2 + y^2)^0.5 - ((x-A)^2 + (y-B)^2)^0.5 - C, where A,B,C are constants I keep fiddling with.
  (In my double loop where a grid of dots is checked, if the equation comes out really close to zero, then I print a black dot on the graph there, but if it is farther away, I use blue or green for really far off.  This method is really dumb, but it is experimental.  It is dumb because the real graph may not be what I am looking at, but it might be if I'm lucky, it seems to work for parabolas that I checked.)
I don't see why only one side of the hyperbola is showing.
Maybe they aren't hyperbolas after all???  I just don't know yet??

Last edited by John E. Franklin (2007-09-11 00:04:12)


igloo myrtilles fourmis

Offline

#8 2007-09-11 14:27:16

arina
Member
Registered: 2007-09-06
Posts: 15

Re: Non-linear Simultaneous Equations problem.

Wow, I think the dot method is pretty good. Which software do you use for this, John? Initially I tried using Matlab and Polymath to try and solve this problem. But they can't really solve implicit equations. So I thought if I could just figure it out manually, then maybe I could write a program for it. But your graphical method seems perfect for this.

Hmmm, I haven't tried using hyperbola function in Matlab. I'll go and try it out now.

If you figure it out, please let me know. I'll be greatly indebted to you. Thanx.

Offline

#9 2007-09-13 00:13:16

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: Non-linear Simultaneous Equations problem.

In case you want to cut and paste this into Just Basic windows computer program and hit run, then you can also get "Just Basic" for nothing off the net.
Here is the BASIC code.

'draw a graph program by John Eric, January 1st, 2006
'updated 2007.

'Run with the little blue running guy above.
'After you wait until calculations are done and
'it says so, then maximize the little window to
'see the graph.  After you are done, then x out
'the graph window, and the print-out window, and
'answer "Yes" to close #1 which is a print handle
'I think.  Then you are back to this code window.

'cronolog rev notes...
'REV AAAQ  graph of y = (.22/6)x^3 + .11x + 4 and curvatures kappas
'REV AAAW starting hyperbolas I think...
'REV AABE dot-method for implicit (double loop graphs)

   dim color$(7)
   color$(1) = "darkred"
   color$(2) = "brown"
   color$(3) = "darkcyan"
   color$(4) = "darkgreen"
   color$(5) = "darkblue"
   color$(6) = "darkgray"
   color$(7) = "black"

   open "MaximizeAfterDun" for graphics as #1
   print #1, "down"
   print #1, "size 1"
   print #1, "color brown"

   ''you can change these enlargement values
   ''to make the graph bigger
   ''I've only used whole numbers so far...
   xenlarge = 8
   yenlarge = 8

''''''PRINT THE GRAPH HERE''''''''
'''pi = 3.1415926535897932384626433832795028841971
'''DOUBLE LOOP FOR HARD IMPLICIT GRAPHS.
''''''black is most accurate, blue far, green way off.
   for x = -7 to 7 step .25
   for y = -7 to 7 step .25
     'if you get a blank graph, try different
     'constants in equation until something shows.
     JQConstant = (x^2+y^2)^0.5 - ((x-4)^2 + (y+3)^2)^0.5 - 3.8
     ''absolute value is taken
     ''below, to check near zero.
     JQConstant = abs(JQConstant)
     If JQConstant > 0.2 then goto [JQbluePrinting]
    [JQPrintThis]
     'BLACK HERE
     yPrintMe = y
     xPrintMe = x
     A$ = "set " + Str$(640 + xPrintMe*xenlarge) + " " + Str$(400-yPrintMe*yenlarge)
     print #1, "color black"
     print #1, A$
     goto [JQDonePrinting]
    [JQbluePrinting]
     'BLUE HERE
     If JQConstant > 1.01 then goto [JQGreenPrinting]
     yPrintMe = y
     xPrintMe = x
     A$ = "set " + Str$(640 + xPrintMe*xenlarge) + " " + Str$(400-yPrintMe*yenlarge)
     print #1, "color blue"
     print #1, A$
     goto [JQDonePrinting]
    [JQGreenPrinting]
     'GREEN HERE
     If JQConstant > 3.01 then goto [JQDonePrinting]
     yPrintMe = y
     xPrintMe = x
     A$ = "set " + Str$(640 + xPrintMe*xenlarge) + " " + Str$(400-yPrintMe*yenlarge)
     print #1, "color green"
     print #1, A$
     goto [JQDonePrinting]

    [JQDonePrinting]
   next y
   next x

''''''''''''''''''''''''''''''''''''

   print #1, "color "; color$(6)
   'horizontal x-axis drawn
   for xx = -600 to 600
       yPixel = 0
       xPixel = xx
       A$ = "set " + Str$(640 + xPixel) + " " + Str$(400-yPixel)
       print #1, A$
   next xx

   print #1, "color "; color$(6)
   'vertical y-axis drawn
   for yPixel = -390 to 390
       xPixel = 0
       A$ = "set " + Str$(640 + xPixel) + " " + Str$(400-yPixel)
       print #1, A$
   next yPixel
   '''''''''print the hash lines on the x-axis''''''''''
   ddd = int(635 / xenlarge)
   for iterbee = -1 * ddd to ddd step 1
     xhash$ = Str$(640 + xenlarge * iterbee)

     A$ = "set " + xhash$ + " 400"
     print #1, A$
     A$ = "set " + xhash$ + " 399"
     print #1, A$
     A$ = "set " + xhash$ + " 401"
     print #1, A$

   next iterbee

   '''''''''print the hash lines on the y-axis''''''''''
   ddd = int(395 / yenlarge)
   for iterbee = -1 * ddd to ddd step 1
   yhash$ = Str$(400 + yenlarge * iterbee)

   A$ = "set " + "640 " + yhash$
   print #1, A$
   A$ = "set " + "639 " + yhash$
   print #1, A$
   A$ = "set " + "641 " + yhash$
   print #1, A$

   next iterbee

   for iteriter = 1 to 10
   Print "All Done, Maximize little window now."
   next iteriter
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
   print #1, "flush"
   wait
   close #1
'''eof'''eof'''end of file'''

igloo myrtilles fourmis

Offline

#10 2007-09-13 20:15:49

arina
Member
Registered: 2007-09-06
Posts: 15

Re: Non-linear Simultaneous Equations problem.

Oh, wow. That's a neat little program. Thank you so much for posting it. I downloaded just Basic and now I'm trying to understand the code.

I used it to create the graph for my first equation and I can see that it gives a set of possible results that include the correct answer. I guess if I could somehow plug in the other two equations I could narrow it down to one correct answer.

The past couple of days, I decided to use Matlab software to find the correct values through a trial & error method. Since matlab is quite reliable in computing vast amount of data quickly, I created a matrix of all possible combinations of x and y values. After a lot of troubleshooting, I've managed to narrow down the first equation to 118 possible results. I'll have to find a way to match results for all three equations to find the final correct x and y coordinate.

By the way, I'm curious as to why you've chosen Basic. Is it a better programming language for mathematical problems? I've never written a program for mathematical problem that has graphical solution. Do you think C can produce this kind of graph too?

But no matter what, it looks like my maths problem won't be a problem for long. :-)

Offline

#11 2007-09-15 09:30:38

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: Non-linear Simultaneous Equations problem.

I program in 5 languages:
PLC ladder logic (used to work with machines at an old job)
assembly language for PC (used to do really fast calculations)
C language (used to do 5000 times faster than BASIC calculations, and easy to use)
Euphoria (used to do a Windows Interface with graphic buttons to press on and make music)
BASIC (use for anything since it is so easy, and can add really long numbers in Just BASIC!!)

Oh, and for Euphoria, I learned to concatentate WAV files to make a song
out of recordings of my clarinet notes, but I had to learn the header information
of the WAV file format.
Also, in C I wrote a calculator that prints answer in DOS command prompt.
Oh, and in Euphoria, I have used 30 to 40 MB of RAM and it still ran!!!

I don't know C++, too hard for me, I'm too simple for OO-land.

Last edited by John E. Franklin (2007-09-15 09:33:17)


igloo myrtilles fourmis

Offline

#12 2007-09-16 20:51:49

arina
Member
Registered: 2007-09-06
Posts: 15

Re: Non-linear Simultaneous Equations problem.

Pretty impressive list! So, is Euphoria considered 'programming'? wink

I used your program as a guide to write Matlab code and succedded in getting the graphs/plots for the three equations. Only things is now I can't extract the x and y values where the graphs intersect.

I modified the Basic code you gave like this:

And I added the conditions for JQ2 and JQ3 in the printing sections of the program. Fortunately, that gave a narrowed set of possible coordinates.

What command could I add to your Just Basic code so that it lists out the possible coordinates as output? And what do you think is the equivalent C command? I can transalate C commands into Matlab easier. dizzy

Last edited by arina (2007-09-16 20:59:00)

Offline

#13 2007-09-17 04:01:14

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: Non-linear Simultaneous Equations problem.

I think you need to create three pairs of list of numbers which
hold the values of all the coordinates you print out to the screen.
Make a list for each of the three equations.
Each time you print out a new dot on the graph, you could
loop through the other two lists for the other two equations and
check to see if you come within a small distance from any
coordinates on the list. 
or alternatively, just make the three lists and then do the
triple loop comparisons after you are all done, see how close
any three points are in the three lists.
Later when you narrow in on the points, you can double-loop
around the areas of interest with smaller steps to get more
accurate results, and test for smaller closenesses.  Like I usually
change things by a factor of ten to step in closer.

If you post your matlab program, or the important parts, I would
love to learn it!!

And Euphoria is about as easy as BASIC or C, but it was easy for me
to make a Windows program because they had lots of sample programs
on the internet in the downloads.  The mouse up and down events were
tricky to handle if the mouse was down more than 1 second, but I used
that to my advantage, since it only has to run on my computer anyway,
then I don't care about ideosyncrasies.  Windows is hard for me to program
in C/C++, so I like Euphoria, and Euphoria is interpreted, but is really quite fast.
It's all on the internet.  Euphoria comes in several packages for different
environments like DOS (command prompt), or Windows, or another ExWindows
one I think and maybe Linux too.

Last edited by John E. Franklin (2007-09-17 04:06:05)


igloo myrtilles fourmis

Offline

#14 2007-09-17 16:15:11

arina
Member
Registered: 2007-09-06
Posts: 15

Re: Non-linear Simultaneous Equations problem.

I've been 'cracking my head' trying to figure out a way to print out the matching coordinates. It seems so strange that the graph is showing the coordinates clear as day but I can't figure out the code to print the coordinates as program output.

I've been going through all possible command searches in the 'matlab help'. I've tried matlab commands like 'intersect', 'diff', etc. I'm trying the loop method you mentioned now.

I've heard that Matlab is rarely used in the industry since the price of  'non-academic purpose' license is sky-high. Still its great for Signal Processing and some of my professors swear by it. Here's a short version of my matlab code so far:

x = -60:0;		   	     % Selecting range of x and y.
y = 0:60;
x1 = x.*x;			       % Square each element in the x matrix.
y1 = y.*y;

for a=1:length(x)
for b=1:length(y)
z1(a,b)=x1(a)+y1(b);	     % Create a MATRIX that contains all possible   
end				  	    % combinations of x (squared) + y (squared). 
end 				         % [MATRIX dimensions: 61 x 61]
mid = (-127-x);         	 % Create a matrix of (-127 - x) for all x values.
x2 = mid.*mid;          	 % Square each element.
ymid = (100-y);			  % Create a matrix of (100 - y) for all y values.
y2 = ymid.*ymid;

for a=1:length(x)
for b=1:length(y)			% Second MATRIX for all possible results for the
z2(a,b)=x2(a)+y2(b);		 % second part of the equation.
end				 	     % [MATRIX dimensions: 61 x 61]
end 

z3=sqrt(z1);				 % Find square-root of the first
z4=sqrt(z2);				 % and second MATRIX.
delta = z3 - z4;

% Locate all results within this range:	      xo = row number
[xo,ya,v] = find(-32 < delta & delta < -28)	% ya = column number					
% The row values / x-coordinates are changed from 0 -> 60 to -60 -> 0.
xa=xo-60;

% Repeat same procedure for 2nd and 3rd equations........
% Result: 3 sets of coordinates: xa, ya, xb, yb and xc, yc
% Plot the graphs:
plot(xc,yc,'d',xa,ya,'.', xb,yb,'o')

I've chosen to plot dots instead of lines too. The coordinates given are whole numbers since the  accuracy is good enough for me.

Now, back to 'head-cracking' for me.

Last edited by arina (2007-09-17 20:12:28)

Offline

#15 2007-09-23 16:36:46

arina
Member
Registered: 2007-09-06
Posts: 15

Re: Non-linear Simultaneous Equations problem.

Hi John,

I'm happy to say that I've finally managed to solve the maths problem completely.

I used triple 'for' loops containing 'if' statements to display the result. Now, I think I'll create a sub-routine for it to average the results and give me one final answer. But it looks like smooth sailing from here on.

I'd like to once again thank you from the bottom of my heart. If it wasn't for your help, I might have spent another two or three long months to get this far, or maybe i would've just given up and handed in incomplete work.

You must have spent a few hours at the very least working on this maths problem for me, a complete stranger. And I wanted you to know that I truly appreciate your kindness.

Thanks ever so much. wave

Offline

Board footer

Powered by FluxBB