Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3985942
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:57:07+00:00 2026-05-20T05:57:07+00:00

Hey all, so I’m implementing the simple version of the discrete fourier transform in

  • 0

Hey all, so I’m implementing the simple version of the discrete fourier transform in python for a class, but something strange is happening to my output and I have no idea why. For example if my input is [a,b,c,d] the values are getting scrambled like [a’,d’,c’,b’] with the head of the list in the same place, but the other values reversed. This is my code:

def DFT(pts, carr):
  t = time.clock()
  F =[0]*pts
  for k in range(pts):
    c = 2j*k*math.pi/pts
    for n in range(pts):
      F[k] += complex(carr[n]) * cmath.exp(n*c)
  t = time.clock()-t
  print(str(pts) + " point DFT finished in " + str(t) + "s")
  return F

It’s super simple, but for some reason it’s flipping the array around all willy-nilly and I have no idea why. Does someone know what’s going on here? I’m certain the input is in the right order.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:57:07+00:00Added an answer on May 20, 2026 at 5:57 am

    I believe you’re missing a negative sign in the calculation of c (see this link).

    With your code:

    >>> DFT(4, [1, 2, 3, 4])
    4 point DFT finished in 0.0310370227732s
    [(10+0j), (-2.0000000000000004-1.9999999999999996j), (-2+9.797174393178826e-16j), (-1.9999999999999982+2.000000000000001j)]
    

    With the missing negative sign:

    >>> DFT(4, [1, 2, 3, 4])
    4 point DFT finished in 4.17962941128e-05s
    [(10+0j), (-2.0000000000000004+1.9999999999999996j), (-2-9.797174393178826e-16j), (-1.9999999999999982-2.000000000000001j)]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all. I have a fairly simple question. I am developing a rich iPad
Hey all i am trying to delete a key from the registery but i
Hey all- I have looked this up on here and Google but none of
hey all, throwing this one out there... hope it's a simple one. using the
Hey all, I have something of an interesting requirement for my project. I need
Hey all i am probably overthinking this but how can i check the textbox
Hey all, I don't know how to properly phrase this but when I run
Hey all, this is something I've wondered about for a while and never really
Hey all, I'm using this code to change my sIFR (version 3) H1 and
Hey all i've tried to add an other view it work properly but it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.