MaplePrimes Questions

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

Hello,

I'm trying to draw the basins of attraction for King's method with f(z) = z^3 - 1 

Thank you in Advance

I'm confused by the state equations resulting from linearizing the DoublePendulum example model.

The state equations are:

diff(x[1](t),t) = x[2](t),

diff(x[2](t),t) = 0,

diff(x[3](t),t) = x[4](t),

diff(x[4](t),t) = 0

where:

x[1](t) = R1_theta(t),

x[2](t) = diff(R1_theta(t),t),

x[3](t) = R2_theta(t),

x[4](t) = diff(R2_theta(t),t)

Am I understanding correctly that the state equations say that the angular acceleration of both revolute joints is zero? This is clearly not the case when you simulate the model and view the plots for angular acceleration. Can someone explain to me what's going on? Model with worksheet attached.

I have defined several expressions that keep coming up in my calculations. 
Like :

Delta := -2*M*r+a^2+r^2;
Sigma := (a^2+r^2)^2-Delta*a^2*sin(theta)^2;

Is it possible to make maple recognize these objects whenever they appear in the result of a calculation?

 I have a set of edges like this

{{1:1,1:2},{1:1,2:1}.........}  like this several may be 300 like this or more

i want it to be converted to

{{"1:1","1:2"},{"1:1","2:1"},......}  like inside double qoutes only

kind help

I have the following expression:

q1:=2.800000000*10^(-30)*a+2.7800000000*10^(-29)*b+2.7800000000*10^(-31)+3.0*10^(-21)+2.*10^(-32)*c+3.*10^(-30)*d;

I saved it as a string, but the format seems to have changed.

q2:=convert(q1,string)

Can I output it as follows:

"2.800000000*10^(-30)*a+2.7800000000*10^(-29)*b+2.7800000000*10^(-31)+3.0*10^(-21)+2.*10^(-32)*c+3.*10^(-30)*d"

I am still learning Maple and so I would like to rely on you power users to help me out. I probably doing something which is not allowed or not using the best method. I would appreciate any advice. Thank you in advance    ProcQuestion.mw 

``

restart:

 

N:=10

10

(1)

PDE:=diff(u(y, t), t) = diff(u(y, t), y, y)

diff(u(y, t), t) = diff(diff(u(y, t), y), y)

(2)

 

ICBC:= {u(y,0) = 0, u(0,t) = cos(t), u(N, t) = 0};

{u(0, t) = cos(t), u(10, t) = 0, u(y, 0) = 0}

(3)

 

sol1:=pdsolve(PDE,ICBC,numeric,spacestep=0.025,timestep=0.00001):

u_at_1 := sol1:-value(u(y,t), t=0.1);

Error, missing operator or `;`

 

u_at_1(0);

[y = 0., t = .1, u(y, t) = HFloat(0.9950041652780257)]

(4)

NULL

Download U.m.mw

Hi

The procedure below work well without using the package LinearAlgebra.

The package conduct to an error.

Thanks for any advice.

restart

with(DocumentTools); with(DocumentTools[Layout]); with(StringTools)

NULL

NULL

NULL

iterration := proc (a, b) local MV, Tlayout; global P; MV := parse(Trim(StringSplit(Split(interface(version), ",")[2], "Maple")[2])); Threads:-Sleep(.2); P := P, plot([[a, b]], style = point); Tlayout := Table(Column(), widthmode = percentage, width = 40, alignment = left, interior = none, Row(Cell(Textfield(InlinePlot(plots:-display(P, title = typeset(Iteration = a))))))); if 2018 < MV then InsertContent(Worksheet(Tlayout)) else InsertContent(Worksheet(Group(Input(Tlayout)))) end if; return  end proc

NULL

NULL

P := NULL

for j to 10 do a := j; b := j^.5; iterration(a, b) end do

Download loop.mwloop.mw

If i have p := 8*T(x, 7)*T(x, 2)+4*T(x, 5)*T(x, 1)+6*T(x, 3)*T(x, 3)+7*T(x, 1)*T(x, 4)

 I want to convert the the multiplication functions like T(x, 7)*T(x, 2) into summation T(x, 7)+T(x, 2)

How do a I multiply tensors?Here's what happens when I try to multiply on by a scalar. It makes no sense.

 

I have the set {1, 2, 3, 4, 6, 8, 12, 17, 19, 20} and i need to select all the elements between 5 and 15 and create another set with just those elements. So, I want to obtain the set {6,8,12}. How might that be done using the select( ) command? Other suggestions welcome.

For a single variable function, I can expand the function 

series(x/(1−x−x^2),x,4);

and get the expansion upto order 4 term.

What shall I do if the function is two variable like f(x,y)=xy/(y−x*sqrt(y)−x^2) and intended to keep terms upto order 5, or moreseries.mw

series(x/(-x^2-x+1), x, 4)

series(x+x^2+2*x^3+O(x^4),x,4)

(1)

series(series(x*y/(1-x*sqrt(y)-x^2), x, 8), y, 4)

O(x^8)+(x^7+x^5+x^3+x)*y+(3*x^6+2*x^4+x^2)*y^(3/2)+(6*x^7+3*x^5+x^3)*y^2+(4*x^6+x^4)*y^(5/2)+(5*x^7+x^5)*y^3+x^6*y^(7/2)+O(y^4)

(2)

``

Download series.mw

say.

My attempt failed as (x^7 + x^5 + x^3 + x)*y etc contains O(8) terms x^7.y

Please help. 

I have some of my main functions defined to take input in different formats. Some have required  parameters and also optional parameters. Similar to how say dsolve can take one ode, or a list of ode's or set of ode's and also other additional arguments.

Currently I use something like  ode::{`=`,set(`=`),list(`=`)} in the signature of the proc to indicate this input can be any of these types. There are also optional aguments.

So inside the proc, it does lots and lots of if this then do such else do such type of logic in order to determine which case/combination of input it is called with.

I am thinking of rewriting all of the API to use overload. Yes, it means I will have lots of copies of the same proc, each to handle specific case of the signature. But it also mean it will be now much simpler inside each of the overloaded proc's to determine which case of call it is processing.

I'd like to ask, is there anything to be aware of before making this change? does it affect performance much? It seems to me it will make the logic and the program simpler.  Here is a very simple example to illustrate.

Which you think is better? I like the overload version more. But I am worried that I will end up with too many versions of the API since I need one for each possible combination and may be this will slow Maple down? 

The following is the worksheet also.

restart;

interface(warnlevel=4);
kernelopts('assertlevel'=2):
foo:=overload(
[
   proc(A::`=`) option overload;
       print("single equation");
   end,
  
   proc(A::set(`=`)) option overload;
       if nops(A)=1 then
          print("single eq in a set");
       else
          print("more than one eq in a set");
       fi;
   end,

   proc(A::list(`=`)) option overload;
       if nops(A)=1 then
          print("single eq in a list");
       else
          print("more than one eq in a list");
       fi;
   end

]):

 

3

foo(x=1);
foo([x=1]);
foo([x=1,y=2]);
foo({x=1});
foo({x=1,y=2})

"single equation"

"single eq in a list"

"more than one eq in a list"

"single eq in a set"

"more than one eq in a set"

restart;

interface(warnlevel=4);
kernelopts('assertlevel'=2):

foo:=proc(A::{`=`,set(`=`), list(`=`)})

    if type(A,`=`) then
        print("single equation");
    elif type(A,set) then
          if nops(A)=1 then
             print("single eq in a set");
          else
             print("more than one eq in a set");
          fi;
    else #must be list
       if nops(A)=1 then
          print("single eq in a list");
       else
          print("more than one eq in a list");
       fi;
    fi;
end proc:

4

foo(x=1);
foo([x=1]);
foo([x=1,y=2]);
foo({x=1});
foo({x=1,y=2})

"single equation"

"single eq in a set"

"more than one eq in a set"

"single eq in a set"

"more than one eq in a set"

 

Download overload.mw

First 10 11 12 13 14 15 16 Last Page 12 of 2155