Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I'm interested in created a group ring, but have no idea how to do it.

In short, a group ring is a free module with the scalars as elements of a ring,R, and the vectors as elements in a group, G. [Wikipedia has a decent description.]

Elements a=r0*g0 and b=r1*g1 have sum a+b=r0*g0+r1*g1 and product a*b=r0*r1*g0*g1

The distributive property is followed.

Suggestions?

Is there a way to remove a unit symbol?  "AddUnit" allows to add additional symbols or change the default symbol, but I don't see any way to remove symbols?

A good example is for the hectare.  Maple 2023 uses "a" as the default symbol for the are, except that the unit symbol "a" does not allow using SI prefixes because the peta- unit prefix then conflicts with the pascal ("Pa").  I can use "AddUnit" to change the default symbol for the are from "a" to "are" but I still cannot enable SI prefixes unless the symbol "a" is removed from the symbol set.  This way hectares ("hare") and petares ("Pare") can be used.

I don't see a way to nondestructively/temporarily delete units either ("RemoveUnit").  Deleting the unit "are" and then recreating it as a new unit with the symbol "are" would solve the same problem.

I just saw that there already exists a separate "hectare" unit with the symbol "ha" which presumably also needs to be removed in order to enable SI prefixes for "are".  This is just one example but a general way to remove units and/or unit symbols should be very helpful.

I'm an engineer and when showing results of calculations, some values will display as fractions, and I would prefer that instead floating numbers are displayed.  Also, there is kind of a quirk where if the multiplier of a unit is 1, the result displays as a unit only. I would prefer to see 1*A rather than A.

I wrote this simple proc to convert a value with or without attached unit to a floating point number if it is a fraction or if it has a unit and the coefficient is 1.

Let me know if there is a more elegant way to do this or you have any suggestions or questions.

   unrationalize := proc(x)
        local 
            returnval,
            localcoeff,
            localunit
        ;
        description
            "Converts a fractional number to float",
            "Units are supported"
        ;
        if type(x, fraction) or type(x, with_unit(fraction)) then 
            returnval := evalf(x)
        elif type(x, with_unit(1, 'localcoeff', 'localunit')) then
            returnval :=  evalf(localcoeff)*localunit
        else 
            returnval := x;
        end if;
        return returnval;
    end  proc;
# Testing the proc
list1 := [1/2, 1/2*Unit(('A')/('V')), 1, Unit('A')];
listDescription := ["Fraction", "Fraction with Unit", "Unity", "Unity with Unit"];
for i, myValue in list1 do
    [listDescription[i], "evalf:", evalf(myValue), "unrationalize:", unrationalize(myValue)];
end do;

hi i need help. can someone help me with maple command for this 2 question? i need to do it for my assignment. all i know that i need to use with(vectorcalculus). all command include graph. thanks



In case this error has been corrected in more recent versions, please feel free to delete this question.

In the felp page relative to anames this example is given

restart:
test1 := 1: test2 := 2: test3 := 3.2: testall := 3.2:
select(type,{anames()},suffixed(`test`));
                 {test1, test2, test3, testall}

Note the backward quotes in suffixed(`test`).
This works only if test is not an assigned name itself:

restart:
test := 0: test1 := 1: test2 := 2: test3 := 3.2: testall := 3.2:
select(type,{anames()},suffixed(`test`));
Error, (in type/suffixed) expecting a 1st argument of type {string, symbol, list(symbol, string), set(symbol, string)}

With simple quotes:

select(type,{anames()},suffixed('test'));
              {test, test1, test2, test3, testall}

 

Hi,

I am exploring the counting functions available in Maple, and I am searching for how to enumerate arrangements with repetition and combinations with repetition ? ThanksCombinatoireTEST.mw

How to handle these errors in plotting the solutions?compare.mw

Currently, the argument is mapped to the HUE coloring scheme (I guess)

plots:-complexplot3d(z, z = -2 - 2*I .. 2 + 2*I, title = -ln(1/c) - ln(c), orientation = [-90, 0, 0])

This makes it difficult to distinguish the sign of the argument close to the positive real axis (just to give an example). To increase contrast I thought about alternatives: Linear ramping from 0 to 2pi from one color to another (similar to phase wrapped images) or a stepped color scheme (in pi/4 increments for example).

I tried color=argument(z/2/Pi) but this did work.

Is there a way to import an MPL file from a URL?

Import("https://www.nicolesharp.net/testbox/test.mpl");

Using the "Import" command on Maple 2023.2 appears to only import the MPL as plaintext and doesn't recognize any of the Maple instructions from the MPL file.

Using the "Get" command with the URL package doesn't do anything useful either.

with(URL) : Get("https://www.nicolesharp.net/testbox/test.mpl");

I recently stumbled across this video Why do calculators get this wrong

At some point, the author (Matt Parker) mentions the Farey's algorithm as a way to get a rational approximation of a number between 0 and 1.
Just for fun I applied this algorithm to build increasingly accurate rational approximations of Pi (see here Rational_approximation.mw). 
The rational approximation 

convert(evalf(Pi), rational);
                             104348
                             ------
                             33215 

is one of those the Farley's algorithm returns.

Is this pure chance, or does Maple indeed use the Farley's algorithm?
If not, what algorithm does convert/rational use?

Any one knows if this is a new bug in int()? It happens only when kernelopts('assertlevel'=2): is on.

Using Maple 2023.2.1 on windows 10.

edit: Found another integral. #3 below. The difference now is that this third integral is solved completely when removing Physics update/lib from libname. While the first two are not solved. But all three now do not give exception with the updated libname. New attachment is below.

ps. just in case I also just send bug report to Maplesoft.  

restart;

201864

interface(version)

`Standard Worksheet Interface, Maple 2023.2, Windows 10, November 24 2023 Build ID 1762575`

Physics:-Version()

`The "Physics Updates" version in the MapleCloud is 1641. The version installed in this computer is 1637 created 2023, November 29, 17:28 hours Pacific Time, found in the directory C:\Users\Owner\maple\toolbox\2023\Physics Updates\lib\`

kernelopts('assertlevel'=2):

integrand:=(-b*x+a)^(4/3)*(b*x+a)^(8/3);
int(integrand,x,method=_RETURNVERBOSE);

(-b*x+a)^(4/3)*(b*x+a)^(8/3)

Error, (in IntegrationTools:-Indefinite:-ExpandAndMapOverSums) assertion failed, Invalid input for ExpandAndMapOverSums

integrand:=(-b*x+a)^(4/3)*(b*x+a)^(4/3);
int(integrand,x,method=_RETURNVERBOSE)

(-b*x+a)^(4/3)*(b*x+a)^(4/3)

Error, (in IntegrationTools:-Indefinite:-ExpandAndMapOverSums) assertion failed, Invalid input for ExpandAndMapOverSums

integrand:=(-b*x^2+a)^(3/2)*(b*x^2+a)^(3/2);
int(integrand,x,method=_RETURNVERBOSE)

(-b*x^2+a)^(3/2)*(b*x^2+a)^(3/2)

Error, (in IntegrationTools:-Indefinite:-ExpandAndMapOverSums) assertion failed, Invalid input for ExpandAndMapOverSums

libname

"C:\Users\Owner\maple\toolbox\2023\Physics Updates\lib", "C:\Program Files\Maple 2023\lib"

restart;

201864

libname:="C:/Program Files/Maple 2023/lib"

"C:/Program Files/Maple 2023/lib"

kernelopts('assertlevel'=2):
integrand:=(-b*x+a)^(4/3)*(b*x+a)^(8/3);
int(integrand,x,method=_RETURNVERBOSE);

(-b*x+a)^(4/3)*(b*x+a)^(8/3)

["risch" = -(1/1215)*(243*b^4*x^4+324*a*b^3*x^3-450*a^2*b^2*x^2-804*a^3*b*x+47*a^4)*(-b*x+a)^(1/3)*(b*x+a)^(2/3)*((-b*x+a)^2)^(1/3)/(b*((b*x-a)^2)^(1/3))+(int((256/729)*a^5/((b*x-a)^2*(b*x+a))^(1/3), x))*((-b*x+a)^2)^(1/3)*((b*x-a)^2*(b*x+a))^(1/3)/((-b*x+a)^(2/3)*((b*x-a)^2)^(1/3)*(b*x+a)^(1/3)), FAILS = ("gosper", "lookup", "derivativedivides", "default", "norman", "trager", "meijerg", "elliptic", "pseudoelliptic", "parallelrisch", "parts")]

integrand:=(-b*x+a)^(4/3)*(b*x+a)^(4/3);
int(integrand,x,method=_RETURNVERBOSE)

(-b*x+a)^(4/3)*(b*x+a)^(4/3)

["risch" = (3/55)*x*(-5*b^2*x^2+13*a^2)*(-b*x+a)^(1/3)*(b*x+a)^(1/3)*((-b*x+a)^2)^(1/3)/((b*x-a)^2)^(1/3)+(int((16/55)*a^4/((b*x-a)^2*(b*x+a)^2)^(1/3), x))*((-b*x+a)^2)^(1/3)*((b*x-a)^2*(b*x+a)^2)^(1/3)/((-b*x+a)^(2/3)*(b*x+a)^(2/3)*((b*x-a)^2)^(1/3)), FAILS = ("gosper", "lookup", "derivativedivides", "default", "norman", "trager", "meijerg", "elliptic", "pseudoelliptic", "parallelrisch", "parts")]

integrand:=(-b*x^2+a)^(3/2)*(b*x^2+a)^(3/2);
int(integrand,x,method=_RETURNVERBOSE)

(-b*x^2+a)^(3/2)*(b*x^2+a)^(3/2)

["default" = (1/7)*(-b*x^2+a)^(1/2)*(b*x^2+a)^(1/2)*((b/a)^(1/2)*b^4*x^9-4*(b/a)^(1/2)*a^2*b^2*x^5+4*a^4*((-b*x^2+a)/a)^(1/2)*((b*x^2+a)/a)^(1/2)*EllipticF(x*(b/a)^(1/2), I)+3*(b/a)^(1/2)*a^4*x)/((-b^2*x^4+a^2)*(b/a)^(1/2)), "risch" = (1/7)*x*(-b^2*x^4+3*a^2)*(-b*x^2+a)^(1/2)*(b*x^2+a)^(1/2)+(4/7)*a^4*(1-b*x^2/a)^(1/2)*(1+b*x^2/a)^(1/2)*EllipticF(x*(b/a)^(1/2), I)*((-b*x^2+a)*(b*x^2+a))^(1/2)/((b/a)^(1/2)*(-b^2*x^4+a^2)^(1/2)*(-b*x^2+a)^(1/2)*(b*x^2+a)^(1/2)), "elliptic" = (-b*x^2+a)^(1/2)*(b*x^2+a)^(1/2)*(-(1/7)*b^2*x^5*(-b^2*x^4+a^2)^(1/2)+(3/7)*a^2*x*(-b^2*x^4+a^2)^(1/2)+(4/7)*a^4*(1-b*x^2/a)^(1/2)*(1+b*x^2/a)^(1/2)*EllipticF(x*(b/a)^(1/2), I)/((b/a)^(1/2)*(-b^2*x^4+a^2)^(1/2)))/(-b^2*x^4+a^2)^(1/2), FAILS = ("gosper", "lookup", "derivativedivides", "norman", "trager", "meijerg", "pseudoelliptic", "parallelrisch", "parts")]

Download jan_13_2024_integrationTools_expand.mw

My friend and colleague Nic Fillion and I are writing another book, this one on perturbation methods using backward error analysis (and Maple).  We have decided to make the supporting materials available by means of Jupyter notebooks with a Maple kernel (there are some Maple worksheets and workbooks already, but going forward we will use Jupyter).

The presentation style is meant to aid reproducibility, and to allow others to solve related problems by changing the scripts as needed.

The first one is up at 

https://github.com/rcorless/Perturbation-Methods-in-Maple

Comments very welcome.  This particular method is a bit advanced in theory (but it's very simple in practice, for weakly nonlinear oscillators).  I haven't coded for efficiency and there may be some improvements possible ("may" he says, sheesh).  Comments on that are also welcome.

-r

The automatic transformation below is a rule in Maple

a := 3:
b := a^2
                               9

that we can prevent using single quotes for instance.

When a is a random variables this becomes

a := Statistics:-RandomVariable(Uniform(0, 1));
                               _R
b := a^2
                                2
                              _R 

# Thus, for instance
Statistics:-Mean(b);
                               1
                               -
                               3



Of course you do know that b is defined as a^2, but if you present this to a student it will be puzzled by the output of b containing _R and not a. Of course you can explain it why this happens, but if b has a more complex expression inoking several random variables, it becomes almost impossible to understand what its display means as it contains only names like _R, _R0, ...

To avoid this difficulty a possibility is to reverse the order of the operations this way

a := 'a':
b := a^2;
                                2
                               a 
a := Statistics:-RandomVariable(Uniform(0, 1));
                              _R
# And then
Statistics:-Mean(b);
                               1
                               -
                               3


But this become quite tricky in some situations, for instance

restart:
b := a^2 - Mean(a)^2
                          2          2
                         a  - Mean(a) 
a := Statistics:-RandomVariable(Uniform(0, 1)):

# The expected result can be got this way
eval(b, Mean = Statistics:-Mean):
Statistics:-Mean(%);
                               1 
                               --
                               12


Or, if you upload the Statistics package

restart
with(Statistics):
b := a^2 - ':-Mean'(a)^2
                          2          2
                         a  - Mean(a) 
a := RandomVariable(Uniform(0, 1)):
eval(b, ':-Mean' = Mean):
Mean(%);
                               1 
                               --
                               12


As we preserved a comprehensible expression for b in the last two examples, this come at the expense of a more complex calculation of the final result.

My goal is the quite simple:  I would like to preserve as long as possible the original names of the random variables (a in the examples above), and get the desired result without never make their "aliases" _R, _R0, _R1, .... appear in intermediate outputs.
The strategy I use is sketched in the file  Manipulation_of_random_variables.mw

Do you have another idea to achieve this goal?

In fact this question could be also stated "Given a random variable _R, could it be possible to recover the name it has been assigned to. I thought to something like this:

restart:
a := Statistics:-RandomVariable(Uniform(0, 1));
b := Statistics:-RandomVariable(Uniform(0, 1));
c := 1:
d := [$1..3]:
                               _R
                              _R0

# This seems correct
FromNames2RV := [anames(RandomVariable)] =~ eval([anames(RandomVariable)]);
                       [b = _R0, a = _R]

# Unfortunately further use of FromNames2RV evaluates its left hand sides
FromNames2RV 
                      [_R0 = _R0, _R = _R]


TIA

restart;
with(geometry);
with(plots);
_EnvHorizontalName = 'x';
_EnvVerticalName = 'y';
point(A, -3, 9);
point(B, -5, 0);
point(C, 6, 0);
xA := -3;
yA := 9;
xB := -5;
yB := 0;
xC := 6;
yC := 0;
triangle(ABC, [A, B, C]);
midpoint(M2, A, C);
midpoint(M1, B, C);
midpoint(M3, A, B);
coordinates(M1);
coordinates(M2);
coordinates(M3);
segment(sA, [A, M1]);
segment(sB, [B, M2]);
segment(sC, [C, M3]);
centroid(G, ABC);
midpoint(J1, A, G);
midpoint(J2, B, G);
midpoint(J3, C, G);
coordinates(J1);
coordinates(J2);
coordinates(J3);
zA := xA + yA*I;
zB := xB + yB*I;
zC := xC + yC*I:
diff((z - zA)*(z - zB)*(z - zC), z)*I;);
allvalues(%, z)
;I am trying to find focus of Steiner ellipse with Marden's theoreme. Thank you.

First 18 19 20 21 22 23 24 Last Page 20 of 2097