On Fri, Aug 2, 2013 at 5:54 AM, Emmanuel Charpentier <[email protected]> wrote: > Maxima.console allows for direct communication between user and maxima, > whereas maxima.interact still filters input and output. Compare : > > sage: maxima.console() > ;;; Loading #P"/home/charpent/sage-5.10/local/lib/ecl/sb-bsd-sockets.fas" > ;;; Loading #P"/home/charpent/sage-5.10/local/lib/ecl/sockets.fas" > ;;; Loading #P"/home/charpent/sage-5.10/local/lib/ecl/defsystem.fas" > ;;; Loading #P"/home/charpent/sage-5.10/local/lib/ecl/cmp.fas" > Maxima 5.29.1 http://maxima.sourceforge.net > using Lisp ECL 12.12.1 > Distributed under the GNU Public License. See the file COPYING. > Dedicated to the memory of William Schelter. > The function bug_report() provides bug reporting information. > (%i1) display2d:false; > > (%o1) false > (%i2) declare(x,real,t,real,m,real,s,real) $ assume(s>0) $ > > (%i4) define(foo(x,m,s),subst((x-m)/s,x,diff(1/(1+%e^-x),x))); > > (%o4) foo(x,m,s):=%e^-((x-m)/s)/(%e^-((x-m)/s)+1)^2 > (%i5) integrate(foo(x,m,s),x,minf,inf); > > (%o5) s > (%i6) integrate(foo(x,m,s)/s,x,minf,inf); > > (%o6) 1 > (%i7) integrate(x*foo(x,m,s)/s,x,minf,inf); > > Is 1/s an integer? > > n; ;;; This is an answer typed in the terminal > Is 2*m/s an integer? > > n; ;;; Ditto > Is m/s an integer? > > n; ;;; Ditto > (%o7) m > (%i8) quit(); > > with : > > sage: maxima.interact() > > --> Switching to Maxima <-- > > maxima: declare(x,real,t,real,m,real,s,real); > done > maxima: assume(s>0); > [s>0] > maxima: define(foo(x,m,s),subst((x-m)/s,x,diff(1/(1+%e^-x),x))); > foo(x,m,s):=%e^-((x-m)/s)/(%e^-((x-m)/s)+1)^2 > maxima: integrate(foo(x,m,s),x,minf,inf); > s > maxima: integrate(foo(x,m,s)/s,x,minf,inf); > 1 > maxima: integrate(x*foo(x,m,s)/s,x,minf,inf); > --------------------------------------------------------------------------- > ValueError Traceback (most recent call last) > /home/charpent/sage-5.10/local/lib/python2.7/site-packages/IPython/core/prefilter.pyc > in prefilter_lines(self, lines, continue_prompt) > 358 for lnum, line in enumerate(llines) ]) > 359 else: > --> 360 out = self.prefilter_line(llines[0], continue_prompt) > 361 > 362 return out > > /home/charpent/sage-5.10/local/lib/python2.7/site-packages/IPython/core/prefilter.pyc > in prefilter_line(self, line, continue_prompt) > 314 # At this point, we invoke our transformers. > 315 if not continue_prompt or (continue_prompt and > self.multi_line_specials): > --> 316 line = self.transform_line(line, continue_prompt) > 317 > 318 # Now we compute line_info for the checkers and handlers > > /home/charpent/sage-5.10/local/lib/python2.7/site-packages/IPython/core/prefilter.pyc > in transform_line(self, line, continue_prompt) > 288 for transformer in self.transformers: > 289 if transformer.enabled: > --> 290 line = transformer.transform(line, continue_prompt) > 291 return line > 292 > > /home/charpent/sage-5.10/local/lib/python2.7/site-packages/sage/misc/interpreter.pyc > in transform(self, line, continue_prompt) > 544 line = 'InputForm[%s]'%line > 545 > --> 546 t = self.shell.interface.eval(line) > 547 > 548 #Once we've evaluated the lines, we can clear the queue > > /home/charpent/sage-5.10/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc > in eval(self, code, strip, synchronize, locals, allow_use_file, split_lines, > **kwds) > 1206 elif split_lines: > 1207 return '\n'.join([self._eval_line(L, > allow_use_file=allow_use_file, **kwds) > -> 1208 for L in code.split('\n') if > L != '']) > 1209 else: > 1210 return self._eval_line(code, > allow_use_file=allow_use_file, **kwds) > > /home/charpent/sage-5.10/local/lib/python2.7/site-packages/sage/interfaces/maxima.pyc > in _eval_line(self, line, allow_use_file, wait_for_prompt, reformat, > error_check, restart_if_needed) > 791 return out > 792 > --> 793 self._expect_expr() > 794 assert len(self._before())==0, 'Maxima expect interface is > confused!' > 795 > > /home/charpent/sage-5.10/local/lib/python2.7/site-packages/sage/interfaces/maxima.pyc > in _expect_expr(self, expr, timeout) > 695 self._sendline(";") > 696 self._expect_expr() > --> 697 raise ValueError, msg > 698 except KeyboardInterrupt, msg: > 699 #print self._expect.before > > ValueError: Computation failed since Maxima requested additional constraints > (try the command "maxima.assume('/s>0')" before integral or limit > evaluation, for example): > Is 1/s an integer? > maxima: ;;; Here, I type Ctrl-D > > --> Exiting back to Sage <-- > > In the maxima.interact() call, sage "sees" the question from maxima, and > acts accordingly (here, suggests an assumption that cannot be made...). > > Is that the intended effect of maxima.interact ?
Yes. maxima.console() fires up an entirely new maxima console (a whole new session) and directly dumps the user into it. maxima.interact() simply takes the existing maxima session -- the (or a) one that Sage controls -- and lets the user directly type commands to it and have results displayed back; all the interaction goes through exactly the same mechanism (mainly pexpect) that Sage uses for commands like maxima.eval. There are a dozen other interfaces that have a .interact() method that works like this. Implementing something like you want might be a good idea or interesting though. -- William > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sage-support. > For more options, visit https://groups.google.com/groups/opt_out. > > -- William Stein Professor of Mathematics University of Washington 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
