# confusion in time invariance?

I am trying to learn shift invariance(time invariance) and i came across a function/system

$$y(t)=3x(t)+2\cos(\pi t/3)$$

I am confused.If it was alone 3x,it should be definitely time invariant(i verified it through MATLAB)

But now it contains two terms, cos term in addition to 3x term,making function complex

Here is MATLAB code i tried to make for this system:

clc
clear all
close all
t=-5:.001:10;
x=heaviside(t)-heaviside(t-5);
y=3*x+2*cos(pi*t/3)
plot(t,y)

legend('y(t)')

figure
plot(t+3,y)

legend('y(t-3)')

figure
t=-5:.001:10;
x_shifted=heaviside(t-3)-heaviside(t-8);
y2=3*x_shifted+2*cos(pi*t/3);
plot(t,y2)

legend('S[x(t-3)]')


Its output shows that my system/function is not time invariant(please correct me if i am wrong)

The given system is not time invariant due to the term $$\cos(\pi t / 3)$$.

Given a system definition of the form:

$$y(t) = 3 x(t) + \cos( \pi t/3)$$ it's easy to see that

$$y(t-d) = 3 x(t-d) + \cos(\pi (t-d) /3) \neq T\{x(t-d)\} = 3 x(t-d) + \cos(\pi t/3)$$

hence the system is time varying...

• Please kindly explain a bit about your part of statement at right side of ≠ sign
– engr
Apr 14 '19 at 7:54
• to the left of the $\neq$ is output shifted by $d$, to the right of the $\neq$ is the result of input shifted by $d$ and they are not equal (unless $d=0$; i.e, not for all $d$) hence time-varying. Apr 14 '19 at 20:54