[LON-CAPA-dev] Installing Modules for LON-CAPA

Gerd Kortemeyer lon-capa-dev@mail.lon-capa.org
Mon, 26 Sep 2005 16:10:47 -0400


Hi Donnell,

On Sep 26, 2005, at 3:33 PM, GARRETT, DONNELL MAZON wrote:

> Hi
>
> That was an example... maybe one that is too simple to show what I'm
> trying to do.
>
> Let's say we want to solve for x and y, and if we randomly generate A,
> B, C, D, E, and F, then
>
> xA + yB = C
> xD + yE = F
>
> how can we find x and y using an algorithm that we don't have to  
> cut and
> paste into each and every problem.


Yep, you can use the .library mechanism (as Guy explained) to write  
routines that you can then <import> into any problem.

But, what I was trying to suggest is building your problem the other  
way around, i.e., randomly determine the solution first.

$x=&random(-4,4,3);
$y=&random(-4,7,3);

Then generate your coefficients:

$a=&random(4,8,1);
$b=&random(4,8,1);
$d=&random(5,9,1);

Now, when determining your $e, you just need to make sure that the  
second equation is not a multiple of the first:

$e=$d/$a*$b+&random(4,8,1);

Then calculate your $c and $f:

$c=$a*$x+$b*$y;
$f=$d*$x+$e*$y;

To your students, you just give $a, $b, $c, $d, $e, and $f, of  
course. Solving an equation system is computing-intensive,  
constructing one is not - and there is no reason why LON-CAPA needs  
to do the same work that the students do.

But maybe the example is really too simple.

- Gerd.