randpoly.tst 1.6 KB

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