Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inefficiency and inconsistency in calculus numerical conversion #1196

Closed
williamstein opened this issue Nov 18, 2007 · 4 comments
Closed

inefficiency and inconsistency in calculus numerical conversion #1196

williamstein opened this issue Nov 18, 2007 · 4 comments

Comments

@williamstein
Copy link
Contributor

> David Harvey did mention to
> me that getting a numerical approximation of sqrt(2) called maxima, so

That's not exactly true, since "Exiting Maxima..." is not printed out below:

sage: float(sqrt(2))
1.4142135623730951
sage: quit
Exiting SAGE (CPU time 0m0.01s, Wall time 0m5.91s).

What happens is that if one requests a numerical *float* approximation
to sqrt(2), then first a float approximation to 2 is computed, then
the math.sqrt method is called on it.  

Unfortunately, evidently right now if one requests a high-precision
numerical approximation Sage currently does
end up calling Maxima:


sage: RealField(100) ( sqrt(2) )
1.4142135623730950488016887242
sage: 
Exiting spawned Maxima process.

I consider this a mistake in implementation, which should be optimized. 

Notice that

sage: sqrt( RealField(100)(2) )
1.4142135623730950488016887242

does not call Maxima anywhere. 

I just investigated, and n(sqrt(2), 100) calls maxima only to simplify
sqrt(2) before even beginning to do any numerical approximation. 
This isn't consistent with how the other coercions (e.g., to float) work.   So I've posted
a patch that changes this behavior.  After applying this patch:

sage: RealField(100) ( sqrt(2) )
1.4142135623730950488016887242
sage: quit
(no "exiting maxima") 

NOTE: I've attached two patches. The first implements the change described above.
The second fixes some resulting doctest failures, and also optimizes computation
of sec, csc, and cot for mpfr elements.

Component: calculus

Issue created by migration from https://trac.sagemath.org/ticket/1196

@williamstein williamstein added this to the sage-2.9 milestone Nov 18, 2007
@williamstein williamstein self-assigned this Nov 18, 2007
@williamstein
Copy link
Contributor Author

Attachment: 7330.patch.gz

patch 1 of 2

@williamstein
Copy link
Contributor Author

patch 2 of 2

@williamstein
Copy link
Contributor Author

comment:1

Attachment: 7332.patch.gz

@williamstein williamstein modified the milestones: sage-2.9, sage-2.8.13 Nov 18, 2007
@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Nov 20, 2007

comment:3

Merged in 2.8.13.rc1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant