MaplePrimes Questions

The question has been asked at http://www.mapleprimes.com/questions/133139-A-Question-About-Obtaining-Power-Of-A-Variable

 

 

However, still, I would like to have a simple, straightfoward solution. The situation is not about several term case, x^a*y^b + x^(a+2)*y^b, but for a single term. I have a term "3*x^k*y^(k+2) ", and how should I do to obtain the power of x, and the power of y? (k and k+2) 

 

I tried the following input as somehow suggested in the link above

***********

term:=3*x^k*y^(k+2);

x_degree:=map(t -> `if`(match(t = a*x^b*y^c, x, 's1'), subs(s1,b), NULL), convert(term, list));
y_degree:=map(t -> `if`(match(t = a*x^b*y^c, y, 's1'), subs(s1,c), NULL), convert(term, list));
print(x_degree,y_degree);

*****

 

I got 

***

k (k + 2)
3 x y
[0, k, 0]
[0, 0, k + 2]
[0, k, 0], [0, 0, k + 2]

****

I have no idea why k appear at second variable in [0,k,0] while k+2 appear at the third in [0,0,k+2]...

Dear all,

I want to compute the charateristic polynomials of some matrices (the number of matrices is more than 10000), and write the coefficients of the resulting polynomials to a text file. The entries of the given matrices are stored in a text file. More specifically, suppose that M_1, M_2 and M_3 are three matrices, and the entries of them are stored in a text file named "data.txt" in the following form:

1 2 3

4 5 6

7 8 9

 

1 -1 0

2 3 6

-3 0 2

 

2 1 -1

1 -1 -2

0 1 2

The resulting output file should be of the following format:

1, -15, 18, 0

1, -6, 13, -28

1, -3, 1, 3

I don't know how to repeatedly read the data from the given text file. I think the procedure should be as follows.

>restart:

>with(LinearAlgebra):

>with(FileTools:-Text):

>fid:=Open("data.txt"):

>fid_1:=Open("data_1.txt"): #data_1 is the output file

>ReadFile(fid); #since the number of matrices is very large, I want the data to be read once

>numlines:=CountLines(fid);

>for i from 1 to numlines do

       here I need repeatedly read the data to a matrix M (I don't know how to do);

       P:=CharacteristicPolynomial(M,x);

       writedata[APPEND]("data_1.txt",map(i-> coeff(p, x, i), [seq(i, i = 0 .. degree(p, x))]));  #this statement cannot write the coefficients of a polynomial in the same row

>end do;

>Close(fid):

>Close(fid_1):

Now as I'm pretty new to Maple, I don't know any better and can't seem to get any information out of the help documents. 

Thanks a lot.

Hi,

So I wrote this script (30 lines) in Maple and it works fine. But now I want Maple to repeat the script while changing my input variable.

My variable is T and I want Maple to perform the script for T=0 to T=15 and with a step size of 0.1.

 

I tried for loop and proc, but could not make it work. What is the most appropriate way do this?

 

Thank you.

 

 

 

Hi everyone. Could I work with functions of complex variable in maple ?

Hi all,

I'm using MAPLE 13 and I'd like to know if someone knows how to generate the variables associated to the CodeGeneration for C code. At this moment I need to create manually the variable generated from the C code.

Example:

JJ := Jacobian(convert(Pint, Vector), [P1xenu, P1yenu, P1zenu, roll, pitch, yaw, D1xbody, D1ybody, P2xenu, P2yenu, P2zenu, ROLL, PITCH, YAW, D2xbody, D2ybody]);

CodeGeneration['C'](JJ, optimize);

Output:

t1 = cov2 * cov2;
t2 = cov1 * cov1;
t4 = 0.1e1 / (t1 + t2);
t5.......

And in the C code I need to create:

double t1, t2, t3..... manually

I can I solve this issue?

Best regards

André Dias

Hi everyone,

I have a question regarding the derivation of tensors/matrices.
Let's assume for simplicity, that I have a vector (6x1) s and a matrix A (6x6)defining Transpose(s)*Inverse(A)*s. From this function I want to calculate the derivative w.r.t. s. My approach would be

restartwith(Physics):
with(LinearAlgebra):
Define(s,A)

Diff(
Transpose(s)*Inverse(A)*s, s)

As a result I get

though I'd rather expect something like Inverse(A)*s + Transpose(s)*Inverse(A)

Now as I'm pretty new to Maple, I can imagine that my approach is wrong, but I don't know any better and can't seem to get any information out of the help documents.

Thanks in advance for any of your suggestions!

In the book "Challenges in Geometry" of the author Christopher J. Bradley at p. 32, the triangle with three sides a := 136, b := 170, c := 174 has three medians ma := 158, mb := 131, mc := 127. I checked

restart:

a:=2*68;

b:=2*85;

c:=2*87;

ma:=sqrt((b^2+c^2)/2-a^2/4);

mb:=sqrt((a^2+c^2)/2-b^2/4);

mc:=sqrt((b^2+a^2)/2-c^2/4);

Now I want to find coordinates of vertices of a triangle like that (in plane). I tried

restart;
DirectSearch:-SolveEquations([(x2-x1)^2+(y2-y1)^2 = 136^2,
(x3-x2)^2+(y3-y2)^2 = 170^2, (x3-x1)^2+(y3-y1)^2 = 174^2], {abs(x1) <= 30, abs(x2) <= 30, abs(y1) <= 30, abs(y2) <= 30, abs(x3) <= 30, abs(y3) <= 30}, assume = integer, AllSolutions, solutions = 5);

but my computer runs too long. I think, there is not a triangle with integer coordiantes. 

How can I get  a triangle  with coordinates of vertices are rational numbers?

 

Dear all,

It's very convenient to define a DE or PDE through Differential Operator D, for example,

((D[1, 1]+D[1, 2]+D[2, 2])(z))(x, y) = exp(x)*sin(y)

Is it possible to realize Inverse Operator Method of Operator D? How to solve the following equation if we rewrite the pde through inverse operator method?

(z)(x, y)=((D[1, 1]+D[1, 2]+D[2, 2])^(-1))exp(x)*sin(y)

 

Thanks a lot.

hi.i am a problem for solve analytic double integration as blow,plese help me....Thanks alot

int(int((2*gamma*cos(psi)/(D-r*sin(theta)*sin(phi))-2*gamma*cos(psi)/(D+r*sin(theta)*sin(phi)))*r^2*cos(theta)*sin(phi), r = 0 .. L), phi = 0 .. Pi)

 

I UPLOAD THIS INTEGRAL AS FOLLOW;;;;;int.mw

int(int((2*gamma*cos(psi)/(D-r*sin(theta)*sin(phi))-2*gamma*cos(psi)/(D+r*sin(theta)*sin(phi)))*r^2*cos(theta)*sin(phi), r = 0 .. L), phi = 0 .. Pi)

``


Download int.mw

I want to extract all the coefficients of a polynomial. For example, let p:=x^5-8x^3+2, and the function coeffs(p) returns 1, -8, 2. In fact, I want to obtain 1, 0, -8, 0, 0, 2. Thanks to everyone.

For some reason, Maple does not use \frac{}{} for things like 1/2 that can occur in an expression

restart;
expr:=1/2;
latex(expr);

            1/2

This make the generated code not good looking. For example using this in Maple:

latex(diff(y(x), x)+y(x)*cos(x)-(1/2)*sin(2*x) = 0);

produces this latex when proccessed:

When the latex is put inside a display in the document.  This is terrible. Is there a way to tell Latex to use \frac{}{} for fractions?

 

Hi:

i will sole the below non-linear equtions in maple,how?(all initial conditons are zero)

EQ1 := -9.034666667*10^5*Pi^2*q3(t)*q1(t)+3044.230933*Pi*q1(t)*q5(t)+3044.230933*Pi*q1(t)*q4(t)+2.541000000*10^5*q1(t)^3*Pi^4+2.171794873*10^5*q1(t)*Pi^2-2.171794873*10^5*q2(t)*Pi+4.372778665*(diff(q1(t), t, t)) = 0
EQ2 := 54294.87180*q2(t)-54294.87180*q1(t)*Pi-.8371635069*q4(t)*Pi+.8371635069*q5(t)*Pi+1.093194666*q2(t)*Pi^2+0.7054749580e-5*(diff(q2(t), t, t)) = 0
EQ3 := 9.034666667*10^5*q1(t)^2*Pi^2+6.776000000*10^5*Pi^2*q3(t)-2283.173200*q5(t)*Pi-2283.173200*q4(t)*Pi = 0
EQ4 := -1.123134385*10^8*q1(t)*(diff(q1(t), t))+636.6197724-5191.348750*q4(t)-2.035463170*10^7*(diff(q5(t), t))-2.035463170*10^7*(diff(q4(t), t))-5191.348750*q5(t) = 0
EQ5 := .7002817496-29887.90348*q4(t)+29887.90348*q5(t)-135.8992605*(diff(q2(t), t))-7463.364956*(diff(q4(t), t))+7463.364956*(diff(q5(t), t)) = 0

 

 

We are using your maple service and required your help in solving below problem '
1. Create a question type Maple Numeric with correct answer 27
2. If user gives 27d and 27e and on evaluate with your service getting response as true.

Please find the attached screens for more information. Also see request and response for numeric value 10 and if you see response even 10d is evaluating as true. This is wrong, please review and advice.

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

mapleScript :: before substitution

expr1:="<math><cn>${#answer}</cn></math>"; expr2:="<math><cn>${#correctAnswer}</cn></math>"; expr3:="<math><cn>${#tolrence}</cn></math>";expr1 := StringTools[SubstituteAll](expr1, ",", "");expr1 := StringTools[RegSubs]("<apply>< *([a-zA-Z]+)[ /]*>" = "<apply><ci>\1</ci>", expr1);expr1 := StringTools[RegSubs]("<apply><ci>(plus|minus|divide|times|power)</ci>" = "<apply><\\1/>", expr1);expr1 := StringTools[RegSubs]("<apply><ci> *([a-zA-Z]+) *</ci>" = "<apply><ci>x_\\1</ci>", expr1);expr1 := StringTools[RegSubs]("<c[ni]> *([0-9]+\\.[0-9]+) *</c[ni]>" = "<apply><ci>convert</ci><cn>\\1</cn><ci>rational</ci><ci>exact</ci></apply>", expr1);expr2 := StringTools[SubstituteAll](expr2, ",", "");expr2 := StringTools[RegSubs]("<apply>< *([a-zA-Z]+)[ /]*>" = "<apply><ci>\\1</ci>", expr2);expr2 := StringTools[RegSubs]("<apply><ci>(plus|minus|divide|times|power)</ci>" = "<apply><\\1/>", expr2);expr2 := StringTools[RegSubs]("<apply><ci> *([a-zA-Z]+) *</ci>" = "<apply><ci>x_\\1</ci>", expr2);expr2 := StringTools[RegSubs]("<c[ni]> *([0-9]+\\.[0-9]+) *</c[ni]>" = "<apply><ci>convert</ci><cn>\\1</cn><ci>rational</ci><ci>exact</ci></apply>", expr2);expr1 := MathML[ImportContent](expr1);expr2 := MathML[ImportContent](expr2);expr := combine(expr1-expr2, [radical,power,trig,ln,power,radical], symbolic);expr3:=MathML[ImportContent](expr3);result := evalb(abs(simplify(expr, symbolic))<=expr3);result := evalb(result = true);if not result then result := evalb(abs(simplify(expr, assume = real))<=expr3) end if;result := evalb(result = true);

mapleScript :: (user input) 10d

expr1:="<math><cn>10d</cn></math>"; expr2:="<math><cn>10</cn></math>"; expr3:="<math><cn>0</cn></math>";expr1 := StringTools[SubstituteAll](expr1, ",", "");expr1 := StringTools[RegSubs]("<apply>< *([a-zA-Z]+)[ /]*>" = "<apply><ci>\1</ci>", expr1);expr1 := StringTools[RegSubs]("<apply><ci>(plus|minus|divide|times|power)</ci>" = "<apply><\\1/>", expr1);expr1 := StringTools[RegSubs]("<apply><ci> *([a-zA-Z]+) *</ci>" = "<apply><ci>x_\\1</ci>", expr1);expr1 := StringTools[RegSubs]("<c[ni]> *([0-9]+\\.[0-9]+) *</c[ni]>" = "<apply><ci>convert</ci><cn>\\1</cn><ci>rational</ci><ci>exact</ci></apply>", expr1);expr2 := StringTools[SubstituteAll](expr2, ",", "");expr2 := StringTools[RegSubs]("<apply>< *([a-zA-Z]+)[ /]*>" = "<apply><ci>\\1</ci>", expr2);expr2 := StringTools[RegSubs]("<apply><ci>(plus|minus|divide|times|power)</ci>" = "<apply><\\1/>", expr2);expr2 := StringTools[RegSubs]("<apply><ci> *([a-zA-Z]+) *</ci>" = "<apply><ci>x_\\1</ci>", expr2);expr2 := StringTools[RegSubs]("<c[ni]> *([0-9]+\\.[0-9]+) *</c[ni]>" = "<apply><ci>convert</ci><cn>\\1</cn><ci>rational</ci><ci>exact</ci></apply>", expr2);expr1 := MathML[ImportContent](expr1);expr2 := MathML[ImportContent](expr2);expr := combine(expr1-expr2, [radical,power,trig,ln,power,radical], symbolic);expr3:=MathML[ImportContent](expr3);result := evalb(abs(simplify(expr, symbolic))<=expr3);result := evalb(result = true);if not result then result := evalb(abs(simplify(expr, assume = real))<=expr3) end if;result := evalb(result = true);

evalResult ::
expr1 := "<math><cn>10d</cn></math>" expr2 := "<math><cn>10</cn></math>" expr3 := "<math><cn>0</cn></math>" expr1 := "<math><cn>10d</cn></math>" expr1 := "<math><cn>10d</cn></math>" expr1 := "<math><cn>10d</cn></math>" expr1 := "<math><cn>10d</cn></math>" expr1 := "<math><cn>10d</cn></math>" expr2 := "<math><cn>10</cn></math>" expr2 := "<math><cn>10</cn></math>" expr2 := "<math><cn>10</cn></math>" expr2 := "<math><cn>10</cn></math>" expr2 := "<math><cn>10</cn></math>" expr1 := 10. expr2 := 10 expr := 0. expr3 := 0 result := true result := true result := true

mapleScript :: (user input) 10
expr1:="<math><cn>10</cn></math>"; expr2:="<math><cn>10</cn></math>"; expr3:="<math><cn>0</cn></math>";expr1 := StringTools[SubstituteAll](expr1, ",", "");expr1 := StringTools[RegSubs]("<apply>< *([a-zA-Z]+)[ /]*>" = "<apply><ci>\1</ci>", expr1);expr1 := StringTools[RegSubs]("<apply><ci>(plus|minus|divide|times|power)</ci>" = "<apply><\\1/>", expr1);expr1 := StringTools[RegSubs]("<apply><ci> *([a-zA-Z]+) *</ci>" = "<apply><ci>x_\\1</ci>", expr1);expr1 := StringTools[RegSubs]("<c[ni]> *([0-9]+\\.[0-9]+) *</c[ni]>" = "<apply><ci>convert</ci><cn>\\1</cn><ci>rational</ci><ci>exact</ci></apply>", expr1);expr2 := StringTools[SubstituteAll](expr2, ",", "");expr2 := StringTools[RegSubs]("<apply>< *([a-zA-Z]+)[ /]*>" = "<apply><ci>\\1</ci>", expr2);expr2 := StringTools[RegSubs]("<apply><ci>(plus|minus|divide|times|power)</ci>" = "<apply><\\1/>", expr2);expr2 := StringTools[RegSubs]("<apply><ci> *([a-zA-Z]+) *</ci>" = "<apply><ci>x_\\1</ci>", expr2);expr2 := StringTools[RegSubs]("<c[ni]> *([0-9]+\\.[0-9]+) *</c[ni]>" = "<apply><ci>convert</ci><cn>\\1</cn><ci>rational</ci><ci>exact</ci></apply>", expr2);expr1 := MathML[ImportContent](expr1);expr2 := MathML[ImportContent](expr2);expr := combine(expr1-expr2, [radical,power,trig,ln,power,radical], symbolic);expr3:=MathML[ImportContent](expr3);result := evalb(abs(simplify(expr, symbolic))<=expr3);result := evalb(result = true);if not result then result := evalb(abs(simplify(expr, assume = real))<=expr3) end if;result := evalb(result = true);

evalResult ::
expr1 := "<math><cn>10</cn></math>" expr2 := "<math><cn>10</cn></math>" expr3 := "<math><cn>0</cn></math>" expr1 := "<math><cn>10</cn></math>" expr1 := "<math><cn>10</cn></math>" expr1 := "<math><cn>10</cn></math>" expr1 := "<math><cn>10</cn></math>" expr1 := "<math><cn>10</cn></math>" expr2 := "<math><cn>10</cn></math>" expr2 := "<math><cn>10</cn></math>" expr2 := "<math><cn>10</cn></math>" expr2 := "<math><cn>10</cn></math>" expr2 := "<math><cn>10</cn></math>" expr1 := 10 expr2 := 10 expr := 0 expr3 := 0 result := true result := true result := true

When I try to export my data from a spreadsheet to Excel, instead of numbers I get a long text containing numbers. For example instead of having just "11625.7677908435" I get "Typesetting:-mprintslash([11625.7677908435], [HFloat(11625.767790843516)])". 

How can I change the decimal to be displayed in the whole spreadsheet. The default decimals to be displayed is 4 in my version. How can I change it to another value? Also I don't want to click on "properties" each time I execute my worksheet. I want it to be automatically display  the number of digits I want. 

First 1400 1401 1402 1403 1404 1405 1406 Last Page 1402 of 2434