p-derivation function for p an odd prime

This function was written in collaboration with Michael Wester. Note that it does not return a simplified (-1)^p = -1. This must be done after application.

>

> # ---------- Programming and Miscellaneous ----------
# Define a simple differentiation operator. This is
# most easily done with recursion!!! our friend.

pdiff:= proc(e) local oper, n;
oper:= op(0, e);
n:= nops(e);

# Start by making the derivative of a sum to be the
# sum of the derivatives.
if oper = `+` then
map(pdiff, e) + cpext(e)
# Actual value of cpext() ( map(x -> x^p, e) - e^p)/p

# Add the product rule.
elif oper = `*` then
pdiff(op(1, e)) * product((op(i, e))^p, i = 2..n) +
op(1, e)^p * pdiff(product(op(i, e), i = 2..n))
+ p*pdiff(op(1,e))*pdiff(product(op(i, e), i = 2..n))

# Before we define a p-derivation of an integer we
# add in this special case because p is always odd.
elif e = -1 then
0

# Now, make the derivative of a constant (c - c^p )/p.
elif oper=integer then
delta(e) # (e - e^p)/p

# Define the derivative of x with respect to x to be one.
elif oper = symbol then
delta (e)

# Enter the generalized power rule for positive powers.
elif oper = `^` and sign(op(2, e))>0 then
(1/p)*(-(op(1,e))^(op(2,e)*p) + ((op(1,e)^p + p*pdiff(op(1,e)))^op(2,e)))


# Enter the generalized power rule for negative powers.
elif oper = `^` and sign(op(2, e))<0 then
-pdiff(op(1,e)^(-(op(2,e))))/(op(1,e)^(-p*op(2,e))
*(op(1,e)^(-p*op(2,e)) + p*pdiff(op(1,e)^(-op(2,e)))))

# Enter the case to default to if none of the above are valid.
else
delta (e);

fi
end;

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

> # ---------- Programming and Miscellaneous ----------
# Define a p-derivation operator modulo p This is
# most easily done with recursion!!! our friend.

pdiffmodp:= proc(e) local oper, n;
oper:= op(0, e);
n:= nops(e);

# Start by making the derivative of a sum to be the
# sum of the derivatives.
if oper = `+` then
map(pdiffmodp, e) + cpext(e)
# Actual value of cpext() ( map(x -> x^p, e) - e^p)/p

# Add the product rule.
elif oper = `*` then
pdiffmodp(op(1, e)) * product((op(i, e))^p, i = 2..n) +
op(1, e)^p * pdiffmodp(product(op(i, e), i = 2..n))

# Before we define a p-derivation of an integer we
# add in this special case because p is always odd.
elif e = -1 then
0

# Now, make the derivative of a constant (c - c^p )/p.
elif oper=integer then
delta(e) # (e - e^p)/p

# Define the derivative of x with respect to x to be one.
elif oper = symbol then
delta (e)

# Enter the generalized power rule for positive powers.
elif oper = `^` and sign(op(2, e))>0 then
(op(2,e))*(op(1,e))^((op(2,e)-1)*p )* pdiffmodp(op(1,e))


# Enter the generalized power rule for negative powers.
elif oper = `^` and sign(op(2, e))<0 then
-pdiffmodp(op(1,e)^(-(op(2,e))))/(op(1,e)^(-2*p*op(2,e)))

# Enter the case to default to if none of the above are valid.
else
delta (e);

fi
end;

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

> pdiffmodp(x+y);

[Maple Math]

> expand(pdiffmodp(x*y*z));

[Maple Math]

> pdiff(z/(z+y));

[Maple Math]
[Maple Math]

>