How to plot several terms in a Fourier series

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 2K views
rmiller70015
Messages
110
Reaction score
1
I was given a function that is periodic about 2π and I need to plot it. I was wondering if there is a way to input a value and have mathematica generate a new graph with the number of iterations. The function is:

$$\sum_{n=1}^{N}\frac{sin(nx)}{n}$$ where n is an odd integer. I guess a better way to express the function is
$$\sum_{k=0}^{N}\frac{sin((2k+1)x)}{2k+1}$$

So far I've only used mathematica to plot simple functions and solve ODE's so I'm not quite sure how to approach this.
 
on Phys.org
I actually found a python source code that did what I needed, but thank you for your willingness to help.
 
Matlab in about 10 lines...

Code:
clear all;

x=linspace(0, 3*pi, 1000);
Z = 0;
for k = 1:3
    y = sin((2*k+1)*x)/(2*k+1);
   plot(x,y)
   hold on;
   Z = Z+y;
end
plot(x,Z);
hold off;
 
  • Like
Likes   Reactions: Jamison Lahman and rmiller70015