Confusion in linearity?
To expand on Justme's reply:

From the looks of your code you seem to have confused what constitutes an LTI system.

In your code the LTI system that I see (y1=2*z) scales an undelayed input signal by 2. The additional 2*cos(pi/t) is NOT part of the system, it is in effect just another sinusoid that you have added to your signal - thus giving it an additional frequency component.

An LTI system can only ever do two things to an input complex signal - it can scale the magnitude and it can modify the phase of frequency components of the signal. It cannot modify the fundamental frequencies of the sinusoidal components of a signal. (NB: It can however create resonances that self-oscillate - this is however cause by recursion in the system)

Returning to your code once again, we see that you have checked the linearity property, but have also included a scaling of the additional sinusoid that you have misattributed as part of the system. If you remove this sinusoid in your system function, you will find that the linearity property holds for your system

Edit: Fixed some technical wording issues