Strange behavior with symbolic and atan

2 Ansichten (letzte 30 Tage)
Tony Tse
Tony Tse am 29 Mai 2018
Kommentiert: Walter Roberson am 29 Mai 2018
Hello,
I am solving a time derivative equation in Matlab. atan is part of the solution. It seems to behave strangely when atan(tan) is around. Although, I am not sure. I have attached the script with my problem. This represents a simple circuit in real life.
In the first part of the script, I represented 10e-9 as rational representation, sym(10e-9, 'r'). This seems to give me discontinuity when tan -> inf, at t=0.5 in this case. To my surprise, representing 10e-9 as a floating point in the second part, solves this problem and give me very close results compared to the real world data! Moreover (maybe unrelated), analysing vSol in the second part show parts that go to 0 but isn't simplified!
I would like to get more idea of what is going on before solving a more complicated problem.
Thanks.

Antworten (1)

Walter Roberson
Walter Roberson am 29 Mai 2018
The oddity you see in the plot is the correct theoretical form.
After substitution of f = 1, there is a subexpression which is arctan(tan(pi*t)/sqrt(3)) . The tan goes to infinity as t = 1/2 from the left, and since tan is discontinuous, the tan goes to -infinity as t = 1/2 from the right. arctan() therefore goes to pi/2 from the left but -pi/2 from the right. Taking into account the other parts of the expression, the limit from the left is 3000*exp(-(1/30)*sqrt(3)) and the limit from the right is 3000*exp((1/30)*sqrt(3))
  2 Kommentare
Tony Tse
Tony Tse am 29 Mai 2018
Bearbeitet: Tony Tse am 29 Mai 2018
Thanks, Walter. That makes sense but what about the 2nd case? It matches the measured data, and not the 1st case.
Walter Roberson
Walter Roberson am 29 Mai 2018
It appears that with the round-off error of converting the floating point version, that the expression ends up with subtracting off an arctan(tan(2*pi*f*t)) term; I guess that ends up canceling out the problem somehow because both arctan() would be on the same side of zero ?

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by