how can child module call parent local proc, witho...

Here is short description of the problem with code MWE below.

Short version of the question

I want to change

parent:=module()
local foo:=proc()
NULL;
end proc;

local child:=module()
export boo:=proc()
foo(); #call works as is
end proc;
end module;

end module;


To

parent:=module()
local foo:=proc()
NULL;
end proc;

local child:=module()
export boo:=proc()

#now call no longer works. Maple wants foo exported
#I want to add parent:- to the call to remind me where foo((
#lives but do not want to make foo() in parent exported

parent:-foo();

end proc;
end module;
end module;


Longer version of the question

I have a parent module with one child local module inside it. In the child module, there is a proc which wants to call parent's local proc named foo().

As is, the child module can just call the parent's local proc foo() by typing foo() without the need to do parent:-foo() this is because child module has access to parent local proc's and maple knows which foo() by searching the scope from bottom up.

The problem comes when I added a proc also called foo() (by mistake) in the child module without noticing there is one with same name in the parent's.

Now the call foo() will end up calling the child's module foo() and not the parent's foo() becuase that is the "closest" one with this name in the scope. All of this makes sense so far.

The problem comes when the child module wants to really call the parent's foo().

One solution is to change the call to parent:-foo() to explicitly says which foo() to call.

This however now fail, since the parent foo() is local ! And Maple when it sees call to parent:-foo() it now insist it be exported proc (even though the call is being made from inside, i.e. from the child).

I do not want to make the parent's foo() exported just so the child can call it.  I want to keep parent's foo() local, as it is meant to be used only inside the parent and by its children.

You might ask, why not then change the name of the child's foo() to some other name so it does not clash with the parent's local proc name. Yes, I can do this. But for large modules in different files with many procs(), there is a always a chance  a local proc can be added by mistake with happend to be the same name as one in the parent and having to manually keep checking names does not look like the right solution.

My question is: How can a child module call parent's local proc() explicitly, but without making the parent proc exported?  Is there is different syntax to use?

Here is a MWE

restart;
parent:=module()

export main:=proc()
child:-boo();
end proc;

local foo:=proc()
print("in parent:-foo() proc");
end proc;

local child:=module()
export boo:=proc()
print("in child:-boo() proc");
foo(); #this works. It called parent's local foo()
end proc;
end module;

end module;


Now doing parent:-main() works as expected. Notice parent's foo is local to parent module.

Now I changed the child module and did this

parent:=module()

export main:=proc()
child:-boo();
end proc;

local foo:=proc()
print("in parent:-foo() proc");
end proc;

local child:=module()
local foo:=proc() #added this using same name by mistake
print("in child:-boo()");
end proc;

export boo:=proc()
print("in child:-boo() proc");
foo(); #now this calls the child's foo() ofcourse. But it was meant to call the parents's
end proc;
end module;

end module;


The fix is to change the call from the child to becomes    parent:-foo() but now Maple will give an error saying parent does not export foo().

Since the child have access to parent's local proc's, is there a different way to tell Maple I want to call parent's foo() and not my own foo() without making parent's foo() exported?

For example , in Python one call call parent's method expliclity using super().foo()

Maple 2021.2

How do I import only selected columns from a csv f...

Hello community,

how can I import only selected columns from a csv file?
My current code is the following:

IK := Import("Indifferenzkurve.csv", output = datadir)

However, I'd like to only import the three columns "E","T", and "S_P and S_TEV", not column " " and "Diff".
On this basis, I'd like to plot "S_P and S_TEV":

plot3d([IK], E = 0.1 .. 1000000, T = 1 .. 45)

Rebekka

add and add with different results...

Hello,

I noted that add and 'add' can give different result, can somebody help me understand it?  Consider the code below:

>phi1 := GAMMA(-(1/2)*vst-8.333500000-(1/2)*r)*GAMMA((1/2)*vst+21/2+(1/2)*r); phi2 := GAMMA(16.66700000+r-2*vst)*GAMMA(2.166500000+vst); xi1 := -vst; xi2 := 16.66700000+r-2*vst; z := 37.52950222; K := 9.846618489*10^(-38)*33.330^(.5000000000*r+10.)

### Then I have the following sums (they were supposed to give the same results):

>f := unapply(K*add(phi1*(-1)^vst*z^(-xi1)/factorial(vst)+phi2*(-1)^vst*z^(-xi2)/(.5*factorial(vst)), vst = 0 .. 10000), r):

>g := unapply(K*'add'(phi1*(-1)^vst*z^(-xi1)/factorial(vst)+phi2*(-1)^vst*z^(-xi2)/(.5*factorial(vst)), vst = 0 .. upto), [r, upto]);

# I am interested in the following quantities:

>evalf(f(1)/f(0));

-6.265883733

>evalf(g(1,10000)/g(0,10000))

25.80438437

That seems very strange to me, why maple gives different results?

Legend Inside Plot...

How we can locate legend inside the plot like the one in the picture

equ1 := BesselJ(sqrt(17)/2, 10*sqrt(t)*sqrt(2))/t^(1/4) + BesselY(sqrt(17)/2, 10*sqrt(t)*sqrt(2))/t^(1/4)
equ2 := BesselJ(sqrt(17)/2, 10*sqrt(t)*sqrt(2))/t^(1/4) + 5*BesselY(sqrt(17)/2, 10*sqrt(t)*sqrt(2))/t^(1/4)
equ3 := BesselJ(sqrt(17)/2, 10*sqrt(t))/t^(1/4) + 5*BesselY(sqrt(17)/2, 10*sqrt(t))/t^(1/4)
plot([equ1, equ2, equ3], t = 0 .. 30, labels = [t, T[2](t)], tickmarks = [0, 0], labelfont = [TIMES, ITALIC, 12], axes = boxed, color = ["Red", "Violet", "Blue"])
C[3] = 1, C[4] = 1, Omega^2 = 50
C[3] = 1, C[4] = 5, Omega^2 = 50
C[3] = 1, C[4] = 5, Omega^2 = 25

Thank you!

How can i calculate avarage of n numbers?...

I want to calculate the arithmetic average of a class of 5 students for 3 different exams. I want to calculate a different average for each exam. I want to use i and j variables. exam grades will be random like 20*i. How can i do this program? Any can do this? Thank you

I try this program but i get error

total:=0;

numb:=0;

for i from 1 to 3 do

for j from 1 to 5 do

N[i,j]:=20*i;

total:=total+N[i,j];

numb:=numb+i

end do;

end do;

evalf(total/numb);

How can I find another beautiful numbers like 22/0...

The date, month, year  22/02/2022 is said a beautiful numbers. Because, the number 2202 symmetry to the number 2022. How can I find another beautiful numbers like that ?

Is there any way to find the equation of intersect...

I have two surfaces f=f(x,y) and g=g(x,y), is there any way to find the equation of intersection curve of them in maple?

contact.mw

solve pde with pdsolve...

hello i want to solve this pde equation numericaly with pdsolve:

diff(u(x, t), x, x) + diff(u(x, t), t, t)/0.5^2 - 2*diff(u(x, t), x, t)/0.5^2 = -0.0013*u(x, t) + 8.6510*u(x, t)^3

and enter this codes:

PDE := diff(u(x, t), x, x) + diff(u(x, t), t, t)/0.5^2 - 2*diff(u(x, t), x, t)/0.5^2 = -0.0013*u(x, t) + 8.6510*u(x, t)^3
IBC := {u(0, t) = 0.01, u(4, t) = 0, u(x, 0) = 0, D[1](u)(x, 0) = 0};
pds := pdsolve(PDE, IBC, numeric, t = time, rage = 0 .. 1);

but this error appear :

Error, (in pdsolve/numeric/process_IBCs) initial/boundary conditions can only contain derivatives which are normal to the boundary, got (D[1](u))(x, 0)

and i don't know how ti fix it.

can someone help me?

Reducing parabola with LinearAlgegra...

how to transform this program using LinearAlgebra instead of linalg  ?

restart;
with(plots);
unprotect(gamma, D);
interface(rtablesize = 10): _EnvHorizontalName := 'x': _EnvVerticalName := 'y':
f := (x, y) -> 4*x^2 + 4*y*x + y^2 - 8*x + 16*y - 17: (for instance)
NULL;
Fg := proc(P::polynom, v::set, V::list, N::list)
local C, M, i, j;
C := coeffs(f(x, y), v, M); seq(if(member(op(i, [M]), N, 'j'), op(j, V) = op(i, [C]), NULL), i = 1 .. nops([M])); end proc:
Fg(f(x, y), {x, y}, [A, B, C, D, E, F], [x^2, y*x, y^2, x, y, 1]):
assign(%);
Delta := -4*A*C + B^2:
var := [x, y]:
with(linalg):
AA := matrix([seq([seq(diff(f(x, y), var[i], var[j])/2, j = 1 .. 2)], i = 1 .. 2)]):
vp := sort([eigenvals(AA)]):
print(Valeur propres de AA  = vp):
DD := jordan(AA, 'P11'):
print(Matrice diagonale semblable à AA:   DD = evalm(DD)):
G := map(normalize, GramSchmidt([col(P11, 1 .. 2)])):
PP := map(simplify, concat(op(G))):
print(Matrice de passage orthogonale:   PP = evalm(PP)):
print(Directions principales de la conique:):
print(I1  = col(PP, 1),  J  = col(PP, 2)):
alpha := 1/2*arctan(B/(A - C)):
print('alpha' = evalf(%)):

M1 := matrix(1, 2, [X, Y]):
M2 := matrix(2, 1, [X, Y]):
multiply(M1, AA, M2):
N := matrix(1, 2, [D, E]):
multiply(M1, AA, M2) + multiply(N, M2):
multiply(M1, transpose(PP), AA, PP, M2) + multiply(N, PP, M2):

NULL;
The parabola in the new base is Y^2 =X*(8*sqrt(5))/5 , <sqrt(5), -2*sqrt(5)>, <sqrt(5), 2*sqrt(5)>

Problem with sum in linked functions...

I am trying to define a sum which is obtained from linked functions (which also contain the sum command).

The problem is: if I modify the first function p and rerun the worksheet (except fot the restart command), then the changes do not affect the result. Does anyone know why? Thank you very much.

 >
 >
 (1)
 >
 (2)
 >
 (3)

If I modify p (I make it twice its initial value), then this does not affect the value of q and r

 >
 (4)
 >
 (5)
 >
 (6)

Why?
Even if I  unassign p, q and r, this does not work, either.

 >
 >
 (7)
 >
 (8)
 >
 (9)

Only if I restart, then I can modify p and change the rest of values

 >
 >
 (10)
 >
 (11)
 >
 (12)
 >
 >

How to define and evaluate a function of two tenso...

I am working with the de Sitter metric which takes the form

$$g=\tau^{-2}\left(-\left(\Lambda / 3-\tau^{2}\right)^{-1} d \tau^{2}+\left(\Lambda / 3-\tau^{2}\right) d t^{2}+g_{\mathbb{S}^{2}}\right)$$

or

g := evalDG((-d&tau; &t d&tau;/(Lambda/3 - tau^2) + (Lambda/3 - tau^2)*(dt &t dt) + (dtheta &t dtheta) + sin(theta)^2*(dphi &t dphi))/tau^2)

in the co-ordinates $\{\tau, t, \theta, \phi\}.$

or

DGsetup([tau, t, theta, phi], M1, verbose)

Define

F := evalDG(-Q*(d&tau; &t dt) + Q*(dt &t d&tau;))

Then I want to define the following function which takes a two tensor (metric) and returns a two tensor as well.

Here \dot(g) is the input tensor, F is the two tensor defined above and the g is the de Sitter metric.

I want to evaluate this expression of \dot{g} = d tau^2/tau^2 and other metrics. How can I do this in Maple?

Any help will be much appreciated.

How to quickly solve a system of equations where t...

With Maple, is there a way to quickly solve systems of equations where the solutions are the coordinates of a vector?
An example of an idea: A problem to solve:
There are points: M(1,0,0) and N(0,0-1); plane (Q): x-y-4=0. Determine the plane (P) containing M and N, making with (Q) a 45 degree angle.
Solution:
Assume: Equation of (P): Ax+By+Cz+D=0
We have:
Normal vector of (P): np(vector):=<A,B,C>
Normal vector of (Q): nq(vector):=<1,-1,0>
Direction vector of line NM: dNM(vector):=<1,0,1>
To determine: A, B, C, it is necessary to solve the system of equations:
cos(45 degrees)= np(vector).nq(vector)/abs(np(vector)) x abs(nq(vector))=1/Sqrt(2)
dNM(vector).np(vector)=0....

How to solve this summation ?...

Hi !

I want to solve several summations which at first glance seems very easy to me.

But I definitely hit a wall. I have Maple 2018 on Windows 10.

I'm not very familiar with the sumtools or Sumtools packages.

I have attached a file that gives you an example summation and the

solution I found and especially I show you the way that I obtained this solution.

The big question is:

Is there a way to transform this summation to arrive at my solution?

Or . Can the result I obtained be demonstrated?

Maple seems unable to solve this summation. Mathematica did no better.

I know very well that this is more a question for mathematicians than for

Maple users. But when I look at the questions in Mapleprimes I see

although there are good mathematicians behind most of these questions.

sum1.mw

(}),At offset 4370 in :-2108.m, unexpected DAG t...

hi

hiiiiiiiiiii

i am working and modling on brushless motor for my project but when i run that i get this error and i can not fix that could you please help me. error is :

equation generation

(}),At offset 4370 in :-2108.m`, unexpected DAG type: 0,125

every project  i run  has the same error