dharr

Dr. David Harrington

8917 Reputation

22 Badges

21 years, 142 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a retired professor of chemistry at the University of Victoria, BC, Canada. My research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity


These are replies submitted by dharr

%0 in the message string in userinfo would give the comma

restart;

showargs:=proc()
userinfo(2,procname,"1. arguments: ",_passed);
userinfo(2,procname,"2. arguments: %0",_passed);
NULL
end proc;

proc () userinfo(2, procname, "1. arguments: ", args); userinfo(2, procname, "2. arguments: %0", args); NULL end proc

infolevel[showargs]:=2;

2

showargs(y(x),sin(y));

showargs: 1. arguments:  y(x) sin(y)

showargs: 2. arguments: y(x), sin(y)

NULL

Download userinfo.mw

@Blanc Is this what you want?

restart

with(GroupTheory)

Define group operation and inverse for additive group mod 53.

n := 53

53

Z := module() export `.`, `/`;
`.`:=(a,b)->a+b mod n; # multiplication rule
`/`:=a->-a mod n;      # inverse of a
end module;

_m2104944203328

Use 1 to generate the group

G := CustomGroup([1], Z); GroupOrder(G)

_m2104873192640

53

els := [Elements(G)[]]

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52]

As expected the orders of all elements except the identity are equal to the group order. Therefore they can all generate the group

map(ElementOrder, els, G)

[1, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53]

We can check by seeing if we can generate the same group from one of these elements

G2 := CustomGroup([23], Z); Elements(G2)

_m2104979438784

{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52}

Some group tests etc are easier if we have a permutation group. Convert it to a permutation group

PG := PermutationGroup(G); g := GroupOrder(PG); IsCyclic(PG)

_m2104894529568

53

true

Find the elements that have ElementOrder equal to the group order

gens, notgens := selectremove(proc (i) options operator, arrow; ElementOrder(i, PG) = g end proc, [Elements(PG)[]])

The identity is not a generator; the other 52 are.

notgens; nops(gens)

[_m2104893251488]

52

We could check by generating the group with an element and see if we get the same group

el27 := Elements(PG)[28]

_m2104972448896

PG2 := Group({el27})

_m2104815721152

evalb(Elements(PG) = Elements(PG2))

true

NULL

Download CyclicGp.mw

@nm Since you were originally interested in the integral, why not just

seq(evalf(Int(sqrt(1+sin(x)^2),x=0..phi)),phi=-3..3,0.5);

which gives the same as MMA. But if you really want to go from the EllipticE, then

restart;

[seq(evalf(Int(sqrt(1+sin(x)^2),x=0..phi)),phi=-3..3,0.5)];

[-3.678135309, -3.140058363, -2.507982114, -1.810019561, -1.123887723, -.5191743566, 0., .5191743566, 1.123887723, 1.810019561, 2.507982114, 3.140058363, 3.678135309]

q:=[seq(int(sqrt(1+sin(x)^2),x=0..phi), phi=-3..3, 1/2)];

[-2^(1/2)*EllipticE((-sin(3)^2+1)^(1/2), (1/2)*2^(1/2))-2^(1/2)*EllipticE((1/2)*2^(1/2)), -2^(1/2)*EllipticE((-sin(5/2)^2+1)^(1/2), (1/2)*2^(1/2))-2^(1/2)*EllipticE((1/2)*2^(1/2)), -2^(1/2)*EllipticE((-sin(2)^2+1)^(1/2), (1/2)*2^(1/2))-2^(1/2)*EllipticE((1/2)*2^(1/2)), -2^(1/2)*EllipticE((1/2)*2^(1/2))+2^(1/2)*EllipticE((1-sin(3/2)^2)^(1/2), (1/2)*2^(1/2)), -2^(1/2)*EllipticE((1/2)*2^(1/2))+2^(1/2)*EllipticE((1-sin(1)^2)^(1/2), (1/2)*2^(1/2)), -2^(1/2)*EllipticE((1/2)*2^(1/2))+2^(1/2)*EllipticE((1-sin(1/2)^2)^(1/2), (1/2)*2^(1/2)), 0, 2^(1/2)*EllipticE((1/2)*2^(1/2))-2^(1/2)*EllipticE((1-sin(1/2)^2)^(1/2), (1/2)*2^(1/2)), 2^(1/2)*EllipticE((1/2)*2^(1/2))-2^(1/2)*EllipticE((1-sin(1)^2)^(1/2), (1/2)*2^(1/2)), 2^(1/2)*EllipticE((1/2)*2^(1/2))-2^(1/2)*EllipticE((1-sin(3/2)^2)^(1/2), (1/2)*2^(1/2)), 2^(1/2)*EllipticE((-sin(2)^2+1)^(1/2), (1/2)*2^(1/2))+2^(1/2)*EllipticE((1/2)*2^(1/2)), 2^(1/2)*EllipticE((1/2)*2^(1/2))+2^(1/2)*EllipticE((-sin(5/2)^2+1)^(1/2), (1/2)*2^(1/2)), 2^(1/2)*EllipticE((1/2)*2^(1/2))+2^(1/2)*EllipticE((-sin(3)^2+1)^(1/2), (1/2)*2^(1/2))]

evalf(q);

[-3.678135308, -3.140058362, -2.507982114, -1.810019561, -1.123887723, -.519174356, 0., .519174356, 1.123887723, 1.810019561, 2.507982114, 3.140058362, 3.678135308]

q:=signum(phi)*(sqrt(2)*EllipticE(sqrt(2)/2) + sqrt(2)*EllipticE(sqrt(-sin(3)^2 + 1), sqrt(2)/2));

signum(phi)*(2^(1/2)*EllipticE((1/2)*2^(1/2))+2^(1/2)*EllipticE((-sin(3)^2+1)^(1/2), (1/2)*2^(1/2)))

[seq(evalf(q),phi=-3..3, 0.5)];

[-3.678135308, -3.678135308, -3.678135308, -3.678135308, -3.678135308, -3.678135308, 0., 3.678135308, 3.678135308, 3.678135308, 3.678135308, 3.678135308, 3.678135308]

NULL

Download EllipticE.mw

@Blanc What calculations do you want to do with them? You can set up these as a custom Group, but if you just want to calculate with them then just using the mod operator is simpler and already built in, e.g. 41 + 27 mod 53. Are you only interested in mod a prime?

@nm You are right - there are different definitions. 

restart;

EllipticE(phi, k) is given by DLMF 19.2.5 as int(sqrt(1-k^2*sin(x)^2), x = 0 .. phi) = int(sqrt(-k^2*t^2+1)/sqrt(-t^2+1), t = 0 .. sin(phi))but they point out that A&S used the upper limit in the second integral as z. Maple uses this second convention. Now Mathematica uses this second convention but takes the second argument m to be what Maple calls k^2. So when Maple produces second argument I, that is equivalent to MMA's second argument -1. So for the integral in question we expect EllipticE(sin(x),I)

II:=simplify(int(sqrt(1+sin(x)^2),x));
simplify(%, symbolic);

csgn(cos(x))*EllipticE(sin(x), I)

EllipticE(sin(x), I)

which suggests we need some appropriate assumptions to get the simpler result. The following works

simplify(II) assuming cos(x)>1;

EllipticE(sin(x), I)

int(sqrt(1+sin(x)^2),x=0..phi,AllSolutions);

piecewise(0 < phi, 2*EllipticE((1/2)*sqrt(2))*sqrt(2)*ceil(-(-2*phi+Pi)/(4*Pi))+2*EllipticE((1/2)*sqrt(2))*sqrt(2)*ceil(-(-2*phi+3*Pi)/(4*Pi))+piecewise((-(-2*phi+Pi)/(2*Pi))::integer, EllipticE((1/2)*sqrt(2))*sqrt(2), sqrt(-cos(phi)^2+2)*cos(phi)*EllipticE(sin(phi), I)/sqrt(-sin(phi)^4+1)), phi <= 0, 2*EllipticE((1/2)*sqrt(2))*sqrt(2)*floor(-(-2*phi+Pi)/(4*Pi))+2*EllipticE((1/2)*sqrt(2))*sqrt(2)*floor(-(-2*phi+3*Pi)/(4*Pi))+piecewise((-(-2*phi+Pi)/(2*Pi))::integer, -EllipticE((1/2)*sqrt(2))*sqrt(2), sqrt(-cos(phi)^2+2)*cos(phi)*EllipticE(sin(phi), I)/sqrt(-sin(phi)^4+1))+4*EllipticE((1/2)*sqrt(2))*sqrt(2))

Download EllipticE.mw

@nm I suppose there could be different definitions.

Please define what you mean by primitive element.

@Suryakanth The approximate solution for theta_p you provide could be a straight line going down to zero at Y=10, rather than an exponential decay if you prefer; it only has to look approximately right. I think you are trying to reproduce Fig 2. But there is no f(Y) or F(Y) given so there is not enough information for me to know what they look like and to know what an approximate solution would look like.

As I said, there may be no mistake. (But I didn't check your equations.)

@Suryakanth This does not mean there is an error in the equations (though there might be). Maple needs some help to start with. The solution to this is to give a list of approximate solutions using the 'approxsoln' option. For example, theta(Y) could be given as an exponential decay function, since that is what it looks like; similarly for Theta_p. Only you know what F and f look like.

This error can also arise from an incorrect formulation of the equations. For example a decaying function with BC D(f)(0) = -1 is accidentally given BC D(f)(0) = 1, so then Maple is expecting an increasing function.

@acer I am using Maple 2025.2, so looks like a regression. Looks like the code in `simplify/table` has been updated to use Cache. 

@nm The forget commands at the top of your worksheet just do the forgetting then. I don't know how to change things permanently. If you knew the exact subprocedure which was giving the problem and had option remember, you could perhaps hack it to remove the option but I wouldn't recommend that.

[Edit: the remembered values are in a cache - see op(4,eval(`simplify/table`)), and there is some updating of the table, but it is not as simple as removing option remember.  forget.mw  ]

Yes I see this with the error messages but not when uploading to Mapleprimes. Presumably a Mapleprimes site issue.

@sand15 Thanks for the comments. As a side point I think I found the effect of the ill-conditioning - if I look at the roots of the denominator and numerator polynomials for the [7,9] case, two of the numerator roots are very close to two of the denominator roots, so it is almost equivalent to a [5,7] case.

Also the Statistics package - see the help page ?Statistics,Regression

There is also the Optimization package, but those are in hardware floating point.

Not entirely clear what your specific requirements are.

@salim-barzani I think you are saying you want to keep the ode in G(xi) and not use a specific solution. In many cases the solution to the ode may not be known, but in this case it is just the harmonic oscillator equation, so it seems to be that using the general solution c[1]*exp(h*xi)+c[2]*exp(-h*xi) (or its equivalent sin/cos form) is entirely equivalent to using the ode.

Then from the solved eqs one can select c[1] and c[2] to cover the specific cases you want, sinh, cosh, exp or (with imaginary h) sin, cos, or why not the general solution? In this case the solutions don't depend on c[1], c[2] or h, so any of the solutions works. 

dsolve.mw

1 2 3 4 5 6 7 Last Page 2 of 96