MaplePrimes Questions

Hello,

I have installed the Physics Package with:

PackageTools:-Install("5137472255164416", version = 329, overwrite)

I have a question about the calculation of the Tensor determinant:

I use two ways to calculate the determinant of the same matrix:

The first with Physics package and the second with LinearAlgebra Package:

It is easy to calculate analytically the result it is : -1

But Physics Package gives : +1 and LinearAlgebra gives: -1

My question is why I found +1 with Physics Package : What I doing wrong ?.

Please find my source hereafter:

**************************************************

restart

with(Physics)

Setup(coordinates = {X = [t, x, y, z]}, dimension = 4, metric = {(1, 1) = 1, (2, 2) = -1, (3, 3) = -1, (4, 4) = -1}, signature = `+---`, mathematicalnotation = true)

Define(H[mu, nu] = Matrix(4, {(1, 1) = 1+h, (1, 2) = h, (2, 2) = -1+h, (3, 3) = -1, (4, 4) = -1}, shape = symmetric))

H[]

H[determinant]

with(LinearAlgebra)

B := Matrix(4, {(1, 1) = 1+h, (1, 2) = h, (2, 2) = -1+h, (3, 3) = -1, (4, 4) = -1}, shape = symmetric)

Determinant(B)

***************************************

Thanks for your answer,

Sincerely yours

Xavier

 

This for me seems strange. A first oder ODE of degree one of form   A+B*y'=0. Asking Maple for its classification, it gives exact AND rational.  After rewriting it in the form y'=f(x,y) , now Maple says it is rational only. It no longer recognize it as exact.

How could this be possible? It is the same ODE, just rewrittng differently.  Maple 2019.1 on windows.

restart;

Typesetting:-Settings(typesetprime=true):

ode:=2*x/y(x)-y(x)/(x^2+y(x)^2)+(-x^2/y(x)^2+x/(x^2+y(x)^2))*diff(y(x),x) = 0;
DEtools:-odeadvisor(ode);

2*x/y(x)-y(x)/(x^2+y(x)^2)+(-x^2/y(x)^2+x/(x^2+y(x)^2))*(diff(y(x), x)) = 0

[_exact, _rational]

dsolve(ode)

y(x) = x/tan(RootOf(-_Z+x*tan(_Z)+_C1))

new_ode:=convert(ode,D); #so I can solve for y'
RHS:=solve(new_ode,D(y)(x));

2*x/y(x)-y(x)/(x^2+y(x)^2)+(-x^2/y(x)^2+x/(x^2+y(x)^2))*(D(y))(x) = 0

(2*x^3+2*x*y(x)^2-y(x)^2)*y(x)/(x*(x^3+x*y(x)^2-y(x)^2))

new_ode:=diff(y(x),x)=RHS;
DEtools:-odeadvisor(new_ode);

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

[_rational]

dsolve(new_ode)

_C1-arctanh((-2/(x^4*(1/y(x)^2+(x-1)/x^3)))^(1/2)*x/((-2*x+2)/(x^3*(1/y(x)^2+(x-1)/x^3))+2)^(1/2))+((-2*x+2)/(x^3*(1/y(x)^2+(x-1)/x^3))+2)^(1/2)/(-2/(x^4*(1/y(x)^2+(x-1)/x^3)))^(1/2) = 0

 


 

Download why_type_changed.mw


 

eq := solve({2*m-5 < 0, -3*m <= 5}, {m})

{-5/3 <= m, m < 5/2}

(1)

" implies result list m  in  `&Zopf;`, so m can m=0, m=1, m=2 and count=3"``

count := 0:

countt = 4

(2)

``

``

``

eq := solve({m-3 < 0, -m <= 6}, {m})

{-6 <= m, m < 3}

(3)

" implies result list m  in  `&Zopf;`, so m can m=-6, m=-5, m=-4, m=-3, m=-2, m=-1, m=0, m=1, m=2 and count=3"

count := 0:

countt = 9

(4)

``


i want to list variable m in integer number from solve?

Can you help me?

@acer

@Carl Love

Download help_list_integer_equation.mw

I want to solve for the coefficients in some multivariate polynomials by equating them to other known multivariate polynomials.

 

Something like this. I have

p[1]=(a+b)*x^2+(a+c)*x*y+d*z;

p[2]=(a-b)*x+e*y*z+f*z^2;

 

I want to impose that p[1]=x^2+2*x*y+3*z and that p[2]=x+4*y*z and I want Maple to tell me the values of (a,b,c,d,e,f).

 

Sounds simple enough, but I have not been able to do it

I want to solve an ODE system numerically, but maple show not converge for iteration, can you give a solution
with(VectorCalculus);
with(linalg);


pi := 4; eta := 6; mh := .1; mv := .3; bh := .15; Nh := 400; Nv := 200; bv := .25; b := .8; d := .1; p := .5; B := 10; A := 1; alpha := .25; beta := .7; K := 400; r := .5; c := .9; q := .8; Sh0 := 225; Sv0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v*Iv(t)-P(t)*Iv(t)*alpha-L4(t)*Iv(t)^2/(2*B^2); eq10 := diff(P(t), t) = P(t)*r*(1-P(t)/Nh)+P(t)*alpha*(Sv(t)+Iv(t))-q*P(t)*c

fcns := {Ih(t), Iv(t), L1(t), L2(t), L3(t), L4(t), L5(t), P(t), Sh(t), Sv(t)}; a := dsolve({eq1, eq10, eq2, eq3, eq4, eq5, eq6, eq7, eq8, eq9, Ih(0) = Ih0, Iv(0) = Iv0, L1(T) = 0, L2(T) = 0, L3(T) = 0, L4(T) = 0, L5(T) = 0, P(0) = P0, Sh(0) = Sh0, Sv(0) = Sv0}, fcns, type = numeric);
fcns := {Ih(t), Iv(t), L1(t), L2(t), L3(t), L4(t), L5(t), P(t), 

  Sh(t), Sv(t)}
Error, (in dsolve/numeric/bvp) initial Newton iteration is not converging

 

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 = [-&infin;, &infin;]; Principal range = [-&pi;/2, &pi;/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 = [-&pi;/2, &pi;/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 = [-&pi;/2, &pi;/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?

First 644 645 646 647 648 649 650 Last Page 646 of 2420