dsolve isn't solving my symbolic ODE correctly
조회 수: 4 (최근 30일)
이전 댓글 표시
I'm trying so solve two simple nonhomogeneous ODEs using dsolve. My forcing functions always have the some form, but I am allowing some parameters of the functions to change, i.e. the frequencies and the amplitude. The forced ODEs are:
and
I expect the particular solutions to be sums of sinusoids at the forcing frequencies. If we just take the Fourier transform of the first equation, we find that:
which is just an amplitude gain with no phase shift. The symbolic toolbox sometimes returns a good particular solution (coefficients are actual numbers in my code):
beta_s_sol(t) =
- 0.0444*cos(2.0944*t) - 0.0934*cos(3.1416*t)
but other times it's not correct. For the same system parameters, the gamma solution was:
gamma_s_sol(t) =
-7.7215e-11*exp(-8.6936*t)*(5.7469e+08*exp(8.6936*t)*sin(2.0944*t) - 1.2101e+09*exp(8.6936*t)*sin(3.1416*t))
Is there a known bug in the symbolic toolbox? I'm designing a control system that relies on those particular solutions and when I get two good solutions, the control system works very well. When I don't get the right solution, the control system doesn't work. I may have some fundamental issues elsewhere, but the controller response correlating with the ODE solution issue is pretty convincing to me.
댓글 수: 1
Torsten
2022년 4월 20일
Is a/b resp. c/d above always positive ? Otherwise, you'll get exp-terms in the solution of the homogenous system.
채택된 답변
John D'Errico
2022년 4월 20일
편집: John D'Errico
2022년 4월 20일
Look carefully at your solution, because you missed something.
gamma_s_sol(t) =
-7.7215e-11*exp(-8.6936*t)*(5.7469e+08*exp(8.6936*t)*sin(2.0944*t) - 1.2101e+09*exp(8.6936*t)*sin(3.1416*t))
______________ _____________
So we see a product of terms. In one case, there is a negative exponential. In the second, we have a positive exponential.
Just use simplify. I also used vpa, to turn the fractions into numbers, making it easier to read. And your numbers were only given to a few decimals anyway, so 5 digits is about all those expressions are worth.
vpa(simplify(gamma_s_sol),5)
ans(t) =
0.093438*sin(3.1416*t) - 0.044375*sin(2.0944*t)
Just a sum of simple trig terms. The exponentials cancel out. All you needed to do was use simplify. The exponentials looked like they were there. But really, they were not, a pure illusion done with mirrors. It was easy to miss. And no bug. Along the way, I assume that somewhere along the way, something exponential gets generated, that ends up completely cancelling out for your problem.
추가 답변 (1개)
Torsten
2022년 4월 20일
Is a/b resp. c/d above always positive ? Otherwise, you'll get exp-terms in the solution of the homogenous system.
Maybe you can just copy the solution here and integrate it as-is in your program code:
댓글 수: 5
Torsten
2022년 4월 20일
And these forcing functions do not allow a symbolic solution without giving numerical values to the parameters involved ?
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!