Re: inequality as constraints on NDSolve

*To*: mathgroup at smc.vnet.net*Subject*: [mg106500] Re: [mg106196] inequality as constraints on NDSolve*From*: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>*Date*: Thu, 14 Jan 2010 05:51:43 -0500 (EST)

Dear Stefano, one way to cope with such a constraint would be to introduce a non-linear replacement of the variables that automatically accounts for the property you need. It is like in theory of magnetism or liquid crystals people introduce a replacement of variables in the equation for order parameters, if they want to neglect the order parameter variation in absolute value. Typically they go to spherical coordinates of the order parameter, rather than to their Cartesian coordinates). If needed, you may have a look into the books: Landau, L. D. & Lifshitz, E. M. Electrodynamics of Continuous Media (Elswier Butterworth-Heinemann, Oxford, 2004) and de Gennes, P. G. The Physics of Liquid Crystals (Oxford University Press, London, 1974). In particular, in your problem the best replacement would be the one most closely related to the physical sense of your variable x=x(t). However, if this physical sense-related transformation is not clear, why not to introduce x=z[t]^2? Or x=Exp[-z[t]] ? You should then formulate your system of equation in terms of y[t] and z[t]. Like this you make sure that your variable is positive everywhere. The price is the additional non-linearity introduced, but since your solution is anyway numeric this may be not that bad. Have success, Alexei Dear Mathematica experts: is there a possibility to implement a constraint in NDSolve? Suppose I want to solve NDSolve[{x'[t] == -y[t] - x[t]^2, y'[t] == 2 x[t] - y[t]^3, x[0] == y[0] == 1}, {x, y}, {t, 20}] But I want that the solutions satisfied the inequality x[t]>0 for every t (because it represent a physical quantity that has no meaning to be negative), i.e., and when it becomes =0 it has to stay zero. I've tried something like x[t_]:=If[x[t]>0,x[t],0] in the definition of x or y but it does not make sense. Somehow, I'd need to change the solution of the system when the solution itself become negative. ThankX for the help, :-) Best regards Stefano Pasetto -- Alexei Boulbitch, Dr., habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal from your system. Thank you for your co-operation.