MaplePrimes Questions

Hello forums,

I appreciate all the help that has been given to me throughout the past months.  I'm trying to solve a differential equation that involves a matrice in it.  I'm not sure if I am entering in the problem in correctly nor do I know what commands to use.  Can someone please be of assistance and teach me?

 

Thanks 

William

Solving_a_linear_algebra_differential_equation.mw

Dear Maple users

I wanted to create a list of random datapoints for the "simple linear regression model". Standard deviation sigma is given, slope a and fixed value b given for the line as well. Before the code below I had some random x-values created for the data points saved in the list X. To calculate the corresponding y-values randomly from a normal distribution with standard deviation sigma and mean equal to a*x+b I wrote the code below:

 

randomize():
for i from 1 by 1 to N do    
    mean:=a*X[i]+b:
    Yvar:=RandomVariable(Normal(mean,sigma));
    S:=Sample(Yvar,1);
    Z[i]:=S[1];
end do:
Y:=convert(Z,list):

....

 

It actually works, but I just found it a bit strange having to repeatedly ask for a random sample with only a single member. Isn't it possible to do it more efficiently? I am aware of the special properties of the normal distribution, which would make it possible to take only one sample and add the mean afterwards, but I am not looking for ad hoc solutions, rather appropriate commands to create simgle random values from a distribution.  

Erik

 

Hi,

I am using A:=LinearAlgebra:-RandomMatrix(10,10,generator=-10..10) to generate a random matrix. How may I specify that every row of A has at least three non-zero entries? 

Thanks!

Hello, i'm doing an interface for LU decomposition. I need to do a multiple windows interface using maplets, and i want to click one button on the inicial interface to open another window with other interface. I also need to create the second interface having N TextFields (N value will be inserted on the first window). Somebody knows how to do it?

Suppose I have a list of plywood dimensions

4 - 40.625" x 20"
2 - 36" x 20"
2 - 34.75" x 20"
3 - 33.75" x 12"
6 - 18.825" x 12"
3 - 32.5" x 12"
3 - 33.75" x 19.5"

How many sheets of 4' x 8' plywood do I need to minimize the cost of my project?

 

How does maple produce a Betweeness centrality matrix for unweighted, strongly connected graphs?

8/24/19. Updated question the bottom

I need to find if expression has  a "-" in front of it or not.  This is for formatting purposes for something I am doing, that is all. 

I was using the command sign() for this, and it seems to work OK, but sometimes a Maple error is generated or not leading term sign is returned.

The sign function computes the sign of the leading coefficient of expr.

Is there a better and more robust way to do this other than using sign() or Am I using sign wrong?

restart;

expr:=-sin(x)/ln(y)+1;
op(expr);

-sin(x)/ln(y)+1

-sin(x)/ln(y), 1

#why this gives 1 as sign for the above?
sign(expr);

1

#workaround?
sign(op(1,expr))

-1

expr:=sin(x)/ln(y)+1;
sign(expr);

sin(x)/ln(y)+1

1

expr:=-x;
sign(expr);

-x

-1

expr:=-LambertW(exp(p))+1;
sign(expr)

-LambertW(exp(p))+1

-1

expr:=-LambertW(exp(p))/(1+LambertW(exp(p)))+1;
sign(expr)

-LambertW(exp(p))/(1+LambertW(exp(p)))+1

Error, invalid argument for sign, lcoeff or tcoeff

#it seems the following is a work around for the above case
#but why it is needed just here?
sign(op(1,expr))

-1

 

 

Download q1.mw

UPDATE

Thanks to comment below about using frontend. I never used this before except for now. It seems a very useful command and I think I will be using it a lot more from now on.

Just to clarify again what I want. I am just looking to see if there is a leading negative sign in front of an expression. I am not looking to find if the expression itself can be postive or negative when evaluated or anything more subtle or deep than that.

I simply want to check if there is literally a "-" in front of the maple expression. That is all.

Only issue left, is why Maple still gives Error, invalid argument for sign, lcoeff or tcoeff for the last example below? Here is the updated worksheet.

restart;

expr:=-sin(x)/ln(y)+1;
frontend(sign,[expr]);

-sin(x)/ln(y)+1

-1

expr:=sin(x)/ln(y)+1;
frontend(sign,[expr]);

sin(x)/ln(y)+1

1

expr:=-x;
frontend(sign,[expr]);

-x

-1

expr:=-LambertW(exp(p))+1;
frontend(print,[expr]);
frontend(sign,[expr]);

-LambertW(exp(p))+1

-O+1

-1

expr:=-LambertW(exp(p))/(1+LambertW(exp(p)))+1 ;
frontend(print,[expr]);
frontend(sign,[expr]);

-LambertW(exp(p))/(1+LambertW(exp(p)))+1

-O/(1+O)+1

Error, invalid argument for sign, lcoeff or tcoeff

 

 

Download q1_2.mw

Can any one find why the first code works and not the second code?
The same code, but not shown in the upload below.

reset; with(Plot)
plot(tan(x), x = -Pi .. Pi, y = -(1/2)*Pi .. (1/2)*Pi, color = ["blue"], legend = Graph*of*inverse*tan*`function"`, caption = " Domain = [-∞, ∞]; Principal range = [-π/2, π/2]")

 

``

``

``

"plot(tan^()(x),x=-Pi..Pi, y = -Pi/(2)..Pi/(2),color = ["blue"],legend = "\"inverse tan (""x"")\"", title= "Graph of inverse tan function", caption  =" Domain = [-infinity, infinity]; Principal range = [-π/2, π/2]")"

Error, invalid =

"plot(tan(x),x=-Pi..Pi, y = -Pi/2..Pi/2,color = ["blue"],legend = , title= "Graph of inverse tan function", caption  =" Domain = [-infinity, infinity]; Principal range = [-π/2, π/2]")"

 

``


 

Download SyntaxErrorinlegend.mw

Just a basic question, wanted to be clear.  When odeavisor returns a list of types (or classifications) of an ODE. This must mean the ODE can be of any one of these types?

For example, this ODE below, it says it is either homogeneous or rational or Abel or dAlembert.

I am asking because it can be much easier to solve an ODE if one knows if it is of one type vs. the other.

For example, for this one below, it is little easier to solve it if one sees it is Abel instead of dAelmbert. 

The hard part is knowing what type of ODE one is trying to solve and so it is important to pick the right/easier type to use.

Which brings another question: When Maple is given an ODE to solve, and it can be of number of types, how does it select which type to use to solve the ODE? Since the method to solve the ODE depends on the type of the ODE. (At least, when solving it by hand it does make a big difference).

Is there any detailed document that explains more how odeadvisor determines the type of the ODE? This is a very powerful and a useful command but I can't find in help any hints on how it determines the type of ODE.

It must use some general method/algorithm to approach this problem instead of trying to match each different ODE type one by one. right?  I tried to trace the code in the debugger, but I do not fully understand the code flow.

restart;

Typesetting:-Settings(typesetprime=true):

ode:=x^2*(4*x-3*y(x))*diff(y(x),x) = (6*x^2-3*x*y(x)+2*y(x)^2)*y(x)

x^2*(4*x-3*y(x))*(diff(y(x), x)) = (6*x^2-3*x*y(x)+2*y(x)^2)*y(x)

DEtools:-odeadvisor(ode)

[[_homogeneous, `class A`], _rational, [_Abel, `2nd type`, `class C`], _dAlembert]

DEtools:-odeadvisor(ode,['dAlembert']);
DEtools:-odeadvisor(ode,['Abel']);
DEtools:-odeadvisor(ode,['homogeneous']);

[_dAlembert]

[[_Abel, `2nd type`, `class C`]]

[[_homogeneous, `class A`]]

new_ode := diff(y(x),x)=convert(solve(ode,diff(y(x),x)),parfrac); # y'= the following below. So it is Abel indeed

diff(y(x), x) = -50/27-(2/3)*y(x)^2/x^2+(1/9)*y(x)/x-(200/27)*x/(-4*x+3*y(x))

#But to solve it as dAlembert, one need to rewrite it as y=x*g(y')+f(y') and it gets messy
#becuase one has to solve for y(x) first, and this will generate more than one ODE
ode:=convert(ode,D);
map(z-> y(x)=convert(z,diff),[solve(ode,y(x))])

x^2*(4*x-3*y(x))*(D(y))(x) = (6*x^2-3*x*y(x)+2*y(x)^2)*y(x)

[y(x) = ((1/2)*(5*(diff(y(x), x))-5+(8*(diff(y(x), x))^3+61*(diff(y(x), x))^2+4*(diff(y(x), x))+52)^(1/2))^(1/3)-2*((1/2)*(diff(y(x), x))+3/4)/(5*(diff(y(x), x))-5+(8*(diff(y(x), x))^3+61*(diff(y(x), x))^2+4*(diff(y(x), x))+52)^(1/2))^(1/3)+1/2)*x, y(x) = (-(1/4)*(5*(diff(y(x), x))-5+(8*(diff(y(x), x))^3+61*(diff(y(x), x))^2+4*(diff(y(x), x))+52)^(1/2))^(1/3)+((1/2)*(diff(y(x), x))+3/4)/(5*(diff(y(x), x))-5+(8*(diff(y(x), x))^3+61*(diff(y(x), x))^2+4*(diff(y(x), x))+52)^(1/2))^(1/3)+1/2+((1/2)*I)*3^(1/2)*((1/2)*(5*(diff(y(x), x))-5+(8*(diff(y(x), x))^3+61*(diff(y(x), x))^2+4*(diff(y(x), x))+52)^(1/2))^(1/3)+2*((1/2)*(diff(y(x), x))+3/4)/(5*(diff(y(x), x))-5+(8*(diff(y(x), x))^3+61*(diff(y(x), x))^2+4*(diff(y(x), x))+52)^(1/2))^(1/3)))*x, y(x) = (-(1/4)*(5*(diff(y(x), x))-5+(8*(diff(y(x), x))^3+61*(diff(y(x), x))^2+4*(diff(y(x), x))+52)^(1/2))^(1/3)+((1/2)*(diff(y(x), x))+3/4)/(5*(diff(y(x), x))-5+(8*(diff(y(x), x))^3+61*(diff(y(x), x))^2+4*(diff(y(x), x))+52)^(1/2))^(1/3)+1/2-((1/2)*I)*3^(1/2)*((1/2)*(5*(diff(y(x), x))-5+(8*(diff(y(x), x))^3+61*(diff(y(x), x))^2+4*(diff(y(x), x))+52)^(1/2))^(1/3)+2*((1/2)*(diff(y(x), x))+3/4)/(5*(diff(y(x), x))-5+(8*(diff(y(x), x))^3+61*(diff(y(x), x))^2+4*(diff(y(x), x))+52)^(1/2))^(1/3)))*x]

 

 

Download q1.mw

 

 

 

Hi,

I have a simple expression  g1:=x^2+x;

Then its derivative D1:=diff(g1,x); which is 2x+1

Then I want to make a function with this derivative f1:=x->D1;

And I want to evalute this function at any point, for instance f1(3)

And what I get for f1(3) is the the derivative 2x+1 and not the value 7 as I would expect.

What am I missig?

Hi, 

I've got this strange error. Could anyone explain me where it comes from?
Thanks in advance.

(PS My Maples's version is  Maple 2015.2, APPLE UNIVERSAL OSX, Dec 20 2015, Build ID 1097895 )
 

restart:

with(plots):
with(geometry):

RegularPolygon(gon,5,point(o,1,1),2);

gon

(1)

restart:

with(plots):

geometry:-RegularPolygon(gon,5,point(o,1,1),2);

Error, (in geometry:-RegularPolygon) wrong type of arguments

 

 


 

Download ErrorMessage.mw

Hey there.

I'm trying to fill out the entries of a matrix. Each matrix element is the result of a very complicated calculation. Currently, I am using nested do loops (two loops total) to scan through each row and column respectively. I find that this process racks up a ton of memory, and that I often run out of memory before the matrix has been completely specified (depending on how big a matrix I want).

First, why is this happening? And second, what is a smarter way to perform the calculation? I will attatch my code below.

Cheers!

MaplePrimes2MuchMemory.mw

Hi 

I am studying Marine Engineer, and we are gonna work alot with vectors. I am using Maple as my mathematical software and i would like to know if you can do a simple vector addition in Maple?
I have tried to make a simple vector diagram to help understand my problem. 
My vector U, is my reference vector, and my two vectors I1 and I2 are the vectors i would like to plus. I know the length of both I1 and I2, and i know the angle between I1 and U and I2 and U.

If i am using my TI-nspire, i can just type in the length and angle on both I1 and I2, to my reference vector, and then plus them together. Is this possible to do in maple?

For the vectors onmy example the result of vector additon of I1+I2 = 2.42 to an angle of 48.07 degree.

The image is just for representation and is not accurate according to the lengths and angles.

Hope someone out there can help me.

 

Dear Users,

I have a set of linear equations which can be presented as A(alpha,n) x(alpha)=b(alpha,n), where 'n' is the dimension of the square matric A.

For a particular value of "n" and "alpha", I can solve the unknown vector x. Further, I can differentiate Ax=b with respect to alpha to find out the rate of change of variable x with respect to alpha.

The above exercise reads, Ax'=b'-xA', which gives the unknown vector x', for a given value of alpha and n.

If I chose different values of n while fixing alpha=alpha0, the rate of change of x with alpha ( x' ) does not converge with 'n'. I noticed that x (alpha=alpha0) converges with n, also x(alpha=alpha0+ delta alpha) also converges with 'n'. I am interested in the query why x' does not converge, in spite of the fact that x converges? Any comments regarding the same are highly appreciated.

 

Thanks,

Grv

I realise this is probably a really obvious question...

I have this function:

(2^(1/3)*Pi*AiryAi(x))/(b*(a*AiryAi(x) + b*AiryBi(x)))

And I want to approximate it near to the root of the equation

a*AiryAi(x) + b*AiryBi(x)=0 (say the solution is x=x0)

The first term - I know - is a term for 1/(x-x0) for which the coefficient is

AiryAi(RootOf(AiryAi(_Z)*a + b*AiryBi(_Z)))*2^(1/3)*Pi/(b*a*AiryAi(1, RootOf(AiryAi(_Z)*a + b*AiryBi(_Z))) + b^2*AiryBi(1, RootOf(AiryAi(_Z)*a + b*AiryBi(_Z)))).

However the next term, which should be a constant, comes out as a really large term which I can't make sense of (I've included it at the bottom of this post but it is very large).

Am I doing something wrong? Because I feel that this should be easier than I'm making it.

 

The determined expansion was:


    (1/3)                                       2
-3 2      Pi RootOf(AiryAi(_Z) a + b AiryBi(_Z))  

                                             3               
  AiryBi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  AiryAi(RootOf(

                                 3      (1/3)    
  AiryAi(_Z) a + b AiryBi(_Z))) b  - 9 2      Pi

                                     2
  RootOf(AiryAi(_Z) a + b AiryBi(_Z))  

                                             2
  AiryBi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  

                                             2    2      (1/3)    
  AiryAi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  a b  - 9 2      Pi

                                     2                           
  RootOf(AiryAi(_Z) a + b AiryBi(_Z))  AiryBi(RootOf(AiryAi(_Z) a

                                                               3
   + b AiryBi(_Z))) AiryAi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  

   2        (1/3)                                       2
  a  b - 3 2      Pi RootOf(AiryAi(_Z) a + b AiryBi(_Z))  

                                             4  3      (1/3)    
  AiryAi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  a  - 4 2      Pi

  RootOf(AiryAi(_Z) a + b AiryBi(_Z)) AiryBi(RootOf(AiryAi(_Z) a

   + b AiryBi(_Z)))

                                                2               
  AiryBi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  AiryAi(RootOf(

                                 3      (1/3)                       
  AiryAi(_Z) a + b AiryBi(_Z))) b  - 8 2      Pi RootOf(AiryAi(_Z) a

   + b AiryBi(_Z)) AiryBi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))

  AiryBi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z))) AiryAi(1,

  RootOf(AiryAi(_Z) a + b AiryBi(_Z))) AiryAi(RootOf(AiryAi(_Z) a

                       2      (1/3)                       
   + b AiryBi(_Z))) a b  - 4 2      Pi RootOf(AiryAi(_Z) a

   + b AiryBi(_Z)) AiryBi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))

                                                2               
  AiryAi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  AiryAi(RootOf(

                                 2        (1/3)                  
  AiryAi(_Z) a + b AiryBi(_Z))) a  b - 4 2      Pi RootOf(AiryAi(

  _Z) a + b AiryBi(_Z))

                                                2
  AiryBi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  

                                             2    2      (1/3)    
  AiryAi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  a b  - 8 2      Pi

  RootOf(AiryAi(_Z) a + b AiryBi(_Z)) AiryBi(1,

  RootOf(AiryAi(_Z) a + b AiryBi(_Z))) AiryAi(1,

  RootOf(AiryAi(_Z) a + b AiryBi(_Z)))

                                             2  2        (1/3)    
  AiryAi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  a  b - 4 2      Pi

  RootOf(AiryAi(_Z) a + b AiryBi(_Z))

                                                2
  AiryAi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  

                                             2  3      (1/3)    
  AiryAi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  a  + 2 2      Pi

                                             2           
  AiryBi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  AiryBi(1,

  RootOf(AiryAi(_Z) a + b AiryBi(_Z))) AiryAi(RootOf(AiryAi(_Z) a

                     3      (1/3)    
   + b AiryBi(_Z))) b  + 2 2      Pi

                                             2           
  AiryBi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  AiryAi(1,

  RootOf(AiryAi(_Z) a + b AiryBi(_Z))) AiryAi(RootOf(AiryAi(_Z) a

                       2      (1/3)                              
   + b AiryBi(_Z))) a b  + 4 2      Pi AiryBi(RootOf(AiryAi(_Z) a

   + b AiryBi(_Z))) AiryBi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))

                                             2    2      (1/3)    
  AiryAi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  a b  + 4 2      Pi

  AiryBi(RootOf(AiryAi(_Z) a + b AiryBi(_Z))) AiryAi(1,

  RootOf(AiryAi(_Z) a + b AiryBi(_Z)))

                                             2  2         (1/3)    
  AiryAi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  a  b + 12 2      Pi

                                                3           
  AiryBi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  AiryAi(1,

                                        3       (1/3)    
  RootOf(AiryAi(_Z) a + b AiryBi(_Z))) b  + 36 2      Pi

                                                2
  AiryBi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  

                                                2    2      
  AiryAi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  a b  + 36

   (1/3)                                                   
  2      Pi AiryBi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))

                                                3  2        (1/3)    
  AiryAi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  a  b + 2 2      Pi

  AiryBi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))

                                             3  2  
  AiryAi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  a  b

         (1/3)                                                  4
   + 12 2      Pi AiryAi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  

   3      (1/3)                                                   
  a  + 2 2      Pi AiryAi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))

                                             3  3\//   
  AiryAi(RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  a / \12

                                                4  4        
  AiryAi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  a  b + 48

                                                3           
  AiryAi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  AiryBi(1,

                                        3  2      
  RootOf(AiryAi(_Z) a + b AiryBi(_Z))) a  b  + 72

                                                2
  AiryAi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  

                                                2  2  3      
  AiryBi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  a  b  + 48

  AiryAi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))

                                                3    4
  AiryBi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  a b

                                                      4  5\
   + 12 AiryBi(1, RootOf(AiryAi(_Z) a + b AiryBi(_Z)))  b /

 

First 582 583 584 585 586 587 588 Last Page 584 of 2358