Python Forum
Gmpy2 Newbie Working on Precision
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Gmpy2 Newbie Working on Precision
#1
I am trying to calculate minute angles, and would like precision of at least 15 digits:

But I fail to understand how Python is rounding.

As I vary the value of asin by factors of 10 (from .001 to .00001), the output adds these zeros between the leading numeral 1 and the next numeral 1 (and some sixes after). See the image below.

And this is happening whether I use the gimpy2 or math modules:

Does the Sin-1 actually do this on radians?

Degrees acts similarly: When the input is very small and changes by a factor of ten (eg., .001 - .00001), the output of asin only changes by a factor of ten — the decimal point just moves one place while leaving the significant figures virtually unchanged.

Confused

   

Thank you!!

A version of the test code being used is shown below:

import gmpy2
import math
from gmpy2 import *
from gmpy2 import get_context as ctx

ctx().precision = 100

# L = mpfr('1000.0')
F = 0.00001
N = 10.0
B = 0.5

C = gmpy2.div(F, N)
c = F / N
D = 2 * C
d = 2 * c

E = B * gmpy2.asin(D)
e = B * math.asin(d)

g = .000002
e2 = B * math.asin(g)
# F = gmpy2.mul(B, E)
# sin(2 * theta) = 2 * sin(theta)cos(theta)

# print("L: ", L, type(L))
print("F: ", F, type(F))
print("N: ", N, type(N))

print("B: ", B, type(B))
print("C: ", C, type(C))
print("c: ", c, type(c))
print("D: ", D, type(D))
print("d: ", d, type(d))

print("E: ", E, type(E))
print("e: ", e, type(e))

print("e2: ", e2, type(e2))

print(ctx())
Reply


Messages In This Thread
Gmpy2 Newbie Working on Precision - by charlesrkiss - Jan-21-2024, 11:54 PM
RE: Gmpy2 Newbie Working on Precision - by casevh - Jan-23-2024, 06:51 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Precision with Decimal Type charlesrkiss 9 820 Jan-18-2024, 06:30 PM
Last Post: charlesrkiss
  Precision conversion garynewport 2 983 Oct-19-2022, 10:47 AM
Last Post: garynewport
Photo Filtering data and precision during calculations Scientifix 0 1,804 Mar-30-2021, 01:00 PM
Last Post: Scientifix
  High-Precision Board Voltage Reading from Python into PD Liam484 1 2,111 Mar-29-2021, 02:57 PM
Last Post: Marbelous
  Decimal (Global precision setting) Valentina 3 3,685 Aug-23-2019, 11:53 AM
Last Post: Valentina
  python decimal scale precision massimo_m 5 5,505 Aug-22-2019, 11:47 AM
Last Post: perfringo
  Trouble with decimal precision Cassie 4 3,181 Feb-14-2019, 08:23 PM
Last Post: Cassie
  precision error chris64 1 2,265 Nov-29-2017, 09:40 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020