# How to impose normalization condition (not initial condition) on DSolve or NDSolve?

I have a set of differential equations (or DAEs): $\begin{cases} 5x_{2} + 3x_{4} + 3x_{5} = \frac{dx_{1}}{dt}\\ 5x_{1} + 5x_{2} + 5x_{3} + 3x_{4} + x_{5}= 0\\ 3x_{2} + 3x_{4} + 10x_{5} = \frac{dx_{3}}{dt}\\x_{1} + 3_{2} + 2x_{3} + 3x_{4} + 10x_{5} = 0\\ x_{1} + 2x_{2} + 3x_{3} + 4x_{4} + 5x_{5} = \frac{dx_{5}}{dt}\end{cases}$

I hope to impose the normalization condition that $|x_{1}|^2+|x_{2}|^2+|x_{4}|^2$=1 for all time. This is, however, not an initial condition.

Can someone help me? Thank you very much.

When I try to add the normalization condition as part of the DAEs equations, the error is:

Solve::inex: Solve was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Solve require exact input, providing Solve with an exact version of the system may help. >> DSolve::bvfail: For some branches of the general solution, unable to solve the conditions. >>

(Note: The above set of differential equations is just arbitrary, may not be consistent or solvable.)

• Please post Mathematica code, not TeX. Thanks Feb 18, 2015 at 17:45
• Also, please do not use subscripts here. They add needless complexity. Instead, use x1 etc. Thanks. Feb 18, 2015 at 17:52
• Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! Feb 18, 2015 at 18:16

a = {{0, 0, 5, 3, 3}, {5, 5, 5, 3, 1}, {0, 3, 0, 3, 10}, {1, 3, 2, 3, 10}, {1, 2, 3, 4, 5}};
vars = {x1@t, x2@t, x3@t, x4@t, x5@t};
normeq = x1[t]^2 + x2[t]^2 + x4[t]^2 == 1;
eq = Thread[a.vars == {x1'[t], 0, x3'[t], 0, x5'[t]}];
sol = DSolve[eq, vars, t];
cs = Solve[normeq /. sol, {C, C, C}];
k = vars /. sol /. cs[] /. C[_] :> 0 // N;
Plot[{k, Norm[{k[[1, 1]], k[[1, 2]], k[[1, 4]]}]}, {t, 0, 2}] Where you can see the normeq is satisfied as requested

• Thank you very much. Do C,C,C mean the constants in the solution in differential equations? After cs = Solve[normeq /. sol, {C, C, C}], I get only the solution of C in terms of C and C. Can you tell me what k means? Thanks Feb 19, 2015 at 0:53
• @kwyip Yep. The Cs are those constants. k means nothing, it's just a holding var for the ODE results Feb 19, 2015 at 2:42
• Does the line "k = vars /. sol /. cs[] /. C[_] :> 0 // N;" mean setting C, C and C to zero? and does the line "Plot[{k, Norm[{k[[1, 1]], k[[1, 2]], k[[1, 4]]}]}, {t, 0, 2}]" mean plotting k, x1, x2, x3, x4 and x5 versus time? Thank you very much. Feb 24, 2015 at 21:03
• I wonder how to assign values to the constants C,C and C. I try with C = 1 but it fails (with the reason (I get the warnings like Set::write: Tag C in C is Protected. >> ) Feb 25, 2015 at 4:42
• @kwyip You still need to learn the very basics. Do this yourExpression /. C->0 and then search the docs for ReplaceAll[] Feb 25, 2015 at 4:45