In general, it is best to refrain from making substantial changes to a post after others have responded to it, particularly if it obfuscates the meaning of the thread. In the current case, the changes that have been made to the original post render the discussion difficult for the reader to understand.
Those who read this discussion should note that they can view the history of edits made to a post by clicking the pencil icon located at the upper right corner of the post. It currently appears as follows for the original post:
The orange color of the pencil will gradually fade to gray during the course of the day, however the history will remain available.
Negative values aren’t a problem, but iterating is. Can you do a summation in mathematics saying “sum of n = -∞ to 1, [some formula involving n]”? (Sorry, I don’t think I can embed MathML in Discourse or I’d do the proper sigma notation.) It doesn’t make sense to iterate over a range like that.
So if you aren’t intending to iterate, what ARE you doing? All you’re posting is code that doesn’t work, and giving us no clue whatsoever as to what you’re actually trying to accomplish.
Okay, so you’re going to need to establish some equation-solving techniques, then turn those into an algorithm for finding the solutions. Once that’s settled, you’ll be able to write that algorithm in Python code, and have Python solve the problem for you.
Yes. Python should automatically solve the x value. If the for-loop I wrote can be processed, it would be fine. So there is no solution to my question?
Mathematically, I know the x range: x <=1 or x >=2. (x is in <=1 or >= 2 range; ideally Python should define exact x values.)
I’m sorry, to me that makes no sense whether I interpret it in terms of mathematics (domains are not “in” ranges, and “range of -infinity” means nothing) or in terms of Python.
I guess you are trying to do maths in Python code, in particular, you want to work out infinite sums using Python.
You can’t. End of story. An infinite loop would take an infinite amount of time to run.
Python is a programming language, not symbolic mathematics. You might try Sage or Sympy, but I strongly recommend you learn a little bit of Python first. Especially for Sympy.
The range function is a short-cut for generating objects which are
(approximately) the same as a list of integers:
range(10) is equivalent to [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
range(5, 10) is equivalent to [5, 6, 7, 8, 9]
You can’t build an infinite list in Python, if you converted every atom of matter in the universe into computer memory there wouldn’t be enough, and even if you could, it would take an infinite amount of time to iterate over it one item at a time.
If you want to evaluate some sort of infinite sum like “sum of 2 to the power of negative n for n from 1 to infinity” you either need symbolic maths software (try Sage, or Mathematica) or you need to find a closed form solution without the infinite sum that you can evaluate in Python.