Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Dears,

Of course, I'm not talking about questioning the structure of the data itself.  This is the basic form of data manipulation in packages such as R, Julia, Python. I am asking what is the DataFrame in Maple for?
Importing a file (attachment) containing about 50,000 rows in 13 columns takes nearly 1 minute. Attempting to do any operation using DataFrame is practically impossible due to computer slowdown. (DELL XPS 17 9710, Maple 2022.2).

Whereas ImportMatrix() and matrix operations (select, remove, map, etc.) take a part of one second.

I wanted to give an example of some simple operation on the DataFrame object, but unfortunately, I lost my patience.

I have attached the file that I wanted to load for testing, which is part of the original (250K rows x 13 columns):

https://www.kaggle.com/datasets/subhamjain/loan-prediction-based-on-customer-behavior?resource=download

50kX13_LOAN.xlsx

It's also possible that I'm doing something wrong..., then I'd like some guidance from you guys. I like the DataFrame concept in Maple. It's just about usability.

wzelik

Hi, 

I have a problem with the graphic of arcsin((2*x)/(1+x^2)). The domain is IR 

arcsin.mw

Ideas? Thanks

Please help me consider the convergence of this improper integral without using Maple. Thank you so much.

 About 6 years ago I aked  a question on testing types in a package. How to Test Input Typed to a Procedure to Determine what to do? - MaplePrimes.  @Carl Love supplied the very good code below. I never used the answer back then as I really didn't understand what to do with it. I have a somewhat of a better idea now and I really need to be able to use this in general..

 Basically the code checks that all the inputs are of the same type and order (which is what the original question specified).

 Q1:- I now need to check  a mixed input type

         A:: a 2 list , B a 3 list   

          or 

           A:: a 2 Vector, and B a 3 Vector.

         etc

       I tried modifying the ModuleApply part of the code at the end, but that either causes errors or kernal looses connection.

Q2:-  What is a good way to handle different numbers of inputs to procedures (exported) here eg Proc1(a), Proc2(a,b), ....,                   ProcN(a1,...,aN)

Q3:-    Would the package exports of the module be the procedures inside the Mydispatch? Or does all of MyModule sit inside                the  package module?

  I have three different packages I would like to apply this to in general.

restart

 

MyModule:= module()
uses TT= TypeTools;
global _T1, _T2L, _T2V, _T3L, _T3V, _MyType;
local
     MyTypes:= {_T1, _T2L, _T2V, _T3L, _T3V},
     AllMyTypes:= MyTypes union {_MyType},

     ModuleLoad:= proc()
     local
          g, #iterator over module globals
          e
     ;
          #op([2,6], ...) of a module is its globals.
          for g in op([2,6], thismodule) do
               e:= eval(g);
               if g <> e and e in AllMyTypes then
                    error "The name %1 must be globally available.", g
               end if
          end do;
          TT:-AddType(_T1, algebraic);
          TT:-AddType(_T2V, 'Vector(2, algebraic)');
          TT:-AddType(_T2L, [algebraic $ 2]);
          TT:-AddType(_T3V, 'Vector(3, algebraic)');
          TT:-AddType(_T3L, [algebraic $ 3]);
          TT:-AddType(_MyType, MyTypes)
     end proc,

     ModuleUnload:= proc()
     local T;
          for T in AllMyTypes do TT:-RemoveType(T) end do
     end proc,

     MyDispatch:= overload([
          proc(A::_T1, B, C)
          option overload;
          local r:= "A, B, C are T1."; #unnecessary; just an example.
               #statements to process this type
          end proc,

          proc(A::_T2L, B, C)
          option overload;
          local r:= "A, B, C are T2L.";
               #
          end proc,

          proc(A::_T2V, B, C)
          option overload;
          local r:= "A, B, C are T2V.";
               #
          end proc,

          proc(A::_T3L, B, C)
          option overload;
          local r:= "A, B, C are T3L.";
               #         
          end proc,

          proc(A, B, C)
          local r:= "A, B, C are T3V.";
               #
          end proc,
#
#I added this
#
          proc(A, B)
          local r:= "A, B, are mixed.";
               #
          end proc
     ]),
#
# I have have  added  'Or'(....(A::_T2L,B::_T3L)
#
     ModuleApply:= proc(
          A::'Or'(And(
               _MyType,
               satisfies(A-> andmap(T-> A::T implies B::T and C::T, MyTypes) )
          ),

          (A::_T2L,B::_T3L)),
          B::_MyType, C::_MyType
     )
          MyDispatch(args)
     end proc
;
     ModuleLoad()    
end module:
 

#Example usage:
#

x:=[9,4];
y:=[5,7];
z:=[1,9];                                 
MyModule(x,y,z);

[9, 4]

[5, 7]

[1, 9]

"A, B, C are T2L."

x:=[9,4];
y:=[5,6,7];
z:=p;                                 
MyModule(x,y);  #Looses kernel connection

[9, 4]

[5, 6, 7]

p

Download Q_19-11-22_Module_Test_Types.mw

mpl files for sure are good for committing to a repository, especially if you are collaborating with someone in writing the code in those files. They can be opened in an editor and worked on just like in the normal course of working in other programming languages and collaborating.

Worksheets and Workbooks I would imagine are alright as well, right? In this case, they are meant to be opened in Maple of course, not in a code editor.

Now, what about mla files? I imagine that if someone obtained an .mla file I created (containing a package, say), and saved it in a path contained in their libname then they would have access to that package. Is this the standard way of sharing packages with others?

If I wrote a package and wanted to share it (via a Github repo, for instance, or simply by emailling) would it consist of a single .mla file?

I have a folder called Packages, and I added its path to libname. I have an .mla file in there that I have been experimenting with to learn about writing packages in Maple.

The workflow I have currently developed is as follows.

Imagine I am working on a library that does something specific. Just to give a simple example, let's say I want to write a package that has functions sum, add, multiply.

I create an mpl file and I edit it in VSCode which has a plugin with syntax highlighting. In this file I write my package, procedures, etc. At the end of the file I add a line that tells LibraryTools to save the package to an mla file that I am keeping in the same directory as the mpl file (for organizational purposes, not for any technicality).

So at this point both these files are in the Packages directory.

Now let's say I want to create another package for doing animations. I would do the same thing: an mpl file and an mla file.

At this point all four files are together in the Packages directory, because that is where Maple knows to search for mla files. 

However, this isn't very convenient if I want to use version control for each package individually.

To do this I would need to have the two files of each package in their own directory (like a subdirectory of Packages)

i can do this of course, by adding each of the two resulting directories (each with two files) to libname. 

But is it possible to tell Maple to simply search all subdirectories of the directory Packages?

In other words, in this workflow, must I update libname every time I make a new package (which consists of a directory, an mpl file, an mla file, and a git file)?

Note: It seems in the course of writing this question I found the answer, but I am still interested in any tips on the best workflow to update a library. Here is the original post (annotated ex post in bold):

I have successully created my own package in Maple. I basically used LibraryTools:-Create to create an .mla file and then I used LibraryTools:-Save, passing in the name of my package and the path to the .mla file. I did this in a worksheet.

I can import it with the command with(MyPackage).

I'd like to add code to the package.

I have a package defined in as

module MyPackage()
  option package;
  export MyModule;

  module MyModule()
    (...)
  end;
 end;

I would like to add a procedure to be exported inside the package.

I tried to add the procedure, save the file, and then use LibraryTools:-Save again, but the error I get is 

Error (in MyPackage) attempting to assign to 'MyPackage' which is protected. Try declaring local 'MyPackage'; see ?protect for details.

I tried to unprotect the name 'MyPackage' but this gives another error

Error, on line %1, unexpected end of input. Error while reading '%1' (this turned out to be a missing semicolon on the Save command, which was the last command in the mpl file. The error messags are quite unhelpful)

Note: As I mentioned before, I did the initial saving of the package from a worksheet (the package code was in a code editing region in the worksheet). In the current attempt to add the new procedure, I copied the code to an .mpl file so I could edit it in a code editor (VSCode). At the end of this file I added the commands to LibraryTools:-Save the package again to the same .mla file as before.

My attempt to unprotect the name "MyPackage" involved simply adding unprotect('MyPackage') as the first line in this .mpl file.

I then used the command read to execute the mpl file from within a worksheet.

What am I doing wrong, and what is the recommended workflow to be able to work on a package?

If I try to update a simple variable in the .mla file it seems to work.

EDIT: The problem seems to be the use of the named module initially, ie module MyPackage().

If I try the whole process again (write a simple package and save it to the mla file) but this time I use the syntax

MyTestPackage = module()

then I can update it no problem (at least for a simple package that I just wrote; for the actual package with my real code I still get even though Maple is able to read the mpl file without a problem, apparently there is still some issue while trying to save. 

Error, on line %1, unexpected end of input. Error while reading '%1'   (turns out it was the missing semicolon)

In summary: don't used named module syntax.

Hello guys.
I want to solve Laplace's equation for a triangle plate, subject to the following boundary conditions:

For the contour y = x, u(x,y) =20

For the contour y = -x+2, u(x,y) =100

diff(u(x,y),x,x)+diff(u(x,y),y,y)=0

Regards,

Oliveira

 

Have you heard of Maple Scripting before? Do you want to extend your Maple Learn documents with your Maple knowledge? Scripting is the process of using Maple to create Maple Learn documents. If you’re already used to Maple, this may be a piece of cake for you, but we wanted to start from the basics for anyone who wants to extend their Maple Learn and Maple knowledge. This process can be used for many different types of documents, from quizzes to intensive 3D visualizations.

So, let’s get started! All Maple Learn document scripting needs the DocumentTools:-Canvas package. The canvas, as you know, is that white space in a Maple Learn document. Therefore, this package is the core content of a scripted document! Always put:

with(DocumentTools:-Canvas):

At the top of your code, or put

uses DocumentTools:-Canvas:

At the start of your procedures.

Now that we’ve told Maple to use the DocumentTools:-Canvas, we need to create a canvas.

Canvases are created as variables, using the command NewCanvas. Inside NewCanvas, you will add a square-bracket list of all the content you want to see inside. For now, just know that you can add text cells with Text(“YOUR TEXT”) and a math cell with Math(YOUR MATH). On the next line, make sure to put either ShareCanvas(YOUR CANVAS VARIABLE) or ShowCanvas(YOUR CANVAS VARIABLE).  ShareCanvas creates a Maple Learn sharelink, while ShowCanvas shows the canvas directly in Maple. Note that ShowCanvas does not have every Maple Learn feature, but makes quick work of fast error checking.

canvas := NewCanvas([Text(“My first canvas”), Math(3*x+2*y)]):

ShareCanvas(canvas);

There are two more things I want to show you in this post: How to make a group have multiple cells (instead of just the one), and how to position your items on the canvas. Let’s start with group making.

To create a group with multiple cells, use the Group() command within the NewCanvas command, and separate the cells with commas, in a list. You don’t need to specify Text() or Math() when using Group().

canvas := NewCanvas([Group([“This is the first cell…”, “The second….”, “and the third.”])]):

At the end of any command/canvas element, within the brackets, you can define position=[x,y] to specify where on the canvas the object should go. You can adjust the precision pixel by pixel until you are happy with the layout.

When we put all these together, we get code that looks like this:

with(DocumentTools:-Canvas):

canvas := NewCanvas([

Group(["This is the first cell…", "The second…", "and the third."], position=[200,200]),

Math(3*x+2, position=[100,100]),

Text("This is text!", position=[400,400])]):

ShareCanvas(canvas);

And in the end, your scripted document looks like this.

We hope this helps you get started with Maple Scripting. There will be another post on even more of what we can do with Maple Scripting, and how we can make these documents even more interactive. Let us know if there’s anything specific you want to see in that post!

 

Why is the Maple giving this error. See attched file. Further, how can we eq. of the form "A+B`*sqrt(C) = 0" by eliminating the common denominator.

CM_TW.mw

Hi, I have an rational polynomial:

r:=-36*u^3*v*(-1 + u + v)*(3*u^2 + u*v - 5*u - 2*v + 2)/(-1 + u)^2;

int(r, u=0..1-v, v=0..1);

Then I got:

I'm confused, why can't maple do this?

Any ideas about how to do this exact integration?

Hello!!
So I am brand new here and am here as somewhat of a last resort, I was in the hospital for a large portion of my semester (Junior Yr Computer Engineering/Electrical Engineering double major) and I am trying to get through the makeup work for my calculus class. The assignments are on maple, and I have been able to do all the actual solving parts with no issue but several of the problems require you to generate a graph as well and I have been working on it for literally 11  hours to no avail. I'm hoping maybe someone here can help me with what the input should be if I list what the graphs of the ones I am stuck on are (somehow managed to get 2 of them to work, but not the rest). No worries if not/if this is the wrong forum for this I am sorry, but I have cycled through every tutoring website I could find and the error I'm getting keeps linking to a page that says there is not a help page available for the error. So heres the problem I am stuck on (as I said I was able to do the solving for each section myself, I just cant get the graphs to work to save my soul):

2. Graph the following with maple:

a) the cardioid r = 8+8sin(theta) and find its area

b) the first octant portion of the surface z=25-x^2, 1<=y<=8 and find the volume of the solid over the xy plane under the surface

c) the solid common to the cylinders x^2+z^2=16 and y^2+x^2=16 and find the volume of the common region

d) the cylinder x^2+y^2=36 and the sphere x^2+y^2+z^2=100 together, then find the volume outside the cylinder and inside the  sphere

e) the region inside the one sheeted hyperboloid x62+y^2-z^2=36 between z=-8 and z=8 and find the volume of the region

f) the "ice cream cone" formed by the  upper half of the sphere x^2+y^2+z^2=400 and the cons z=sqrt(3x^2=3y^2), then find the z-coordinate of its center of mass written as a rounded decimal number with 3 places, assuming density is constant. 

Yeah, that is one of 11 problems on the project I know its a ton. Anyway like I said I am kind of posting this as a hail mary but if anyone can help me with what the input is supposed to be on any of these at all I would be eternally grateful, as I have 2 more of these projects to make up from while I was in the hospital and I have been on this one question all night. I will literally take ANYTHING. Thanks so much for reading and for anyone who takes the time to help out. 

hi. i want to improve my integration calculation speed, it takes me hours to calculate the results for even N=8. but i want for much more N's such as 20 30. can calculation speed improve? thanks in advance

Download M.mw

Problema with textplot

restart:with(plots):
  with(geometry):
  _EnvHorizontalName := 'x':
  _EnvVerticalName := 'y':
  a := 7:
  b := 3:
  ellipse(p, x^2/a^2 + y^2/b^2 - 1, [x, y]):
  Fig := proc(t)
              local M, l1,L1,L2,  q, m, c , tex;
              global a, b, p;
              point(M, a*cos(t), b*sin(t));
              if   VerticalCoord(M)=0
              then line(l1, x=HorizontalCoord(M));
              else m:=eval[recurse]( rhs
                                     ( isolate
                                       ( diff
                                         ( eval
                                           ( Equation(p),
                                             y=y(x)
                                           ),
                                           x
                                         ),
                                         diff(y(x),x)
                                       )
                                     ),
                                     [ y(x)=y,
                                       x=HorizontalCoord(M),
                                       y=VerticalCoord(M)
                                     ]
                                   );
                   c:=VerticalCoord(M)-m*HorizontalCoord(M);
                   line(l1, y=m*x+c);
              fi;
              reflection(q, p, l1);
              line(L1, [point(P1, evalf~(coordinates(foci(q)[1]))),
                            point(P2, evalf~(coordinates(foci(q)[2])))]):  
              line(L2, [point(P3, evalf~(coordinates(foci(p)[1]))),
                            point(P4, evalf~(coordinates(foci(p)[2])))]): 
              segment(P1P3,[P1,P3]): circle(cir1,[P3,2*a]):
              segment(P2P4,[P2,P4]): 
              circle(cir1,[P3,2*a]): circle(cir2,[P4,2*a]):
              textplot([[P2[], "F1"], [P4[], "F2"]], font = [times, 10], align = {below, left}):            
              draw( [ p(color = blue),P1P3(color=magenta,linestyle=3),
                      q(color = blue),P2P4(color=magenta,linestyle=3),
                      l1(color = black),L1(color = black),cir1(color=magenta,linestyle=3),
                      cir2(color=magenta,linestyle=3),
                      M(color = blue, symbol = solidcircle, symbolsize = 16),
                      P1(color = red, symbol = solidcircle, symbolsize = 16),
                      P2(color = red, symbol = solidcircle, symbolsize = 16),
                      P3(color = red, symbol = solidcircle, symbolsize = 16),
                      P4(color = red, symbol = solidcircle, symbolsize = 16)
                    ],
                    axes = none,
                    scaling = constrained);
          end proc:
#
# Change nFig to type float
#
   nFig := 180.0:
#
# Make sure loop index is a float, and change end point
# on loop to nFig-1.0
#
   Figs := seq(Fig(2*Pi*i/nFig), i = 0.0 .. nFig-1.0):
   plots:-display(Figs, insequence = true);
Error, (in plots:-textplot) improper op or subscript selector
Error, (in plots:-display) expecting plot structure but received: Figs

Hi maple users 

I am working with the PDE solver.

i am receiving a following error

"unable to compute solution for t>HFloat(0.0):" 

Kindly do the needful how to rectify this error.

dumm.mw

First 138 139 140 141 142 143 144 Last Page 140 of 2097