How do I plot this periodic step function with GNUplot?

Click For Summary
The discussion focuses on plotting a periodic step function using GNUplot, derived from a summation involving the step function u. The user notes that while plotting this function directly in GNUplot is challenging, it can be simplified by using iteration in a programming language like C to generate numerical results. The modulo operation, represented by the % sign in both C and GNUplot, is highlighted as a key element in the function's formulation. However, the complexity arises from needing to manage two independent variables, k and t, for the summation, which complicates the graphing process in 2D. Ultimately, the conversation concludes that while plotting the function is feasible, it requires careful handling of the summation and iteration.
randombill
Messages
81
Reaction score
0
\sum_{k=0}^{∞} (t-2k) [u(t-2k)-u(t-2(k+1))] = f(t)

where u is the step function and the graph of this is supposed to be 45 degree lines repeating to infinity. Sort of like

/ / / / / / / / / ad infinitum. I took this equation out of this lecture note on page 10. Fig 5.4 is supposedly the graph of it and example 5.27 is where they ask to solve it.
 
Last edited:
Physics news on Phys.org
What do you know about the modulo operation?
 
A lot actually. Thats the % operator in C/C++ right? Actually I figured out that plotting this function is next to impossible in GNUplot based on my searches online and this was actually plotted with Maple. There is a free Maple (clone) called Sage and runs in Oracle VirtualBox but I haven't tried it. What I did figure out is that it would be easier to use iteration (for loop, while, etc) in a modern programming language such as C and substitute that for the summation part of the problem. From there the problem falls together by simply plotting the numerical result from a dat file in GNUplot. I think that solves it.
 
I don't think it is difficult to plot this function in gnuplot once you use the modulo operation (which is also in gnuplot represented by the % sign) as it is nothing else than f(t)=t%2
 
Okay but what about the periodic part using the summation. That usually requires two independent variables but most 2d graphers can only do one. For the summation you would need k and t to be both variables dynamically changing. I can easily graph one line using 2t but I would still need to repeat it iteratively using summation over k. And shouldn't it be f(t)=k%2?
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
35K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 20 ·
Replies
20
Views
4K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K