Tuesday, February 25, 2014

#codemaths: algebra functions and image URLs

I've added some function (for my own benefit really) that saves time in anticipating many scenarios in generating random questions--reduce() and coeff() functions using the #codemaths application.

When used, the reduce function can simplify fractions. For example, for random variables a and b, reduce(a,b) would simplify a=4 and b=1 to 4 and a=2 and b=4 to 1/2. It is still your job to make sure b is not zero with the constraints.

The coefficient function allows expressions to be simplified--most helpful for anticipating the best final answer. There are some specific options to differentiate how it is used.
If I have the expression ax+by=c using random values for a,b and c (again making sure 'a' and 'b' aren't zero in the constraints), if I use the coeff function I can programmatically simplify the scenario 1x+-4y=5 to x-4y=5. 
To code it you need to use "lead" for a coefficient like a that is the lead coefficient in the expression and "constant" if a term you want to simplify is just a constant term with no variable. 
In the example above you would code <coeff(a,"lead")>x<coeff(b)>y=<c>. In this case you don't need the "constant" or coeff fuction for c. The equation 1x+-1y=3 would simplify to x-y=3.
That could be used in this example however: ax+b=c: <coeff(a,"lead")>x<coeff(b,"constant")>=<c>. The equation 1x+-1=3 would simplify to x-1=3.
You can also now use a url of an image to be included in a question such as this one:

No comments:

Post a Comment