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

n() returns symbolic expression #9913

Closed
zimmermann6 opened this issue Sep 16, 2010 · 13 comments
Closed

n() returns symbolic expression #9913

zimmermann6 opened this issue Sep 16, 2010 · 13 comments

Comments

@zimmermann6
Copy link

from sage-support:
http://groups.google.com/group/sage-support/browse_thread/thread/b36c90f1490eac19#

sage: a=(sqrt(4*(sqrt(3) - 5)*(sqrt(3) + 5) + 48) + 4*sqrt(3))/ (sqrt(3) + 5) 
sage: a.imag().n()
0.939469338708203*sin(0.500000000000000*pi)

CC: @sagetrac-cwitty

Component: symbolics

Author: Burcin Erocal

Reviewer: Paul Zimmermann

Merged: sage-4.6.1.alpha0

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

@jasongrout
Copy link
Member

comment:1

Even simpler:

sage: n(arctan2(0,-log(2)))
pi

@zimmermann6
Copy link
Author

comment:2

Note also the strange tty output (look in the 2nd argument of arctan2):

sage: a=(sqrt(4*(sqrt(3) - 5)*(sqrt(3) + 5) + 48) + 4*sqrt(3))/ (sqrt(3) + 5)
sage: a.imag()
sin(1/2*arctan2(0, -88* + 48))*sqrt(abs(4*(sqrt(3) - 5)*(sqrt(3) + 5) + 48))/(sqrt(3) + 5)

Should I open a separate ticket for that?
Paul

@burcin
Copy link

burcin commented Sep 18, 2010

comment:3

I'm changing the component to symbolics, since this is probably a bug in pynac.

Regarding the problem with the output Carl mentions in comment:2: This is also present in GiNaC, but the printing is better:

ginsh - GiNaC Interactive Shell (ginac V1.5.7)
  __,  _______  Copyright (C) 1999-2010 Johannes Gutenberg University Mainz,
 (__) *       | Germany.  This is free software with ABSOLUTELY NO WARRANTY.
  ._) i N a C | You are welcome to redistribute it under certain conditions.
<-------------' For details type `warranty;'.

Type ?? for a list of help topics.
> a=(sqrt(4*(sqrt(3) - 5)*(sqrt(3) + 5) + 48) + 4*sqrt(3))/ (sqrt(3) + 5);
(sqrt(48+4*(5+sqrt(3))*(-5+sqrt(3)))+4*sqrt(3))*(5+sqrt(3))^(-1)
> imag_part(a);
(5+sqrt(3))^(-1)*sqrt(abs(48+4*(5+sqrt(3))*(-5+sqrt(3))))*sin(1/2*atan2(0,48+4*(-22)))

Note the term 4*(-22) at the end of the last line.

We should open a new ticket for this and report it on the GiNaC list. I'm not sure if this has anything to do with this ticket ATM. Numeric evaluation seems to work fine in GiNaC:

> evalf(imag_part(a));
0.9394693387082032295

@zimmermann6
Copy link
Author

comment:4

Burcin,

We should open a new ticket for this and report it on the GiNaC list.

I've reported a new ticket (#9947). I let you report it on the GiNaC list.

Paul

@burcin
Copy link

burcin commented Sep 24, 2010

Changed keywords from none to pynac

@burcin
Copy link

burcin commented Sep 24, 2010

comment:5

Replying to @zimmermann6:

Burcin,

We should open a new ticket for this and report it on the GiNaC list.

I've reported a new ticket (#9947). I let you report it on the GiNaC list.

This issue was fixed upstream by Richard Kreckel.

While the fix makes the original example on this ticket work, Jason's example from comment:1 or the one reported by Tian Wei on sage-support (below) still don't work.

sage: b = sqrt(-log(2))
sage: print b.imag().n()
0.832554611157698*sin(0.500000000000000*pi)

@burcin
Copy link

burcin commented Oct 10, 2010

Attachment: trac_9913-arctan2_evalf.patch.gz

@burcin
Copy link

burcin commented Oct 10, 2010

comment:6

I uploaded a patch to fix this. The problem wasn't in pynac after all, it was the numeric approximation function for arctan2().

@burcin
Copy link

burcin commented Oct 10, 2010

Changed keywords from pynac to none

@zimmermann6
Copy link
Author

comment:7

positive review, good work Burcin!

Paul

@zimmermann6
Copy link
Author

Author: Burcin Erocal

@zimmermann6
Copy link
Author

Reviewer: Paul Zimmermann

@jdemeyer
Copy link

jdemeyer commented Nov 1, 2010

Merged: sage-4.6.1.alpha0

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

5 participants