A blog is that is all about mathematics and calculators, two of my passions in life.

Friday, August 5, 2016

HP Prime CAS: Degree of a Polynomial and Homogeneous Test

HP
Prime CAS: Degree of a Polynomial and Homogeneous Test

Note

The
following two programs degpoly and ishomogeneous are CAS Mode specific
programs. When you are creating a new
program file in this instance, make sure the CAS box is checked on the New
Program screen (see below).

Degree of
a Polynomial

The
program degpoly is a more complete version of the degree command. The degree command tests a single variable,
default to x if no variable is specified.
The program degpoly calculates the degree of a polynomial, considering
four variables: x, y, z, and t.
Combinations of these four variables, such as x*y, x*y*z, and t*z are also
considered.

HP Program degpoly:

#cas

degpoly(poly):=

BEGIN

// 2016-07-31 EWS

// x,y,z,t

LOCAL tms,cnt,pt,lst,wp,dg,dgr;

tms:=part(poly);

lst:={};

FOR pt FROM 1 TO tms DO

wp:=part(poly,pt);

dg:=degree(wp,x)+degree(wp,y)+

degree(wp,z)+degree(wp,t);

lst:=concat(lst,{dg});

END;

dgr:=MAX(lst);

return dgr;

END;

#end

I
recommend that you type out the commands when programming in CAS mode. Make sure the suffix “CAS.” is removed from
any command inside the program.

Accessing
CAS Programs

In
CAS mode, press [Vars], then the soft key (CAS), select Program for the list of
programs

Examples:

degpoly(x^2
+ 3*x – 1) returns 2

degpoly(x^2
+ 3*y – 1) returns 2

degpoly(x*y
– y^2 + t) returns 2

degpoly(x^2*y^2
– 3*z^2) returns 4

Polynomial Homogeneous
Test

A
polynomial is homogeneous if all of the nonzero terms has the same degree. Tests a polynomial of four variables x, y, z,
and t and their combinations (x*y, x*z, x*y*z, etc). If the polynomial in question is homogeneous,
the program returns a 1 (for true), otherwise 0 is returned (for false).