Return to the description of the Challenger puzzle

Create a random tomography puzzle


To test your tomography program on a variety of data, you will need some functions which will help you create a 'random' tomography program.  The functions below also create the equations that you will need to solve in order to find the solution to the tomography problem as it is presented on the web page.  These functions do not introduce 'errors' as was mentioned in the description of the problem, therefore you should be able to find an exact solution to the problems output by this function.  This may not be true of the problem listed in the picture.

Return a set of equations that represent those that wlll be necessary to set up to solve the tomographic problem.

> createtomogeqs:=proc() local i,j,blackeqs,blueeqs,redeqs,greeneqs;
blackeqs:=seq(add(x[i,j],j=1..5)=blk[i],i=1..5);
blueeqs:=seq((4*x[i+0,5]+x[i+1,5]+2*x[i+0,4]+3*x[i+1,4]
+x[i+0,3]/4+9*x[i+1,3]/2+x[i+2,3]/4+3*x[i+1,2]+2*x[i+2,2]
+x[i+1,1]+4*x[i+2,1])/5=blue[i],i=1..3);
redeqs:=seq(add((2*j-1)*x[i+0,j]+(11-2*j)*x[i+1,j],j=1..5)/10=red[i],
i=1..4);
greeneqs:=seq(add((2*j-1)*x[i+1,j]+(11-2*j)*x[i+0,j],j=1..5)/10
=green[i],i=1..4);
{blackeqs,blueeqs,redeqs,greeneqs};
end:

> createtomogeqs();

Given the list of values that you see in the diagram on the web page, return the equations with the black, blue, red and green values substitued in to their respective equation.

> substomogdata:=proc(blackvals,bluevals,redvals,greenvals) local i;
subs({seq(blk[i]=blackvals[i],i=1..5),
seq(blue[i]=bluevals[i],i=1..3),
seq(red[i]=redvals[i],i=1..4),
seq(green[i]=greenvals[i],i=1..4)},createtomogeqs());
end:

> substomogdata([4.,1.,5.,4.,3.], [3.1,3.7,4.4], [2.7,2.8,4.7,3.9], [2.3,3.2,4.3,3.1]);

Given a 5x5 matrix, return the list of values in the tomographic equations. Note that the output is of the form [blackeqns, blueeqns, redeqns, greeneqns]

> maketomogdata:=proc(sq5by5) local i,j;
subs({seq(seq(x[i,j]=sq5by5[i,j],i=1..5),j=1..5)}, createtomogeqs());
map(x->op(2,x) = op(1,x),%);
evalf(subs(%,[[seq(blk[i],i=1..5)],[seq(blue[i],i=1..3)],
[seq(red[i],i=1..4)],[seq(green[i],i=1..4)]]));
end:

> maketomogdata([[1,0,0,0,1], [1,1,0,1,1], [1,0,1,0,1], [1,0,0,0,1], [1,0,0,0,1]]);

> substomogdata(op(%));

Create a random 5x5 matrix with 0s and 1s

> rand5tomogmat:=proc() local i,j,sr;
sr:=rand(0..1);
[seq([seq(sr(),i=1..5)],j=1..5)];
end:

> rand5tomogmat();

> maketomogdata(%);

> substomogdata(op(%));
 

Return to the description of the Challenger puzzle