Unanswered Questions

This page lists MaplePrimes questions that have not yet received an answer

Consider the following code in an .mpl file

$define MACRO1 "1"

$define MACRO2 "2"

 

$ifdef __FILE__

$define MACRO3 "3"

$endif

 

$ifdef MACRO1

$define MACRO4 "4"

$endif

 

f := proc()

print(MACRO1, MACRO2, MACRO3, MACRO4, __FILE__):

end:

If we run this from a worksheet and call the procedure f, the printed output is

"1", "2", MACRO3, "4", "/Users/zenterix/..."

Why does $ifdef __FILE__ evaluate to false? Ie, why doesn't MACRO3 get defined? I thought __FILE__ was a predefined macro.

I have been unable to re-size and imported image into a Maple Flow 2022.2 document. I just used my old Maple Flow 2021 and I had no problem. When I use Maple Flow 2022.2 I cannot re-size an imported image. I was able to re-size an imported image in Maple Flow 2022.1. Is it just me or has anybody else experienced the same problem? I also imported the image into Maple 2022.2 and had no problem re-sizing the image.

I formatted all the input math expressions with a different style and then exported them to create a style set called Mystyle1. However, when I load Mystyle1 and apply it to a document, the functions that were typed partially obey the style, but the expressions that were inserted through the palette do not; font and size are different and bold is not applied.
Does anyone know why this happens?

If anyone wants to test it, Mystyle1 and a simple document are attached.

Regards,

Oliveira

Example.mw

Mystyle1.mw

@ASHAN's question was about a linestyle which wasn't displayed as expected.

Maybe a handling error on my part?

To ASHAN:

Hello;

Hope you are fine. I need to learn how can I call my code in the other file of maple, define new value for A and can get results. For this purpose, I just take an simple example as

questionmaple.mw

restart; A := 5; B := 10; AAA[0] := 10; for i from 0 while i <= A do AAA[i+1] := B*i*AAA[0] end do

5

 

10

 

10

 

0

 

100

 

200

 

300

 

400

 

500

(1)
 

``

Download questionmaple.mw

I would like to read data from a google sheet document. I can download a local copy to excel format, but then I'm no longer tied to the origional file.

MyPackageTools := module()
    option package;

    export addPackageDirectoryToLibname, savePackageToMla;

    addPackageDirectoryToLibname := proc(packageDir)

        local mapleInitFile, newLibname:

        mapleInitFile := "/Library/Frameworks/Maple.framework/Versions/2022/lib/init":

        try 
            FileTools:-Text:-Open(mapleInitFile, 'append'):
        catch:
            return "Failed to open file":
        end:

        try
            newLibname := cat("libname := \"", packageDir, "\", libname:" ):
            FileTools:-Text:-WriteLine(mapleInitFile, newLibname):
        catch:
            FileTools:-Text:-Close(mapleInitFile):  
            return "Failed to write to file.": 
        end: 

        try
            FileTools:-Text:-Close(mapleInitFile):   
            return "Added to libname successfully. Restart worksheet for changes to come into effect.":
        catch: 
            return "Failed to close file":
        end:
    end:

    savePackageToMla := proc(mlaPath, mplPath, packageName)

        read(mplPath);

        LibraryTools:-Save(packageName, mlaPath);

    end:
end:

I'd like to automate my workflow a bit. I having a hard time making savePackageToMla work. The commands inside it are the ones I would run in a Maple worksheet to save a package to an .mla file.

The error I get when I try to use this is

Error, (in LibraryTools:-Save) 1st variable is not a name or equation |/Users/marcusegues/maple/Packages/MyPackageTools/MyPackageTools.mpl:38|

Note that the goal is to pass in an mla path and an mpl path. The mpl file is read. The package that is read is the same as the argument packageName. 

I invoke this procedure with something like

savePackageToMla(mlaPath, mplPath, 'MyPackage')

where 

mplPath := '/somePath/MyPackage.mpl';
mlaPath := 'somePath/MyPackage.mla';

and MyPackage.mpl contains something like

MyPackage := module()
  option package;
  (...)
end;

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

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

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

HHow do i correct "error, illegal use of an object as a name"

Dear maple user i am facing difficulty to plot the graph   for different values  of parameter M=2,4  and fixing t=j=0 to 2 and   y=i=0 to 4 on x axis and U on y axis. I am unable to plot 2D . I am enclosing the codes and sample graphs. 

restart; 
# Parameter values:
 Pr:=0.71:E:=1:A:=0:Sc:=0.02: K:=1:

a := 0: b := 1: N := 9:
h := (b-a)/(N+1): k := (b-a)/(N+1):

 lambda:= 1/h^2:  lambda1:= 1/k^2:
# Initial conditions
for i from 0 to N do 
  U[i, 0] := h*i+1:
end do:


for i from 0 to N do 
  T[i, 0] := h*i+1:
end do:
for i from 0 to N do 
  C[i, 0] := h*i+1:
end do:

# Boundary conditions
for j from 0 to N+1 do 
  U[0, j] := exp(A*j*lambda); 
  U[N+1, j] := 0;
  T[0, j] := j*lambda1; 
  T[N+1, j] := 0;
  C[0, j] := j*lambda1; 
  C[N+1, j] := 0 
end do:


#Discretization Scheme
for i to N do 
  for j from 0 to N do 
    eq1[i, j]:= lambda1*(U[i, j+1]-U[i, j]) = (Gr/2)*(T[i, j+1]+T[i,j])+(Gr/2)*(C[i, j+1]+C[i,j])+(lambda^2/2)*(U[i-1,j+1]-2*U[i,j+1]+U[i+1,j+1]+U[i-1,j]-2*U[i,j]+U[i+1,j])-(M/2)*(U[i,j+1]+U[i,j]) ;
    eq2[i, j]:= lambda1*(T[i, j+1]-T[i, j]) = (1/Pr)*(lambda^2/2)*(T[i,j+1]-2*T[i,j+1]+T[i+1,j+1]+T[i-1,j]-2*T[i,j]+T[i+1,j])+(E*lambda^2)*((U[i+1,j]-U[i,j])^2);
    eq3[i, j]:= lambda1*(C[i, j+1]-C[i, j]) = (1/Sc)*(lambda^2/2)*(C[i,j+1]-2*C[i,j+1]+C[i+1,j+1]+C[i-1,j]-2*C[i,j]+C[i+1,j])+(K/2)*((C[i,j+1]+C[i,j]))  
  end do
end do:


#
# Determine the unknowns in the system
#
  `union`(  seq(seq( indets( eq1[i,j], name), i=1..N), j=0..N),
            seq(seq( indets( eq2[i,j], name), i=1..N), j=0..N),
            seq(seq( indets( eq3[i,j], name), i=1..N), j=0..N)
          );
#
# And how many unknowns
#
   numelems(%);
#
# And the number of equations
#
  numelems(eq1)+numelems(eq2)+numelems(eq3);

#
# So if one supplies values for 'Gr' and 'M', and
# (assuming the equations are consistent), one ought
# to be able to get values for C[1..9, 1..10],
# T[1..9,1..10], and U[1..9,1..10]
#
# As an example below, choos Gr=1.0 and M=2, then the
# following obtains a 'solution` afer a minute or so
#
  fsolve( eval( [ seq(seq(eq1[i,j], i=1..N),j=0..N),
                  seq(seq(eq2[i,j], i=1..N),j=0..N),
                  seq(seq(eq3[i,j], i=1..N),j=0..N)
                ],
                [Gr=1.0, M=2]
 )
        );


 

 

 

Hi got this set of error using the Plot package. Anyone here know what they mean? 

Maple offers the dimension “lenght” whereas MapleSim offers two types.

What is the difference between the two types length and distance?

Can they always be used interchangeably?

First 29 30 31 32 33 34 35 Last Page 31 of 334