Why summation and integrate give different results? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!What is the difference between @staticmethod and @classmethod?What is the difference between Python's list methods append and extend?Python join: why is it string.join(list) instead of list.join(string)?Difference between __str__ and __repr__?Why does comparing strings using either '==' or 'is' sometimes produce a different result?What's the difference between eval, exec, and compile?Use of *args and **kwargsWhy is reading lines from stdin much slower in C++ than Python?UnicodeEncodeError: 'ascii' codec can't encode character u'xa0' in position 20: ordinal not in range(128)Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?
How long can a nation maintain a technological edge over the rest of the world?
Why aren't road bicycle wheels tiny?
Can gravitational waves pass through a black hole?
Does Prince Arnaud cause someone holding the Princess to lose?
Why does Java have support for time zone offsets with seconds precision?
Does a Draconic Bloodline sorcerer's doubled proficiency bonus for Charisma checks against dragons apply to all dragon types or only the chosen one?
All ASCII characters with a given bit count
Why isPrototypeOf() returns false?
Arriving in Atlanta after US Preclearance in Dublin. Will I go through TSA security in Atlanta to transfer to a connecting flight?
What's parked in Mil Moscow helicopter plant?
Was there ever a LEGO store in Miami International Airport?
Why did Israel vote against lifting the American embargo on Cuba?
Are these square matrices always diagonalisable?
/bin/ls sorts differently than just ls
Are there existing rules/lore for MTG planeswalkers?
Israeli soda type drink
"Working on a knee"
Bright yellow or light yellow?
Array Dynamic resize in heap
Raising a bilingual kid. When should we introduce the majority language?
What is ls Largest Number Formed by only moving two sticks in 508?
What is a 'Key' in computer science?
Why did Europeans not widely domesticate foxes?
Has a Nobel Peace laureate ever been accused of war crimes?
Why summation and integrate give different results?
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!What is the difference between @staticmethod and @classmethod?What is the difference between Python's list methods append and extend?Python join: why is it string.join(list) instead of list.join(string)?Difference between __str__ and __repr__?Why does comparing strings using either '==' or 'is' sometimes produce a different result?What's the difference between eval, exec, and compile?Use of *args and **kwargsWhy is reading lines from stdin much slower in C++ than Python?UnicodeEncodeError: 'ascii' codec can't encode character u'xa0' in position 20: ordinal not in range(128)Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I think I am misunderstanding something. I think that printed results of this code snippet must be equal, but they are not:
import sympy
x = sympy.Symbol('x')
summation = sympy.summation(sympy.exp(-x), (x, 0, sympy.oo))
print(summation) # 1/(-exp(-1) + 1)
integration = sympy.integrate(sympy.exp(-x), (x, 0, sympy.oo))
print(integration) # 1
Can you explain the difference between summation
and integrate
?
python sympy
add a comment |
I think I am misunderstanding something. I think that printed results of this code snippet must be equal, but they are not:
import sympy
x = sympy.Symbol('x')
summation = sympy.summation(sympy.exp(-x), (x, 0, sympy.oo))
print(summation) # 1/(-exp(-1) + 1)
integration = sympy.integrate(sympy.exp(-x), (x, 0, sympy.oo))
print(integration) # 1
Can you explain the difference between summation
and integrate
?
python sympy
add a comment |
I think I am misunderstanding something. I think that printed results of this code snippet must be equal, but they are not:
import sympy
x = sympy.Symbol('x')
summation = sympy.summation(sympy.exp(-x), (x, 0, sympy.oo))
print(summation) # 1/(-exp(-1) + 1)
integration = sympy.integrate(sympy.exp(-x), (x, 0, sympy.oo))
print(integration) # 1
Can you explain the difference between summation
and integrate
?
python sympy
I think I am misunderstanding something. I think that printed results of this code snippet must be equal, but they are not:
import sympy
x = sympy.Symbol('x')
summation = sympy.summation(sympy.exp(-x), (x, 0, sympy.oo))
print(summation) # 1/(-exp(-1) + 1)
integration = sympy.integrate(sympy.exp(-x), (x, 0, sympy.oo))
print(integration) # 1
Can you explain the difference between summation
and integrate
?
python sympy
python sympy
asked Mar 22 at 15:07
SanyashSanyash
2,96821229
2,96821229
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
SymPy's summation
function sums the expression with the integers in the given range replacing the variable:
summation(sympy.exp(-x), (x, 0, sympy.oo))
Is equivalent to
exp(0) + exp(-1) + exp(-2) + ...
Which is approximately equal to:
1 + 0.37 + 0.14 + ...
Integration is a different function, which can be interpreted as calculating the area bounded by the curve generated by the function and the x axis (shaded in orange here):
Oh, I forgot that summation goes over integers only... Thank you.
– Sanyash
Mar 22 at 15:27
add a comment |
Nothing wrong.
If you notice the summation is a sum of geometric sequence, you will find it to be different to integration.
Summation:
sum exp(-x)
= sum exp(-1)^x
= exp(-1)^0 / (1 - exp(-1))
= 1 / (1 - exp(-1))
Integration:
int exp(-x) dx
= - [ exp(-x) ]
= - [ exp(-infinity) - exp(0) ]
= - [ 0 - 1 ]
= 1
Sorry. StackOverflow do not do LaTeX.
Hmmm, I don't know what issum of geometric sequence
, can you explain this?
– Sanyash
Mar 22 at 15:13
added algebraic derivation
– adrtam
Mar 22 at 15:14
Still can't understand the part where you describe summation derivation... Whysum exp(-1)^x
turns toexp(-1)^0 / (1 - exp(-1))
?
– Sanyash
Mar 22 at 15:22
en.wikipedia.org/wiki/Geometric_series formula section, the paragraph starts with "As n goes to infinity"
– adrtam
Mar 22 at 15:27
Thank you very much for explanation. Hope you don't worry about accepting another answer, because it points for the root of the problem: I forgot that summation goes over integers only, that's why I thought the results must be equal.
– Sanyash
Mar 22 at 15:31
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302579%2fwhy-summation-and-integrate-give-different-results%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
SymPy's summation
function sums the expression with the integers in the given range replacing the variable:
summation(sympy.exp(-x), (x, 0, sympy.oo))
Is equivalent to
exp(0) + exp(-1) + exp(-2) + ...
Which is approximately equal to:
1 + 0.37 + 0.14 + ...
Integration is a different function, which can be interpreted as calculating the area bounded by the curve generated by the function and the x axis (shaded in orange here):
Oh, I forgot that summation goes over integers only... Thank you.
– Sanyash
Mar 22 at 15:27
add a comment |
SymPy's summation
function sums the expression with the integers in the given range replacing the variable:
summation(sympy.exp(-x), (x, 0, sympy.oo))
Is equivalent to
exp(0) + exp(-1) + exp(-2) + ...
Which is approximately equal to:
1 + 0.37 + 0.14 + ...
Integration is a different function, which can be interpreted as calculating the area bounded by the curve generated by the function and the x axis (shaded in orange here):
Oh, I forgot that summation goes over integers only... Thank you.
– Sanyash
Mar 22 at 15:27
add a comment |
SymPy's summation
function sums the expression with the integers in the given range replacing the variable:
summation(sympy.exp(-x), (x, 0, sympy.oo))
Is equivalent to
exp(0) + exp(-1) + exp(-2) + ...
Which is approximately equal to:
1 + 0.37 + 0.14 + ...
Integration is a different function, which can be interpreted as calculating the area bounded by the curve generated by the function and the x axis (shaded in orange here):
SymPy's summation
function sums the expression with the integers in the given range replacing the variable:
summation(sympy.exp(-x), (x, 0, sympy.oo))
Is equivalent to
exp(0) + exp(-1) + exp(-2) + ...
Which is approximately equal to:
1 + 0.37 + 0.14 + ...
Integration is a different function, which can be interpreted as calculating the area bounded by the curve generated by the function and the x axis (shaded in orange here):
edited Mar 22 at 15:27
answered Mar 22 at 15:24
ukemiukemi
3,2303728
3,2303728
Oh, I forgot that summation goes over integers only... Thank you.
– Sanyash
Mar 22 at 15:27
add a comment |
Oh, I forgot that summation goes over integers only... Thank you.
– Sanyash
Mar 22 at 15:27
Oh, I forgot that summation goes over integers only... Thank you.
– Sanyash
Mar 22 at 15:27
Oh, I forgot that summation goes over integers only... Thank you.
– Sanyash
Mar 22 at 15:27
add a comment |
Nothing wrong.
If you notice the summation is a sum of geometric sequence, you will find it to be different to integration.
Summation:
sum exp(-x)
= sum exp(-1)^x
= exp(-1)^0 / (1 - exp(-1))
= 1 / (1 - exp(-1))
Integration:
int exp(-x) dx
= - [ exp(-x) ]
= - [ exp(-infinity) - exp(0) ]
= - [ 0 - 1 ]
= 1
Sorry. StackOverflow do not do LaTeX.
Hmmm, I don't know what issum of geometric sequence
, can you explain this?
– Sanyash
Mar 22 at 15:13
added algebraic derivation
– adrtam
Mar 22 at 15:14
Still can't understand the part where you describe summation derivation... Whysum exp(-1)^x
turns toexp(-1)^0 / (1 - exp(-1))
?
– Sanyash
Mar 22 at 15:22
en.wikipedia.org/wiki/Geometric_series formula section, the paragraph starts with "As n goes to infinity"
– adrtam
Mar 22 at 15:27
Thank you very much for explanation. Hope you don't worry about accepting another answer, because it points for the root of the problem: I forgot that summation goes over integers only, that's why I thought the results must be equal.
– Sanyash
Mar 22 at 15:31
add a comment |
Nothing wrong.
If you notice the summation is a sum of geometric sequence, you will find it to be different to integration.
Summation:
sum exp(-x)
= sum exp(-1)^x
= exp(-1)^0 / (1 - exp(-1))
= 1 / (1 - exp(-1))
Integration:
int exp(-x) dx
= - [ exp(-x) ]
= - [ exp(-infinity) - exp(0) ]
= - [ 0 - 1 ]
= 1
Sorry. StackOverflow do not do LaTeX.
Hmmm, I don't know what issum of geometric sequence
, can you explain this?
– Sanyash
Mar 22 at 15:13
added algebraic derivation
– adrtam
Mar 22 at 15:14
Still can't understand the part where you describe summation derivation... Whysum exp(-1)^x
turns toexp(-1)^0 / (1 - exp(-1))
?
– Sanyash
Mar 22 at 15:22
en.wikipedia.org/wiki/Geometric_series formula section, the paragraph starts with "As n goes to infinity"
– adrtam
Mar 22 at 15:27
Thank you very much for explanation. Hope you don't worry about accepting another answer, because it points for the root of the problem: I forgot that summation goes over integers only, that's why I thought the results must be equal.
– Sanyash
Mar 22 at 15:31
add a comment |
Nothing wrong.
If you notice the summation is a sum of geometric sequence, you will find it to be different to integration.
Summation:
sum exp(-x)
= sum exp(-1)^x
= exp(-1)^0 / (1 - exp(-1))
= 1 / (1 - exp(-1))
Integration:
int exp(-x) dx
= - [ exp(-x) ]
= - [ exp(-infinity) - exp(0) ]
= - [ 0 - 1 ]
= 1
Sorry. StackOverflow do not do LaTeX.
Nothing wrong.
If you notice the summation is a sum of geometric sequence, you will find it to be different to integration.
Summation:
sum exp(-x)
= sum exp(-1)^x
= exp(-1)^0 / (1 - exp(-1))
= 1 / (1 - exp(-1))
Integration:
int exp(-x) dx
= - [ exp(-x) ]
= - [ exp(-infinity) - exp(0) ]
= - [ 0 - 1 ]
= 1
Sorry. StackOverflow do not do LaTeX.
edited Mar 22 at 15:13
answered Mar 22 at 15:11
adrtamadrtam
3,4601321
3,4601321
Hmmm, I don't know what issum of geometric sequence
, can you explain this?
– Sanyash
Mar 22 at 15:13
added algebraic derivation
– adrtam
Mar 22 at 15:14
Still can't understand the part where you describe summation derivation... Whysum exp(-1)^x
turns toexp(-1)^0 / (1 - exp(-1))
?
– Sanyash
Mar 22 at 15:22
en.wikipedia.org/wiki/Geometric_series formula section, the paragraph starts with "As n goes to infinity"
– adrtam
Mar 22 at 15:27
Thank you very much for explanation. Hope you don't worry about accepting another answer, because it points for the root of the problem: I forgot that summation goes over integers only, that's why I thought the results must be equal.
– Sanyash
Mar 22 at 15:31
add a comment |
Hmmm, I don't know what issum of geometric sequence
, can you explain this?
– Sanyash
Mar 22 at 15:13
added algebraic derivation
– adrtam
Mar 22 at 15:14
Still can't understand the part where you describe summation derivation... Whysum exp(-1)^x
turns toexp(-1)^0 / (1 - exp(-1))
?
– Sanyash
Mar 22 at 15:22
en.wikipedia.org/wiki/Geometric_series formula section, the paragraph starts with "As n goes to infinity"
– adrtam
Mar 22 at 15:27
Thank you very much for explanation. Hope you don't worry about accepting another answer, because it points for the root of the problem: I forgot that summation goes over integers only, that's why I thought the results must be equal.
– Sanyash
Mar 22 at 15:31
Hmmm, I don't know what is
sum of geometric sequence
, can you explain this?– Sanyash
Mar 22 at 15:13
Hmmm, I don't know what is
sum of geometric sequence
, can you explain this?– Sanyash
Mar 22 at 15:13
added algebraic derivation
– adrtam
Mar 22 at 15:14
added algebraic derivation
– adrtam
Mar 22 at 15:14
Still can't understand the part where you describe summation derivation... Why
sum exp(-1)^x
turns to exp(-1)^0 / (1 - exp(-1))
?– Sanyash
Mar 22 at 15:22
Still can't understand the part where you describe summation derivation... Why
sum exp(-1)^x
turns to exp(-1)^0 / (1 - exp(-1))
?– Sanyash
Mar 22 at 15:22
en.wikipedia.org/wiki/Geometric_series formula section, the paragraph starts with "As n goes to infinity"
– adrtam
Mar 22 at 15:27
en.wikipedia.org/wiki/Geometric_series formula section, the paragraph starts with "As n goes to infinity"
– adrtam
Mar 22 at 15:27
Thank you very much for explanation. Hope you don't worry about accepting another answer, because it points for the root of the problem: I forgot that summation goes over integers only, that's why I thought the results must be equal.
– Sanyash
Mar 22 at 15:31
Thank you very much for explanation. Hope you don't worry about accepting another answer, because it points for the root of the problem: I forgot that summation goes over integers only, that's why I thought the results must be equal.
– Sanyash
Mar 22 at 15:31
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302579%2fwhy-summation-and-integrate-give-different-results%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown