Group Abstract Group Abstract

Message Boards Message Boards

0
|
15.6K Views
|
8 Replies
|
5 Total Likes
View groups...
Share
Share this post:

[?] Get Fourier series coefficients with for loop?

Posted 9 years ago

Hello everyone, I'd like to get the coefficients of the Fourier series with a for loop. I tried to do it in the following way:

For[i = -10, i < 11, i++, FourierCoefficient[Sin[t], t, i]]

but it does not work. Can you help me please?

Thank you very much.

POSTED BY: Gennaro Arguzzi
8 Replies
POSTED BY: Michael Rogers
POSTED BY: Neil Singer

Fourier series coefficients with for loop

POSTED BY: Neil Singer

Build in functions work faster than program code.

POSTED BY: Ivan Siahlo

Sorry, I don't know the reason. I was alerting you to Stephen Wolfram's statement since you were using a For command to solve your problem.

Regards

POSTED BY: Ed Forrester

Hi @Ed Forrester. Do you know why for command is bad?

POSTED BY: Gennaro Arguzzi

Gennaro, a side note. Stephen Wolfram mentions in his book "An Elementary Introduction To The Wolfram Language" on page 237 that the For command is almost always a bad idea, and can almost always be replaced by much cleaner code using constructs such as Table.

POSTED BY: Ed Forrester

Gennaro, try this: Table[FourierCoefficient[Sin[t], t, i], {i, -10, 10}] Regards,

POSTED BY: Ed Forrester
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard