Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Certainly a standard question.

I have an integer n*n matrix A (the entries are explicitly integers; there is no variable -type x- in the matrix). I want the Smith normal form of A, that is A=UDV where U,V are integer matrices with determinant +-1 and D is a diagonal matrix with -eventually- some zero and positive integers d_i s.t. d_i divides d_{i+1}.

"SmithForm()" doesn't work directly (I get rational -non integer- matrices). Maybe it is necessary to declare the matrix A as 'Matrix(integer)' ...
Thank you in advance for your help.

Has anybody been able to get Maple working on macOS Sonoma 14.4. I know it's not supported yet, but I thought there might be someone who has solved the issue with the app crashing immediately after startup.

point(A, xA, yA);
point(B, xB, yB);
point(C, xC, yC):
L3 := linestyle = 3
triangle(Tr, [A, B, C])
line(AP, [A, P]);
line(BP, [B, P]);
line(CP, [C, P]);
dr := draw([Tr(t3), AP(cbl, L3), BP(cbl, L3), CP(cbl, L3)]),
textplot([[coordinates(A)[], "A"], [coordinates(B)[], "B"], [coordinates(C)[], "C"]], align = {above, right});
display({dr, ellip}, scaling = constrained, axes = none, view = [-1 .. 14, -1 .. 11]);
Why doesn’t Maple show me the expected effect ? Thank you.

How do  I solve system of differential equations in finite difference method or finite element method?

eq1 := (diff(f(x), x, x, x))*(a*beta*f(x)^2-1)+(diff(f(x), x))^2-2*a*beta*f(x)*(diff(f(x), x))*(diff(f(x), x, x))+(diff(f(x), x))*(M+k[1])-(diff(f(x), x, x))*f(x)-(alpha*theta(x)+delta*phi(x))/rho = 0;

eq2 := -(diff(theta(x), x, x))*K[SB]*(Df-(Rd+k[hnf]/k[bf])/Pr)+N[t]*K[SB]*(diff(theta(x), x))^2-N[b]*(diff(theta(x), x))*(diff(phi(x), x))-(diff(f(x), x))*(diff(theta(x), x))-lambda*theta(x)-mu*Ec*(M*(diff(f(x), x))^2+(diff(f(x), x, x))^2) = 0;

eq3 := diff(phi(x), x, x)+Le*Sr*(diff(theta(x), x, x))+Le*f(x)*(diff(phi(x), x)) = 0;

ics := f(0) = 0, (D(f))(0) = 0, theta(0) = 1, phi(0) = 1;

bcs := (D(f))(100) = 0, theta(100) = 0, phi(100) = 0;


Parameters1 := rho = 2063.905, k[hnf] = .29942, k[bf] = .2520, mu = .38694, a = .1, beta = 5, k[1] = 2.0, M = 10, alpha = 20, delta = 20, K[SB] = .5, Df = 3, Pr = 1.2, Rd = 5, N[t] = 1.2, N[b] = 1.0, lambda = 1.5, Ec = 5, Le = .1, Sr = .1;

 


dS := -beta*S*Q;
dQ := Q*S*beta - Q*alpha;
dR := alpha*Q;
beta := 0.2;
alpha := 0.1;
S0 := 0.8;
Q0 := 0.2;
R0 := 0;
RungeKutta := proc(f::list, y0::list, t0::float, tf::float, h::float) local n, t, y, k1, k2, k3, k4, i; n := 1 + floor((tf - t0)/h); t := Vector(n, fill = 0); y := Matrix(n, length(y0), fill = 0); t[1] := t0; y[1] := Vector(y0); for i to n - 1 do k1 := Vector(map(f, t[i], y[i])); k2 := Vector(map(f, t[i] + 1/2*h, y[i] + 1/2*h*k1)); k3 := Vector(map(f, t[i] + 1/2*h, y[i] + 1/2*h*k2)); k4 := Vector(map(f, t[i] + h, y[i] + h*k3)); y[i + 1] := y[i] + 1/6*h*(k1 + 2*k2 + 2*k3 + k4); t[i + 1] := t[i] + h; end do; [t, y]; end proc;
f = [dS, dQ, dR];
t0 := 0;
tf := 50;
h := 0.1;
result := RungeKutta(f, [S0, Q0, R0], t0, tf, h);
t_values := result[1];
S_values := result[2][() .. (), 1];
Q_values := result[2][() .. (), 2];
R_values := result[2][() .. (), 3];
plots:-display(plot(t_values, S_values, color = "blue", legend = "Susceptible"), plot(t_values, Q_values, color = "red", legend = "Infected"), plot(t_values, R_values, color = "green", legend = "Recovered"), legend = ["Susceptible", "Infected", "Recovered"], title = "Simulation of Infectious Disease Model", xlabel = "Time", ylabel = "Population", view = [0 .. tf, 0 .. 1]);
Warning, (in RungeKutta) `i` is implicitly declared local
                         dS := -0.2 S Q

                     dQ := 0.2 S Q - 0.1 Q

                          dR := 0.1 Q

                          beta := 0.2

                          alpha := 0.1

                           S0 := 0.8

                           Q0 := 0.2

                            R0 := 0

RungeKutta := proc (f::list, y0::list, t0::float, tf::float, 

   h::float) local n, t, y, k1, k2, k3, k4, i; n := 1+floor((tf-\

  t0)/h); t := Vector(n, fill = 0); y := Matrix(n, length(y0), 

   fill = 0); t[1] := t0; y[1] := Vector(y0); for i to n-1 do 

   k1 := Vector(map(f, t[i], y[i])); k2 := Vector(map(f, 

   t[i]+(1/2)*h, y[i]+(1/2)*h*k1)); k3 := Vector(map(f, 

   t[i]+(1/2)*h, y[i]+(1/2)*h*k2)); k4 := Vector(map(f, t[i]+h, 

   y[i]+h*k3)); y[i+1] := y[i]+(1/6)*h*(k1+2*k2+2*k3+k4); 

   t[i+1] := t[i]+h end do; [t, y] end proc


[-0.2 S Q, 0.2 S Q - 0.1 Q, 0.1 Q] = [-0.2 S Q, 0.2 S Q - 0.1 Q, 

  0.1 Q]


                            t0 := 0

                            tf := 50

                            h := 0.1

Error, invalid input: RungeKutta expects its 3rd argument, t0, to be of type float, but received 0
                     t_values := result[1]

               S_values := result[2][() .. (), 1]

               Q_values := result[2][() .. (), 2]

               R_values := result[2][() .. (), 3]

Warning, expecting only range variable result[2][(NULL) .. (NULL),1] in expression result[1] to be plotted but found name result[1]
Warning, expecting only range variable result[2][(NULL) .. (NULL),2] in expression result[1] to be plotted but found name result[1]
Warning, expecting only range variable result[2][(NULL) .. (NULL),3] in expression result[1] to be plotted but found name result[1]
Error, (in plots:-display) unexpected options: [xlabel = "Time", ylabel = "Population"]

I want to center align all the math in my document. I have not been able to find a shortcut key for alignment, and I cannot find a default setting for alignment anywhere. I don't want to mouse click every single time.

Please help, thanks!

Howdy,

I am trying to do explicit Lie algebra computations, and I am not sure the best way to automate these.

Suppose I have a Lie algebra with basis e1 through e8, and I have some linear functions:

f(e1,e2) = c1e1+c2e2+...+c8e8

Now suppose I want to compute something like

[e5, f] - f([e5,e1],e2) + f([e5,e2],e1), or more generally x.f with the typical module structure.

I can do this line by line - say [e5,e1] = -e1 and [e5,e2] = 0, then I can ask Maple for LieBracket(e5,f)+f(e1,e2)-0. However, I'd like to make an operator that does this for me. Can anyone please point me in the right direction?

Thanks!

Good day. 

I recently constructed a Maple model using an LPSolve routine to solve for a classic factory (Operations Research) assignment problem. Basically, this involves 4 factories that, in any combination, can supply goods and fulfil demand to 10 customers. If any given factory is activated, the model determines what factory should supply what customer so that the weighted-distance is minimized.

However, in addtion to this - I would like to know the quantity of items that each factory supplies to each of their respective customers and I would like to verify that the quantity demanded by each customer is fulfilled. 

I was hoping that somebody could guide me on how to do this. Any suggestions would be most welcomed.

The model is attached.

Thanks for reading!

MaplePrimes_Jan_27.mw

I am trying to draw the streamline for my coupled system but do not get the outcome. Could anyone please help in this regard?

Detail: My system contains x and y;  Regrading x=0, if I do not assign it to zero, do not get the results. Otherwise, there is no need to put x=0 because I am interested in plotting stream plots between y and x (y on the vertical axis and x on the horizontal axis). Besides this, I solved this system analytically, then considered the stream function, did some steps, and plotted the streamline. It is different from the stream function, which has been obtained directly by using the numeric method. I have assigned the values to the parameters that I used during the analytical plot. I put x=0 and did not get the answer. Besides,  I am uploading the graph as a reference, which I have obtained by considering the stream function. This plot is similar to my flow direction, and I expect the same results from the numeric method.

streamline_Help.mw

The equal sign ":=" in my document sign has changed to a "d".  The equal sign "=" has not changed.  Is there a setting I need to change?

Thank you in advance.

I am trying to find the value of y4 at t=infinity and t=-infinity when lambda1>lambda2 or lambda1<lambda2. But every time I got the same answer. For example, if we do it by hand then the terms which are responsible for making the indeterminate form can be extracted and canceled (see Fig.). 

But in limit.mw y4 is too lengthy-expression and very difficult to do it manually.

The Statistics package contains a function named Specialize (which quite strangely doesn't appear when you expand the sections of this package).
Here is what help(Specialize) says:

The Specialize function takes a random variable or distribution data structure that contains symbolic parameters, and performs a substitution to specialize the given random variable or distribution.

My goal was to work with mixtures of two random variables. There are many ways to do that depending on the what you really want to achieve, but an elegant way is to define such a mixture this way:

  • Let X and Y two random variables representing the two components to be mixed.
    For instance X = Normal(mu, sigma) and Y = Normal(nu, tau).
     
  • Let B a Bernoulli random variable with parameter P.
     
  • Then M = B*X + (1-B)*Y represents a random mixture of the two components in proportions (p, 1-p).
    Note that M is a 5-parameters random variable.

Doing the things this way enables getting a lot of formal informations about M such as its mean, variance, and so on.

In order to illustrate what the mixture is I draw the histogram of a sample of M.
To do this I Specialized the three random variables X, Y, B.

I used parameters

mu=-3, nu=3, sigma=1, tau=1, p=1/2


My first attempt was to draw a sample of the random variable Mspec defined this way

Mspec := Specialize(B, [p=1/2])*Specialize(X, [mu=-3, sigma=1]) + (1-Specialize(B, [p=1/2]))*Specialize(Y, [nu=3, tau=1]);

As you see in the attached file (first plot) the histogram is wrong (so is the variance computed formally).

I changed this into

Mspec := Specialize(B, [p=1/2])*(Specialize(X, [mu=-3, sigma=1])-Specialize(Y, [nu=3, tau=1])) + Specialize(Y, [nu=3, tau=1]);

without more significative success: while the variance is nox corrext the histogram still remains obviously wrong (plot number 2)

My last attempt, which now gives q correct result (plot 3) was:

Bspec := Specialize(B, [p=1/2]);
Mspec := Bspec*Specialize(X, [mu=-3, sigma=1]) + (1-Bspec)*Specialize(Y, [nu=3, tau=1]);

Specialize.mw

I agree that one can easily do this stuff without using  Specialize.
For instance by using the procedure given at the end ofthe attached file.
Or by truly constructing a mixture Distribution (which would be more elegant but more complex).

I also agree that Specialize is in itself of a relative low interest except for educational purposes (you present the theoritical results and next you run a numerical application while giving numeric values to the formal parameters).

But why providing such an anecdotal function if it doesn't do the job correctly?

Note that these results were obtained with Maple 2015, but I doubt they'll be any better for more recent versions, given the confidential nature of Specialize.

I am trying to calculate the line element ds^2, for a de Sitter spacetime in 2+1 dimensions with positive cosmological constant, using the following metric and energy moment tensor:
1- ds² = -A(r) c^2 dt^2 + B(r) dr^2 + r^2d{\theta}^2,
2- T^{\mu \nu} = -(\rho + p) dx^{\mu} dx^{\nu} + p g^{\mu \nu}.

I tried several ways but I can't solve it using Maple 2023, Physics package. Could someone show me step by step how to solve this problem?

Images of the line element we need to find, the metric tensor associated with the problem and the components of the Riemann tensor.
My goal is to calculate the metric tensor, line element and associated components of the Riemann tensor for De Sitter spacetime with positive cosmological constant.

Hello everyone,

I'm trying to learn how to use Shoot Library 9.

Unfortunately, I'm not doing very well. I'm getting an error that I don't understand. I don't know where it comes from.

Please help me solve this odes system using this library.

I attached my Maple worksheet file.

ShootLib_Test.mw

I'm currently addressing a problem related to modified Bessel functions using an older version of Maple (the specific version escapes my memory). In an attempt to resolve issues, I've experimented with the trial version of Maple 2023, but I've encountered an unusual phenomenon. Expressions that were previously simplifiable in Maple now resist simplification. The specific expression provided below, which should equate to 1, fails to be recognized as such by Maple. This poses a concern as it could lead to overly complex expressions in subsequent steps, considering this expression is only an intermediate stage. Is there a recommended approach to overcome this challenge?

f := (BesselI(0, alpha)*alpha-2*BesselI(1, alpha))/(BesselK(0, alpha)*BesselI(1, alpha)*BesselI(0, alpha)*alpha^2+BesselK(1, alpha)*BesselI(0, alpha)^2*alpha^2-2*BesselI(1, alpha))

(BesselI(0, alpha)*alpha-2*BesselI(1, alpha))/(BesselK(0, alpha)*BesselI(1, alpha)*BesselI(0, alpha)*alpha^2+BesselK(1, alpha)*BesselI(0, alpha)^2*alpha^2-2*BesselI(1, alpha))

simplify(f)

(BesselI(0, alpha)*alpha-2*BesselI(1, alpha))/(BesselK(0, alpha)*BesselI(1, alpha)*BesselI(0, alpha)*alpha^2+BesselK(1, alpha)*BesselI(0, alpha)^2*alpha^2-2*BesselI(1, alpha))

eval(f, alpha = .25)

1.000000000

NULL

Download question.mw

First 15 16 17 18 19 20 21 Last Page 17 of 2153