Date: Sun, 5 Feb 95 22:56:29 CST From: rusin (Dave Rusin) To: [Permission pending] Subject: Re: Solving this set of nonlinear equations Newsgroups: sci.math In article <[identifier deleted - djr]> you write: > > One thing I neglected to mention is that I know the derivative >of the vector q. I don't know of a way to invert a vector, so is >there some way I could use Newton's method to solve for the four >angles? Derivative with respect to what? I'm guessing that you mean a, b, c, d are changing in time, so that the qi are as well, and you know d(qi)/dt. (Another interpretation is that you mean you know all d(qi)/da, d(qi)/db, etc) Unfortunately it's still true that you don't have enough information to determine a b c d. Generally, specifying q1 q2 q3 q4 picks out not a specific point but rather a _curve_ in a-b-c-d space. Let me add that "inverting a vector" makes no sense, but inverting a matrix does, and you're right, you can use Newton's method for that. Given a function F : R^n --> R^n (that is, F is an n-tuple of functions of n variables, like your 4 functions of 4 variables) you can solve F(x)=q for x (where q is a known point in R^n) by iteratively calculating x(n+1) = x(n) - [F'(x(n))]^(-1).F(x(n)). But this requires inverting the matrix F'(x(n)) which in turn requires that the image of F be an open subset of R^n (at least near F(x(n)) ). Unfortunately for you, this is not going to happen with your F because the only q's which occur lie in the unit sphere Sum qi^2 = 1. Perhaps you can clarify how the problem arises? Then we can see if there's some extra information you're not providing us. dave ============================================================================== Newsgroups: sci.math From: pmontgom@cwi.nl (Peter L. Montgomery) Subject: Re: Solving this set of nonlinear equations Date: Mon, 6 Feb 1995 09:48:32 GMT In article <[identifier deleted - djr]> [Permission pending] writes: >> I have a four element real vector q defined as follows: >> >> | q_1 | | cos(a) cos(b) cos(c) + sin(a) cos(d) sin(c) | >> | q_2 | = | cos(a) sin(b) cos(c) + sin(a) sin(d) sin(c) | >> | q_3 | | sin(a) cos(b) cos(c) - cos(a) cos(d) sin(c) | >> | q_4 | | sin(a) sin(b) cos(c) - cos(a) sin(d) sin(c) | >> >> I have the values of q_1, q_2, q_3, q_4; >> I also know that 0.0 <= a, c <= pi * 0.5 >> Is there a way to solve for a, b, c, d? > One thing I neglected to mention is that I know the derivative >of the vector q. I don't know of a way to invert a vector, so is >there some way I could use Newton's method to solve for the four >angles? The second comment (about derivatives) is confusing. Do you mean derivative with respect to time? Or do you have partial derivatives? The values of q_1 through q_4 do not determine a through d uniquely. We can check by hand that q_1^2 + q_3^2 = cos(b)^2 cos(c)^2 + cos(d)^2 sin(c)^2, q_2^2 + q_4^2 = sin(b)^2 cos(c)^2 + sin(d)^2 sin(c)^2, q_1^2 + q_2^2 + q_3^2 + q_4^2 = cos(c)^2 + sin(c)^2 = 1. Therefore all possibly values of the vector [q_1, q_2, q_3, q_4]] lie on a sphere in four-dimensional space. This sphere is locally a three-dimensional surface, so we cannot locally solve for four angles a, b, c, d. If we fix the angle a, then we can readily solve for the others. From the given equations, we derive cos(b)*cos(c) = q_1*cos(a) + q_3*sin(a), sin(b)*cos(c) = q_2*cos(a) + q_4*sin(a), cos(d)*sin(c) = q_1*sin(a) - q_3*cos(a), sin(d)*sin(c) = q_2*sin(a) - q_4*cos(a) . The first two equations give b and cos(c); the latter two give d and sin(c). The computed b (resp. d) may be erroneous if cos(c) (resp. sin(c)) is near zero. In this case use a different value for a. -- Peter L. Montgomery pmontgom@cwi.nl San Rafael, California Mathematically gifted, unemployed, U.S. citizen. Interested in computer architecture, program optimization, computer arithmetic, cryptography, compilers, computational mathematics. 17 years industrial experience. ============================================================================== Newsgroups: sci.math From: [Permission pending] Subject: Solving this nonlinear set of equations Date: Mon, 6 Feb 1995 19:34:27 GMT Hello, In sci.math pmontgom@cwi.nl (Peter L. Montgomery) wrote: > In article <[identifier deleted - djr]> > [Permission pending] writes: >>> I have a four element real vector q defined as follows: >>> >>> | q_1 | | cos(a) cos(b) cos(c) + sin(a) cos(d) sin(c) | >>> | q_2 | = | cos(a) sin(b) cos(c) + sin(a) sin(d) sin(c) | >>> | q_3 | | sin(a) cos(b) cos(c) - cos(a) cos(d) sin(c) | >>> | q_4 | | sin(a) sin(b) cos(c) - cos(a) sin(d) sin(c) | >>> >>> I have the values of q_1, q_2, q_3, q_4; >>> I also know that 0.0 <= a, c <= pi * 0.5 >>> Is there a way to solve for a, b, c, d? >> >> One thing I neglected to mention is that I know the derivative >>of the vector q. I don't know of a way to invert a vector, so is >>there some way I could use Newton's method to solve for the four >>angles? > > The second comment (about derivatives) is confusing. Do you mean ^^^^^^^^^^^^ Sorry about that, I should have been more specific. The derivative of q is with repsect to time. The equation for q' is as follows: | q_1' | | 0.0 -omega_1 -omega_2 -omega_3 | | q_1 | | q_2' | = 0.5 * | omega_1 0.0 omega_3 -omega_2 | | q_2 | | q_3' | | omega_2 -omega_3 0.0 omega_1 | | q_3 | | q_4' | | omega_3 omega_2 -omega_1 0.0 | | q_4 | where omega_1, omega_2, and omega_3 are the x, y, and z components of the angular velocity, respectively, in radians per second. Thus, the derivative of q is one half of a 4x4 skew-symmetric matrix multiplied by q. [sig deleted - djr] ============================================================================== Subject: [no subject line -- djr] Date: Mon, 13 Feb 95 14:11:32 EST From: [Permission pending] To: rusin@math.niu.edu Hello, You wrote: From: rusin@math.niu.edu (Dave Rusin) > Good news and bad news. You still can't do what you ask, but you can > do something different, possibly useful. > > No matter how you slice it, there is for each q a circle's worth > of possibilities for (a,b,c,d). Your differential equation states > how the circles evolve over time. You would need some additional > information to say _where_ on each circle you intend to be at time > t. For example, it would be sufficient to specify one of the parameters > (say a=0 ) or to specify how one would change (say da/dt=constant). > (Is this perhaps omega_i for some i ?) > > On the other hand, if the omega_i are constant, then you may > parameterize your q's a little differently -- would that be any help? The omega_i are not constant. However, omega_1 is reasonably well behaved and I believe that omega_1 = b'. But I don't believe that's enough info to crack this, so I'll tell you what I'm using it for. I was numerically integrating a set of highly oscillatory ODEs, so I decided to fit a variable frequency, variable amplitude sine wave to the ODEs. I did this by replacing the oscillating functions in the state vector with their amplitudes and phase angles to make the system of ODEs less nonlinear, thereby allowing an increase in the step size. The set of ODEs is actually a sum of two sine waves. The first term in the sum (angles a, b, c) is the dominant one, with angle b maintaining a fairly steady frequency. Angle d also maintains a fairly steady frequency. I'm using the sine and cosine of a and c as amplitudes, which is why I needed them between 0 and pi / 2.0 inclusive. So I know b', and I probably want to maximize d', and minimize a' and c'. If it's neccessary to solve for the min-max problem I also have the second derivative of the vector q with respect to time. If I don't get just the right values for a, b, c, and d my system of ODEs could oscillate just as badly as my original system. [sig deleted - djr] ============================================================================== Newsgroups: sci.math,sci.math.num-analysis From: [Permission pending] Subject: Solving this set of equations Date: Thu, 2 Mar 1995 18:15:43 GMT Hello, >> I have a four element real vector q defined as follows: >> >> | q_1 | | cos(a) cos(b) cos(c) + sin(a) cos(d) sin(c) | >> | q_2 | = | cos(a) sin(b) cos(c) + sin(a) sin(d) sin(c) | >> | q_3 | | sin(a) cos(b) cos(c) - cos(a) cos(d) sin(c) | >> | q_4 | | sin(a) sin(b) cos(c) - cos(a) sin(d) sin(c) | >> >> I have the values of q_1, q_2, q_3, q_4; >> I also know that 0.0 <= a, c <= pi * 0.5 >> Is there a way to solve for a, b, c, d? >> > The derivative of q is with repsect to time, and I have > these values as well. The > equation for q' is as follows: > > | q_1' | | 0.0 -omega_1 -omega_2 -omega_3 | | q_1 | > | q_2' | = 0.5 * | omega_1 0.0 omega_3 -omega_2 | | q_2 | > | q_3' | | omega_2 -omega_3 0.0 omega_1 | | q_3 | > | q_4' | | omega_3 omega_2 -omega_1 0.0 | | q_4 | > > where omega_1, omega_2, and omega_3 are the x, y, and z > components of the angular velocity, respectively, in > radians per second. > > Thus, the derivative of q is one half of a 4x4 skew-symmetric > matrix multiplied by q. Several people have stated that there is no unique solution to the problem, which is true. I have studied the problem some more and I now know which solution I want. I want to find a solution for the angles a, b, c, d such that the derivative with respect to time of either angle b or d is maximized when I substitute the sines, cosines, and derivatives of the four angles into q'. If the solutions are different, I would also like to know the solution for (a, b, c, d) such that the derivative with respect to time of either angle a or c is minimized. I also know the second derivative of q with respect to time, if that is needed for the min-max problem. Any suggestions on how to proceed? [sig deleted - djr] ============================================================================== Date: Mon, 17 Apr 95 14:34:42 EDT From: [Permission pending] To: rusin@math.niu.edu Subject: [no subject line -- djr] Hello, This was posted on sci.math.symbolic: In article <[identifier deleted - djr]> [Permission pending] wrote: ->Hello, -> ->I have a four element real vector q defined as follows: -> ->| q_1 | | cos(a) cos(b) cos(c) + sin(a) cos(d) sin(c) | ->| q_2 | = | cos(a) sin(b) cos(c) + sin(a) sin(d) sin(c) | ->| q_3 | | sin(a) cos(b) cos(c) - cos(a) cos(d) sin(c) | ->| q_4 | | sin(a) sin(b) cos(c) - cos(a) sin(d) sin(c) | -> ->I have the values of q_1, q_2, q_3, q_4; ->I also know that 0.0 <= a, c <= pi * 0.5 ->I am looking for a way to solve for a, b, c, d. -> ->The derivative of q is with repsect to time, and I have ->these values as well. The ->equation for q' is as follows: -> ->| q_1' | | 0.0 -omega_1 -omega_2 -omega_3 | | q_1 | ->| q_2' | = 0.5 * | omega_1 0.0 omega_3 -omega_2 | | q_2 | ->| q_3' | | omega_2 -omega_3 0.0 omega_1 | | q_3 | ->| q_4' | | omega_3 omega_2 -omega_1 0.0 | | q_4 | [ellipsis for the sake of brevity] ->Namely, I want ->to find a solution for ->the angles a, b, c, d such that the derivative with respect ->to time of either angle b or d is maximized [further ellipsis] I can maybe give you a strategy to attempt. First, try solving for the cosines and sines, rather than the angles; you can recover the angles once you know the cosines. Rewrite your first set of equations replacing Cos[a] with a variable ca, etc. Get rid of the sines (sa, sb, sc, sd) by substituting +/- sqrt(1-ca^2) for sa, etc. (I'm assuming that you'll know in advance which quadrant each angle lies in. If not, you may have to try all combinations.) You're left with four nonlinear equations in four unknowns (ca, cb, cc, cd). The catch is that the Jacobian determinant vanishes (I checked this), so you really cannot solve for all four cosines. Try to solve for three of them interms of the fourth (let's say cb is the one we hold out). A computer algebra package (Mathematica, Macsyma, ...) *might* be able to solve this - no guarantees. Assuming you manage to get a solution (which gives the cosines of a, c, and d in terms of the cosine of b), differentiate the right side of the first equation and substitute out all sines and the cosines of a, c and d (leaving cos(b)). Set that equal to the time derivative of q (the left side of the second equation) and try to maximize the derivative of b subject to those constraints. It's a nonlinear optimization problem with nonlinear constraints. That's as far as I can see to take it. Good luck. Paul ************************************************************************** * Paul A. Rubin Phone: (517) 432-3509 * * Department of Management Fax: (517) 432-1111 * * Eli Broad Graduate School of Management Net: RUBIN@MSU.EDU * * Michigan State University * * East Lansing, MI 48824-1122 (USA) * ************************************************************************** Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. J. W. v. GOETHE [sig deleted - djr] ==============================================================================