From: Chris S. <san...@us...> - 2005-11-15 09:38:09
|
Update of /cvsroot/stack/stack-1-0/scripts/maxima In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24976/scripts/maxima Modified Files: stackmaxima.mac Log Message: Index: stackmaxima.mac =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/maxima/stackmaxima.mac,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** stackmaxima.mac 10 Nov 2005 09:42:11 -0000 1.47 --- stackmaxima.mac 15 Nov 2005 09:38:01 -0000 1.48 *************** *** 829,847 **** ansnote: "ATPartFrac_single_fraction", fb:StackAddFeedback("","ATPartFrac_single_fraction") ! ) ! else if topOp = "+" or topOp = "-" or topOp = "*" then block([sExprPartFrac,oldsimp], oldsimp:simp, simp:true, val: "true", ! sExprPartFrac:ev(partfrac(sExpr,wrt),simp), ! if sExprPartFrac=expand(sExpr) or sExprPartFrac=sExpr then block( rawmk: string(1), ansnote:"ATPartFrac_true" ) ! else block( rawmk: string(0), ansnote:"ATPartFrac_false" ), - fb:StackAddFeedback("","ATPartFrac_true"), simp:oldsimp ), --- 829,869 ---- ansnote: "ATPartFrac_single_fraction", fb:StackAddFeedback("","ATPartFrac_single_fraction") ! ), ! if topOp = "*" then block([tExprPartFrac,sExprexpand,oldsimp], oldsimp:simp, simp:true, val: "true", ! tExprPartFrac:ev(partfrac(tExpr,wrt),simp), ! sExprexpand:expand(sExpr), ! if tExprPartFrac=sExprexpand or tExprPartFrac=sExpr or sameDenoms(sExprexpand,tExprPartFrac) then ! block( ! rawmk: string(1), ! ansnote:"ATPartFrac_true_*" ! ) ! else block( ! rawmk: string(0), ! ansnote:"ATPartFrac_false_*" ! ), ! simp:oldsimp ! ), ! if topOp = "+" or topOp = "-" then block([tExprPartFrac,oldsimp,val], ! oldsimp:simp, ! simp:true, ! val: "true", ! tExprPartFrac:ev(partfrac(tExpr,wrt),simp), ! if tExprPartFrac=expand(sExpr) or tExprPartFrac=sExpr then ! block( rawmk: string(1), ansnote:"ATPartFrac_true" ) ! else if sameDenoms(sExpr,tExprPartFrac) then ! block( ! rawmk: string(1), ! ansnote:"ATPartFrac_true_nonstd" ! ) ! else block( rawmk: string(0), ansnote:"ATPartFrac_false" ), simp:oldsimp ), *************** *** 976,1071 **** )$ - /*********************/ - /* Calculus question */ - /*********************/ - - /* An answer test for integration questions.*/ - /* sa is the students' ansewer, sbl is a list consisting of (1) the integrand, and (2) the variable */ - ATInt(sa,sbl) := - block([old_simp,KEEPFLOAT,RawMark,FeedBack,AnswerNote,str,da,db,dd,dc,sb,var,cont,ans,ex], - old_simp:simp, simp:true, RawMark:0, FeedBack:"", AnswerNote:"", - /* SBL is a list: the teacher's answer, the variable, and whether formative feedback is to be provided. */ - if listp(sbl) then (var:sbl[2], sb:diff(sbl[1],var), cont:TRUE) else - ( cont:FALSE, FeedBack:StackAddFeedback("","ATInt_error_list"), AnswerNote:"ATInt_error_list"), - - /* SA should be only an expression. */ - if expressionp(sa)=false then - return(StackReturnOb("false","0","ATInt_SA_not_expression",StackAddFeedback("","ATAlgEquiv_SA_not_expression"))), - - KEEPFLOAT:TRUE, /* See pg 23 */ - if cont then - (ans : int(sb,var), - da:diff(sa,var), - db:diff(sb,var), - ex:trigreduce(trigexpand(trigrat(sa-ans))), - dd:float(ex), - dc:numberp(dd) and dd#0.0, - if Stack_Test(da,sb) then - if dc then - (RawMark:0, FeedBack:StackAddFeedback("","ATInt_const_int"), AnswerNote:"ATInt_const_int") - else - if Stack_Test(sa,ans) then - (RawMark:0, FeedBack:StackAddFeedback("","ATInt_const"), AnswerNote:"ATInt_const") - else - (RawMark:1, AnswerNote:"Correct") - else - if Stack_Test(sa,db) then - (RawMark:0, FeedBack:StackAddFeedback("","ATInt_diff"), AnswerNote:"ATInt_diff") - else - (RawMark:0, FeedBack:StackAddFeedback("","ATInt_generic",StackDISP(sb,"$$"),StackDISP(var,"$"),StackDISP(da,"$$")), AnswerNote:"ATInt_generic") - ), /* End of cont loop */ - simp:old_simp, - return(StackReturnOb("true",STRING(RawMark),AnswerNote,FeedBack)) - )$ - - /* An answer test for differentiation questions.*/ - /* sa is the students' ansewer, sbl is a list consisting of (1) the integrand, and (2) the variable */ - ATDiff(sa,sbl) := - block([old_simp,KEEPFLOAT,RawMark,FeedBack,AnswerNote,str,da,db,dd,dc,sb,var,cont], - old_simp:simp, simp:true, RawMark:0, FeedBack:"", AnswerNote:"", - /* SBL is a list: the teacher's answer, the variable, and whether formative feedback is to be provided. */ - if listp(sbl) then (var:sbl[2], sb:sbl[1], cont:TRUE) else - ( cont:FALSE, FeedBack:StackAddFeedback("","ATDiff_error_list"), AnswerNote:"ATDiff_error_list"), - - /* SA should be only an expression. */ - if expressionp(sa)=false then - return(StackReturnOb("false","0","ATDiff_SA_not_expression",StackAddFeedback("","ATAlgEquiv_SA_not_expression"))), - - KEEPFLOAT:TRUE, /* See pg 23 */ - if cont then - ( - if Stack_Test(sa,sb) then - (RawMark:1, AnswerNote:"Correct") - else - if Stack_Test(diff(sa,var),int(sb,var)) then - (RawMark:0, AnswerNote:"ATDiff_int",FeedBack:StackAddFeedback("","ATDiff_int")) - ), /* End of cont loop */ - simp:old_simp, - return(StackReturnOb("true",STRING(RawMark),AnswerNote,FeedBack)) - )$ - - /*******************************************************************************/ - /* Very specific maxima functions */ - /*******************************************************************************/ - - - /* A function for one particular type of question! */ - - /* fntrans_unpack(ex) */ - /* ex is assumed to be an expression of the form, a*f(b*x+c)+d */ - /* That is to say, the result of applying some kind of grpahical transformation to f. */ - /* If the function sucesfully unpacks this, it returns the list [TRUE,a,b,c,d] */ - /* If the function fails, it returns [FALSE,a,b,c,d], where it goes as far as it can. */ - fntrans_unpack(ex):=block([f,l,aa,bb,cc,dd], - l:ex, - if atom(l) then return([FALSE,aa,bb,cc,dd]), - if op(l)="+" then (dd:part(l,2),l:part(l,1)) else dd:0, - if atom(l) then return([FALSE,aa,bb,cc,dd]), - if op(l)="*" then (aa:part(l,1),l:part(l,2)) else aa:1, - if op(l)=f then (l:part(l,1),bb:coeff(l,x,1),cc:coeff(l,x,0)) else return([FALSE,aa,bb,cc,dd]), - /* if atom(l) then return([FALSE,aa,bb,cc,dd]), */ - return([TRUE,aa,bb,cc,dd]) - )$ - /*****************************************************************/ --- 998,1001 ---- *************** *** 1153,1156 **** --- 1083,1112 ---- + /* When checking the form of a partial fraction, we need to ensure that the + *form* of the demoninators are the same. That is to say that the sets + of expressions on the denominators are equal, up to +/-1. For example, + we could have 1/(n+1)+1/(1-n) or 1/(n+1)-1/(n-1). This makes life harder! + */ + sameDenoms(SA,TA) := block([k,ret,sAargs,sAset,tAargs,tAset,dTA,dTB], + tAargs:args(TA), + tAset:set(), + /* Create a set of +-1*denoms in the teacher's expression */ + for k:1 thru length(tAargs) do block( + dTA : ev(expand(denom(tAargs[k])),simp), + dTB : ev(expand(-1*denom(tAargs[k])),simp), + tAset : union(set(dTA,dTB),tAset) + ), + /* Create a set of +-1*denoms in the student's expression */ + sAargs:args(SA), + sAset:set(), + for k:1 thru length(sAargs) do block( + dTA : ev(expand(denom(sAargs[k])),simp), + dTB : ev(expand(-1*denom(sAargs[k])),simp), + sAset : union(set(dTA,dTB),sAset) + ), + ret:setequality(sAset,tAset), + return(ret) + )$ + /* **************Numerator Same Test*************************** */ *************** *** 1168,1240 **** false ); - - - - - /* **************************PartFrac Test***************************** */ - /* requires: Student Answer */ - /* Teachers Question */ - /* Respect To which the fractions are parted */ - /* returns: StackReturnOb */ - /* CASE 1: topOp is divisor - single fraction */ - /* CASE 2: CORRECT answer - true */ - /* CASE 3: Different Variables - diff vars */ - /* CASE 4: Different amount of parts - Diff parts */ - /* CASE 5: Different Numerator - ret factored expression */ - /* CASE 6: Different Denominator - ret sDenom and tDenom */ - /* ******************************************************************** */ - - isPartFrac(sExpr, tExpr, wrt):= - block([val, rawmk, ansnote, fb], - rawmk: 0, fb: "", ansnote: "", ret: StackReturnOb(val,rawmk,ansnote,fb), - if factor( expand( sExpr ) ) = factor( expand( tExpr ) ) then - block( [topOp, list], - topOp: op(sExpr), list: args(sExpr), - if topOp = "//" then block( - val: "false", - rawmk : string(0), - ansnote: "ATPartFrac_single_fraction", - fb:"AtPartFrac_single_Fraction" - ) - else if topOp = "+" or topOp = "-" or topOp = "*" then block( - val: "true", - rawmk: string(1), - ansnote: "ATPartFrac_true", - fb: "AtPartFrac_true" - ), - ret: StackReturnOb(val,rawmk,ansnote,fb), - return(ret) - ) - else if sameVars(sExpr, tExpr) # true then - block( - val: "true", - rawmk: string(0), - ansnote : "ATPartFrac_diff_variables", - fb:"AtPartFrac_diff_variables" - ) - else - - block( - - [sDeg,tDeg], - sDeg: deg(denom(factor(sExpr))), - tDeg: deg(denom(factor(tExpr))), - sNDeg: deg(num(factor(sExpr))), - tNDeg: deg(num(factor(tExpr))), - if tNDeg # sNDeg then - block( - val:"true", - rawmk: string(0), - ansnote: "ATPartFrac_denom_ret", - fb: Sconcat("AtPartFrac_denom_ret ", denom(factor(sExpr)), " " , denom(factor(tExpr))) - ) - else - if sDeg = 2 then - quadTest(sExpr,tExpr,wrt) - else if sDeg = 3 then - tripTest(sExpr, tExpr, wrt) - - )); - /* **********************QUAD TEST***************************** */ --- 1124,1127 ---- *************** *** 1384,1387 **** --- 1271,1365 ---- ); + /*********************/ + /* Calculus question */ + /*********************/ + + /* An answer test for integration questions.*/ + /* sa is the students' ansewer, sbl is a list consisting of (1) the integrand, and (2) the variable */ + ATInt(sa,sbl) := + block([old_simp,KEEPFLOAT,RawMark,FeedBack,AnswerNote,str,da,db,dd,dc,sb,var,cont,ans,ex], + old_simp:simp, simp:true, RawMark:0, FeedBack:"", AnswerNote:"", + /* SBL is a list: the teacher's answer, the variable, and whether formative feedback is to be provided. */ + if listp(sbl) then (var:sbl[2], sb:diff(sbl[1],var), cont:TRUE) else + ( cont:FALSE, FeedBack:StackAddFeedback("","ATInt_error_list"), AnswerNote:"ATInt_error_list"), + + /* SA should be only an expression. */ + if expressionp(sa)=false then + return(StackReturnOb("false","0","ATInt_SA_not_expression",StackAddFeedback("","ATAlgEquiv_SA_not_expression"))), + + KEEPFLOAT:TRUE, /* See pg 23 */ + if cont then + (ans : int(sb,var), + da:diff(sa,var), + db:diff(sb,var), + ex:trigreduce(trigexpand(trigrat(sa-ans))), + dd:float(ex), + dc:numberp(dd) and dd#0.0, + if Stack_Test(da,sb) then + if dc then + (RawMark:0, FeedBack:StackAddFeedback("","ATInt_const_int"), AnswerNote:"ATInt_const_int") + else + if Stack_Test(sa,ans) then + (RawMark:0, FeedBack:StackAddFeedback("","ATInt_const"), AnswerNote:"ATInt_const") + else + (RawMark:1, AnswerNote:"Correct") + else + if Stack_Test(sa,db) then + (RawMark:0, FeedBack:StackAddFeedback("","ATInt_diff"), AnswerNote:"ATInt_diff") + else + (RawMark:0, FeedBack:StackAddFeedback("","ATInt_generic",StackDISP(sb,"$$"),StackDISP(var,"$"),StackDISP(da,"$$")), AnswerNote:"ATInt_generic") + ), /* End of cont loop */ + simp:old_simp, + return(StackReturnOb("true",STRING(RawMark),AnswerNote,FeedBack)) + )$ + + /* An answer test for differentiation questions.*/ + /* sa is the students' ansewer, sbl is a list consisting of (1) the integrand, and (2) the variable */ + ATDiff(sa,sbl) := + block([old_simp,KEEPFLOAT,RawMark,FeedBack,AnswerNote,str,da,db,dd,dc,sb,var,cont], + old_simp:simp, simp:true, RawMark:0, FeedBack:"", AnswerNote:"", + /* SBL is a list: the teacher's answer, the variable, and whether formative feedback is to be provided. */ + if listp(sbl) then (var:sbl[2], sb:sbl[1], cont:TRUE) else + ( cont:FALSE, FeedBack:StackAddFeedback("","ATDiff_error_list"), AnswerNote:"ATDiff_error_list"), + + /* SA should be only an expression. */ + if expressionp(sa)=false then + return(StackReturnOb("false","0","ATDiff_SA_not_expression",StackAddFeedback("","ATAlgEquiv_SA_not_expression"))), + + KEEPFLOAT:TRUE, /* See pg 23 */ + if cont then + ( + if Stack_Test(sa,sb) then + (RawMark:1, AnswerNote:"Correct") + else + if Stack_Test(diff(sa,var),int(sb,var)) then + (RawMark:0, AnswerNote:"ATDiff_int",FeedBack:StackAddFeedback("","ATDiff_int")) + ), /* End of cont loop */ + simp:old_simp, + return(StackReturnOb("true",STRING(RawMark),AnswerNote,FeedBack)) + )$ + + /*******************************************************************************/ + /* Very specific maxima functions */ + /*******************************************************************************/ + + + /* A function for one particular type of question! */ + + /* fntrans_unpack(ex) */ + /* ex is assumed to be an expression of the form, a*f(b*x+c)+d */ + /* That is to say, the result of applying some kind of grpahical transformation to f. */ + /* If the function sucesfully unpacks this, it returns the list [TRUE,a,b,c,d] */ + /* If the function fails, it returns [FALSE,a,b,c,d], where it goes as far as it can. */ + fntrans_unpack(ex):=block([f,l,aa,bb,cc,dd], + l:ex, + if atom(l) then return([FALSE,aa,bb,cc,dd]), + if op(l)="+" then (dd:part(l,2),l:part(l,1)) else dd:0, + if atom(l) then return([FALSE,aa,bb,cc,dd]), + if op(l)="*" then (aa:part(l,1),l:part(l,2)) else aa:1, + if op(l)=f then (l:part(l,1),bb:coeff(l,x,1),cc:coeff(l,x,0)) else return([FALSE,aa,bb,cc,dd]), + /* if atom(l) then return([FALSE,aa,bb,cc,dd]), */ + return([TRUE,aa,bb,cc,dd]) + )$ /* Stack expects some output */ |