Skip to content

Inaccurate trignometric functions for "very" large/small inputs #126

@SwayamInSync

Description

@SwayamInSync
print(np.sin(1e100))
print(np.sin(npq.QuadPrecision("1e100")))
print(np.sin(npq.QuadPrecision("1e100", backend="longdouble")))

# output
-0.3806377310050287
0.679816461925869553732614638474571
-0.380637731005028678854529289310449

This is kind of expected, since using taylor expansion for large arguments can cause higher ULP.

A possible workaround in numpy_quaddtype is we can patch the trignometric functions to use any argument reduction strategies like Payne Hanek

@ngoldbaum what is your opinion here? We can also go in the current trivial way and mention in documentation about the working ranges but this won't be similar to NumPy's default behaviour as it seems to apply the reductions before trig functions.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions