[sage-support] Sage Crash Report

2019-03-11 Thread Jacques Avigdor
Thanks
Jacques

-- 
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 https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.
***

IPython post-mortem report

{'commit_hash': u'b467d487e',
 'commit_source': 'installation',
 'default_encoding': 'UTF-8',
 'ipython_path': '/usr/lib/python2.7/dist-packages/IPython',
 'ipython_version': '5.5.0',
 'os_name': 'posix',
 'platform': 'Linux-4.18.0-16-generic-x86_64-with-Ubuntu-18.04-bionic',
 'sys_executable': '/usr/bin/python',
 'sys_platform': 'linux2',
 'sys_version': '2.7.15rc1 (default, Nov 12 2018, 14:31:15) \n[GCC 7.3.0]'}

***



***

Crash traceback:

---
---
ImportError   Python 2.7.15rc1: /usr/bin/python
   Mon Mar 11 16:56:11 2019
A problem occurred executing Python code.  Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
/usr/share/sagemath/bin/sage-ipython in ()
  1 #!/usr/bin/env python
  2 # -*- coding: utf-8 -*-
  3 """
  4 Sage IPython startup script.
  5 """
  6 
  7 from sage.repl.interpreter import SageTerminalApp
  8 
  9 app = SageTerminalApp.instance()
---> 10 app.initialize()
global app.initialize = >
 11 app.start()

 in initialize(self=, argv=None)

/usr/lib/python2.7/dist-packages/traitlets/config/application.pyc in 
catch_config_error(method=, 
app=, *args=(None,), **kwargs={})
 72 TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR = False
 73 else:
 74 raise ValueError("Unsupported value for environment variable: 
'TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR' is set to '%s' which is none of 
 {'0', '1', 'false', 'true', ''}."% _envvar )
 75 
 76 
 77 @decorator
 78 def catch_config_error(method, app, *args, **kwargs):
 79 """Method decorator for catching invalid config 
(Trait/ArgumentErrors) during init.
 80 
 81 On a TraitError (generally caused by bad config), this will print 
the trait's
 82 message, and exit the app.
 83 
 84 For use on init methods, to prevent invoking excepthook on invalid 
input.
 85 """
 86 try:
---> 87 return method(app, *args, **kwargs)
method = 
app = 
args = (None,)
kwargs = {}
 88 except (TraitError, ArgumentError) as e:
 89 app.print_help()
 90 app.log.fatal("Bad config encountered during initialization:")
 91 app.log.fatal(str(e))
 92 app.log.debug("Config at the time: %s", app.config)
 93 app.exit(1)
 94 
 95 
 96 class ApplicationError(Exception):
 97 pass
 98 
 99 
100 class LevelFormatter(logging.Formatter):
101 """Formatter with additional `highlevel` record
102 

/usr/lib/python2.7/dist-packages/IPython/terminal/ipapp.pyc in 
initialize(self=, argv=None)
301 
302 return super(TerminalIPythonApp, self).parse_command_line(argv)
303 
304 @catch_config_error
305 def initialize(self, argv=None):
306 """Do actions after construct, but before starting the app."""
307 super(TerminalIPythonApp, self).initialize(argv)
308 if self.subapp is not None:
309 # don't bother initializing further, starting subapp
310 return
311 # print self.extra_args
312 if self.extra_args and not self.something_to_run:
313 self.file_to_run = self.extra_args[0]
314 self.init_path()
315 # create the shell
--> 316 self.init_shell()
self.init_shell = >
317 # and draw the banner
318 self.init_banner()
319 # Now a variety of things that happen after the banner is 
printed.
320 self.init_gui_pylab()
321 self.init_extensions()
322 self.init_code()
323 
324 def init_shell(self):
325 """initialize the InteractiveShell instance"""
326 # Create an InteractiveShell instance.
327 # shell.display_banner should always be False for the terminal
328 # based app, because we call shell.show_banner() by hand below
329 # so the banner shows *before* 

[sage-support] Re: simplification options

2019-03-11 Thread Simon King
Hi Michael,

On 2019-03-11, Michael Beeson  wrote:
> I tried various simplification functions.I suppose I could start over, 
>  not using "symbolic expressions" but 
> declaring K to be a suitable field or ring, maybe a quadratic extension of 
> the field of rational functions in a. 
> That is probably the "right" way to do it.

Probably!

> But I wish there were a simpler way.

Why do you think using a sub-optimal far too general tool (e.g., symbolic
variables when in fact the problem is about polynomial) is "simpler"?

Best regards,
Simon

-- 
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 https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: simplification options

2019-03-11 Thread Eric Gourgoulhon
Le lundi 11 mars 2019 19:05:04 UTC+1, Michael Beeson a écrit :
>
>  I appreciate Eric's post,  and I do use subs  sometimes,  but it makes me 
> nervous since
> it will happily substitute any old thing you tell it to,  even an 
> incorrect thing.  So,  if your idea
> is to check a computation, it is a dangerous thing. 
>

In order to minimize the error risk in the substitution, note that you can 
use the Python variable b defined as
b = sqrt(1-a^2)
in the argument of subs(), thereby avoiding any duplicate code. The whole 
code becomes then

sage: var('p,q,r,a')  # note: no b at this stage
(p, q, r, a)
sage: b = sqrt(1-a^2) 
sage: eq = (p*a+r*b+q)^2
sage: eq = eq.expand(); eq
a^2*p^2 - a^2*r^2 + 2*sqrt(-a^2 + 1)*a*p*r + 2*a*p*q + 2*sqrt(-a^2 + 1)*q*r 
+ q^2 + r^2
sage: eq.subs({b: SR.var('b')})
a^2*p^2 + 2*a*b*p*r - a^2*r^2 + 2*a*p*q + 2*b*q*r + q^2 + r^2



-- 
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 https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: simplification options

2019-03-11 Thread Nils Bruin
On Monday, March 11, 2019 at 11:05:04 AM UTC-7, Michael Beeson wrote:
>
>  I appreciate Eric's post,  and I do use subs  sometimes,  but it makes me 
> nervous since
> it will happily substitute any old thing you tell it to,  even an 
> incorrect thing.  So,  if your idea
> is to check a computation, it is a dangerous thing.  True,  if you put 
> only correct equations in, 
> you'll usually get correct ones out.  
>

Checking a result is usually much easier: Take the original form of the 
equation, subtract the simplified form, and check that the difference is 
divisible by the relations you impose, such as b^2-(1-a^2). No special 
normal forms are required, just a divisibility test. This gets more 
complicated when there are more relations, because then you'll need an 
ideal membership test, but then you can just present that as "the 
computational tool" (plus, with a bit of luck you can extract the way in 
which the difference can be expressed in terms of the generating relations. 
The algorithm in principle encounters that information on the way) 

-- 
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 https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: simplification options

2019-03-11 Thread Michael Beeson
 I appreciate Eric's post,  and I do use subs  sometimes,  but it makes me 
nervous since
it will happily substitute any old thing you tell it to,  even an incorrect 
thing.  So,  if your idea
is to check a computation, it is a dangerous thing.  True,  if you put only 
correct equations in, 
you'll usually get correct ones out.  

-- 
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 https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: simplification options

2019-03-11 Thread Eric Gourgoulhon
What about something like

sage: var('p,q,r,a')
(p, q, r, a)
sage: b = sqrt(1-a^2)
sage: eq = (p*a+r*b+q)^2
sage: eq = eq.expand(); eq
a^2*p^2 - a^2*r^2 + 2*sqrt(-a^2 + 1)*a*p*r + 2*a*p*q + 2*sqrt(-a^2 + 1)*q*r 
+ q^2 + r^2
sage: b = var('b')
sage: eq.subs({sqrt(1-a^2): b})
a^2*p^2 + 2*a*b*p*r - a^2*r^2 + 2*a*p*q + 2*b*q*r + q^2 + r^2

-- 
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 https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] simplification options

2019-03-11 Thread Michael Beeson
In the following example  I would like to make Sage realize that  (p,q,r) 
are constants and (a,b) are variables
so in the end everything should be expressed as a polynomial in a,b.   In 
particular b^2 should be rewritten as 1-a^2
(b and a are actually sin and cosine of something)  but b should not be 
rewritten as sqrt(1-a^2).   And, 
in the end the terms should be grouped so we see explicitly the 
coefficients of a,b,1, and a^2.  Of course this
example is simple enough to do by hand,  but I want to know how to control 
Sage enough to get this to happen in Sage.
I tried various simplification functions.I suppose I could start over, 
 not using "symbolic expressions" but 
declaring K to be a suitable field or ring, maybe a quadratic extension of 
the field of rational functions in a. 
That is probably the "right" way to do it.   But I wish there were a 
simpler way.   I'm writing a paper with 
little snippets of Sage code with which the reader, who will be a 
mathematician probably unfamiliar with SageMath,
can check the computations, or see how the computations can be checked.
  So the code should be readable to such a person,  ruling out the 
introduction
of new fields.The code below is perfectly readable in that sense,  but 
it doesn't quite do the job.

def mar11b():
var('p,q,r,a,b')
b = sqrt(1-a^2)
lam = p*a + r*b + q
mu = r*a - p*b
lam = sqrt(N/2)
eq = lam^2 - (p*a+r*b+q)^2
eq = eq.expand()
print(eq)

-- 
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 https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.