# Strange behavior with symbolic and atan

3 views (last 30 days)
Tony Tse on 29 May 2018
Commented: Walter Roberson on 29 May 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.

Walter Roberson on 29 May 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))