Using piece-wise defined functions in systems of DE's 

 

 

If you choose to do Lab 2.4, you will need to work with a system of first-order differential equations that involves a piecewise defined function.  To create a piecewise defined function in Maple, use the following syntax. 

 

> Typesetting:-mrow(Typesetting:-mi(
 

> Typesetting:-mrow(Typesetting:-mi(
 

proc (y) options operator, arrow; piecewise(`<=`(0, y), y, `<`(y, 0), 0) end proc (1)
 

> Typesetting:-mrow(Typesetting:-mi(
 

Plot_2d
 

 

The following code defines the system of first-order DE's that corresponds to the second-order DE in Part 3 of Lab 2.4.  Here, I have used k_1=12.5 and k_2=4.7, but you can modify these values if you choose. 

 

> Typesetting:-mrow(Typesetting:-mi(
 

[diff(y(t), t) = v(t), diff(v(t), t) = `+`(10, `-`(`*`(12.5, `*`(y(t)))), `-`(`*`(4.7, `*`(piecewise(`<=`(0, y(t)), y(t), `<`(y(t), 0), 0)))))] (2)
 

> Typesetting:-mrow(Typesetting:-mi(
 

Plot_2d
 

>