# [?] Solve the following system of differential equations with DSolve?

Posted 4 months ago
780 Views
|
4 Replies
|
2 Total Likes
|
 Hi, I want to solve following system of differential equations sola = DSolve[{x5'[t] == -b, x1'[t] == x2[t], x2'[t] == (k*b*Cos[fi])/x5[t], x3'[t] == x4[t], x4'[t] == k*b*Sin[fi]/x5[t] - g, x1[0] == 0, x2[0] == 0, x3[0] == 0, x4[0] == 0, x5[0] == m0}, {x1[t], x2[t], x3[t], x4[t], x5[t]}, t] Gives following output: {{x5[t] -> m0 - b t, x2[t] -> k Cos[fi] Log[-m0] - k Cos[fi] Log[-m0 + b t], x1[t] -> ( b k t Cos[fi] - k m0 Cos[fi] Log[-m0] + b k t Cos[fi] Log[-m0] + k m0 Cos[fi] Log[-m0 + b t] - b k t Cos[fi] Log[-m0 + b t])/b, x4[t] -> -g t + k Log[-m0] Sin[fi] - k Log[-m0 + b t] Sin[fi], x3[t] -> (-b g t^2 + 2 b k t Sin[fi] - 2 k m0 Log[-m0] Sin[fi] + 2 b k t Log[-m0] Sin[fi] + 2 k m0 Log[-m0 + b t] Sin[fi] - 2 b k t Log[-m0 + b t] Sin[fi])/(2 b)}} but there is a mistake in the Log[-m0], there should be a +m0. How can I thread this?
4 Replies
Sort By:
Posted 4 months ago
 There is no bug. Mathematica is giving an alternative version of the expression you are expecting. They are the same in the real domain (but interestingly are different in the complex domain). You can see this by doing a numerical integration and comparing the solutions: solb = NDSolve[{x5'[t] == -b, x1'[t] == x2[t], x2'[t] == (k*b*Cos[fi])/x5[t], x3'[t] == x4[t], x4'[t] == k*b*Sin[fi]/x5[t] - g, x1[0] == 0, x2[0] == 0, x3[0] == 0, x4[0] == 0, x5[0] == m0} /. { b -> 2, m0 -> 2, k -> 1, fi -> 2, g -> 10}, {x1, x2, x3, x4, x5}, {t, 0, 10}][[1]] Plot[{(x4[t] /. solb) - ( x4[t] /. sola /. {b -> 2, m0 -> 2, k -> 1, fi -> 2, g -> 10})}, {t, 0, 1}] This plot will give numbers down at the tolerance of the numerical integration. Maybe a mathematician will have a good explanation for why this Integrate[(k*b*Cos[fi])/(m0 - b*t), t] gives the solution you expect with Log[+m0] while the same expression in DSolve gives the other form (and they are identical in the Real domain).Regards,NeilI hope this helps.
Posted 4 months ago
 Thank you Neil for your helpful answer. The problem is that I don't need just the numerical results but also the analytical formulas to compare them with my calculations by hand and I also append on this system of dif. equations next one like this solb = DSolve[{x1'[t] == x2[t], x2'[t] == 0, x3'[t] == x4[t], x4'[t] == - g, x5'[t] == 0, x1[0] == sola[tp][[1]], x2[0] == sola[tp][[2]], x3[0] == sola[tp][[3]], x4[0] == sola[tp][[4]], x5[0] == sola[tp][[5]]}, {x1[t], x2[t], x3[t], x4[t], x5[t]}, t] and do some more derivatives with these results. I tried also to consider some assumptions: \$Assumptions = {m0 > 0 && k > 0. && b > 0. && g > 0}; which gives the results with the right sign in the Log but adds some imaginary terms: {{x5[t] -> m0 - b t, x2[t] -> k Cos[fi] (I \[Pi] + Log[m0]) - k Cos[fi] Log[-m0 + b t], x1[t] -> ( b k t Cos[fi] - k m0 Cos[fi] (I \[Pi] + Log[m0]) + b k t Cos[fi] (I \[Pi] + Log[m0]) + k m0 Cos[fi] Log[-m0 + b t] - b k t Cos[fi] Log[-m0 + b t])/b, x4[t] -> -g t + k (I \[Pi] + Log[m0]) Sin[fi] - k Log[-m0 + b t] Sin[fi], x3[t] -> (-b g t^2 + 2 b k t Sin[fi] - 2 k m0 (I \[Pi] + Log[m0]) Sin[fi] + 2 b k t (I \[Pi] + Log[m0]) Sin[fi] + 2 k m0 Log[-m0 + b t] Sin[fi] - 2 b k t Log[-m0 + b t] Sin[fi])/( 2 b)}} The only solution of my problem I found is to delete the imaginary terms in the outputs and then make further calculations with it, which is not convenient. (I had to do it by hand, Functions like Re[] unfortunately did not help).Regards Frantiek
 The only solution of my problem I found is to delete the imaginary terms in the outputs and then make further calculations with it, which is not convenient. (I had to do it by hand, Functions like Re[] unfortunately did not help). Try result /. Complex[0,1]->0 
 Or more generally result // ComplexExpand @* Re