Question: How to define a piecewise periodic function in multiple variables, e.g. apply a duty cycle on a function in 2 variables?

Hello,

I'm struggling with following simple problem which I however cannot seem to implement easily in Maple:

  • I have 2 different periodic functions: f1 and f2, each time in  variables x and t.
  • On the second function f2 a duty cycle with period T and fraction q should need to be applied so that:
    • during the DUTY (=ON or 1) part of this period, so from 0 -> q*T, f2__DC=f2
    • during the remainder (=OFF or 0) part of this period, so from q*T->T, f2__DC=0
    • each subsequent DUTY part starts at the same point where it ended at the previous cycle, so as if f2 was 'froozen' during the OFF part (see code for more details, but basically this means that the t parameter needs to be constantly translated depending on which duty cycle we are in).
  • In the end I want to calculate f1*f2 in a simple way using ranges for both variables x and t so that e.g. plotting can easily be done.

I've tried implicit functions and procedures but keep getting stuck whenever I introduce a second variable.  Somehow, Maple does not seem to work straightforward with non-univariate stuff.  Such an examples can also not be found in the programming guide so I'm hoping that one of you knows how to tackle this.

Any help will be much appreciated!
 

restart;
with(plots):

f1 := (x, t) -> A * (1 + B * sin(a*x-b*t));

proc (x, t) options operator, arrow; A*(1+B*sin(a*x-b*t)) end proc

(1)

f2 := (x, t) -> C * (1 + E * sin(c*x-d*t));

proc (x, t) options operator, arrow; C*(1+E*sin(c*x-d*t)) end proc

(2)

A:=1: B:=0.5: a:=100: b:=1:
C:=1: E:=0.5: c:=10: d:=10:

densityplot(f1(x,t) * f2(x,t), x = 0..1, t = 0..10, style=patchnogrid);

 

#Duty cycle (DC) applied to f2
# ON state:      n*T <= t <(n+q)*T  : f2__DC(x,t)=f2(x,t-n*(1-q)*T)
# OFF state: (n+q)*T <= t < (n+1)*T : f2__DC(x,t)=0 (so all other cases)
# (n is a positive integer, zero included, and n=floor(t/T))

T:=1:
q:=0.3; #fraction of T where DC is 1=ON

#How to apply the above DC to f2(x,t) so that f2__DC is obtained and following command works:
densityplot(f1(x,t) * f2__DC(x,t), x = 0..1, t = 0..10, style=patchnogrid);

 


 

Download dutycycle_.mw

Please Wait...