2020-10-04 00:29:54 -0600 | received badge | ● Notable Question (source) |

2020-10-02 03:58:39 -0600 | received badge | ● Popular Question (source) |

2017-12-06 15:42:13 -0600 | received badge | ● Nice Question (source) |

2017-11-16 04:46:53 -0600 | commented question | Is it normal, that we need to redeclare a variable inside a function? Oh my, I'm so ashamed, you are right! Thanks a lot! |

2017-11-16 03:54:37 -0600 | asked a question | Is it normal, that we need to redeclare a variable inside a function? I defined this function The output if I evaluate it in 33 is , which is not correct, because the second integral, when i = 2, should also be 1. Now I realised that if I added the line b= (y*(y+1))/2 inside the for-loop, everything worked fine, indeed with the function The output is Why do we need to redeclare the variable b inside the for-loop? With a program like Matlab, this is not necessary, is this a special feature of Sage, should I always redeclare variables when opening for,while,if-statements? |

2017-11-15 07:10:21 -0600 | commented answer | Problem evaluating a very tiny integral Thank you for your very well written answer! |

2017-11-15 07:10:05 -0600 | commented answer | Problem evaluating a very tiny integral Thank you for your answer, I really appreciate it! I knew the integral I posted above, was a very tiny one, it is actually a simpler version of the one I need to evaluate, because I tried to simplify the problem, in order to make it readable. I like both answers, but I accepted the other one, because it allows me to solve my problem using the converse error function, which I found being preciser than the error function itself. I would also like to thank mforets for his/her (?) hints. |

2017-11-15 07:07:28 -0600 | received badge | ● Scholar (source) |

2017-11-15 07:07:26 -0600 | received badge | ● Supporter (source) |

2017-11-14 09:31:55 -0600 | commented question | Problem evaluating a very tiny integral @mforets I don't know what you mean. If you tell Sage to compute the difference between erf(256.5) and erf(255.5), with the code print erf(256.5)-erf(255.5), it tells you that it is 0. Is there a way to make it more precise? |

2017-11-14 01:42:58 -0600 | received badge | ● Student (source) |

2017-11-14 01:40:26 -0600 | received badge | ● Editor (source) |

2017-11-13 22:42:22 -0600 | asked a question | Problem evaluating a very tiny integral Hi everyone, I'm pretty new with sage. I was forced to change from MATLAB to Sage, because I was told Sage does approximate very tiny numbers better as it can work with sqrt(2) as sqrt(2) and not as the rational number approximating it. Approximations are very important for my problem. I need to evaluate this integral $$\sum_{c=1}^{d}\int_{\min(256c-0.5,\frac{y(y+1)}{2})}^{\min(256c+0.5,\frac{y(y+1)}{2})}\frac{1}{\sqrt{2\pi}}e^{-\frac{x^2}{2}}\, dx$$ Suppose d = 1, then this is simply the integral $$ \int_{255.5}^{256.5}\frac{1}{\sqrt{2\pi}}e^{-\frac{x^2}{2}}\, dx$$ To evaluate this integral I wrote the following code
because the integral above is the same as the difference of the distribution function of a standard distributed gaussian random variable between the boundaries of the integral. However, and you can check yourselves if you don't believe it, the result I get with sage is 0. I guess that this is due to some approximation, which sage does. Indeed the exact value of the integral is pretty close (and with pretty I mean a lot) to 0. My problem is that I need to be able to have the exact value, because the sum of integrals I'm working with and my whole work behind this integral requires me to be very careful with those little tiny numbers. I tried to use the function
to deal with this problem, but something funny and apparently inexplicable happened when I was trying to use it. To be precise I defined this code: And if I let it run, the result I get is which I assume is correct, and at least it tells me that Sage is able to read my code and output a result. If I call the function VarianceOfvy(2), the result I get is 3/65536*sqrt(11133895), which is also correct. Now, if I'm changing the command with and try to let the whole program run again, Sage is not able anymore to output a result. I'm really lost and I don't know what to do. Could someone advise me and give me some hints on how to evaluate those tiny integrals, in such a way that I don't loose any approximation? |

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.