dsolve isn't solving my symbolic ODE correctly

조회 수: 4 (최근 30일)
Dominic Riccoboni
Dominic Riccoboni 2022년 4월 20일
편집: Dominic Riccoboni 2022년 4월 20일
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
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
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
Dominic Riccoboni
Dominic Riccoboni 2022년 4월 20일
Thank you for looking into this in detail. I agree that doing so for the above gamma result gets a good solution. I did actually try simplify at one point and the exponential terms went away, I must have just forgotten to do that before writing this post. It probably would have prevented the post in the first place.
I think I was just frustrated – there’s got to be some other factor I’m changing too readily that’s causing the control system to break and I keep trying to blame the wonky looking solutions I sometimes get when I don’t use simplify. I’ll just have simplify in there permanently and that’ll probably be that.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Torsten
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
Torsten 2022년 4월 20일
And these forcing functions do not allow a symbolic solution without giving numerical values to the parameters involved ?
Dominic Riccoboni
Dominic Riccoboni 2022년 4월 20일
편집: Dominic Riccoboni 2022년 4월 20일
No, they definitely could, it's just the way I've structured my code, I don't want someone to have to select from a list of parameterized solutions. I just want them to be able to ask for a desired trajectory in x and y coordinates (the forcing functions are the x and y accelerations) and the code will automatically compute consistent trajectories in the angles (gamma and beta). It's just to be as general as possible.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by