cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

## Periodic Functions, How define them?  3-Visitor

## Periodic Functions, How define them?

I want something like this:

f(t) = 1 if 2n.T < t <= (2n+1).T T is some constant

f(t) = 0 otherwise

but how can I tell to Mathcad 14 that n belongs to Z, the positive and negative integers ???

MC lets me definde a variable in finite intervals, n:=1.. 10, ok

It would be desirable something like n E Z

can you give me a real example to realize what tools of Mathcad I must use? 1 ACCEPTED SOLUTION

Accepted Solutions  1-Newbie
(To:jcoolman)

With the mod-function you are running into problems with neagtive values. The Mathcad modulo mod(x,m) unfortunately gives the result in the interval ]-m; m[ with the same sign as x. So mod (-13, 5) yields -3 and not +2, as we need here. You can use "mod(mod(t,T) + T, T)" as a workaround and stay in [0; m[.

For more complicated functions I would in the first step define an auxiliary function piecewise in one period, e.g. 0 to 2T in your case.

There are a lot of methods which comes to mind, e.g.

- using if-statements (nested, for more complex functions)

- using Mathcads programming facilities (looks best, in my opinion)

- use of the Heaviside function

- using boolean expressions

As a second step I would make this auxiliary function periodic by

- using the floor function, or by

- using a recursive definition

Of course you could combine the two steps in one function.

See the newly attached worksheet - hope it helps.

Regard

WR

7 REPLIES 7  23-Emerald I
(To:jcoolman)

starting place  3-Visitor
(To:Fred_Kohlhepp)

Nice!

But it's not fully periodic, it fails at the origin.

Anyway, I turn this into a little more complicated issue, what if one wants:

f(t) = t.t if 2n.T < t <= (2n+1).T T is some constant

f(t) = T.(2T-t) if (2n+1)T < t <= (2n+2).T

how define n belongs to Z, infinite set of negative and positive integers.  23-Emerald I
(To:jcoolman)  1-Newbie
(To:jcoolman)

Added a program to fred's example
(nice Fred, would never have thought of that)

You can modify the funtion to get other shapes as well.  1-Newbie
(To:jcoolman)

With the mod-function you are running into problems with neagtive values. The Mathcad modulo mod(x,m) unfortunately gives the result in the interval ]-m; m[ with the same sign as x. So mod (-13, 5) yields -3 and not +2, as we need here. You can use "mod(mod(t,T) + T, T)" as a workaround and stay in [0; m[.

For more complicated functions I would in the first step define an auxiliary function piecewise in one period, e.g. 0 to 2T in your case.

There are a lot of methods which comes to mind, e.g.

- using if-statements (nested, for more complex functions)

- using Mathcads programming facilities (looks best, in my opinion)

- use of the Heaviside function

- using boolean expressions

As a second step I would make this auxiliary function periodic by

- using the floor function, or by

- using a recursive definition

Of course you could combine the two steps in one function.

See the newly attached worksheet - hope it helps.

Regard

WR  1-Newbie
(To:rag)

Nice work! Seems to be a somewhat comprehensive compilation.

Wonder if someone could come up with other elegant ways of graphing piecewise functions and making them periodic.

Grenn  3-Visitor
(To:jcoolman)

Thanks winfrod for his brilliant class. 