Ask Your Question

Mathark's profile - activity

2024-01-18 15:49:23 +0100 received badge  Notable Question (source)
2022-10-27 10:55:54 +0100 received badge  Popular Question (source)
2021-05-22 15:06:15 +0100 commented answer Numerical approximation error involving cosh and sinh

That is what I needed. Thanks!

2021-05-21 15:59:59 +0100 marked best answer Numerical approximation error involving cosh and sinh

Hi. I'm new to Sage and to computational mathematics in general. I have been trying to code something, but I am struggling to understand some numerical approximation errors. My problem seems to boil down to the following phenomenon:

sage: x = exp(12*pi*i*i)
sage: x.n()
0.000000000000000

Which is as expected, $x=e^{-12\pi }$ is "very close" to 0. However, I do not understand why Sage gives me

sage: (5+x).n()
4.00000000000000

If I give it more bits of precision, then it works:

sage: (5+x).n(200)
5.0000000000000000424115118301607754401746440550887456940681

But I can't understand why it is making such grotesque error. Sage knows $x$ is very small (it returned 0.000000000000000). So why did it approximate $5+x$ to 4?

What is also weird, is that if I repeat the same computation with 4+x or 6+x instead, then it works just fine:

sage: (6+x).n()
6.00000000000000

My apologies if this is something trivial in computational maths, but can someone clarify what is going on here?

In a situation like this, is there a way for me to know if I have given Sage enough bits of precision to get at least the first few digits correct?

(Remark: I wrote exp(12*pi*i*i) instead of exp(-12*pi) to make Sage use sinh and cosh.)

2021-05-21 15:59:59 +0100 received badge  Scholar (source)
2021-05-21 15:59:54 +0100 received badge  Supporter (source)
2021-05-21 15:59:49 +0100 commented answer Numerical approximation error involving cosh and sinh

Now, with this in mind, I think I could code some kind of precision handling into many parts of my code. But I wonder, d

2021-05-21 15:48:18 +0100 commented answer Numerical approximation error involving cosh and sinh

Thanks you so much!! This answer was incredibly helpful. So, it was not a bug!! Though, is there a way for me to know if

2021-05-20 18:58:02 +0100 commented question Numerical approximation error involving cosh and sinh

So this is a bug? I was trying to do some computations with modular forms, but was getting some weird errors when evalua

2021-05-20 17:04:57 +0100 received badge  Student (source)
2021-05-20 17:03:49 +0100 asked a question Numerical approximation error involving cosh and sinh

Numerical approximation - Newbie question Hi. I'm new to SAGE and to computational mathematics in general. I have been t