1% randpoly.tst 2 3% F.J.Wright@Maths.QMW.ac.uk, 14 July 1994 4 5off allfac; on div, errcont; 6 7% Univariate: 8% ---------- 9randpoly x; 10% Equivalent to above: 11randpoly {x}; 12randpoly(x, dense); % univariate default already dense 13randpoly(x, degree=10, ord=5); 14 15% Bivariate: 16% --------- 17% Default is sparse 18randpoly {x,y}; 19randpoly({x,y}, dense); 20randpoly({x,y}, degree=10); 21% Lots of terms: 22randpoly({x,y}, dense, degree=10); 23randpoly({x,y}, dense, degree=10, ord=5); 24% Sparse: 25randpoly({x,y}, deg=10, ord=5); 26% Dense again: 27randpoly({x,y}, terms=1000, maxdeg=10, mindeg=5); 28 29% Exponent and coefficient functions: 30% ---------------------------------- 31randpoly({x,y}, expons = rand(-10 .. 10)); 32% Trivial example: 33randpoly({x,y}, expons = proc 5); 34randpoly({x,y}, expons = proc(2*random(0 .. 5))); 35 36randpoly({x,y}, coeffs = rand(-999 .. 999)); 37procedure coe; randpoly(a, terms=2)$ 38randpoly({x,y}, coeffs = coe); 39randpoly({x,y}, coeffs = coe, degree = 10); 40 41% Polynomials composed with general expressions: 42% --------------------------------------------- 43randpoly({x,y^2}); 44randpoly(x^2 - y^2); 45% This should give the constant term: 46sub(x=y, ws); 47randpoly({x^2 - a^2, y - b}); 48% This should give the constant term: 49sub(x=a, y=b, ws); 50 51% Polynomials with specified zeros: 52% -------------------------------- 53randpoly(x = a); 54% This should give 0: 55sub(x=a, ws); 56randpoly({x = a, y = b}); 57% This should give 0: 58sub(x=a, y=b, ws); 59 60% Invalid input detection: 61% ----------------------- 62randpoly({x,y}, degree=foo); 63randpoly({x,y}, foo); 64randpoly({x,y}, degree=-5); 65 66on allfac; off div, errcont; 67 68end; 69