MaplePrimes Questions

The procedures "getCP" which uses "cpsub" (not exported) acts differently inside the package as opposed to them outside it.
In the package it returns a column matrix which is incorrect. Should return a 2 row matrix. They dismantle a polynomial into it's powers and coefficients. I know one cant run the package here. Included are the two procedures and the text of the notepad file to make the package.

restart

NULL

with(AlgCalc)

[`⊕`, FundThrm, SignedArea, diag, diftab, faulD, faulS, getCP]

f := sort(2+x^7+5*x^2-7*x^a+k*x^2, [x], ascending)

2-7*x^a+5*x^2+k*x^2+x^7

getCP(f, x)

Matrix(%id = 36893490212391698668)

NULL

g := sort(5*x^8+k*x^2-7*x^3+x+2, [x], ascending)

2+x+k*x^2-7*x^3+5*x^8

CP := getCP(g, x)

Matrix(%id = 36893490212391688180)

NULL

restart

with(AlgCalc)

[`⊕`, FundThrm, SignedArea, diag, diftab, faulD, faulS, getCP]

NULL

f := sort(2+x^7+5*x^2-7*x^a+k*x^2, [x], ascending)

2-7*x^a+5*x^2+k*x^2+x^7

getCP(f, x)

Matrix(%id = 36893490212390043884)

g := sort(5*x^8+k*x^2-7*x^3+x+2, [x], ascending)

2+x+k*x^2-7*x^3+5*x^8

getCP(g, x)

Matrix(%id = 36893490212390032796)

 

restart

 

Dismantlimg a polynomial  uses the following 2 procedures

" cpsub:= proc(t, var:=alpha)  description "used by getCP";       local i,cf,varpwr;                   if   not has(t, var)                  then return < 0,t>:               elif whattype(t)=`^` then return <op(t)[2],1>;                  else varpwr,cf:= selectremove(has,[op(t)],var);                       if op(varpwr)=var then                        return <1, `*`(op(cf))> ;                   end if;                     for i from 1 to nops(varpwr) do                    if numer(varpwr[i])=1  then if op((1)/(varpwr[i]))=alpha then varpwr[i]:=-1 else  varpwr[i] :=-op((1)/(varpwr[i]))[2] end if else  varpwr[i]:=op(varpwr[i])[2]end if                        end do;                   return <`+`(op(varpwr)),`*`(op(cf))>;                   #print(op(t));                                   end if ;            end proc:"

NULL

``

getCP := proc (f, var := alpha) local t; description "Dissmantles a polynomial into powers and coefficients"; if not has(f, var) then return `<,>`(0, f) elif whattype(f) = `^` then return `<,>`(op(f)[2], 1) elif whattype(f) = `*` then return `<|>`(`~`[cpsub]([f], var)[]) else `<|>`(`~`[cpsub]([op(f)], var)[]) end if end proc

NULL

f := sort(2+x^7+5*x^2-7*x^a+k*x^2, [x], ascending)

2-7*x^a+5*x^2+k*x^2+x^7

cp := getCP(f, x)

Matrix(%id = 36893490212391322676)

whattype(cp)

Matrix

NULL

Notepad file to Create AlgCalc.

 

AlgCalc := module ()
export SignedArea,
           `&oplus;`,

             getCP,

             diag,
             diftab,
             faulD,
             faulS,
             FundThrm;
        

 option package;

$include "SignedArea.mm"
$include "`&oplus;`.mm"
$include "cpsub.mm"
$include "getCP.mm"
$include "diag.mm"
$include "diftab.mm"
$include "faulD.mm"
$include "faulS.mm"
$include "FundThrm.mm"

end module;

Download 6-11-22_Procedures_acting_differently_in_Package.mw

There is a document on the Maple website entitled "Writing Packages". It contains the following snippet when talking about libname

Note: Maple automatically adds lib subdirectories of directories in HOMEDIR/maple/toolbox as well as your current directory to the predefined variable libname. Therefore, modifying the .mapleinit or maple.ini file is only necessary if you want to designate a directory as the default location in which the savelib command will save your library files.

Is this snippet accurate?

If we create a directory called test and create a directory inside called lib and in it a repository called myRepo.mla, and in Maple the current working directory is test, will test/lib/myRepo.mla be found by libname?

It doesn't seem to be the case.

in the context of solving an ode, sometimes the constant of integration that will satisfy an initial condition is +infinity or -infinity.

But Maple's solve does not find such solutions to the constant of integration. It only can solve for finite value if it can.

When this happens, I manually try taking the limit as the constant of integration goes to +- infinity, until I get an equation where both sides are the same or fail, and then give up.

I was wondering if there is a way or different command/package which will find solution such as infinity (which is valid solution to constant of integration).

Here are two examples

ode:=diff(y(x),x)=1/(LambertW(-exp(-1+_C1+x))+1);
ic:=[diff(y(x),x)=1,x=0];
eq2:=eval(ode,ic);
solution_for_constant := solve(eq2,_C1,'allsolutions'=true,'tryhard'=true);

Maple can not solve for _C1. It gives

But when trying manually few values, I find that _C1=-infinity satisfies the equation

limit(rhs(eq2),_C1=0);
limit(rhs(eq2),_C1=1);
limit(rhs(eq2),_C1=-1);
limit(rhs(eq2),_C1=infinity);
limit(rhs(eq2),_C1=-infinity);

The above shows that _C1 = -infinity is the constant of integration. Another simpler example

eq:=exp(-1 + _C1) = 0;
solution_for_constant:=solve(eq,_C1) assuming real;
limit(lhs(eq),_C1=-infinity)

The above shows that _C1=-infinity is solution for exp(-1+C_1)=0.  which one can see by just looking at it as exp(-infinity)=0.  Adding assumptions did not help.I also tried symbolic option.

I am not familar with SolveTools package, may there is something there.

So for now, my code just try the limit until it finds solution or gives up.

Any suggestions if Maple itself can find such solutions?

Maple 2022.2

Does the below infinite sum involving primes converge?sum(1/(Prime(n)Prime(n+1)Prime(n+2)*Prime(n+3)),n=1... infinity) Free WolframAlpha app runs out of time while evaluating this sum... The term values which free WolframAlpha app shows for this sum (starting from the term 41 and on) is 0.0059292... If 0.0059292 is indeed the value for this sum, could then more significant digits be produced? Thanks, Best Regards, Alexander R. Povolotsky

Why is a more direct approach of defining a table now working and giving an indexed type, while the indirect approach is giving a table?

atable := table()

table( [ ] )``

(1)

a := table()

table( [ ] )

(2)

atable["a"] := a

a

(3)

atable["b"] := table()

table( [ ] )

(4)

whattype(atable["a"])

table

(5)

whattype(atable["b"])

indexed

(6)

NULL

Download tabledefinition.mw

Hello,

I am trying to create a Homogeneous transformation matrix, where I am given the point 'p' through which a unit rotation axis 'x' passes and the point/vector on which this Homogenous transformation acts is rotated by 'theta'.

I used the Rodrigues formula (the one in the blue-green box) to define the rotation matrix;

unit_axis_cross_mat := unapply(<<0 | -x[3] | x[2]>, <x[3] | 0 | -x[1]>, <-x[2] | x[1] | 0>>, x::Vector);
rot_mat := unapply(LinearAlgebra[IdentityMatrix](3) + unit_axis_cross_mat(<x[1], x[2], x[3]>)*sin(theta) + MatrixPower(unit_axis_cross_mat(<x[1], x[2], x[3]>), 2)*(1 - cos(theta)), x::Vector, theta)

I then tried to concatenate them to generate the matrix function

, where the exponential term represents the rotation matrix (defined above) as such:

trans_mat_ang := unapply(ArrayTools[Concatenate](1, ArrayTools[Concatenate](2, rot_mat(<x[1], x[2], x[3]>, theta), (LinearAlgebra[IdentityMatrix](3) - rot_mat(<x[1], x[2], x[3]>, theta)) . <p[1], p[2], p[3]>), <0 | 0 | 0 | 1>), x::Vector, theta, p::Vector)

But I end up getting the error 

"Error, (in ArrayTools:-Concatenate) number of columns must match"

To diagnose it, I try to evaluate the 1st Concatenation:

trans_mat := unapply(<ArrayTools[Concatenate](2, rot_mat(<x[1], x[2], x[3]>, theta), (LinearAlgebra[IdentityMatrix](3) - rot_mat(<x[1], x[2], x[3]>, theta)) . <p[1], p[2], p[3]>)>, x::Vector, p::Vector, theta);

which runs successfully, but when I try to evaluate it:

trans_mat(<1, 0, 0>, <1, 0, 0>, 0)

, I get a symbolic expression .

Although the expression is correct algabrically, I expected a full evaluation for the numerical inputs.

I am attaching my Homogeneous_Transformation.mw for your ease of diagnosis.

Is this the cause of the error of "Number of Columns must match"?

Any help towards this would be appreciated.

Regards

 

Hello,

I'm attempting to scale the vertical axis of a histogram plot such that each bin reflects the percentage of the total bins (all bins sum to 1). Matlab has an option ('probability') for their histogram command which does this. I've attempted to solve this myself in the attached worksheet but I'm not satisfied with the results (just a hack to replace axis labels). Specifically, I would like for the underlying data in the plot to match the axis scaling. An example can be seen in the image below.

Thank you for your consideration,

Ron

Histogram_percentage.mw

 

 

 

I've worked as a programmer before, but now I dedicate a lot of time to learning math, and so I have been using Maple.

I was wondering if there is some standard way that people work when they have a relatively large codebase. For example, can we define procedures in one file (like a document) and then just import them in another document?

I am reading about the difference between document and worksheet mode on the Maple website.

There is a table called "Difference between Documents and Worksheets" and one row has the following information


My question is about the operation on the left side. The impression I get from reading that is that if I just enter the equation in 2D math mode and hit enter it will solve the equation without me having to type in the command "solve". But Maple simply echoes the equation back to me when I do this in Maple 2022. What am I missing?

Dear all

I have a coupled system of PDEs, 
I would like to return the exact solution of the system using error integral function or complementary error function is possible

compute_integral_using_erfc_fct.mw

thank you for your help 

How to display the coordinate set that was used to create the following plot:

with(plots):

de := plot3d(y*sin(x), x = 0 .. 2*Pi, y = -2 .. 2)

Regards

Oliveira

Does anyone have any idea why Maple can obtain a closed form of 

Int(f, t=1..3);

but doesn't for 

Int(g, t=1..3);

?

The Int forms are quite close and I don't understand what makes Maple's task that difficult in the second case (the issue seems to come from the conditions in the piecewise function).
Can we force Maple to perform the second integration ?

TIA

restart:

interface(Version)

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

f := piecewise(z/t < 0, 0, z/t < 1, 630*z^8/t^8-2520*z^7/t^7+3780*z^6/t^6-2520*z^5/t^5+630*z^4/t^4, 0)/t:

Int(f, t=1..3);

value(%);  # returns a closed form of the integral

g := piecewise(z/t < 1, 0, z/t < 2, 10080-60480*z/t+156240*z^2/t^2-226800*z^3/t^3+202230*z^4/t^4-113400*z^5/t^5+39060*z^6/t^6-7560*z^7/t^7+630*z^8/t^8, 0)/t:

Int(g, t=1..3);

value(%): # unable to return a closed form of the integral

Download MyIntegral.mw

Fig := proc(t) 
local xD, yD, D, C, Ii, Points, tex,sol; 
global A, B, b, Omega1, EL1, EL2; 
xD := Omega1[1] + aa*cos(t); 
yD := bb*sin(t); 
D := [xD, yD]; 
C := [xD + b, yD]; 
sol:=solve({EQ(A,D),EQ(C,B)},{x,y});
Ii:=[subs(sol,x),subs(sol,y)]:
Points := pointplot([A[], B[], C[], C[], D[], E[], Omega1[]], symbol = solidcircle, color = [red], symbolsize = 6); 
tex := textplot([[A[], "A"], [B[], "B"], [C[], "C"], [D[], "D"], [E[], "E"], [Omega1[], "&Omega;1"]], align = ["above", "right"]); 
display([polygonplot([A, B, C, D], color = blue, filled = true, transparency = 0.9), Points, tex, EL1, EL2,plot([D,Ii]),plot([Ii,C])], axes = normal, scaling = constrained); end proc:
Fig((3*Pi)/4):
display([seq(Fig((2*Pi*i)/40), i = 1 .. 80)], insequence = true);
Warning, data could not be converted to float Matrix
Warning, data could not be converted to float Matrix
Warning, data could not be converted to float Matrix
Warning, data could not be converted to float Matrix
Warning, data could not be converted to float Matrix
Warning, data could not be converted to float Matrix
Warning, data could not be converted to float Matrix
Warning, data could not be converted to float Matrix
I am sorry; How to manage with such a message. Thank you very much.

Hi, someone help please. How I can fix the following problem (preferably avoiding for-loops as they are too slow):

From a family of subsets (say) S={{a,b},{a,b,c},{b,c},{c}} of the set X={a,b,c}
1). Extract all the subsets i.e. members of S, which have 'a' as their member?
2). For any (a,b) in X x X, check if 'a' is member of all those subsets which have 'b' also as their member or not?
 

I have few questions on this subject.

1) One can view internal maple procs using the command showstats. For example showstat(`dsolve`) prints the dsolve proc. And showstat(`dsolve/SERIES`)  prints the proc called  dsolve/SERIES(). And this i s what I do not understand. What is the signifcance of in the above?    Since dsolve itself is a proc, what does mean? does this means SERIES is an internal proc inside dsolve proc? That is not likely. I see things like convert/tan/simpler again, what does the mean here? it can't be that simpler is an inner proc inside tan proc which is inside convert proc? I never used /  myself in mycode in a proc name.

How are these procs organized physically? I mean inside Maplesoft computers. Is each proc in separate .mpl file? How does the /  comes into play?  I tried to make a proc myself with forward / but got syntax error. So this / must mean some other logical relation, but I do not know to emulate it myself.

 

2) Why one must add ` ` around the names when using showstats for system procs, but not for my own module? For example, I did the following

A:=module()
  export foo:=proc()
      NULL;
  end proc;
end module;
                    
showstat(A:-foo)

And that worked. But if I type showstat(`A:-foo`)  maple gives error Error, (in showstat) procedure name expected

but with system proc, must have the `` there. If I type showstat(convert/tan/simpler) it is an error.

 

3) Why showstat(`DEtools/odeadvisor`)  gives Error, (in showstat) procedure name expected? But help says odeadvisor is in DEtools module.

 

4) Why can't one display the source of the module itself, and it has to be a proc? For example showstat(`DEtools`) gives error, because `DEtools` is not a proc, but a whole module.

Are these things described more somewhere? I only know about with(LibraryTools); 
Browse(); 

First 265 266 267 268 269 270 271 Last Page 267 of 2428