[math-fun] Simultaneous solutions of 2 eqns., 2 unknowns
I have 2 equations in x & y, each of form trig(x) + P(x,y) = 0 where trig is sin or cos, and P is a real polynomial of degree 3 or 4. I just found out that I have no idea how to ask Mathematica to solve this numerically. (I tried Roots, Solve, NSolve, N[Solve[...],10], and few other things, but it always came back with a No Can Do message.) On the other hand, with the Mac "Grapher" utility, I can plot each locus and see where they intersect. Biggest problem with Grapher is, when I enter 100% logically equivalent forms of the same equation (like just putting one term on the other side of the equation!) (and yes, changing its sign), it sometimes plots entirely different curves, which have entirely different intersections. Can someone please advise me how to get either of these programs to succeed? (By the way, I'm almost sure my equations have infinitely many simultaneous solutions, but I'm only interested in the unique one that's in the first quadrant nearest the origin.) Thanks in advance. --Dan _____________________________________________________________________ "It don't mean a thing if it ain't got that certain je ne sais quoi." --Peter Schickele
Wrt an infinity of solutions, probably not. sin & cos are bounded (on the reals), and the regions -1 <= P(x,y) <= 1 are usually also bounded, with only a small number of sign changes, etc. In the ordinary case, I'd expect only a few intersections of the two equations. Of course, if you open it up to complex solutions, there will be "many". Rich ________________________________________ From: math-fun-bounces@mailman.xmission.com [math-fun-bounces@mailman.xmission.com] On Behalf Of Dan Asimov [dasimov@earthlink.net] Sent: Friday, September 26, 2008 2:55 PM To: math-fun Subject: [math-fun] Simultaneous solutions of 2 eqns., 2 unknowns I have 2 equations in x & y, each of form trig(x) + P(x,y) = 0 where trig is sin or cos, and P is a real polynomial of degree 3 or 4. I just found out that I have no idea how to ask Mathematica to solve this numerically. (I tried Roots, Solve, NSolve, N[Solve[...],10], and few other things, but it always came back with a No Can Do message.) On the other hand, with the Mac "Grapher" utility, I can plot each locus and see where they intersect. Biggest problem with Grapher is, when I enter 100% logically equivalent forms of the same equation (like just putting one term on the other side of the equation!) (and yes, changing its sign), it sometimes plots entirely different curves, which have entirely different intersections. Can someone please advise me how to get either of these programs to succeed? (By the way, I'm almost sure my equations have infinitely many simultaneous solutions, but I'm only interested in the unique one that's in the first quadrant nearest the origin.) Thanks in advance. --Dan _____________________________________________________________________ "It don't mean a thing if it ain't got that certain je ne sais quoi." --Peter Schickele _______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
Hi Dan, Does Mathematica have a program to solve a non-linear program? Maple has such a package called Optimization with a procedure called NPSolve: "The NLPSolve command solves a nonlinear program (NLP), which involves computing the minimum (or maximum) of a real-valued objective function, possibly subject to constraints." Given a non-linear equation f(x,y) = g(x,y) and some constrains on x and y you can use NLPSolve to approximate a minimum for (f(x,y)-g(x,y))^2 subject to the given constrains. If you are lucky this gives a good approximation to a root of the equation. Here's an example: with(Optimization): NLPSolve((sin(x)-(1+x+y+x*y+x^2))^2, x = -7 .. 7, y = -7 .. 7); [ -25 [4.44089930500321336 10 , ] [x = 0.0000666681463949959582, y = -0.999933340741678832]] This means that if you substitute the given values for x and y in the equation the square of the lhs - rhs will be around 10^(-25). By changing the limits on x and y some other solutions can be found. And if you are in doubt you can set Digits to a higher value and get a more accurate solution--or at least some reassurance: Example: Digits:=100: NLPSolve((sin(x)-(1+x+y+x*y+x^2))^2, x = -7 .. 7, y = -7 .. 7); [ -173 [5.8478670710163984868158374216393067890572900 10 , [x = 0.000066668146839\ 280351116636520154710912470196287461485149815331828625112954588606673218267\ 62749753848043, y = -0.9999333407419011157720156383077005618533735537598369\ ] 563309909561603215660978391628821708141013478306]] --Cheers, Edwin On Fri, 26 Sep 2008, Dan Asimov wrote:
I have 2 equations in x & y, each of form
trig(x) + P(x,y) = 0
where trig is sin or cos, and P is a real polynomial of degree 3 or 4.
I just found out that I have no idea how to ask Mathematica to solve this numerically.
(I tried Roots, Solve, NSolve, N[Solve[...],10], and few other things, but it always came back with a No Can Do message.)
On the other hand, with the Mac "Grapher" utility, I can plot each locus and see where they intersect.
Biggest problem with Grapher is, when I enter 100% logically equivalent forms of the same equation (like just putting one term on the other side of the equation!) (and yes, changing its sign), it sometimes plots entirely different curves, which have entirely different intersections.
Can someone please advise me how to get either of these programs to succeed?
(By the way, I'm almost sure my equations have infinitely many simultaneous solutions, but I'm only interested in the unique one that's in the first quadrant nearest the origin.)
Thanks in advance.
--Dan
_____________________________________________________________________ "It don't mean a thing if it ain't got that certain je ne sais quoi." --Peter Schickele
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
participants (3)
-
Dan Asimov -
Edwin Clark -
Schroeppel, Richard