Re: [sage-support] Re: Bug:Different results when using preparse

2015-03-13 Thread M M
I tried on a different machine with Sage Version 6.5, Release Date: 
2015-02-17   and I get the same behaviour described in the original post. 
Where parsing a string and evaluating returns different results than using 
the resulted sage expression.

On Thursday, 12 March 2015 17:00:45 UTC-4, Nils Bruin wrote:

 On Thursday, March 12, 2015 at 1:00:28 PM UTC-7, M M wrote:

 Thanks so much for all the efforts for making sage output consistent 
 results for the numerical approximation. However, the main problem I had 
 was the fact that Sage returns different answers when I preparse the string 
 of the same sage expression as in the examples of the original post.

 I was not able to replicate that behaviour on a recent build. 


-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] Re: Bug:Different results when using preparse

2015-03-12 Thread M M
Thanks so much for all the efforts for making sage output consistent 
results for the numerical approximation. However, the main problem I had 
was the fact that Sage returns different answers when I preparse the string 
of the same sage expression as in the examples of the original post.

On Wednesday, 11 March 2015 17:18:12 UTC-4, William wrote:

 On Wed, Mar 11, 2015 at 2:07 PM, Dima Pasechnik dim...@gmail.com 
 javascript: wrote: 
  
  
  On Wednesday, 11 March 2015 16:44:32 UTC, William wrote: 
  
  On Wed, Mar 11, 2015 at 9:35 AM, Dima Pasechnik dim...@gmail.com 
 wrote: 
   On 2015-03-11, Nils Bruin nbr...@sfu.ca wrote: 
   On Wednesday, March 11, 2015 at 2:46:25 AM UTC-7, Dima Pasechnik 
 wrote: 
   
   I tried this integral directly in Maxima, and taking bfloat of it 
   outputs nonsense. 
   
   
   I have noticed before that bfloats aren't infectious enough: 
 operations 
   on 
   bfloats can easily result in a normal double. I think there are 
 ways 
   to 
   convince maxima to use bfloats more pervasively. Perhaps a global 
   precision 
   setting somewhere? 
   
   
   I wish there was a more accessible full implementation of Risch 
   algorithm... 
   
   
   This is a rational function, so a first calculus course would 
 already 
   teach 
   you the relevant part of the Risch algorithm. It's a little more 
 tricky 
   to 
   
   Risch, as implemented in Axiom, does not do factorisation (i.e. no 
   partial fractions). 
   In this example at least it produces much nicer looking 
 antiderivative, 
   no huge integers. 
   http://axiom-wiki.newsynthesis.org/ExampleIntegration 
   
   Dima 
  
  For what it's worth, here's how to mostly do that Axiom session, but 
  in a SageMathCloud worksheet... 
  
  
  
 https://cloud.sagemath.com/projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/files/support/2015-03-11-093745-axiom-integral.sagews
  
  
  
  here is a better version (all the stuff works): 
  
 https://cloud.sagemath.com/projects/bb6fd6ca-6304-4dda-be31-bd2dd5eb3d98/files/support/2015-03-11-093745-axiom-integral.sagews
  
  

 Thanks!  I replaced mine by yours. 

 William 

  Dima 
  
  
  
  William 
  
   
   get an ostensibly real-valued function as an antiderivative. Anyway, 
   sympy 
   produces a reasonable-looking antiderivative. 
   
   Interestingly, we have: 
   
   sage: I=integral(x/(x^3-x+1), x, 1, 2, algorithm='sympy') 
   sage: RIF(I) 
   TypeError: unable to simplify to a real interval approximation 
   
   The offending subexpression seems to be: 
   
   sage: A=(299838966359964800*69^(5/6)*2^(2/3) - 
   1151508116605*69^(2/3)*2^(1/3)*(25*sqrt(69) + 207)^(1/3) - 
   99785894223312000*sqrt(69)*(25*sqrt(69) + 207)^(2/3) + 
   2271318237097115625*69^(1/3)*2^(2/3) - 
   99785894223312000*69^(1/6)*2^(1/3)*(25*sqrt(69) + 207)^(1/3) - 
   497728835949744*9522^(1/3)*(25*sqrt(69) + 207)^(1/3) - 
   828883890137982336*(25*sqrt(69) + 207)^(2/3) + 
   219331275901257879*276^(1/3))^(QQ(-1)) 
   sage: RIF(A) 
   TypeError: unable to simplify to a real interval approximation 
   
   Note the *rational* exponent -1. If that's an integer there's no 
   problem. 
   Using RealIntervalField(200) has the same problem. Using 
 RealField(...) 
   seems to work fine. 
   
   
   -- 
   You received this message because you are subscribed to the Google 
   Groups sage-support group. 
   To unsubscribe from this group and stop receiving emails from it, 
 send 
   an email to sage-support...@googlegroups.com. 
   To post to this group, send email to sage-s...@googlegroups.com. 
   Visit this group at http://groups.google.com/group/sage-support. 
   For more options, visit https://groups.google.com/d/optout. 
  
  
  
  -- 
  William (http://wstein.org) 
  
  -- 
  You received this message because you are subscribed to the Google 
 Groups 
  sage-support group. 
  To unsubscribe from this group and stop receiving emails from it, send 
 an 
  email to sage-support...@googlegroups.com javascript:. 
  To post to this group, send email to sage-s...@googlegroups.com 
 javascript:. 
  Visit this group at http://groups.google.com/group/sage-support. 
  For more options, visit https://groups.google.com/d/optout. 



 -- 
 William (http://wstein.org) 


-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Bug:Different results when using preparse

2015-03-10 Thread M M
I get different results from Sage when I try to get a numerical 
approximation for an expression and if I use evaluate a preparse of the 
string. I get different results on different versions of sage as well. Here 
are samples:

--

| Sage Version 5.3, Release Date: 2012-09-08 |

| Type notebook() for the browser-based notebook interface.|

| Type help() for help.|

--

sage: eval(preparse(numerical_approx(integral(x/(x^3-x+1), x, 1, 2

0.132008722884722

sage: numerical_approx(integral(x/(x^3-x+1), x, 1, 2))

0.132008722884722

sage: A = integral(x/(x^3-x+1), x, 1, 2)

sage: A_str = str(A)

sage: eval(preparse(numerical_approx(+A_str +)))

-0.393296585552547

sage: 


┌┐
│ Sage Version 6.5, Release Date: 2015-02-17 │
│ Type notebook() for the browser-based notebook interface.│
│ Type help() for help.│
└┘
sage: eval(preparse(numerical_approx(integral(x/(x^3-x+1), x, 1, 2
1.45943044687563
sage: numerical_approx(integral(x/(x^3-x+1), x, 1, 2))
1.45943044687563
sage: A = integral(x/(x^3-x+1), x, 1, 2)
sage:
sage: A_str = str(A)
sage:
sage: eval(preparse(numerical_approx(+A_str +)))
0.159046901967485
sage:

┌┐
│ Sage Version 6.2, Release Date: 2014-05-06 │
│ Type notebook() for the browser-based notebook interface.│
│ Type help() for help.│
└┘
sage: eval(preparse(numerical_approx(integral(x/(x^3-x+1), x, 1, 2
1.64714767119638
sage: numerical_approx(integral(x/(x^3-x+1), x, 1, 2))
1.64714767119638
sage: A = integral(x/(x^3-x+1), x, 1, 2)
sage: A_str = str(A)
sage: eval(preparse(numerical_approx(+A_str +)))
0.162416510011260
sage:


On the Notebook on the cloud it gives me the following error although the 
version is the same as one of the versions I tried locally
version()
'Sage Version 6.5, Release Date: 2015-02-17'

numerical_approx(integral(x/(x^3-x+1), x, 1, 2))
Error in lines 1-1 Traceback (most recent call last): File 
/projects/f700a2f3-7f30-4b47-9f18-e0309eb8c48c/.sagemathcloud/sage_server.py, 
line 875, in execute exec compile(block+'\n', '', 'single') in namespace, 
locals File , line 1, in module File string, line 1, in module 
File 
/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/misc/functional.py,
 
line 1298, in numerical_approx return x._numerical_approx(prec, 
algorithm=algorithm) File sage/symbolic/expression.pyx, line 4861, in 
sage.symbolic.expression.Expression._numerical_approx 
(build/cythonized/sage/symbolic/expression.cpp:27184) x = 
self._convert(kwds) File sage/symbolic/expression.pyx, line 1034, in 
sage.symbolic.expression.Expression._convert 
(build/cythonized/sage/symbolic/expression.cpp:7790) cdef GEx res = 
self._gobj.evalf(0, kwds) ValueError: power::eval(): division by zero


-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Strange behaviour in a simple function

2011-09-29 Thread m m
Hi
I have written very simple function, which code I paste below. The
thing is that it produces completely unexpected results. I paste them
below. Please let me know if this is a bug or I just do something
completely wrong. I change in tests only the modulus M.

def MLCG_S(B,M,N,x0):
x = x0
L = []
for i in range(1,N):
x = Mod(B*x, M) #MLCG(B,M,x)
print x==B
print (B-M)
print (x-M)
print M-B
print M-x
return L;
2^31-1
Invocation: LCG_16807 = MLCG_S(16807,2^31-1,2,1);
Result:
True
-2147466840
16807
2147466840
2147466840
___2^20-1
Invocation:LCG_16807 = MLCG_S(16807,2^20-1,2,1);
Result:
True
-1031768
16807
1031768
1031768
___2^10-1
Invocation:LCG_16807 = MLCG_S(16807,2^10-1,2,1);
Result:
True
15784
439
-15784
584

Above, not only the first two differences are different, but also the
last two differences are different!

Cheers

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org