MaplePrimes Questions

This is a much simplified version of a problem I am seeing. I think I have to remove all the coerce code I added as it seems to have problems.

Made an object with constructor that take an optional argument. These optional arguments use coerce to convert different types on one type of list.

I have another proc foo() that is called with these arguments, also same optional ones, and it then creates the object passing these arguments to it. 

The problem is that if foo() is called with an optional argument itself, which will default to empty list [], I am not able to create the object now, when doing  ':-ic'=ic  since debugger gives 

Error, invalid input: too many and/or wrong type of arguments passed to ModuleCopy; first unused argument is [] = []

Even though I made sure to pass the optional argument using  ':-name'=value.

The strange thing is that this only shows in the debugger. i.e. when typing the command in the debugger window. But in my application, it does not work inside the debugger and outside since it is much more complicated setup.  This is the simplest example I could make to show the same error in the debugger.

A small example will show the problem.

restart;
A:=module()
   option object;
   export ode;
   export ic;

   export ModuleCopy::static:=proc(_self, proto::A, ode::`=`,
                    { ic::coerce( (ic::list(`=`))->ic, 
                                  (ic::set(`=`))->[ic[]],
                                  `:-NoUserValue`):=[]
                    },$)
        print("ode=",ode);
        print("ic=",ic);
    end proc;
end module;

foo:=proc(ode::`=`,{ ic::coerce( (ic::list(`=`))->ic, 
                     (ic::set(`=`))->convert(ic,list),
                     `:-NoUserValue`):=[]
                    },$)
    local o;
    DEBUG();
    o:=Object(A,ode,':-ic'=ic);
end proc:

# and now

foo(diff(y(x),x)=1)

Now the debugger window shows at the line above just before calling the object constructor. This is what happens next

 

But if I click continue it does not produce an error and actually works. (in my main application, with similar setup, it gives an exception).

If I can figure why debugger gives this error, may be that will help me figure my more complicated setup.  I know if I do not use coerce, the debugger error goes away. Here is a version without coerce, and it works

restart;
A:=module()
   option object;
   export ode,ic;
   export ModuleCopy::static:=proc(_self, proto::A, ode::`=`, { ic::list(`=`):=[] })
        print("ode=",ode);
        print("ic=",ic);
    end proc;
end module;
                  A := Object<<2457889631168>>

foo:=proc(ode::`=`, { ic::list(`=`):=[]})
    local o;
    DEBUG();
    o:=Object(A,ode,':-ic'=ic);
end proc:

#now do
foo(diff(y(x),x)=1)

Now the debugger window comes up, but now see the difference:

 

No error!  even though  `ic` was [] in this case also, like the first example.

So for now, I will remove all the coerce code just to get my application to work again even though I like it, but it seems to cause a problem.

question: What the first example above given an error in the debugger?  

Notice this error only shows up when using a module of type object

Update

This is just to confirm that removing the coerce API and replacing it back as it was with traditional optional arguments as in the second example above the exception went away.  My code is way too large to post here, but that is the only difference I have.  I think there is a problem using coerce with Object constructor calling somewhere.  But I am OK now, and able to continue work.

Given a graph G say and a positive integer k

I am in look out how to remove

 edge-disjoint copies of G in G^k

That is edge disjoint copies of G into its power graph all possible ways 

Again it is the maximum number of copies I means 

Keeping this particular way can someone help kind help please

I will surely acknowledge it 

G into to GraphPower(G,k)

I was wondering if there was a way to permute a list to get a list of sums of permutations.
for example,

list:=[a,b,c]
permute(list,2) gives me ([a,b] [b,c] [c,a])

I would like to get this instead: ([a+b],[b+c],[c+d])

NULL

the quick brown fox jumps over the lazy dog

NULL

Download the_quick_brown_fox_jumps_over_the_lazy_dog.mw

I have a long description that contains some Maple commands.
I dont want to use # as the lines dont show up when i use

Isee:=proc(a)
    interface(verboseproc = 3);
    printf("%P", eval(a));
end proc

The long description is. Any way around the problem?  

Test:=proc(A,B,C)  description  "Computes projective line through 2 projective points or intersert of 2 projective lines as a projective point or coincidence of piont  line   
 Does some checking on validity of inputs.   
Mobposn:- Global Variable, must = 1 or 3. 
Points are returned as <1,x,y> or <x,y,1>   
 Lines are returned as <z,x,y> or <x,y,z>,  
normalgpt :- Global Variable must be 0 or 1. 
Points with algecraic elements are not reduced to <1,x,y> or <x,y,1> if 0  
 Points are defined as row vectors and  lines as column `vectors"`; 

 print(A,B,A-C); 

 end proc;

Hi, please how do I return the roots of a function in the form of I*y. The roots are [-.2381948477, -0.1434221912e-3, 0., 0.1434221912e-3, .2381948477] and I want to return them as [-.2381948477*I, -0.1434221912e-3*I, 0., 0.1434221912e-3*I, .2381948477*I]. I tried to use subs () function but couldn't work.

with(Student[Calculus1]):

soln := Roots(y-0.4646295e-3*tanh(y)+0.1839145082e-2*tanh(y)/(0.6000000000e-3*y^2-0.1840000000e-2), y);

subs(soln, I*y);

I don't have Maple yet, but if it can solve this problem for me then I'm ready to purchase!

I have a probability mass function pmf(in) to define a discrete probability distribution, based on a combinatoric analysis of an object of size n. So I don't have a drv X, I have a formula to generate Xn for 0 <= n, where n + 1 is then the size of the outcome alphabet.

In other words, 
Xn = {0 <= i <= n : p(xi) = pmf(i, n)}

Where pmf(i, n) is 'well behaved' in the sense that it's not producing arbitrary results. As n increases, Xn has the same distribution simply with more detail.

So my question is, can Maple calculate the entropy, usually written H(X), of this distribution at, dare I say it, the limit, X?

Can it calculate it symbolically, or can it 'only' approximate it by a Taylor series or something?

Thanks in advance, this problem really has me stumped!

Is it possible to create a shaded area between a set of three LineChats in Maple?

Hi,

I want to LinearSolve a square matrix (434160,434160) with sparse storage.

When I use SparseIterative with levelfill = 1, the commande gives a solution with very bad precision. I used many other options to get better precision without succes.

When I use SparseDirect (which I want to use), my PC (with 16G RAM) is bloqued and I must shut down it. 

Is any advices to use SparseDirect for matrix with high dimensions and sparse storage. 

Or, I must use another PC or another type of storage.

Thanks in advance.

Dear power users, could someone be so kind to help me out with this file and give me some explanation on what I did wrong?

QuestionMaplePrimes.mw Thank you for you time and help

Why does an attempt to solve the ODEs in the uploaded worksheet fail and how can this error be removed so they can be solved?

Unable_to_convert.mw

restart;
with(plots): with(geometry):
_EnvHorizontalName := 'x':
_EnvVerticalName := 'y':
a := 7:
point(E, 0, a*sqrt(3)/2):
point(B, -a/2, 0):
point(C, a/2, 0):
point(o, 0, a*sqrt(3)/6):
point(A, 0, a/2):
point(H, 0, 0):
R := (3-sqrt(3))*sqrt(2)*a/12:
point(J, 0, a*sqrt(3)/6 - R):
triangle(Tr1, [E, B, C]):
triangle(Tr2, [A, B, C]):
StretchRotation(E1, E, B, Pi/4, clockwise, sqrt(2)/2);
coordinates(E1);
StretchRotation(E2, E, C, Pi/4, counterclockwise, sqrt(2)/2);
coordinates(E2);
triangle(Tr3, [E, B, E1]);
triangle(Tr4, [E, C, E2]);
triangle(Tr5, [B, C, J]);
circle(cir, [point(P1,[0,a*sqrt(3)/6]), R]):
poly := Matrix([[0, a*sqrt(3)/2], [-7/4 + (7*sqrt(3))/4, -7/4 + (7*sqrt(3))/4], [0, a/2], [7/4 - (7*sqrt(3))/4, -7/4 + (7*sqrt(3))/4]], datatype = float);
pol1 := polygonplot(poly, colour = "Magenta", transparency = 0.7, gridlines);
tex := textplot([0.2, a*sqrt(3)/2, "zE"], 'align' = {'above', 'right'});
draw([Tr1(color = cyan),
Tr3(color = green),
tex,
cir(color=blue),
Tr2(color = red),
Tr4(color = grey),
Tr1(color=blue)],'view' = [-5 .. 5, 0 .. 7], 
axes = normal, scaling = constrained,size=[800,800]);
Error, (in geometry:-draw) the option must be of type equation or name
line(L1, [B, o]);
Equation(L1);
line(L1, -(7*x*sqrt(3))/6 + (7*y)/2 - (49*sqrt(3))/12 = 0);
reflection(J1, J, L1);
triangle(Tr6, [B, J1, E]);
line(L2, [C, o]);
Equation(L2);
line(L2, -(7*x*sqrt(3))/6 - (7*y)/2 + (49*sqrt(3))/12 = 0);
reflection(J3, J, L2);
triangle(Tr7, [C, J3, E]);
triangle(T1, [E, J1, A]);
triangle(T2, [E, C, E2]);
triangle(T3, [B, H, J]);
triangle(T4, [C, H, J]);

draw([cir(color = orange, filled = true, transparency = 0.1), pol1, Tr6(color = blue, filled = true, transparency = 0.2), Tr5(color = blue, filled = true, transparency = 0.2), Tr7(color = blue, filled = true, transparency = 0.2), T1(color = green, filled = true, transparency = 0.2), T2(color = green, filled = true, transparency = 0.2), T3(color = green, filled = true, transparency = 0.2), T4(color = green, filled = true, transparency = 0.2)], axes = none, scaling = constrained);
Error, (in geometry:-draw) the option must be of type equation or name
NULL;
NULL;

Why these errors messages ? Thank you.

Problem 1)   Give graph G1 and a graph G2  the problem is to extract maximum isomorphic copies of G1 from G2 such that it has no edge intersection maximum number is floor((number of edges of G2)/(number of edges of G1)) and display the Edge sets of those isomorphic graphs and the graph formed by the remaining edges sometimes their may be no remaing edges too.  Need all possible such copies.

Problem 2) Give graph G1 and a graph G2  the problem is to extract maximum isomorphic copies of G1 from G2 such that each copy has  exactly one edge intersection with each of the copies and that one edge intersection occurs only between those two copies and  display the Edge sets of those isomorphic graphs . Need all possible such copies.

If any more examples or explation will give kind help please I can give more examples or more kind please help.

I had written this c++ code years back for problem 2 which i have forgotten kind help if possible to make it better with maplesoft.

Please take your time. Kind help help plese it will be very helpful it is of real help.

orthogonal.txt

I had written this c++ code years back for problem 1 which i have forgotten kind help if possible to make it better with maplesoft.

Please take your time. Kind help help plese it will be very helpful it is of real help.

decom.txt

Need to maintain memory space as graph size is a little big may be 

would usage of database or any other be useful dont know I had done those code in c++ long back which i forgotten logic too.

Please please help based on latest technology please take your time and kind help I apologize disturb you kind help.

I would surely acknowledge for this great work as much as I can much more than I can acknowlege too

I am using Maple 2020

I need to conver 2D points to projective points. Originally I used lists but now need to handle vectors too. To add to that that the projective coordinate for points is now being stated as [1,x,y] instead of [x,y,1]. That is was easy enough to handle for lists.

I have a lot of old worksheets that use the list form [x,y,1] that I want to maintain compatibility with. I only have one procedure I need to convert.
 

Mobposn := 1;
testP := [2, 7];
if Mobposn = 1 then
    [1, op(testP)];
else
    [op(testP), 1];
end if;

I need to do the same for vector definition of the points. The points are defined as row Vectors

A:=<2,7>^%T

to get

Ap:=<1,2,7>^%T

or

Ap:=<2,7,1>^%T

I know coud just do (as these are short vectors)
 

Ap:=<1,A_1,A_2>^%T

or
Ap:=<A_1,A_2,1>^%T

Is there a more general way?

I am trying to do the following computation. I  extracted n*1 matrix from n*n matrix which unbelievably gives vector?

How I can do the following multiplication without using convert command? Or how to extract n*1 matrix (not vector) from n*n matrix without using convert?

``

restart

``

``

A := Matrix(4, 4, {(1, 1) = m[1, 1], (1, 2) = m[1, 2], (1, 3) = m[1, 3], (1, 4) = m[1, 4], (2, 1) = m[2, 1], (2, 2) = m[2, 2], (2, 3) = m[2, 3], (2, 4) = m[2, 4], (3, 1) = m[3, 1], (3, 2) = m[3, 2], (3, 3) = m[3, 3], (3, 4) = m[3, 4], (4, 1) = m[4, 1], (4, 2) = m[4, 2], (4, 3) = m[4, 3], (4, 4) = m[4, 4]})

A := Matrix(4, 4, {(1, 1) = 0, (1, 2) = m[1, 2], (1, 3) = m[1, 3], (1, 4) = m[1, 4], (2, 1) = 0, (2, 2) = m[2, 2], (2, 3) = m[2, 3], (2, 4) = m[2, 4], (3, 1) = 0, (3, 2) = m[3, 2], (3, 3) = m[3, 3], (3, 4) = m[3, 4], (4, 1) = 0, (4, 2) = m[4, 2], (4, 3) = m[4, 3], (4, 4) = m[4, 4]})

(1)

A(1 .. 4, 1) := Matrix(4, 1):

A

Matrix([[0, m[1, 2], m[1, 3], m[1, 4]], [0, m[2, 2], m[2, 3], m[2, 4]], [0, m[3, 2], m[3, 3], m[3, 4]], [0, m[4, 2], m[4, 3], m[4, 4]]])

(2)

B := A(1 .. 4, 2)

B := Vector(4, {(1) = m[1, 2], (2) = m[2, 2], (3) = m[3, 2], (4) = m[4, 2]})

(3)

A.B

4

(4)

F := Matrix(4, 1, {(1, 1) = 0.4279668887e-7, (2, 1) = -0.3901148183e-7, (3, 1) = 0.3900685346e-7, (4, 1) = 0.})

Typesetting:-delayDotProduct(A, B)-F

Error, (in rtable/Sum) invalid input: dimensions do not match: Vector[column](1 .. 4) cannot be added to Matrix(1 .. 4, 1 .. 1)

 

A.convert(B, Matrix)-F

Matrix(4, 1, {(1, 1) = m[1, 2]*m[2, 2]+m[1, 3]*m[3, 2]+m[1, 4]*m[4, 2]-0.4279668887e-7, (2, 1) = m[2, 2]^2+m[2, 3]*m[3, 2]+m[2, 4]*m[4, 2]+0.3901148183e-7, (3, 1) = m[3, 2]*m[2, 2]+m[3, 3]*m[3, 2]+m[3, 4]*m[4, 2]-0.3900685346e-7, (4, 1) = m[2, 2]*m[4, 2]+m[3, 2]*m[4, 3]+m[4, 2]*m[4, 4]})

(5)

``

Download soalzarb.mw

First 165 166 167 168 169 170 171 Last Page 167 of 2308