[Aimmath-commit] AIM/WEB-INF/maple Random.mpl,1.14,1.15 RandArgs.mpl,1.3,1.4
Brought to you by:
gustav_delius,
npstrick
From: <mo...@us...> - 2004-03-13 00:52:34
|
Update of /cvsroot/aimmath/AIM/WEB-INF/maple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30268 Modified Files: Random.mpl RandArgs.mpl Log Message: minor improvements Index: Random.mpl =================================================================== RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/Random.mpl,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Random.mpl 21 Feb 2004 03:51:36 -0000 1.14 --- Random.mpl 13 Mar 2004 00:43:51 -0000 1.15 *************** *** 468,472 **** "Produces a \"nice\" binomial from its arguments (which is more complicated than it sounds). If one looks through the problems assigned in a typical calculus or precalc book, one will notice that there are certain rules that authors tend to follow when designing \"nice\" questions. This procedure attempts to produce a \"nice\" random binomial of the form @a*x^n+b*y^m@ where @a:=Rand(arange)@, @b:=Rand(brange)@, @x:=Rand(_x)@, @y:=Rand(_y)@, @n:=Rand(deg)@, and @m:=Rand(ydeg)@. Only the argument @x@ is mandatory. Both @x@ and @y@ can be any any algebraic expression or Inert Expression.", proc(_x,deg,arange,brange,_y,ydeg) ! local n,a,b,ar,br,i,x,y,m; --- 468,472 ---- "Produces a \"nice\" binomial from its arguments (which is more complicated than it sounds). If one looks through the problems assigned in a typical calculus or precalc book, one will notice that there are certain rules that authors tend to follow when designing \"nice\" questions. This procedure attempts to produce a \"nice\" random binomial of the form @a*x^n+b*y^m@ where @a:=Rand(arange)@, @b:=Rand(brange)@, @x:=Rand(_x)@, @y:=Rand(_y)@, @n:=Rand(deg)@, and @m:=Rand(ydeg)@. Only the argument @x@ is mandatory. Both @x@ and @y@ can be any any algebraic expression or Inert Expression.", proc(_x,deg,arange,brange,_y,ydeg) ! local n,a,b,ar,br,i,x,y,m,Tym,Txn; *************** *** 486,489 **** --- 486,492 ---- if nargs>5 then m:=Rand(ydeg) fi; + Txn:=`if`(n=1,x,ToThe(x,n)); + Tym:=`if`(m=1,y,ToThe(y,m)); + # don't let them both be negative for i to 20 do *************** *** 525,532 **** # overridden... use b if nargs>3 then ! return Plus(Times(b,ToThe(y,m)),Times(a,ToThe(x,n))); # default.. don't use b else ! return Plus(1,Times(a,ToThe(x,n))); fi; # b is negative so put it second --- 528,535 ---- # overridden... use b if nargs>3 then ! return Plus(Times(b,Tym),Times(a,Txn)); # default.. don't use b else ! return Plus(1,Times(a,Txn)); fi; # b is negative so put it second *************** *** 534,544 **** # overridden... use both if nargs>3 then ! return Plus(Times(a,ToThe(x,n)),Times(b,ToThe(y,m))); # only a was overidden, so ignore b elif nargs=3 then ! return Plus(1,Times(a,ToThe(x,n))); # default...use just one else ! return Rand(Plus(ToThe(x,n),b),Plus(1,Times(a,ToThe(x,n)))) fi # neither are negative so it doesn't matter who is first --- 537,547 ---- # overridden... use both if nargs>3 then ! return Plus(Times(a,Txn),Times(b,Tym)); # only a was overidden, so ignore b elif nargs=3 then ! return Plus(1,Times(a,Txn)); # default...use just one else ! return Rand(Plus(Txn,b),Plus(1,Times(a,Txn))) fi # neither are negative so it doesn't matter who is first *************** *** 546,557 **** # b overridden... use both if nargs>3 then ! return Plus(Rand(Permute(Times(b,ToThe(y,m)),Times(a,ToThe(x,n))))); # only a was overidden, so ignore b elif nargs=3 then ! return Plus(1,Times(a,ToThe(x,n))); # default...use just one in either order else ! return Rand(Fn(Plus,Permute(b,ToThe(x,n))), ! Plus(1,Times(a,ToThe(x,n))) ); fi --- 549,560 ---- # b overridden... use both if nargs>3 then ! return Plus(Rand(Permute(Times(b,Tym),Times(a,Txn)))); # only a was overidden, so ignore b elif nargs=3 then ! return Plus(1,Times(a,Txn)); # default...use just one in either order else ! return Rand(Fn(Plus,Permute(b,Txn)), ! Plus(1,Times(a,Txn)) ); fi Index: RandArgs.mpl =================================================================== RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/RandArgs.mpl,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RandArgs.mpl 16 Feb 2004 03:17:56 -0000 1.3 --- RandArgs.mpl 13 Mar 2004 00:43:51 -0000 1.4 *************** *** 127,130 **** --- 127,138 ---- `Package/Assign`(`Rand/Recip/Binomial/Power_Posint/Integer`,"", Fn(Over,`Rand/NonzeroInteger`,`Rand/Binomial/Power_Posint/Integer`)): + `Package/Assign`(`Rand/Recip/Binomial/Quadratic/Integer/PosCoeffs`,"", + Fn(Over,`Rand/Posint`, + [Fn(Plus, + `Rand/Posint`, + Fn(Times,`Rand/Posint`,ToThe(x,2))), + Fn(Plus, + Fn(Times,`Rand/Posint`,ToThe(x,2)), + `Rand/Posint`)])); `Package/Assign`(`Rand/Recip/Binomial/Trans/Root`,"", Fn(Over,`Rand/NonzeroInteger`,`Rand/Binomial/Trans/Root`)): *************** *** 1309,1312 **** --- 1317,1321 ---- "Rand/Recip/Binomial/Linear", "Rand/Recip/Binomial/Power_Posint/Integer", + "Rand/Recip/Binomial/Quadratic/Integer/PosCoeffs", "Rand/Recip/Binomial/Trans/Root", "Rand/Recip/Binomial/Trans/Integer", |