MaplePrimes Questions

CodeGeneration returns round brackets when converting a matrix to numpy. According to Python syntax it should return square brackets. I am using Maple 18, so maybe this issue has been solved in more recent releases.

MWE

----------------
>restart:
>with(CodeGeneration):
>QLoc:=proc()
local Q:
Q:= Matrix(2,2):
Q(1,1) := 1E5:
Q(2,2) := 1E4:
Q(1,2) := 1E3:
Q(2,1) := 1E3:
return Q:
end proc:
 

>Python(QLoc);

import numpy

def QLoc ():
    Q = numpy.mat([[0,0],[0,0]])
    Q(1, 1) = 0.1e6
    Q(2, 2) = 0.1e5
    Q(1, 2) = 0.1e4
    Q(2, 1) = 0.1e4
    return(Q)

------------

Hey all Maple experts, Kris here!

I could really use some help/clarfication on what is going on with alias, diff, and pointers for vectors.

A short description of what I want to do:
I have 4 equations with 4 variables. The first two equations and variables (1 and 2) are called private, and the last two (3 and 4) are called common. I want to establish an implicit dependence of common on private, namely that the private variables 1 and 2 depend on 3 and 4. Then I want to derivate the private equations with respect to the common variables.

Thus, I create pointers that point to the correct private or common equation or variables with the loop.
for i from 1 to 2 do
iP[i]:=i:
iC[i]:=i+2;
od:

So that for example, a set of four equations named "phi" phi[1..4] where phi[iP[1]] is the first private equation, and phi[iC[1]] is the first common equation. Hopefully so far I have been clear. I create an alias, and continue to derivate these equations. However, I notice that Maple does not recognize the functions in the diff command if the "pointer" notation is used. I will paste the entire code for you all to look at and maybe you can see where things get "weird". Namely if I write phi[1], is not the same as phi[iP[1]], even though iP[1]:=1 (Both are integers). 

p.s. I have used implicitdiff. It is way too slow and memory inefficient for many equations (hundreds to thousands). So that is why I am trying to find a work-around.

restart:
Digits:=15:
with(LinearAlgebra):


for i from 1 to 2 do
iP[i]:=i:
iC[i]:=i+2;
od:


alias(seq(x[iP[i]]=x[iP[i]](seq(x[iC[j]],j=1..2)),i=1..2)):
alias(seq(seq(dPdC[i,iC[k]]=diff(x[iP[i]](seq(x[iC[j]],j=1..2)),x[iC[k]]),k=1..2),i=1..2));


# Define all (PRIVATE + COMMON) phi expressions.
# 1 and 2 are the PRIVATE equations.
# 3 and 4 are the COMMON equations.
phix[1]:= x[3]**2+x[4]**2:
phix[2]:= x[1]   +x[4]:
phix[3]:= x[1]   +x[3]+x[1]:
phix[4]:= x[1]   +x[3]+x[1]:

for i from 1 to 2   do
f[i]:=x[iP[i]]-phix[iP[i]]:
od:


f[1];

x[1]-phix[1];

print(iP[1],iC[1]);

print(x[iP[1]]-phix[iP[1]],x[iC[1]]);

TEST1:=diff(x[1]-phix[1],x[3]);

TEST2:=diff(f[1],x[3]);

TEST3:=diff(f[1],x[iC[1]]);

TEST4:=diff(x[iP[1]]-phix[iP[1]],x[iC[1]]);

The result is 
      
                     -x[3]^2  - x[4]^2  + x[1]
                      x[1] - x[3]^2  - x[4]^2 
                              1, 3
     
                  -x[3]^2 - x[4]^2  + x[1], x[3]
                      dPdC[1, 3] - 2 x[3]
                            -2 x[3]
                            -2 x[3]
                            -2 x[3]
Where dPdC includes the implicit derivatives, which is the answer I want, but then I am forced to write by hand what the elements are. If I put the expression in a loop with the pointers, then I get the other "TEST" answers, and as you can see, the implicit dependence from alias has been ignored.
 

 how can i define constants alpha and beta are positive in maple? ;these constants are coefficints of PDE (higgs field equation)

I just had maple downloaded and the command prompt and classic worksheet seem to work but when I try to use the desktop app maplew.exe the initial loading image comes up but then nothing happens. I don't know how to fix this :/ thanks.

Hello, I am looking to understand in more depth how the function isprime(n) works. After reading Section 6.2.4 'Other Primality Tests' of Padro's Introduction to Cryptography with maple, I understand that it performs some prior trial divisions before a Miller-Rabin test (of which it calls GMP) and then a Lucas test.

 I have also seen the post on these forums:

 https://www.mapleprimes.com/questions/204087-Maple-Specialprimes 

to see the result of showstat(isprime), which verifies my summary as above. I am curious as to what exact function is being called upon from gmp by gmp_isprime(n). Since there is no obvious analog function found in GMP, and the popular mpz_probab_prime_p() takes a second argument, which is not given here. I found the documentation gives a download of the GMP code used here:

https://www.maplesoft.com/support/downloads/GMP.html

I pose two questions, the first:

  1. Since I do not own Maple 2017, is the result of showstat(isprime) the same as that given above in Maple18? COuld someone be so kind as to post a raw output of this below?
  2. What function for primality test is being called upon in GMP, I am very familiar with GMP and the only test that can be called without a value of 'reps' (or rounds of MR) is found in demos/isprime.c in the GMP download maple gives, which uses mpz_probab_prime_p(n,25), i.e 25 rounds of Miller Rabin, but seems unlikely to just be used, as it is a demo.

Thanks,

Jake

hello everyone!!

I need to plot the function x^3-x^2-x-1, and in the plot I need to calculate de point X that make the function equals to cero (the cutting point with the x axis).

Thanks you!!

Hello dear!

Hope everyone is fine. I want to solve the system of algebraic equations. The answer of c[i]'s should be in term of q. Please see the attachment and fix the problem for any value of M. I am waiting your positive response. Thanks in advance. 

Help.mw

I am trying to model a parallel manipulator but I am receiving an error message

State variable'diff(diff(`Main.R41.theta`(t),t),t)' does not appear in dynamic or constraint equations.

I tried changing the Revolute joint 41 but the same error is repeated. 

You can find my model here: ParalelManipulator_v2.msim

Can you help me solve this issue? Thank you in advance!

Dear All,

I wanted to check the calcultations carried out in a Journal Article I was reading as I was not very convinced.

The objective is to find q1i, q2i, q3i in terms of px, py, and pz and constant parameters φ, a, b, h, and r.

I have realised that the results given by the article do not match with the solution to the dsolve command.

Could you please spot where the mistake is?

My Solution: IK_equations.mw

help me on thispde_solutionalpha.mw
 

restart

M := 1; S := .78; K := .5; Sh := .2; alpha := .7; R := .3; N := .6; k := .5

pde1 := diff(u(y, t), t)+S.(diff(u(y, t), y))-2*k^2*u(y, t) = diff(u(y, t), y, y)+theta(y, t)+N.C(y, t)+M.u(y, t)+u(y, t)/K

                pde2 := theta(y, t)+t*(diff(theta(y, t), t))+S*(diff(theta(y, t), y)) = (diff(theta(y, t), y, y))/Pr-alpha.theta(y, t)

pde3 := C(y, t)+t*(diff(C(y, t), t))+S*(diff(C(y, t), y)) = (diff(C(y, t), y, y))/Sh-R.C(y, t)

PDE := unapply({pde || (1 .. 3)}, Pr)

proc (Pr) options operator, arrow; {C(y, t)+t*(diff(C(y, t), t))+.78*(diff(C(y, t), y)) = 5.000000000*(diff(diff(C(y, t), y), y))-.3*C(y, t), diff(u(y, t), t)+.78*(diff(u(y, t), y))-.50*u(y, t) = diff(diff(u(y, t), y), y)+theta(y, t)+.6*C(y, t)+3.000000000*u(y, t), theta(y, t)+t*(diff(theta(y, t), t))+.78*(diff(theta(y, t), y)) = (diff(diff(theta(y, t), y), y))/Pr-.7*theta(y, t)} end proc

(1)

IBC := {C(0, t) = 1, C(1, t) = 0, C(y, 0) = 0, theta(0, t) = 1, theta(1, t) = 0, theta(y, 0) = 0, u(0, t) = 0, u(1, t) = 0, u(y, 0) = 0}

``

PrList := [.71, 7, 10, 100]; Colours := table(`~`[`=`](PrList, ["blue", "red", "green", "cyan"])); for Pr in PrList do pds := pdsolve(PDE(Pr), IBC, numeric); Plots[Pr] := pds:-plot[display](u(y, t), t = .5, linestyle = "solid", colour = Colours[Pr], legend = sprintf("Pr=%2.2f", Pr), title = "Velocity Profile", labels = ["y", "theta"]) end do; plots:-display([seq(Plots[Pr], `in`(Pr, PrList))])

 

NULL


 

Download pde_solutionalpha.mw

 

Dear All,

I'm stuck in a question, perhaps somebody can help. I have to solve the following equation: 

restart;
with(LinearAlgebra);
A := Matrix(3, 3, [[1, 3, 2], [4, 5, 1], [3, 7, 2]]);
      
M := IdentityMatrix(3);
   
eq := A^2*a+A*b+M*c;
K:= A^-2
Set := {seq(eq[i] = K[i], i = 1 .. nops(eq))};

 

But now I want to solve for a, b and c. I tried this with the solve function, but I gives an error. What do I have to do now?

Math


                            

 

Hello,

I'm trying to find the way to manipulate matrix equalities easily and isolate them as variables like if they were simple real variables but keeping the matrix properties.  However, I couldn't find the way to do it efficiently without describing all the parameters of the matrices.  I'd like to keep them as variables rather than perform matrix operations when defining the expressions. I've attached a snapshot which describes my problem much better:pdf_kmaple.pdf.

For instance, I'd like to be able to isolate the expression that defines the state-space when I change the discretization method.  

I'm wondering if there's a generic way I can use to isolate other matrix systems as well.

Thank you very much for your help!

JMarc

fgh := proc (x) options operator, arrow; [x, x^2, x^3] end proc;

sol := proc (x) options operator, arrow; min(`~`[Re](select(proc (t) options operator, arrow; is(abs(Im(t)) < 0.1e-19) and is(0 < Re(t)) end proc, fgh(x)))) end proc;

eval('sol(x)', [x = X]);

eval(%, X = 1)

 

Why does this not work?

Good morning,

I've been having some trouble entering this expression in Maple 17.

My teacher suggested using this format, however, this format is from 2004 and certainly isn't recognized by the current version of Maple, as it keeps spitting back 0=0 no matter how many different ways I try to enter it.

Could anyone provide feedback on the correct syntax of how to enter this expression? Thank you very much for your time.

Exporting one plot in program works well:

       MapleEngine.EvalMapleStatement(kv, "Export(\"D:\\\\MyGraph.jpeg\",plot(sin(x)*cos(2*x)));");

But if I'm trying to export two plots, program stops working and prints no exception:
        MapleEngine.EvalMapleStatement(kv, "Export(\"D:\\\\MyGraph.jpeg\",plot(sin(x)*cos(2*x)));");
        MapleEngine.EvalMapleStatement(kv, "Export(\"D:\\\\MyGraph2.jpeg\",plot(sin(x)*cos(2*x)));");

What is the cause?

First 909 910 911 912 913 914 915 Last Page 911 of 2428