From: Simon H. <sim...@us...> - 2010-09-30 16:56:53
|
Update of /cvsroot/stack/stack-dev/maxima In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv28438/maxima Modified Files: stacktex.lisp initMaxima.php unittests.mac maximafun.php stackmaxima.mac Removed Files: stackmaxima_5.15.0.bat stackmaxima_5.11.0.bat stackmaxima_5.13.0.bat stackmaxima_5.12.0.bat Log Message: Merging 2.2 branch (with some additional fixes to ensure seamless updating for version lines) Index: stackmaxima.mac =================================================================== RCS file: /cvsroot/stack/stack-dev/maxima/stackmaxima.mac,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** stackmaxima.mac 14 May 2010 16:36:00 -0000 1.79 --- stackmaxima.mac 30 Sep 2010 16:56:14 -0000 1.80 *************** *** 74,77 **** --- 74,78 ---- load("format/format.lisp"); load("implicit_plot.lisp"); + load("grobner.lisp"); /* Does not quite work yet ..... */ *************** *** 485,489 **** ); ! /* commonfac(l) returns the hcf of a list of numbers */ commonfaclist(l) := block([i,a,ret], if listp(l) then --- 486,490 ---- ); ! /* commonfac(l) returns the gcd of a list of numbers */ commonfaclist(l) := block([i,a,ret], if listp(l) then *************** *** 589,592 **** --- 590,610 ---- )$ + /* ********************************** */ + /* Parts of expressions */ + /* ********************************** */ + + /* op(ex) is unsafe on atoms: this is a fix. */ + /* This function always returns a string */ + stack_op(ex) := block( + if atom(ex) then return(""), + if op(ex)#"-" then + if stringp(op(ex)) then return(op(ex)) else return(string(op(ex))) + else + if atom(first(ex)) then + return("") + else + if stringp(op(first(ex))) then return(op((first(ex)))) else return(string(op(ex))) + )$ + /* This function takes an expression ex and returns a list of coefficients of v */ coeff_list(ex,v):= block([deg,kloop,cl], *************** *** 628,644 **** )$ - /* Reduces an inequality to either ? > 0 or ? >=0 */ - ineqreduce(ex) := block([op2,ex2], - if atom(ex) then return(ex), - if op(ex)="=" then return(ev(part(ex,1) - part(ex,2),simp,trigreduce) = 0), - if op(ex)=">" then return(ev(part(ex,1) - part(ex,2),simp,trigreduce) > 0), - if op(ex)=">=" then return(ev(part(ex,1) - part(ex,2),simp,trigreduce) >= 0), - if op(ex)="<" then return(ev(part(ex,2) - part(ex,1),simp,trigreduce) > 0), - if op(ex)="<=" then return(ev(part(ex,2) - part(ex,1),simp,trigreduce) >= 0), - ex2:args(ex), - ex2:map(ineqreduce,ex2), - return(apply(op(ex),ex2)) - )$ - expressionp(ex) := block( if matrixp(ex) or listp(ex) or equationp(ex) or inequalityp(ex) or setp(ex) then --- 646,649 ---- *************** *** 806,817 **** )$ /* Two equations are the "same" when they have identical roots with identical multiplicities */ ATEquation(SA,SB):= block([RawMark,SA1,SB1,SB2], RawMark:0, ! SA1:fullratsimp(trigexpand(rhs(SA)-lhs(SA))), ! SB1:fullratsimp(trigexpand(rhs(SB)-lhs(SB))), ! SA1:SA1*denom(SA1), ! SB1:SB1*denom(SB1), if SA1#0 then /* We need a slight hack to turn %i+1 into a number */ --- 811,860 ---- )$ + /* Equationss */ + stack_eqnprepare(ex):=block([ret], + ret:fullratsimp(trigexpand(rhs(ex)-lhs(ex))), + ret:ret*denom(ret), + return(expand(ret)) + )$ + + stack_eqncompare(SA,SB,sl):=block([ret,G0,G1], + G0 :poly_buchberger(SA,sl), + G1 :poly_buchberger(SB,sl), + ret:poly_grobner_equal(G0,G1,sl), + return(ret) + )$ + + stack_assignmentp(ex):=block( + if atom(ex) then return(false) + else if op(ex)#"=" then return(false) + else if atom(lhs(ex)) and not(real_numberp(lhs(ex))) and real_numberp(rhs(ex)) then return(true) + else return(false) + )$ + + stack_assignmentrev(ex):=block( + if atom(ex) then return(ex) + else if op(ex)#"=" then return(ex) + else if real_numberp(lhs(ex)) and not(real_numberp(rhs(ex))) then return(rhs(ex)=lhs(ex)) + else return(ex) + )$ + + /* Take a list of equations, and re-evaluate it in the context of any assignments of the form d=10 + This is needed in practice with systems of equations, as students may write [d=10, d=v*t] */ + stack_eval_assignments(ex):= block([asl,sl], + if not(listp(ex)) then return(ex), + sl:maplist(stack_assignmentrev,ex), + asl:filter(stack_assignmentp,sl), + if not(emptyp(asl)) then + (sl:listify(setdifference(setify(sl),setify(asl))), + sl:ev(sl,asl)), + return(sl) + )$ + /* Two equations are the "same" when they have identical roots with identical multiplicities */ ATEquation(SA,SB):= block([RawMark,SA1,SB1,SB2], RawMark:0, ! SA1:stack_eqnprepare(SA), ! SB1:stack_eqnprepare(SB), if SA1#0 then /* We need a slight hack to turn %i+1 into a number */ *************** *** 822,830 **** )$ ATInequality(SA,SB):= block([RawMark,FeedBack,AnswerNote,SA1,SB1,samex], RawMark:0, FeedBack:"", AnswerNote:"", ! SA:ineqreduce(SA), ! SB:ineqreduce(SB), SA1:ev(part(SA,1),simp), SB1:ev(part(SB,1),simp), --- 865,887 ---- )$ + /* Reduces an inequality to either ? > 0 or ? >=0 */ + stack_ineqprepare(ex) := block([op2,ex2], + if atom(ex) then return(ex), + if op(ex)="=" then return(ev(part(ex,1) - part(ex,2),simp,trigreduce) = 0), + if op(ex)=">" then return(ev(part(ex,1) - part(ex,2),simp,trigreduce) > 0), + if op(ex)=">=" then return(ev(part(ex,1) - part(ex,2),simp,trigreduce) >= 0), + if op(ex)="<" then return(ev(part(ex,2) - part(ex,1),simp,trigreduce) > 0), + if op(ex)="<=" then return(ev(part(ex,2) - part(ex,1),simp,trigreduce) >= 0), + ex2:args(ex), + ex2:map(stack_ineqprepare,ex2), + return(apply(op(ex),ex2)) + )$ + + ATInequality(SA,SB):= block([RawMark,FeedBack,AnswerNote,SA1,SB1,samex], RawMark:0, FeedBack:"", AnswerNote:"", ! SA:stack_ineqprepare(SA), ! SB:stack_ineqprepare(SB), SA1:ev(part(SA,1),simp), SB1:ev(part(SB,1),simp), *************** *** 885,890 **** FeedBack:"", /* Check they are equal */ ! SA:map(ineqreduce,map(trigreduce,SA)), ! SB:map(ineqreduce,map(trigreduce,SB)), if (subsetp(SA,SB) and subsetp(SB,SA)) then return([true,1,AnswerNote,FeedBack]), --- 942,947 ---- FeedBack:"", /* Check they are equal */ ! SA:map(stack_ineqprepare,map(trigreduce,SA)), ! SB:map(stack_ineqprepare,map(trigreduce,SB)), if (subsetp(SA,SB) and subsetp(SB,SA)) then return([true,1,AnswerNote,FeedBack]), --- stackmaxima_5.11.0.bat DELETED --- --- stackmaxima_5.15.0.bat DELETED --- Index: maximafun.php =================================================================== RCS file: /cvsroot/stack/stack-dev/maxima/maximafun.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** maximafun.php 3 Oct 2007 12:24:17 -0000 1.6 --- maximafun.php 30 Sep 2010 16:56:14 -0000 1.7 *************** *** 19,22 **** --- 19,25 ---- $maxima_cmd['%enumer']['use'] = 't'; + $maxima_cmd['%f']['urls'][] = 'maxima_16.html#IDX636'; + $maxima_cmd['%f']['use'] = 't'; + $maxima_cmd['%gamma']['urls'][] = 'maxima_31.html#IDX1065'; $maxima_cmd['%gamma']['use'] = 's'; *************** *** 46,49 **** [...13409 lines suppressed...] ! $maxima_cmd['zlabel']['urls'][] = 'maxima_48.html#IDX1868'; ! $maxima_cmd['zlabel']['use'] = ''; ! ! $maxima_cmd['zlange']['urls'][] = 'maxima_58.html#IDX2297'; ! $maxima_cmd['zlange']['use'] = ''; ! ! $maxima_cmd['zrange']['urls'][] = 'maxima_48.html#IDX1855'; $maxima_cmd['zrange']['use'] = ''; ! $maxima_cmd['ztics']['urls'][] = 'maxima_48.html#IDX1873'; $maxima_cmd['ztics']['use'] = ''; + $maxima_cmd['ztics_axis']['urls'][] = 'maxima_48.html#IDX1884'; + $maxima_cmd['ztics_axis']['use'] = ''; + + $maxima_cmd['ztics_rotate']['urls'][] = 'maxima_48.html#IDX1879'; + $maxima_cmd['ztics_rotate']['use'] = ''; ?> \ No newline at end of file Index: initMaxima.php =================================================================== RCS file: /cvsroot/stack/stack-dev/maxima/initMaxima.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** initMaxima.php 23 Jun 2009 14:39:36 -0000 1.5 --- initMaxima.php 30 Sep 2010 16:56:14 -0000 1.6 *************** *** 172,175 **** --- 172,182 ---- // Exceptions: Maxima variable names which are allowed to be variable names as part of STACK. + // Enable students to use any Greek letters as part of an answer. + + $greek = array(alpha,nu,beta,xi,gamma,omicron,delta,pi,epsilon,rho,zeta,sigma,eta,tau,theta,upsilon,iota,phi,kappa,chi,lambda,psi,mu,omega); + foreach ($greek as $gl) { + $gl = strtoupper($gl); + $sA .= ", '$gl' "; + } --- stackmaxima_5.12.0.bat DELETED --- Index: stacktex.lisp =================================================================== RCS file: /cvsroot/stack/stack-dev/maxima/stacktex.lisp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** stacktex.lisp 28 Oct 2009 14:03:07 -0000 1.5 --- stacktex.lisp 30 Sep 2010 16:56:14 -0000 1.6 *************** *** 1,13 **** ;; Customize Maxima's TEX() function. To give better control to the output. ! ;; Chris Sangwin 21 Jan 2009. ! ;; Useful files: ! ;; \Maxima-5.9.0\share\maxima\5.9.0\share\utils\mactex-utilities.lisp ! ;; \Maxima-5.9.0\share\maxima\5.9.0\src\mactex.lisp ;; Additional mactex utilities taken from the distributed file ;; mactex-utilities.lisp ! ;; Based on code by Richard J. Fateman, copyright 1987. ! ;; Fateman's code was ported to Common Lisp by William ! ;; Schelter. ;; If you want LaTeX style quotients, first load mactex and second --- 1,13 ---- ;; Customize Maxima's TEX() function. To give better control to the output. ! ;; Chris Sangwin 27 Sept 2010. ! ;; Useful files: ! ;; \Maxima-5.21.1\share\maxima\5.21.1\share\utils\mactex-utilities.lisp ! ;; \Maxima-5.21.1\share\maxima\5.21.1\src\mactex.lisp ;; Additional mactex utilities taken from the distributed file ;; mactex-utilities.lisp ! ;; Based on code by Richard J. Fateman, copyright 1987. ! ;; Fateman's code was ported to Common Lisp by William ! ;; Schelter. ;; If you want LaTeX style quotients, first load mactex and second *************** *** 39,46 **** (defun tex-matrix (x l r) ;; matrix looks like ((mmatrix)((mlist) a b) ...) ! (append l `("\\left[\\begin{array}{") (tex-matrix-col-count x "c") ; Replace every column with a "c" `("} ") ! ; Below is the bit we need - forms the array (mapcan #'(lambda(y) (tex-list (cdr y) nil (list " \\\\ ") " & ")) (cdr x)) '("\\end{array}\\right]") r) --- 39,46 ---- (defun tex-matrix (x l r) ;; matrix looks like ((mmatrix)((mlist) a b) ...) ! (append l `("\\left[\\begin{array}{") (tex-matrix-col-count x "c") ; Replace every column with a "c" `("} ") ! ; Below is the bit we need - forms the array (mapcan #'(lambda(y) (tex-list (cdr y) nil (list " \\\\ ") " & ")) (cdr x)) '("\\end{array}\\right]") r) *************** *** 64,68 **** (tex (cadr x) (append l (texsym (caar x))) r 'mparen 'mparen)) ! (defprop &? ("?") texsym) --- 64,68 ---- (tex (cadr x) (append l (texsym (caar x))) r 'mparen 'mparen)) ! (defprop &? ("?") texsym) *************** *** 141,142 **** --- 141,149 ---- ((eql (elt x 0) #\\) x) (t (concatenate 'string "\\mbox{" x "}")))) + + + ;; Sort out display on inequalitis + ;; Chris Sangwin, 21/9/2010 + + (defprop mlessp (" < ") texsym) + (defprop mgreaterp (" > ") texsym) \ No newline at end of file --- stackmaxima_5.13.0.bat DELETED --- Index: unittests.mac =================================================================== RCS file: /cvsroot/stack/stack-dev/maxima/unittests.mac,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** unittests.mac 14 May 2010 16:36:00 -0000 1.14 --- unittests.mac 30 Sep 2010 16:56:14 -0000 1.15 *************** *** 167,168 **** --- 167,188 ---- UT('exdowncase(%pi),%pi); + UT('stack_assignmentp(x=1),true); + UT('stack_assignmentp(x=sqrt(2)),true); + UT('stack_assignmentp(3=1),false); + UT('stack_assignmentp(d=v*t),false); + UT('stack_assignmentp(1=x),false); + + UT('stack_op(1),""); + UT('stack_op(x),""); + UT('stack_op(%pi),""); + UT('stack_op(3+z),"+"); + UT('stack_op(3*z),"*"); + UT('stack_op(3^z),"^"); + UT('stack_op(3/z),STACK_DIV_OP); + UT('stack_op(sin(3*z)),"sin"); + UT('stack_op((-1)/(x^2+1)),"/"); + UT('stack_op(1-x),"+"); + UT('stack_op(x-1),"+"); + UT('stack_op("-"(x-1)),"+"); + UT('stack_op("-"(1/(x^2+1))),STACK_DIV_OP); + UT('stack_op("-"(2*x)),"*"); |