Skip to content

Hardwire return values for domain limits of arcsin and arccos - #8

Merged
jepler merged 7 commits into
circuitpython:mainfrom
CedarGroveStudios:patch-1
Feb 15, 2022
Merged

Hardwire return values for domain limits of arcsin and arccos#8
jepler merged 7 commits into
circuitpython:mainfrom
CedarGroveStudios:patch-1

Conversation

@CedarGroveStudios

@CedarGroveStudios CedarGroveStudios commented Feb 14, 2022

Copy link
Copy Markdown
Contributor

fix for issue #7

@jepler jepler left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I have some comments and possibly changes to request

Comment thread jepler_udecimal/utrig.py Outdated
if x == 1:
r = pi / 2 # pi * 1/2 radians
elif x == -1:
r = pi * 3 / 2 # pi * 3/2 radians

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be -pi/2?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the unit circle method, 3/2pi rad is equal to -1/2pi rad

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still rather see it match math.asin:

>>> math.asin(-1)
-1.5707963267948966

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Hadn't considered compatibility with math.asin. Thanks for your patience.

Comment thread jepler_udecimal/utrig.py Outdated
Comment thread jepler_udecimal/utrig.py Outdated
3/2 pi rad is equal to -pi/2 rad
other changes were caused by file editing issues. sorry about that.
@jepler

jepler commented Feb 15, 2022

Copy link
Copy Markdown
Collaborator

I believe your change to the return-precision of acos was correct, and the test cases need to be updated to reflect the change:

Failed example:
    Decimal('.1').acos()
Expected:
    Decimal('1.47062890563333682288579851219')
Got:
    Decimal('1.470628905633336822885798512')

…sin`

Also update acos example to reflect actual result rounded to 28 digits. Verified other examples, as well.
```>>> math.asin(-1)
-1.5708
>>> Decimal.asin(-1)
Decimal('-1.570796326794896619231321692')```

also updated `acos` example; verified other examples, as well
@CedarGroveStudios

Copy link
Copy Markdown
Contributor Author

updated the acos example with the new value.

@jepler
jepler self-requested a review February 15, 2022 15:53

@jepler jepler left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for sticking through my requested changes! I cleaned up a few last things.

@jepler
jepler merged commit 251c846 into circuitpython:main Feb 15, 2022
@CedarGroveStudios
CedarGroveStudios deleted the patch-1 branch February 15, 2022 18:16
adafruit-adabot added a commit to adafruit/CircuitPython_Community_Bundle that referenced this pull request Feb 16, 2022
Updating https://github.com/jepler/Jepler_CircuitPython_udecimal to 1.0.5 from 1.0.4:
  > Merge pull request circuitpython/Jepler_CircuitPython_udecimal#10 from jepler/update-black-ci-etc
  > Merge pull request circuitpython/Jepler_CircuitPython_udecimal#8 from CedarGroveStudios/patch-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants