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 70123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:40:53+00:00 2026-05-10T19:40:53+00:00

Here is my sample code. It is meant to be an iterative procedure for

  • 0

Here is my sample code. It is meant to be an iterative procedure for gauss seidel (matrix solver). Essentially when the error is small enough it breaks out of the while loop.

i=1 while (i>0):     x_past = x_present      j=0     while(j<3):         value=0         k=0         while(k<3):             if(k!=j):                 if(i==1):                     if(k>j):                         value=value+0                     else:                         value=value+x_present[k]*eqn[j][k]                     else:                     value=value+x_present[k]*eqn[j][k]             else:                 value=value+eqn[j][k]             k=k+1         x_present[j:j+1]=[value]         j=j+1     print 'X_PAST'     print x_past     print 'X_PRESENT'     print x_present         if(error(x_past, x_present)<10**-2):         break;     i=i+1 

I’ve reduced the code so its more manageable. if you don’t understand what its doing its not really that important to solving this problem.

Here is the issue. Everytime

x_present[j:j+1]=[value] 

is run, x_past is made equal to x_present. I don’t know why this is the case as the only place i have set x_past equal to x_present is at the top of the loop. If I take away the

x_past=x_present 

sentence, x_past is never made equal to x_present. This leads me to think it is some combination of the two statements that is causing the issue.

This is a big problem cause if x_past = x_present the error = 0 every time and the loop breaks after the first iteration. The code does work, for example if I tell the code to run for 8 iterations and the break it gives me the answer its supposed to.

I’ve been trying to figure this out for the last 4 hours and am completely stumped. I haven’t been working with python long, so my trouble shooting skills syntax wise aren’t that great. Any help would be appreciated!!

  • 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. 2026-05-10T19:40:54+00:00Added an answer on May 10, 2026 at 7:40 pm

    Yes, I think the answers here show your problem. Just to try and clarify a little bit.

    You’re referencing a list, so when the list changes any reference to that list will reflect that change. To demonstrate:

    >>> x_present = [4,5,6] >>> >>> x_past = x_present >>> >>> x_past [4, 5, 6] >>> >>> x_present.append(7) >>> >>> x_past [4, 5, 6, 7] >>> 

    If you want a copy of the list you have to do do this, listcopy = mylist[:]. (or import copy;listcopy = copy.copy(mylist)

    >>> x_past = x_present[:] >>> x_past [4, 5, 6, 7] >>> >>> x_present.append(8) >>> >>> x_past [4, 5, 6, 7] 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 64k
  • Answers 64k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You're trying to do validation in a binder. That's not… May 11, 2026 at 10:45 am
  • added an answer Yes. Facebook supports desktop applications, but they must go through… May 11, 2026 at 10:45 am
  • added an answer It is not built-in to rails at this time, but… May 11, 2026 at 10:45 am

Related Questions

Here is my sample code. It is meant to be an iterative procedure for
Here is my sample code: from xml.dom.minidom import * def make_xml(): doc = Document()
This really has my stumped today. I'm sure its simple, but... Here is my
My objective here is really simple -- I'm trying to set an NSString to
My goal here is to create a very simple template language. At the moment,
Here is my code, which takes two version identifiers in the form 1, 5,
Here is my current question: I'm guessing that my problem (described below) is being
here is my directory structure. /user/a /user/b /user/b inside folder a,b,c there is a
Here is my question, Would it be possible, knowing that classic asp support server-side
Here is my function ( updated ): Public Shared Function shortenUrl(ByVal URL As String)

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.