From: Chris S. <san...@us...> - 2010-12-06 16:03:47
|
Update of /cvsroot/stack/stack-dev/maxima In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv26851/maxima Modified Files: stackmaxima.mac assessment.mac unittests_load.mac noun_arith.mac rtest_assessment_simpfalse.mac Added Files: .cvsignore Log Message: --- NEW FILE: .cvsignore --- stackmaxima_loc.bat *.ERR Index: stackmaxima.mac =================================================================== RCS file: /cvsroot/stack/stack-dev/maxima/stackmaxima.mac,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** stackmaxima.mac 1 Dec 2010 18:32:25 -0000 1.87 --- stackmaxima.mac 6 Dec 2010 16:03:38 -0000 1.88 *************** *** 38,43 **** OPT_OUTPUT:"LaTeX", /* */ ! STACK_DIV_OP:"//", ! if MAXIMA_VERSION_NUM>=15.0 then STACK_DIV_OP:"/", true --- 38,43 ---- OPT_OUTPUT:"LaTeX", /* */ ! DIV_OP:"//", ! if MAXIMA_VERSION_NUM>=15.0 then DIV_OP:"/", true *************** *** 54,57 **** --- 54,60 ---- alias(simplify,fullratsimp); /* Allows simplify to be something */ + alias(Stack_Test,algebraic_equivalence); /*Legacy: 6/12/10 */ + + infix("=>"); "=>"(a,b):=a>=b; *************** *** 444,486 **** /* ********************************** */ - /* expandp(p) is true if p equals its expanded form */ - expandp(p):= block([simp:true], if p=expand(p) then true else false)$ - - /* factorp(p) is true if p equals its factored form */ - factorp(p) := block([a], - if ev(p=factor(p),simp) then return(true), - if atom(p) then return(false), - /* Note, in Maxima factor((1-x)) = -(x-1), so we need to fix this, for learning and teaching! */ - if ev(-1*factor(p) = expand(-1*p),simp) then return(true), - if op(p)="^" and atom(part(p,1)) then return(true), - if op(p)="^" and factorp(part(p,1)) then return(true), - if op(p)="*" then return(all_listp(factorp,args(p))), - return(false) )$ - - - /* A general all purpose function on **expressions**. - Takes two objects and returns true if they are equal, and false otherwise - This is a "bash as hard as possible" function - */ - Stack_Test(SA,SB) := - block([keepfloat,trigexpand,logexpand,ex,vi], - trigexpand:true, /* see pg 80 */ - logexpand:super, - keepfloat:true, /* see pg 23 */ - ex:errcatch(ev(fullratsimp(SA-SB),simp)), - if ex=[] then return(false), - ex:ex[1], - if floatnump(ex) then return(false), - ex:num(ex), /* after a fullratsimp, we have a ratio. We should only need to consider the top */ - ex:trigsimp(ex), - /* ex:trigreduce(ex), CJS, removed 21/1/2010. This was breaking ATSingleFrac! Don't know why. */ - if fullratsimp(ex)=0 then return(true), - ex:radcan(ex), - ex:factcomb(ex), - if fullratsimp(ex)=0 then return(true), - for vi:1 while ex#sqrtdenest(ex) do ex:sqrtdenest(ex), - if fullratsimp(ex)=0 then return(true) else return(false) - )$ - /* A general, all purpose answer test based maximum simplifiaction. --- 447,450 ---- *************** *** 560,566 **** return([false,0,"ATAlgEquiv_SA_not_expression",StackAddFeedback("","ATAlgEquiv_SA_not_expression")]), /* Otherwise we have two expressions*/ ! if Stack_Test(SA,SB) then RawMark:1 ! else if Stack_Test(exdowncase(SA),exdowncase(SB)) then AnswerNote:"ATAlgEquiv WrongCase ", ret:[true,RawMark,AnswerNote,FeedBack], --- 524,530 ---- return([false,0,"ATAlgEquiv_SA_not_expression",StackAddFeedback("","ATAlgEquiv_SA_not_expression")]), /* Otherwise we have two expressions*/ ! if algebraic_equivalence(SA,SB) then RawMark:1 ! else if algebraic_equivalence(exdowncase(SA),exdowncase(SB)) then AnswerNote:"ATAlgEquiv WrongCase ", ret:[true,RawMark,AnswerNote,FeedBack], *************** *** 674,682 **** SA1:ev(part(SA,1),simp), SB1:ev(part(SB,1),simp), ! sameex:Stack_Test(SA1,SB1), if (op(SA)=op(SB) and sameex) then RawMark:1, if op(SA)=">" and op(SB)=">=" then (AnswerNote:"ATInequality_strict",FeedBack:StackAddFeedback("","ATInequality_strict")), if op(SA)=">=" and op(SB)=">" then (AnswerNote:"ATInequality_nonstrict",FeedBack:StackAddFeedback("","ATInequality_nonstrict")), ! if Stack_Test(-1*SA1,SB1) then (AnswerNote:concat(AnswerNote," ATInequality_backwards"),FeedBack:StackAddFeedback(FeedBack,"ATInequality_backwards")), return([true,RawMark,AnswerNote,FeedBack]) )$ --- 638,646 ---- SA1:ev(part(SA,1),simp), SB1:ev(part(SB,1),simp), ! sameex:algebraic_equivalence(SA1,SB1), if (op(SA)=op(SB) and sameex) then RawMark:1, if op(SA)=">" and op(SB)=">=" then (AnswerNote:"ATInequality_strict",FeedBack:StackAddFeedback("","ATInequality_strict")), if op(SA)=">=" and op(SB)=">" then (AnswerNote:"ATInequality_nonstrict",FeedBack:StackAddFeedback("","ATInequality_nonstrict")), ! if algebraic_equivalence(-1*SA1,SB1) then (AnswerNote:concat(AnswerNote," ATInequality_backwards"),FeedBack:StackAddFeedback(FeedBack,"ATInequality_backwards")), return([true,RawMark,AnswerNote,FeedBack]) )$ *************** *** 798,840 **** - /* This function takes two expressions. - It establishes if there exists a substitution of the variables of ex2 into ex1 which renders - ex1 algebraically equivalent to ex2. - If such a substitution exists the function returns it in a form so that - - ex2 = ev(ex1, subst_equiv(ex1,ex2)) - - If no such permutation exists it returns the empty list []. - If it could not establish this, because there are too many combinations to reasonably consider, - then the function returns false. - */ - subst_equiv(ex1,ex2):=block([lv1,lv2,lvi,lvp,lvs,lve,il,perm_size,simp], - simp:true, - perm_size:4, /* This algorithm is order factorial(perm_size) and so this needs to be small. */ - lv1:listofvars(ex1), - lv2:listofvars(ex2), - if length(lv1)#length(lv2) then return([]), - /* If the lists are too long, try a weaker condition */ - /* We assume the variables which occur in both are correctly assigned. */ - /* Can we find a permutation of those left in each? */ - if length(lv1)>perm_size then ( - lv1:setify(lv1), - lv2:setify(lv2), - lvi:intersection(lv1,lv2), - lv1:listify(setdifference(lv1,lvi)), - lv2:listify(setdifference(lv2,lvi)) - ), - if length(lv1)>perm_size then return(false), - /* */ - lvp:listify(permutations(lv2)), - /* Create a list of subsitutions */ - lvs:map(lambda([ex],zip_with("=",lv1,ex)),lvp), - /* Create list of expressions with which to compare ex1 */ - lve:map(lambda([ex],ev(ex1,ex)),lvs), - lve:map(lambda([ex],ATAlgEquivfun(ex,ex2)),lve), - lve:map(second,lve), - lve:map(lambda([ex],equal(ex,1)),lve), - if apply("or",lve) then (il:sublist_indices(lve,identity),lvs[il[1]]) else [] - )$ ATSubstEquiv(SA,SB) :=block([simp:true,ret], --- 762,765 ---- *************** *** 857,870 **** - /* This function makes a substitution of all variables for their lower case equivalents. - Useful when wanting to do a specific case sensitivity - check, e.g. that X^2=1 is x^2=1, without using subst_equiv. - - Note that exdowncase(X-x)=0, of course! - */ - exdowncase(ex):=block([lv], - lv:listofvars(ex), - lv:map(lambda([v],v=parse_string(sdowncase(string(v)))),lv), - return(subst(lv,ex)))$ /**********************************************/ --- 782,785 ---- *************** *** 1192,1196 **** fb: StackAddFeedback("","ATFacForm_error_degreeSA") ), ! aequiv:Stack_Test(SA,SB), /* An integer answer is always correct. */ if (integerp(SA)) then --- 1107,1111 ---- fb: StackAddFeedback("","ATFacForm_error_degreeSA") ), ! aequiv:algebraic_equivalence(SA,SB), /* An integer answer is always correct. */ if (integerp(SA)) then *************** *** 1299,1307 **** val:true, rawmk:1, fb: "", ansnote: "", ret:[val,rawmk,ansnote,fb], ! if Stack_Test(sExpr,tExpr) then block([topOp, list], topOp: op( sExpr ), list: args( sExpr ), ! if topOp = STACK_DIV_OP then block( val: true, /* Whether a single fraction is an invalid answer is really a matter of taste! */ rawmk :0, --- 1214,1222 ---- val:true, rawmk:1, fb: "", ansnote: "", ret:[val,rawmk,ansnote,fb], ! if algebraic_equivalence(sExpr,tExpr) then block([topOp, list], topOp: op( sExpr ), list: args( sExpr ), ! if topOp = DIV_OP then block( val: true, /* Whether a single fraction is an invalid answer is really a matter of taste! */ rawmk :0, *************** *** 1399,1403 **** if atom(SA) then ! if Stack_Test(SA,SB) then return(StackReturnOb("1","","")) else --- 1314,1318 ---- if atom(SA) then ! if algebraic_equivalence(SA,SB) then return(StackReturnOb("1","","")) else *************** *** 1406,1411 **** /* Check for single fraction */ fbn:"", ! if op(SA) = STACK_DIV_OP then block( ! if (freeof(STACK_DIV_OP,num(SA)) and freeof(STACK_DIV_OP,denom(SA))) then block( rawmk:"1", ansnote: "ATSingleFrac_true") --- 1321,1326 ---- /* Check for single fraction */ fbn:"", ! if op(SA) = DIV_OP then block( ! if (freeof(DIV_OP,num(SA)) and freeof(DIV_OP,denom(SA))) then block( rawmk:"1", ansnote: "ATSingleFrac_true") *************** *** 1419,1423 **** fb: StackAddFeedback(fb,ansnote), /* Check for algebraic equivalence */ ! if not(Stack_Test(SA,SB)) then block( rawmk:"0", fbn:"ATSingleFrac_ret_exp", --- 1334,1338 ---- fb: StackAddFeedback(fb,ansnote), /* Check for algebraic equivalence */ ! if not(algebraic_equivalence(SA,SB)) then block( rawmk:"0", fbn:"ATSingleFrac_ret_exp", *************** *** 1434,1438 **** divthru(q):= ! if (not atom(q) and part(q,0)=STACK_DIV_OP) then block([num,den,div,quo,rem], --- 1349,1353 ---- divthru(q):= ! if (not atom(q) and part(q,0)=DIV_OP) then block([num,den,div,quo,rem], *************** *** 1564,1568 **** /* case: (x-1)^2/k */ ! if opa=STACK_DIV_OP and elementp(wrt,setify(listofvars(denom(SA))))#true and atom(num(SA))#true and op(num(SA))="^" and part(num(SA),2)=2 then cform:true, /* The sum of somthing */ --- 1479,1483 ---- /* case: (x-1)^2/k */ ! if opa=DIV_OP and elementp(wrt,setify(listofvars(denom(SA))))#true and atom(num(SA))#true and op(num(SA))="^" and part(num(SA),2)=2 then cform:true, /* The sum of somthing */ *************** *** 1588,1592 **** /* Check for algebraic equivalence */ ! if cform and Stack_Test(SA,SB) then return(StackReturnOb("1","ATCompSquare_true","")), --- 1503,1507 ---- /* Check for algebraic equivalence */ ! if cform and algebraic_equivalence(SA,SB) then return(StackReturnOb("1","ATCompSquare_true","")), *************** *** 1599,1640 **** - /* ********************************** */ - /* Analysis tests */ - /* ********************************** */ - - /* This determines if an expression is continuous - ex the expression, - v the variable, - xp the point at which to evaluate. */ - continuousp(ex,v,xp) := block([lp,lm], - lp: ev(limit(ex,v,xp,minus),simp), - lm: ev(limit(ex,v,xp,plus),simp), - /* print(lp), print(lm), */ - if lp # und - and lm # und - and lp # ind - and lm # ind - and lp # inf - and lm # inf - and lp # minf - and lm # minf - and lp = lm - then true else false - )$ - - - /* This determines if an expression is differentiable - ex the expression, - v the variable, - xp the point at which to evaluate, - n the number of times it is differentiated (optional). - */ - diffp(ex,[args]) := block([v,xp,n], - v:args[1], - xp:args[2], - n:1, - if length(args)=3 then n:args[3], - return(continuousp(diff(ex,v,n),v,xp)) - )$ /*********************/ --- 1514,1517 ---- *************** *** 1709,1713 **** /* This strips off any trailing constant of integration from the student's answer */ SAa:strip_int_const(ev(SA,logexpand:super),v), ! /* Check for constant of integration - code copied from Stack_Test */ ex:errcatch(ev(fullratsimp(SA-SB),simp,trigexpand:true,logexpand:super,keepfloat:true)), if ex=[] then return(false), --- 1586,1590 ---- /* This strips off any trailing constant of integration from the student's answer */ SAa:strip_int_const(ev(SA,logexpand:super),v), ! /* Check for constant of integration - code copied from algebraic_equivalence */ ex:errcatch(ev(fullratsimp(SA-SB),simp,trigexpand:true,logexpand:super,keepfloat:true)), if ex=[] then return(false), *************** *** 1720,1732 **** SAd:diff(SA,v), SBd:diff(SB,v), ! if Stack_Test(SAd,SBd) then if dc then (rawmk:0, fb:StackAddFeedback("","ATInt_const_int"), ansnote:"ATInt_const_int") else if freeof(log,SA) and not(atom(ex)) and not(atom(-ex)) then (rawmk:0, fb:StackAddFeedback("","ATInt_wierdconst"), ansnote:"ATInt_wierdconst") ! else if Stack_Test(SA,SB) then (rawmk:0, fb:StackAddFeedback("","ATInt_const"), ansnote:"ATInt_const") else /* Check the student's answer has the correct form */ ! ( if Stack_Test(SAa,SB) then (rawmk:1, ansnote:"ATInt_true") else --- 1597,1609 ---- SAd:diff(SA,v), SBd:diff(SB,v), ! if algebraic_equivalence(SAd,SBd) then if dc then (rawmk:0, fb:StackAddFeedback("","ATInt_const_int"), ansnote:"ATInt_const_int") else if freeof(log,SA) and not(atom(ex)) and not(atom(-ex)) then (rawmk:0, fb:StackAddFeedback("","ATInt_wierdconst"), ansnote:"ATInt_wierdconst") ! else if algebraic_equivalence(SA,SB) then (rawmk:0, fb:StackAddFeedback("","ATInt_const"), ansnote:"ATInt_const") else /* Check the student's answer has the correct form */ ! ( if algebraic_equivalence(SAa,SB) then (rawmk:1, ansnote:"ATInt_true") else *************** *** 1734,1738 **** ) else /* Check for the special cases where the buggy rule is true */ ! if Stack_Test(SAa,diff(SBd,v)) and Stack_Test(exp(x),SBd)#true then (rawmk:0, fb:StackAddFeedback("","ATInt_diff"), ansnote:"ATInt_diff") else ( --- 1611,1615 ---- ) else /* Check for the special cases where the buggy rule is true */ ! if algebraic_equivalence(SAa,diff(SBd,v)) and algebraic_equivalence(exp(x),SBd)#true then (rawmk:0, fb:StackAddFeedback("","ATInt_diff"), ansnote:"ATInt_diff") else ( *************** *** 1790,1797 **** val:true, rawmk:0, fb:"", ansnote:"", ret:[val,rawmk,ansnote,fb], ! if Stack_Test(SA,SB) then (rawmk:1, ansnote:"ATDiff_true") else ! if Stack_Test(diff(SA,v),int(SB,v)) then (rawmk:0, ansnote:"ATDiff_int ", fb:StackAddFeedback("","ATDiff_int")) else ( --- 1667,1674 ---- val:true, rawmk:0, fb:"", ansnote:"", ret:[val,rawmk,ansnote,fb], ! if algebraic_equivalence(SA,SB) then (rawmk:1, ansnote:"ATDiff_true") else ! if algebraic_equivalence(diff(SA,v),int(SB,v)) then (rawmk:0, ansnote:"ATDiff_int ", fb:StackAddFeedback("","ATDiff_int")) else ( Index: assessment.mac =================================================================== RCS file: /cvsroot/stack/stack-dev/maxima/assessment.mac,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** assessment.mac 1 Dec 2010 18:32:25 -0000 1.1 --- assessment.mac 6 Dec 2010 16:03:38 -0000 1.2 *************** *** 7,10 **** --- 7,16 ---- /****************************************************************/ + MAXIMA_VERSION:map(parse_string, tokens(?\*autoconf\-version\*, 'digitcharp))$ + MAXIMA_VERSION_NUM:float(MAXIMA_VERSION[2]+MAXIMA_VERSION[3]/10)$ + + /* Note how Maxima has changes this.... */ + DIV_OP:"//"$ + if MAXIMA_VERSION_NUM>=15.0 then DIV_OP:"/"$ /* ********************************** */ *************** *** 52,55 **** --- 58,72 ---- )$ + /* This function makes a substitution of all variables for their lower case equivalents. + Useful when wanting to do a specific case sensitivity + check, e.g. that X^2=1 is x^2=1, without using subst_equiv. + + Note that exdowncase(X-x)=0, of course! + */ + exdowncase(ex):=block([lv], + lv:listofvars(ex), + lv:map(lambda([v],v=parse_string(sdowncase(string(v)))),lv), + return(subst(lv,ex)))$ + /* ********************************** */ *************** *** 123,127 **** lowesttermsp(ex) := block([simp:false,ex1,ex2,ex3], if atom(ex) then return(true), ! if op(ex)#STACK_DIV_OP then return(true), if gcd(num(ex),denom(ex))=1 then return(true) else return(false) )$ --- 140,144 ---- lowesttermsp(ex) := block([simp:false,ex1,ex2,ex3], if atom(ex) then return(true), ! if op(ex)#DIV_OP then return(true), if gcd(num(ex),denom(ex))=1 then return(true) else return(false) )$ *************** *** 131,135 **** if atom(ex) then (if numberp(ex) then return([ex]) else return([])) else ( ! if op(ex)=STACK_DIV_OP and simp_numberp(num(ex)) and simp_numberp(denom(ex)) then return([ex]), ex2:args(ex), flatten(maplist(list_expression_numbers,ex2))) --- 148,152 ---- if atom(ex) then (if numberp(ex) then return([ex]) else return([])) else ( ! if op(ex)=DIV_OP and simp_numberp(num(ex)) and simp_numberp(denom(ex)) then return([ex]), ex2:args(ex), flatten(maplist(list_expression_numbers,ex2))) *************** *** 227,228 **** --- 244,387 ---- polynomialpsimp(e):= polynomialp(e, listofvars(e))$ + /* ********************************** */ + /* Equivalence */ + /* ********************************** */ + + /* A general all purpose function on **expressions**. + Takes two objects and returns true if they are equal, and false otherwise + This is a "bash as hard as possible" function + */ + algebraic_equivalence(SA,SB) := + block([keepfloat,trigexpand,logexpand,ex,vi], + trigexpand:true, /* see pg 80 */ + logexpand:super, + keepfloat:true, /* see pg 23 */ + ex:errcatch(ev(fullratsimp(SA-SB),simp)), + if ex=[] then return(false), + ex:ex[1], + if floatnump(ex) then return(false), + ex:num(ex), /* after a fullratsimp, we have a ratio. We should only need to consider the top */ + ex:trigsimp(ex), + /* ex:trigreduce(ex), CJS, removed 21/1/2010. This was breaking ATSingleFrac! Don't know why. */ + if fullratsimp(ex)=0 then return(true), + ex:radcan(ex), + ex:factcomb(ex), + if fullratsimp(ex)=0 then return(true), + for vi:1 while ex#sqrtdenest(ex) do ex:sqrtdenest(ex), + if fullratsimp(ex)=0 then return(true) else return(false) + )$ + + /* This function takes two expressions. + It establishes if there exists a substitution of the variables of ex2 into ex1 which renders + ex1 algebraically equivalent to ex2. + If such a substitution exists the function returns it in a form so that + + ex2 = ev(ex1, subst_equiv(ex1,ex2)) + + If no such permutation exists it returns the empty list []. + If it could not establish this, because there are too many combinations to reasonably consider, + then the function returns false. + */ + subst_equiv(ex1,ex2):=block([lv1,lv2,lvi,lvp,lvs,lve,il,perm_size,simp], + simp:true, + perm_size:4, /* This algorithm is order factorial(perm_size) and so this needs to be small. */ + lv1:listofvars(ex1), + lv2:listofvars(ex2), + if length(lv1)#length(lv2) then return([]), + /* If the lists are too long, try a weaker condition */ + /* We assume the variables which occur in both are correctly assigned. */ + /* Can we find a permutation of those left in each? */ + if length(lv1)>perm_size then ( + lv1:setify(lv1), + lv2:setify(lv2), + lvi:intersection(lv1,lv2), + lv1:listify(setdifference(lv1,lvi)), + lv2:listify(setdifference(lv2,lvi)) + ), + if length(lv1)>perm_size then return(false), + /* */ + lvp:listify(permutations(lv2)), + /* Create a list of subsitutions */ + lvs:map(lambda([ex],zip_with("=",lv1,ex)),lvp), + /* Create list of expressions with which to compare ex1 */ + lve:map(lambda([ex],ev(ex1,ex)),lvs), + lve:map(lambda([ex],ATAlgEquivfun(ex,ex2)),lve), + lve:map(second,lve), + lve:map(lambda([ex],equal(ex,1)),lve), + if apply("or",lve) then (il:sublist_indices(lve,identity),lvs[il[1]]) else [] + )$ + + + /* ********************************** */ + /* Algebraic form tests */ + /* ********************************** */ + + /* expandp(p) is true if p equals its expanded form */ + expandp(p):= block([simp:true], if p=expand(p) then true else false)$ + + /* factorp(p) is true if p equals its factored form */ + factorp(p) := block([a], + if ev(p=factor(p),simp) then return(true), + if atom(p) then return(false), + /* Note, in Maxima factor((1-x)) = -(x-1), so we need to fix this, for learning and teaching! */ + if ev(-1*factor(p) = expand(-1*p),simp) then return(true), + if op(p)="^" and atom(part(p,1)) then return(true), + if op(p)="^" and factorp(part(p,1)) then return(true), + if op(p)="*" then return(all_listp(factorp,args(p))), + return(false) )$ + + + + /* ********************************** */ + /* Analysis tests */ + /* ********************************** */ + + /* This determines if an expression is continuous + ex the expression, + v the variable, + xp the point at which to evaluate. */ + continuousp(ex,v,xp) := block([lp,lm], + lp: ev(limit(ex,v,xp,minus),simp), + lm: ev(limit(ex,v,xp,plus),simp), + /* print(lp), print(lm), */ + if lp # und + and lm # und + and lp # ind + and lm # ind + and lp # inf + and lm # inf + and lp # minf + and lm # minf + and lp = lm + then true else false + )$ + + + /* This determines if an expression is differentiable + ex the expression, + v the variable, + xp the point at which to evaluate, + n the number of times it is differentiated (optional). + */ + diffp(ex,[args]) := block([v,xp,n], + v:args[1], + xp:args[2], + n:1, + if length(args)=3 then n:args[3], + return(continuousp(diff(ex,v,n),v,xp)) + )$ + + /* ********************************** */ + /* Buggy rules */ + /* ********************************** */ + + + /* (a+b)^n -> a^n+b^n */ + buggy_pow(ex) := block([ex_ex], + if atom(ex) then return(ex), + if op(ex)="/" and atom(part(ex,2))#true and op(part(ex,2))="+" then return(map(lambda([ex2],part(ex,1)/ex2),part(ex,2))), + if atom(part(ex,1)) or op(part(ex,1))#"+" then return(map(buggy_pow,ex)), + if op(ex)="^" then return(map(lambda([ex2],ex2^buggy_pow(part(ex,2))),map(buggy_pow,part(ex,1)))), + if op(ex)=sqrt then return(map(sqrt,map(buggy_pow,part(ex,1)))), + print(op(ex)) + )$ Index: unittests_load.mac =================================================================== RCS file: /cvsroot/stack/stack-dev/maxima/unittests_load.mac,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** unittests_load.mac 1 Dec 2010 18:32:25 -0000 1.5 --- unittests_load.mac 6 Dec 2010 16:03:38 -0000 1.6 *************** *** 5,9 **** /* NOTE: we need to run tests with simp:false and simp:true */ ! no_fails:0$ all_pass:true$ --- 5,11 ---- /* NOTE: we need to run tests with simp:false and simp:true */ ! /* C:\Program Files\Maxima-5.22.1\share\maxima\5.22.1\src */ ! /* The testsuite uses the function approx-alike (defined in src/mload.lisp) to check for equality. */ ! /* I think you'll need to write your own approx-alike function. */ no_fails:0$ all_pass:true$ Index: noun_arith.mac =================================================================== RCS file: /cvsroot/stack/stack-dev/maxima/noun_arith.mac,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** noun_arith.mac 19 Jan 2010 18:01:21 -0000 1.6 --- noun_arith.mac 6 Dec 2010 16:03:38 -0000 1.7 *************** *** 65,69 **** ex:subst("*","noun*",ex), ex:subst("-","noun-",ex), ! ex:subst(STACK_DIV_OP,"noun/",ex), ex:subst("^","noun^",ex), define(UNARY_RECIP a, a^(-1)), --- 65,69 ---- ex:subst("*","noun*",ex), ex:subst("-","noun-",ex), ! ex:subst(DIV_OP,"noun/",ex), ex:subst("^","noun^",ex), define(UNARY_RECIP a, a^(-1)), *************** *** 71,90 **** remfunction("noun+","noun*","noun/","noun^","noun-"),ex)$ - - /* This is too complex, OH! if I had thought of subst earlier...... :-( - - verb_arith_sum(a,b) := if listp(b) then a+apply("+",b) else a+b; - verb_arith_prod(a,b) := if listp(b) then a*apply("*",b) else a*b; - - verb_arith(ex) := block( - define((a noun+ [b]), 'verb_arith_sum(a,b)), - define((a noun* [b]), 'verb_arith_prod(a,b)), - define(a noun/ b, a/b), - define(a noun^ b, a^b), - define(noun- a, -1*a), - ex:ev(ex,nouns), - remfunction("noun+","noun*","noun/","noun^","noun-"),ex)$ - */ - /* (5) */ noun_arith(ex) := block( --- 71,74 ---- *************** *** 92,96 **** ex:subst("noun*","*",ex), ex:subst(lambda([ex],UNARY_MINUS noun* ex),"-",ex), /* Unary minus really communtes with multipication*/ ! ex:subst(lambda([ex1,ex2], ex1 noun* (UNARY_RECIP ex2)),STACK_DIV_OP,ex), /* Turn 1/x into x^(-1), in a special form */ ex:subst("noun^","^",ex), ev(ex))$ --- 76,80 ---- ex:subst("noun*","*",ex), ex:subst(lambda([ex],UNARY_MINUS noun* ex),"-",ex), /* Unary minus really communtes with multipication*/ ! ex:subst(lambda([ex1,ex2], ex1 noun* (UNARY_RECIP ex2)),DIV_OP,ex), /* Turn 1/x into x^(-1), in a special form */ ex:subst("noun^","^",ex), ev(ex))$ *************** *** 144,179 **** )$ - /* ************************************** */ - /* Test suite */ - /* ************************************** */ - - /* p:[/*x n+ x, - x n+ n- x n+ 1 n+ n- z, - n- z, - - z, */ - 1-z, - noun_arith(1-z), /* tex(1-z) works, but tex(noun_arith(1-z)) does not. - 1 + x n+ x, - 2 n* 3 n* x n+ z^2, - 1 + (x n+ x), - 2 n^ t, - x n^ 2 n+ 1, - 1 n/ (1 n+ n n^ 2), - 2 n/ 4, */ - sin(1 n+ x n^ 2)]$ - */ - - /* FOR kloop:1 THRU length(p) DO - (print(p[kloop]),tex(p[kloop]),ex:verb_arith(p[kloop]),print(ex),print(noun_arith(ex)),print(""))$ - */ - /* Things to consider: 7/11/9 - - (1) What about pushing -1 thorugh /, - eg x*(-y) vs -(x*y) - - (2) What about even powers? - e.g. (1-x)^2 vs (x-1)^2 - - */ --- 128,131 ---- Index: rtest_assessment_simpfalse.mac =================================================================== RCS file: /cvsroot/stack/stack-dev/maxima/rtest_assessment_simpfalse.mac,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rtest_assessment_simpfalse.mac 1 Dec 2010 18:32:25 -0000 1.2 --- rtest_assessment_simpfalse.mac 6 Dec 2010 16:03:38 -0000 1.3 *************** *** 99,100 **** --- 99,114 ---- "-\\left(x-1\\right)"$ + buggy_pow( 3*(x+1)^2 ); + 3*(x^2+1^2)$ + buggy_pow(x^(a+b)^2); + x^(a^2+b^2)$ + buggy_pow(x^(a+b)^(1/2)); + x^(a^(1/2)+b^(1/2))$ + buggy_pow((x+1)^(a+b)^2); + x^(a^2+b^2)+1^(a^2+b^2)$ + buggy_pow( 3*(x+1)^-1 ); + 3*(1/x+1/1)$ + buggy_pow( 3*(x+1)^-2 ); + 3*(1/x^2+1/1^2)$ + buggy_pow(sin(sqrt(a+b))); + sin(sqrt(a)+sqrt(b))$ |