MaplePrimes Questions

I want to use union, intersection and minus to find. Help me

I have a whole lot of conditions to test on the signum of answers. This gets difficult to read so I am wondering could something like the following be done?

a, b, c, d := 1, -1, 1, -1;
if a, b, c, d = 1, 0, -1, -1 then
    print("foo");
end if;

The above obviously doesn't work. The reason I would like to do this is it would be simple to read the patterns of 1's and 0's.

Any ideas?

matrix_inverse.mw

Here attached is my script. The execution of the worksheet gets stuck at the MatrixInverse(M) step. What do you suggest in order to speed up the computation?

As you can see, my matrix M is a 3x3 symmetric matrix, but quite convoluted. Eventually, I need to multiply the resulting inverse by another (row) vector.

Thank you for looking into this!

Hello. There is some system of differential equations with respect to the unknowns u1(x), u2(x), u3(x) with boundary conditions. Solved numerically using the dsolve command.
Is it possible to build a graph of a function of the form W=a*u1(x)+b*u2(x)+c*u3(x) based on this solution?

Thank you for your answers.

This seems like a very simple questaion, but I have been spinning my wheels trying to find the answer.

Is there a single command the will return a list of all symbols used in a symbolic expression?

Thank you, David

I want to check whether the last expression is zero symbolically in maple. I am trying to learn how to calculate symbolically in Maple. Any suggestion would be very appreciated.


restart;

with(Physics);
with(Physics[Vectors]);

[`*`, `.`, Annihilation, AntiCommutator, Antisymmetrize, Assume, Bra, Bracket, Check, Christoffel, Coefficients, Commutator, CompactDisplay, Coordinates, Creation, D_, Dagger, Decompose, Define, Dgamma, Einstein, EnergyMomentum, Expand, ExteriorDerivative, Factor, FeynmanDiagrams, FeynmanIntegral, Fundiff, Geodesics, GrassmannParity, Gtaylor, Intc, Inverse, Ket, KillingVectors, KroneckerDelta, LeviCivita, Library, LieBracket, LieDerivative, Normal, NumericalRelativity, Parameters, PerformOnAnticommutativeSystem, Projector, Psigma, Redefine, Ricci, Riemann, Setup, Simplify, SortProducts, SpaceTimeVector, StandardModel, SubstituteTensor, SubstituteTensorIndices, SumOverRepeatedIndices, Symmetrize, TensorArray, Tetrads, ThreePlusOne, ToContravariant, ToCovariant, ToFieldComponents, ToSuperfields, Trace, TransformCoordinates, Vectors, Weyl, `^`, dAlembertian, d_, diff, g_, gamma_]

 

[`&x`, `+`, `.`, ChangeBasis, ChangeCoordinates, Component, Curl, DirectionalDiff, Divergence, Gradient, Identify, Laplacian, Nabla, Norm, Setup, diff]

(1)

 

 

 

H[s]:=sum(Norm(p_[n])^2/2/m+U(q_[n]),n=1..s)+(1/2)*sum(sum(V(q_[i]-q_[j]),j=i..s),i=1..s);

sum((1/2)*Physics:-Vectors:-Norm(p_[n])^2/m+U(q_[n]), n = 1 .. s)+(1/2)*(sum(sum(V(q_[i]-q_[j]), j = i .. s), i = 1 .. s))

(2)

H[N-s]:=sum(Norm(p_[n])^2/2/m+U(q_[n]),n=s+1..N)+(1/2)*sum(sum(V(q_[i]-q_[j]),j=s+1..N),i=s+1..N);

sum((1/2)*Physics:-Vectors:-Norm(p_[n])^2/m+U(q_[n]), n = s+1 .. N)+(1/2)*(sum(sum(V(q_[i]-q_[j]), j = s+1 .. N), i = s+1 .. N))

(3)

 

 

Download Ch3.mw
 

 

 

 

I do not remember is this was asked before.

In other OOP languages such as Java, it allows one to name object variable name same as method name. I found this example on the net for java to illustrate

class Test {

  private boolean isVal;

  public boolean isVal() {
      return isVal;
  }

}

In Maple, this is not allowed. So now I have to come up with new name for either the method or the variable that returns that hidden internal variable.

Here is an example

A:=module()
  option object;
  local is_valid::truefalse:=false;
  export is_valid::static:=proc(_self,$)::truefalse;
    return _self:-is_valid;
  end proc;
end module;

THis gives error

Error, (in A) exported variable `is_valid` cannot be multiply declared

It will be nice if Maple allows this. For now one has to rename either the variable or the method. Which is little annoying.

Is this something that could  be easily added to Maple in a future release?

I changed today my code to use DEtools:-odeadvisor(ode,y(x),[linear]); to check that the ode is linear or not before calling DEtools:-convertAlg 

The problem is that sometimes the advisor returns _linear on what is not linear ode (at least the way it is originally written). Here is an example

              (x+y(x))*diff(y(x),x) = 0;

From help page:

 

In the event that convertAlg cannot isolate for the proper list form (for instance, if the DE is not a linear ODE) then FAIL is returned.

 

So now I am worried  that using odeadvisor to check for linear ode is not the right method.

Is there a build-in method in Maple to check if an ode is linear or not? (I do have my own code to do this, but I thought it is better to use a buildin method, as it will be more robust).

Should DEtools:-odeadvisor(ode,y(x),[linear]) have returned _linear in this case?

interface(version);

`Standard Worksheet Interface, Maple 2022.1, Windows 10, May 26 2022 Build ID 1619613`

ode:=(x+y(x))*diff(y(x),x) = 0;
DEtools:-odeadvisor(ode,y(x));
#check if linear ODE
DEtools:-odeadvisor(ode,y(x),[linear]);

(x+y(x))*(diff(y(x), x)) = 0

[_quadrature]

[_linear]

DEtools:-convertAlg(ode,y(x));

FAIL

 

Download why_fail_sept_17_2022.mw

In the website https://en.wikipedia.org/wiki/Geodesic there is an animation of an insect tracing a path on a torus while walking "forward". The caption to the animation says that the path is then by definition a geodesic.

I would like to duplicate this animation in Maple (and other "walking forward" geodesics on other surfaces) which seems to require an exact definition of walking forward but I cannot find such a definition on this or any other website.

Also, I thought that a geodesic is the shortest distance between two points in space, but no such end points are shown in the website's animation. Then how can the word geodesic apply to the insect's path?

Hi senior, I am using Maple 2022 version. I am facing a issue regrading opening of maple worksheet. If connected with wifi then maple worksheet will open and work properly, while i disconnected the internet, maple crashed and pop up a message to activate license again..

How do we truncate a polynomial in Maple, that is, obtain only the terms of degree <= n?

For example, if 

P(x)=x^2+2*x^3+x^6

then the truncation [P(x)]4 is

P(x)=x^2+2*x^3

and the truncation [P(x)]is

P(x)=x^2

dAlmbert ode has the form

 

Also from Maple own help page, it agrees with Wikipedia and says:

 

Now, given this ode

ode:=y(x)=ln(cos(diff(y(x),x)))+diff(y(x),x)*tan(diff(y(x),x));
eval(ode,diff(y(x),x)=p)

Then clearly the above is not dAlmbert. Right? it is missing the x. But odeadvisor says it is:

restart;
ode:=y(x)=ln(cos(diff(y(x),x)))+diff(y(x),x)*tan(diff(y(x),x));
DEtools:-odeadvisor(ode)

What Am I missing here?

Update

These are the rules I know about this ode. For y=x f(p)+ g(p). 

g(p) can be zero, yes, but in this case, f(p) has to be nonlinear in p for it to be dAlembert (else it will be either separable or linear.

I did not think f(p) can be zero and it remains dAlermber, even if g(p) remains nonlinear in p. So y=g(p) can not be dAlembert, even if g(p) is nonlinear.

May be Maple uses its own definition of dAlembert?. I do not know. This will be new definition to me. Is there a reference that mentions this case of y=g(p) classified as dAlembert for nonlinear g?

Maple 2022.1 on windows 10


Using plot3d(..., style=surfacecontour, ...) or contourplot3d(...) displays wrong level curves when some axis are switched to a log mode.

Example:

restart:

interface(version)

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

X := (0.4000000000e-4*(-R+80.00))/(R*(0.4e-1+M__a)):

plot3d(X, R=0..10, M__a=10^0..10^4, style=surfacecontour, color=gold)

 

plot3d(X, R=0..10, M__a=10^0..10^4, axis[2]=[mode=log], axis[3]=[mode=log], style=surfacecontour, color=gold)

 

plots:-display(
  plots:-contourplot3d(X, R=0..10, M__a=10^0..10^4, axis[2]=[mode=log], axis[3]=[mode=log], color=red),
  plot3d(X, R=0..10, M__a=10^0..10^4, style=surface, color=gold)
)

 

 

Download WrongLevelCurves.mw

 

The problem is not dramatic because there is a workaround.
 

restart:

interface(version)

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

X := (0.4000000000e-4*(-R+80.00))/(R*(0.4e-1+M__a)):

fig := plot3d(X, R=0..10, M__a=10^0..10^4, style=surfacecontour, color=gold):
Tr  := plottools:-transform((x, y, z) -> [x, log[10](y), log[10](z)]):
plots:-display(Tr(fig), axis[2]=[tickmarks=[seq(i=10^i, i=0..4)]], axis[3]=[tickmarks=[seq(i=nprintf("%1.0e", 10.^i), i=-7..-1)]])

 

 

Download WrongLevelCurves_Workaround.mw

 

I've attached a maple file (.mw). After solving the first order condition of SW expression, I tried to obtain an optimal point for en. To do that I used solve API, and obtained a solution in rootof. I want to comment on the relationship of en with other parameters like A, theta, zeta, etc. Therefore, I want to understand the interpretation of rootof and how analytically I can simplify it further if possible.

restart

SW := (1/6)*a*(8*sqrt(epsilon[n]*theta[n]*a)*Zeta[n]+3*a*tau-3*a)+(1/3)*e[n]*(-beta[n]*e[n]^2+3*delta[n]*A+4*sqrt(e[n]*theta[n]*A))

(1/6)*a*(8*(varepsilon[n]*theta[n]*a)^(1/2)*Zeta[n]+3*a*tau-3*a)+(1/3)*e[n]*(-beta[n]*e[n]^2+3*delta[n]*A+4*(e[n]*theta[n]*A)^(1/2))

(1)

``

NULL

Opt_effort_FOC := diff(SW, e[n])

-(1/3)*beta[n]*e[n]^2+delta[n]*A+(4/3)*(e[n]*theta[n]*A)^(1/2)+(1/3)*e[n]*(-2*beta[n]*e[n]+2*theta[n]*A/(e[n]*theta[n]*A)^(1/2))

(2)

``

NULL

solve(Opt_effort_FOC = 0, e[n])

RootOf(-A^3*delta[n]*theta[n]^2-2*A^2*_Z*theta[n]^2+_Z^4*beta[n])^2/(theta[n]*A)

(3)

NULL

``

Download RootOf_maple.mw

I know that this is a stupid question but I cannot find how to do the dyadic product of two matrix. Those matrix could be two tensor matrix and I need to do this multiplication:

Thank you in advance for your help.

Mario

First 61 62 63 64 65 66 67 Last Page 63 of 2212