Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hi,

I have an inverse I solved for with RootOf, which I transfrom and then try to numerically integrate the transformation. I get the following error: Error, (in convert/radical) too many levels of recursion

Integrating the inverse itself works, it is after applying the transformation 1/(1+x2) that I get the issue. Eventually I want to integrate something less simple, but here the problem already starts. 

Thanks for the help! Its for science! 
 

g1_inveq := proc (t, x, alp) options operator, arrow; tan((x-t)/(alp*(1+t^2)))-t end proc

proc (t, x, alp) options operator, arrow; tan((x-t)/(alp*(1+t^2)))-t end proc

(1)

g1_inv := proc (v, alp) options operator, arrow; evalf(RootOf(g1_inveq(t, v, alp) = 0, t, 1)) end proc

proc (v, alp) options operator, arrow; evalf(RootOf(g1_inveq(t, v, alp) = 0, t, 1)) end proc

(2)

evalf(Int(1/(1+g1_inv(v1, .5)^2), v1 = 0 .. 1))

Error, (in convert/radical) too many levels of recursion

 

``


 

Download recursionerror.mw

 

Hey all together,

this is my first question in this community and it is maybe a very simple one:

If I have a given matrix. How can I process individual elements with an mathmatical operation?

For example, I have a diagonal matrix and want to get a matrix in which every non-zero element is the square root of the inverse of its former element.

Has someone an idea?

Thank you very much!

hello , there , i want ask a Question ,

i have a vector result n hier , and there is a long part with ^1/2 (like unter) , which is not defined before , just from compute ,i want to replace this part with A, and have tried to use subs , but it didnt work . 

And i have tried to define it before compute, and then use subs , aber it also didnt work .

so how can i replace or define this part in the result?

thanks

 

Dearz

I draw multiple graphs in singal coordinate with same line style. I don't know how to change the line style and color for g[1], g[2] and g[3] becuase of loop. Please some fix my problem to give them different style and color.

graph.mw

In a previous Mapleprimes question related to Dirac Matrices, I was asked how to represent the algebra of Dirac matrices with an identity matrix on the right-hand side of  %AntiCommutator(Physics:-Dgamma[j], Physics:-Dgamma[k]) = 2*g[j, k]. Since this is a hot-topic in general, in that, making it work, involves easy and useful functionality however somewhat hidden, not known in general, it passed through my mind that this may be of interest in general. (To reproduce the computations below you need to update your Physics library with the one distributed at the Maplesoft R&D Physics webpage.)

 

restart

with(Physics)

 

First of all, this shows the default algebra rules loaded when you load the Physics package, for the Pauli  and Dirac  matrices

Library:-DefaultAlgebraRules()

%Commutator(Physics:-Psigma[j], Physics:-Psigma[k]) = (2*I)*(Physics:-Psigma[1]*Physics:-LeviCivita[4, j, k, `~1`]+Physics:-Psigma[2]*Physics:-LeviCivita[4, j, k, `~2`]+Physics:-Psigma[3]*Physics:-LeviCivita[4, j, k, `~3`]), %AntiCommutator(Physics:-Psigma[j], Physics:-Psigma[k]) = 2*Physics:-KroneckerDelta[j, k], %AntiCommutator(Physics:-Dgamma[j], Physics:-Dgamma[k]) = 2*Physics:-g_[j, k]

(1)

Now, you can always overwrite these algebra rules.

 

For instance, to represent the algebra of Dirac matrices with an identity matrix on the right-hand side, one can proceed as follows.

First create the identity matrix. To emulate what we do with paper and pencil, where we write I to represent an identity matrix without having to see the actual table 2x2 with the number 1 in the diagonal and a bunch of 0, I will use the old matrix command, not the new Matrix (see more comments on this at the end). One way of entering this identity matrix is

`𝕀` := matrix(4, 4, proc (i, j) options operator, arrow; KroneckerDelta[i, j] end proc)

array( 1 .. 4, 1 .. 4, [( 4, 1 ) = (0), ( 1, 2 ) = (0), ( 2, 3 ) = (0), ( 1, 3 ) = (0), ( 2, 2 ) = (1), ( 4, 2 ) = (0), ( 3, 4 ) = (0), ( 1, 4 ) = (0), ( 3, 1 ) = (0), ( 4, 4 ) = (1), ( 3, 2 ) = (0), ( 1, 1 ) = (1), ( 2, 1 ) = (0), ( 4, 3 ) = (0), ( 3, 3 ) = (1), ( 2, 4 ) = (0)  ] )

(2)

The most important advantage of the old matrix command is that I is of type algebraic and, consequently, this is the important thing, one can operate with it algebraically and its contents are not displayed:

type(`𝕀`, algebraic)

true

(3)

`𝕀`

`𝕀`

(4)

And so, most commands of the Maple library, that only work with objects of type algebraic, will handle the task. The contents are displayed only on demand, for instance using eval

eval(`𝕀`)

array( 1 .. 4, 1 .. 4, [( 4, 1 ) = (0), ( 1, 2 ) = (0), ( 2, 3 ) = (0), ( 1, 3 ) = (0), ( 2, 2 ) = (1), ( 4, 2 ) = (0), ( 3, 4 ) = (0), ( 1, 4 ) = (0), ( 3, 1 ) = (0), ( 4, 4 ) = (1), ( 3, 2 ) = (0), ( 1, 1 ) = (1), ( 2, 1 ) = (0), ( 4, 3 ) = (0), ( 3, 3 ) = (1), ( 2, 4 ) = (0)  ] )

(5)

Returning to the topic at hands: set now the algebra the way you want, with an I matrix on the right-hand side, and without seeing a bunch of 0 and 1

%AntiCommutator(Dgamma[mu], Dgamma[nu]) = 2*g_[mu, nu]*`𝕀`

%AntiCommutator(Physics:-Dgamma[mu], Physics:-Dgamma[nu]) = 2*Physics:-g_[mu, nu]*`𝕀`

(6)

Setup(algebrarules = (%AntiCommutator(Physics[Dgamma][mu], Physics[Dgamma][nu]) = 2*Physics[g_][mu, nu]*`𝕀`))

[algebrarules = {%AntiCommutator(Physics:-Dgamma[mu], Physics:-Dgamma[nu]) = 2*Physics:-g_[mu, nu]*`𝕀`}]

(7)

And that is all.

 

Check it out

(%AntiCommutator = AntiCommutator)(Dgamma[mu], Dgamma[nu])

%AntiCommutator(Physics:-Dgamma[mu], Physics:-Dgamma[nu]) = 2*Physics:-g_[mu, nu]*`𝕀`

(8)

Set now a Dirac spinor; this is how you could do that, step-by-step.

 

Again you can use {vector, matrix, array} or {Vector, Matrix, Array}, and again, if you use the Upper case commands, you always have the components visible, and cannot compute with the object normally since they are not of type algebraic. So I use matrix, not Matrix, and matrix instead of vector so that the Dirac spinor that is both algebraic and matrix, is also displayed in the usual display as a "column vector"

 

_local(Psi)

Setup(anticommutativeprefix = {Psi, psi})

[anticommutativeprefix = {_lambda, psi, :-Psi}]

(9)

In addition, following your question, in this example I explicitly specify the components of the spinor, in any preferred way, for example here I use psi[j]

Psi := matrix(4, 1, [psi[1], psi[2], psi[3], psi[4]])

array( 1 .. 4, 1 .. 1, [( 4, 1 ) = (psi[4]), ( 3, 1 ) = (psi[3]), ( 1, 1 ) = (psi[1]), ( 2, 1 ) = (psi[2])  ] )

(10)

Check it out:

Psi

Psi

(11)

type(Psi, algebraic)

true

(12)

Let's see all this working together by multiplying the anticommutator equation by Psi

(%AntiCommutator(Physics[Dgamma][mu], Physics[Dgamma][nu]) = 2*Physics[g_][mu, nu]*`𝕀`)*Psi

Physics:-`*`(%AntiCommutator(Physics:-Dgamma[mu], Physics:-Dgamma[nu]), Psi) = 2*Physics:-g_[mu, nu]*Physics:-`*`(`𝕀`, Psi)

(13)

Suppose now that you want to see the matrix form of this equation

Library:-RewriteInMatrixForm(Physics[`*`](%AntiCommutator(Physics[Dgamma][mu], Physics[Dgamma][nu]), Psi) = 2*Physics[g_][mu, nu]*Physics[`*`](`𝕀`, Psi))

Physics:-`.`(%AntiCommutator(Physics:-Dgamma[mu], Physics:-Dgamma[nu]), array( 1 .. 4, 1 .. 1, [( 4, 1 ) = (psi[4]), ( 3, 1 ) = (psi[3]), ( 1, 1 ) = (psi[1]), ( 2, 1 ) = (psi[2])  ] )) = 2*Physics:-g_[mu, nu]*Physics:-`.`(array( 1 .. 4, 1 .. 4, [( 4, 1 ) = (0), ( 1, 2 ) = (0), ( 2, 3 ) = (0), ( 1, 3 ) = (0), ( 2, 2 ) = (1), ( 4, 2 ) = (0), ( 3, 4 ) = (0), ( 1, 4 ) = (0), ( 3, 1 ) = (0), ( 4, 4 ) = (1), ( 3, 2 ) = (0), ( 1, 1 ) = (1), ( 2, 1 ) = (0), ( 4, 3 ) = (0), ( 3, 3 ) = (1), ( 2, 4 ) = (0)  ] ), array( 1 .. 4, 1 .. 1, [( 4, 1 ) = (psi[4]), ( 3, 1 ) = (psi[3]), ( 1, 1 ) = (psi[1]), ( 2, 1 ) = (psi[2])  ] ))

(14)

The above has the matricial operations delayed; unleash them

%

Physics:-`.`(%AntiCommutator(Physics:-Dgamma[mu], Physics:-Dgamma[nu]), array( 1 .. 4, 1 .. 1, [( 4, 1 ) = (psi[4]), ( 3, 1 ) = (psi[3]), ( 1, 1 ) = (psi[1]), ( 2, 1 ) = (psi[2])  ] )) = 2*Physics:-g_[mu, nu]*(array( 1 .. 4, 1 .. 1, [( 4, 1 ) = (psi[4]), ( 3, 1 ) = (psi[3]), ( 1, 1 ) = (psi[1]), ( 2, 1 ) = (psi[2])  ] ))

(15)

Or directly perform in one go the matrix operations behind (13)

Library:-PerformMatrixOperations(Physics[`*`](%AntiCommutator(Physics[Dgamma][mu], Physics[Dgamma][nu]), Psi) = 2*Physics[g_][mu, nu]*Physics[`*`](`𝕀`, Psi))

Physics:-`.`(%AntiCommutator(Physics:-Dgamma[mu], Physics:-Dgamma[nu]), array( 1 .. 4, 1 .. 1, [( 4, 1 ) = (psi[4]), ( 3, 1 ) = (psi[3]), ( 1, 1 ) = (psi[1]), ( 2, 1 ) = (psi[2])  ] )) = 2*Physics:-g_[mu, nu]*(array( 1 .. 4, 1 .. 1, [( 4, 1 ) = (psi[4]), ( 3, 1 ) = (psi[3]), ( 1, 1 ) = (psi[1]), ( 2, 1 ) = (psi[2])  ] ))

(16)

REMARK: As shown above, in general, the representation using lowercase commands allows you to use `*` or `.` depending on whether you want to represent the operation or perform the operation. For example this represents the operation, as an exact mimicry of what we do with paper and pencil, both regarding input and output

`𝕀`*Psi

Physics:-`*`(`𝕀`, Psi)

(17)

And this performs the operation

`𝕀`.Psi

array( 1 .. 4, 1 .. 1, [( 4, 1 ) = (psi[4]), ( 3, 1 ) = (psi[3]), ( 1, 1 ) = (psi[1]), ( 2, 1 ) = (psi[2])  ] )

(18)

Or to only displaying the operation

Library:-RewriteInMatrixForm(Physics[`*`](`𝕀`, Psi))

Physics:-`.`(array( 1 .. 4, 1 .. 4, [( 4, 1 ) = (0), ( 1, 2 ) = (0), ( 2, 3 ) = (0), ( 1, 3 ) = (0), ( 2, 2 ) = (1), ( 4, 2 ) = (0), ( 3, 4 ) = (0), ( 1, 4 ) = (0), ( 3, 1 ) = (0), ( 4, 4 ) = (1), ( 3, 2 ) = (0), ( 1, 1 ) = (1), ( 2, 1 ) = (0), ( 4, 3 ) = (0), ( 3, 3 ) = (1), ( 2, 4 ) = (0)  ] ), array( 1 .. 4, 1 .. 1, [( 4, 1 ) = (psi[4]), ( 3, 1 ) = (psi[3]), ( 1, 1 ) = (psi[1]), ( 2, 1 ) = (psi[2])  ] ))

(19)

And to perform all these matricial operations within an algebraic expression,

Library:-PerformMatrixOperations(Physics[`*`](`𝕀`, Psi))

Matrix(%id = 18446744079185513758)

(20)

``

 


 

Download DiracAlgebraWithIdentityMatrix.mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

Maple function code:

GetAngle := proc(opp, hyp)
local theta;
theta = arcsin(opp/hyp);
evalf(180/Pi*theta);
end proc:
GetAngle(4,5)
                       57.29577950 theta

Matlab code:

function [outputArg1,outputArg2] = GetAngle(opp,hyp)
    theta = asin(opp/hyp);
    outputArg1 = 180/pi*theta;
end

> GetAngle(4,5)

ans =

   53.1301

Ditto same code from Maple programming guide 2017:

 

Why is there a difference in the answer, am I coding it wrong? I mean any syntax errors that I am not following?

I need find CPU time for a set of mathematical calculations,  what is the best method in maple 18?

Dear all!

I am facing problem to find the solution of system of linear equations as attached for different values of alpha, please the see the attachment and fix my problem

Equations.mw

Thanks in advance

Hi there,

I know for a given 2x2 system of differential equations, it is possible for maple to plot a phase portrait on x-y plane (or a graph with directions and arrows).And this is also possible in a 3x3 system by choosing 2 variables / the plane of projection by including the code scene=[x(t),y(t)] (on x-y plane) .

My question is:

given a system of 3x3 differential equations,like

dx/dt = f(x(t),y(t),z(t))

dy/dt = g(x(t),y(t),z(t))

dz/dt = h(x(t),y(t),z(t)),

how could I produce a 3D vector field of the system? (with arrows)

Thanks!

Good day!

I am working to solve a double series (LP  minimization) problem of the form 

z = add(add(x[i,j]*y[i,j]*z[j], j=1..6), i=1..3).

However, this returns a set [ ]. 

Since LPSolve does not operate on a set (removing the brackets manually will enable LPSolve to obtain the solution), can anyone suggest what is wrong with the structure of this z-equation? x, y are matrices and z is a column vector.

 

Thanks!

If I insert a hyperlink to a website, it works fine when I'm in Maple, but when I export my Maple to pdf, the hyperlink is not clickable anymore.

I've tried using both Windows' "Microsoft Print to PDF", Maple's own "Export to PDF", "cutepdf" as well as MacOS "Save to PDF". Is there a way of doing this?

 

Best wishes

Hey any one can help? I calculated the characteristical Polynom of my Matrix M:

-(lambda-2)^2*(544-lambda^9-328*lambda^7-16*cos(x-y)+6*cos(x-y)*lambda+6*cos(x+y)*lambda-408*cos(y)*lambda^2-408*cos(x)*lambda^2+540*cos(y)*lambda+540*cos(x)*lambda-28*cos(y)*lambda^4-28*cos(x)*lambda^4+152*cos(y)*lambda^3+152*cos(x)*lambda^3+2*cos(y)*lambda^5+2*cos(x)*lambda^5-256*cos(y)+17232*lambda^2-256*cos(x)-7852*lambda^5+17768*lambda^4+2088*lambda^6+28*lambda^8-16*cos(x+y)-23632*lambda^3-5844*lambda)

now I want to solve the second part of the polynomial with lambda^9 but maple gives me the RootOf-function

_Z^9-28*_Z^8+328*_Z^7-2088*_Z^6+(-2*cos(y)-2*cos(x)+7852)*_Z^5+(28*cos(y)+28*cos(x)-17768)*_Z^4+(-152*cos(y)-152*cos(x)+23632)*_Z^3+(408*cos(y)+408*cos(x)-17232)*_Z^2+(-12*cos(x)*cos(y)-540*cos(y)-540*cos(x)+5844)*_Z+32*cos(x)*cos(y)+256*cos(y)+256*cos(x)-544

How can I simplify this expression to solve over lambda.

purpose is to plot all the eigenvalues.

 

Thank you in advance.

Hello,

Why does the following work as expected...

f__c := proc (x__0, y__0) options operator, arrow; piecewise(x__0^2+y__0^2 <= 1 and (x__0-1)^2+y__0^2 <= 1 and x__0^2+(y__0-1)^2 <= 1 and (x__0-1)^2+(y__0-1)^2 <= 1, 1, not (x__0^2+y__0^2 <= 1 and (x__0-1)^2+y__0^2 <= 1 and x__0^2+(y__0-1)^2 <= 1 and (x__0-1)^2+(y__0-1)^2 <= 1), 0) end proc

But the following does not?

cnd := x__0^2+y__0^2 <= 1 and (x__0-1)^2+y__0^2 <= 1 and x__0^2+(y__0-1)^2 <= 1 and (x__0-1)^2+(y__0-1)^2 <= 1
f__c := proc (x__0, y__0) options operator, arrow; piecewise(cnd, 1, not cnd, 0) end proc

(Sorry about the lack of formatting, the forum insists my Maple syntax is invalid)

The first one produces the expected result, x__0 and y__0 are treated as variables in the condition (i.e. f__c(a, b) returns the same piecewise function with x__0 replaced with a and y__0 replaced with b); the second one does not (i.e. f__c(a, b) returns the piecewise function, still with x__0 and y__0 in the condition, and never gets evaluated).

Dear all

I have a system of PDes, the code i think it's well writte but when I use pdesolve i have no solution obtained.

Maybe I must add something else

Many thinks

sysPDes.mw

First 881 882 883 884 885 886 887 Last Page 883 of 2215