 Heaviside ( unit )  step function ' Maxima', version 1.0
peter.vlasschaert@gmail.com, 08/11/2018

load packages.

kill(all)$
load(lrats)$

rem : how to draw function with unit (delay) step function.

tutorial : Heaviside ( unit )  step function ' Maxima'
==========================================

definition : unit step function without shifting
======================================

unitstep(x):= if x<0 then 0  else 1.0000000001;

wxplot2d(unitstep(x),[x,-π,π]);

 pulse train 'blue' , activated with 'sinus' signal
=======================================

wxplot2d([unitstep(sin(t)),sin(t)],[t,-6*π,6*π]);

used :power supply from ac ((a)lternating (c)urrent)  'to' dc ((d)irect ((c)urrent) combination with some
electronic circuits.

same for 'square wave'.
====================

wxplot2d([unitstep(sin(t))-unitstep(sin(t-π)),sin(t)],[t,-6*π,6*π]);

unit step with delay of constant =2
=============================

p1:wxplot2d([unitstep(t-2)],[t,-3*π,3*π]);

definition :unit(d)step(t,c),  c=constante
=================================
-  (d) = delay variable , t=time 

unitdstep(x,c):= if x<c then 0  else 1.0000000001;

p2:wxplot2d([unitdstep(t,2)],[t,-3*π,3*π]);

▶;

p1,p2 :  gives the same result.

pulse between 2 and 4 (height = 2)
=============================

p3:wxplot2d([2*unitdstep(t,2)-2*unitdstep(t,4)],[t,-3*π,3*π]);

slope , become when t, '*' is before unitdstep function
=============================================

p3:wxplot2d([t*unitdstep(t,3)],[t,-3*π,3*π]);

signal : composition
=================

see : Ex: Write a Ramp Function Using the Unit Step Function
=>  youtube :https://www.youtube.com/watch?v=PLj1T5XHdIw

  →   piecewise function 
=====================

example : 1e)  t < 4            =>  0               =>   t 1 = 4 , y1 =0 , (start point:  slope  up)
                    2e) 4 ≤ t < 8      =>  3    (up)    =>  a ≤ t < b  => c  ,(slope ,m )
                    3e)  t ≥  8           => 3

up : + slope : m, equation line  .
-----------------------------------------------

interval between a,b :
=================

a: 4;
b: 8;

height :
=====

c:3;

slope
=====

m : c/(b-a);

rem : x => t

start point : (t1,y1)
===============

t1:4;
y1:0;

equation of line : up       => +  'm'
                                 down => -   'm'
========================

p4:(y-y1) = m*(t-t1);
p4a:ratsimp(p4);

p4b:rhs(p4);

  →   piecewise function ' how to do maxima '
======================================

 1e)  t < 4            => 0
 2e) 4 ≤ t < 8      =>y=(3*(t-4))/4
 3e)  t ≥  8          => 3

?  How to draw
-----------------------

f1(t):= if t <4 then 0 else if t ≤ 8 then (3*(t-4))/4 else 3.0000001;

wxplot2d([f1(t)],[t,0,10]);

 ?  unit delay step function  ' draw '
============================== 

p5:p4b*(unitdstep(t,4)-unitdstep(t,8))+3*unitdstep(t,8);
wxplot2d([p5],[t,0,10]);

f2(t):= p4b*(unitdstep(t,4)-unitdstep(t,8))+3*unitdstep(t,8);

wxplot2d([f2(t)],[t,0,10]);

function with parameters (a,b,c)   'see above'
===========================

f3(t,a,b,c):= p4b*(unitdstep(t,a)-unitdstep(t,b))+c*unitdstep(t,b);

p6:f3(t,4,8,3);

wxplot2d([p6],[t,0,10]);

rem : math , use
==============
command : ratcoef, lratsubst

p7:q1=p4b*('unitdstep(t,a1)-'unitdstep(t,b1))+c1*'unitdstep(t,b1);

p8:expand(p7);

p9    => coef :  'unitdstep(t,a1)                         .
p9a  => coef :  'unitdstep(t,b1) , subst => c1.

p9:ratcoef(rhs(p8),'unitdstep(t,a1));
p9a:lratsubst( [c1=c],ratcoef(rhs(p8),'unitdstep(t,b1)));

p10:q2=p9*'unitdstep(t,a1)+p9a*'unitdstep(t,b1);

p10a:lratsubst([a1=4,b1=8],rhs(p10));

p10b:wxplot2d([p10a],[t,0,10]);

use : control theory , ' Laplace Transformation', time domain to freq domain ,visaversa.           

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------