# Question:How does the program terminate after exactly 1 solution has been found?

## Question:How does the program terminate after exactly 1 solution has been found?

Maple

Hi!

In the program below, all solutions are found for the equation S.R=T subject to

the constraints given by eq1 and eq2. I've tried it for a

few different choices of T and there's usually 80+ solutions.

I want to try more complicated choices of T (for example,

I want the matrix T to have every entry a distinct prime number).

But then the program crashes. I assume the equations get complicated

or there are just too many solutions. My question is, is there a way to

have the program self-terminate once exactly 1 solution is found?

I do not need all solutions, I am simply trying to find a specific T such that the

equation does NOT hold, thus once a solution is found for my choice of T then

it's enough and I want the program to terminate so that I can try another

choice of T. The program is below. How can it be modified? THANKS!

` `

restart;
S := Matrix( [ [a_1, a_2, a_3, a_4], [b_1, b_2, b_3, b_4], [c_1, c_2, c_3, c_4], [d_1, d_2, d_3, d_4] ] );
eq1:=a_1*d_1 = b_1*c_1, a_2*d_2 = b_2*c_2, a_3*d_3 = b_3*c_3, a_4*d_4 = b_4*c_4;
R := Matrix( [ [s_1, t_1, r_1, l_1], [s_2, t_2, r_2, l_2], [s_3, t_3, r_3, l_3], [s_4, t_4, r_4, l_4] ] );
eq2:=s_1*l_1 = t_1*r_1,s_2*l_2 = t_2*r_2,s_3*l_3 = t_3*r_3,s_4*l_4 = t_4*r_4;
T := Matrix( [ [1, 0, 0, 1], [0, 1, 0, 0], [0, 1, 0, 0], [1, 0, 0, 1] ] );
S.R=~T;
convert(%,set);
res:=solve(% union {eq1,eq2});
nops([res]);
res[1];

﻿