Maple 2015 Questions and Posts

These are Posts and Questions associated with the product, Maple 2015

with(RegularChains):
with(ChainTools):
with(MatrixTools):
with(ConstructibleSetTools):
with(ParametricSystemTools):
with(SemiAlgebraicSetTools):
with(FastArithmeticTools):
R := PolynomialRing([x,y,z,a,b]):
sys := [x^2 + y^2 - x*y - 1 = 0, y^2 + z^2 - y*z - a^2 = 0, z^2 + x^2 - x*z - b^2 = 0,x > 0, y > 0, z > 0, a - 1 >= 0, b-a >= 0, a+1-b > 0]:

dec := RealTriangularize(sys,R): # very slow
Display(dec, R);

dec := LazyRealTriangularize(sys,R): # it is faster
dec2 := value(dec): # very slow
value(dec2); 

find a , b to satisfy sys have real solution

expect  one of solution is below, but above function are very slow, load a very time still no result, where is wrong?

R1 = a^2+a+1-b^2;
R1 = a^2-1+b-b^2;

[R1 > 0, R2 > 0]


 

Hi,

Is it possible to force Maple to simplify these Sum(s) ?
SimplifySum.mw
 

s := Sum(a*X[n]+b, n=1..N);
simplify(s);
value(s);  # part of the job done  but...


IWouldLikeToHave = a*Sum(X[n], n=1..N) + b*N; # or +N*b, it doesn't matter

Sum(a*X[n]+b, n = 1 .. N)

 

Sum(a*X[n]+b, n = 1 .. N)

 

N*b+sum(a*X[n], n = 1 .. N)

 

IWouldLikeToHave = a*(Sum(X[n], n = 1 .. N))+N*b

(1)

s := Sum(X[n]+Y[n], n=1..N);
(expand@value)(s);


IWouldLikeToHave = Sum(X[n], n=1..N) + Sum(Y[n], n=1..N);

Sum(X[n]+Y[n], n = 1 .. N)

 

sum(X[n]+Y[n], n = 1 .. N)

 

IWouldLikeToHave = Sum(X[n], n = 1 .. N)+Sum(Y[n], n = 1 .. N)

(2)

 

 

 

Thanks in advance

 

Hi, 

I can't find a unique way to define a mixture of two random variables that enables at the same time to compute its PDF and generate a sample.
In the attached file you will find two methods :

  1. the first one is the most formal and only CAS are supposed to be able to allow its implementation:
     it enables computing the PDF and the CDF (trivial) but fails to generate a sample.
    (PS : in a first attempt I had defined only the PDF, which should have been enough for method=envelope does work... ... at my opinion)
     
  2. the second method is the one one would use in non CAS languages (for instance Matlab, R, ...). It enables generating a sample (of course) but fails to compute the PDF (which is not very surprising).

So my question: does anyone here would have some suggestions to make one these two methods capable to compute both the PDF (eventually the CDF) and generate samples ?

PS: still have this kind of problems (tomleslie suggested months ago that using interface(rtablesize=10) could help but it's not the case here)
Maple Worksheet - Error
Failed to load the worksheet /maplenet/convert/Mixture_of_random_variables.mw .

 

Download Mixture_of_random_variables.mw

 

Hi 

I got, a bit by mistake, a weird result that seems to come from the way "Maple" manipulates infinity (please have a look at the results below)
I couldn't find a correct explanation to these results in the help pages dedicated to infinity or evaluation.

Could anyone explain me why, in some circumstances, 'infinity' seems to be a name (for instance infinity*Pi; does not return  infinity but infiniy/Pi).
Thanks in advance

 

restart:

with(Statistics):

f := PDF(Cauchy(0, 1), x)

1/(Pi*(x^2+1))

(1)

m := int(x*f, x=-infinity..+infinity);

undefined

(2)

p := int(x*f, x);

(1/2)*ln(x^2+1)/Pi

(3)

# Naive "proof" : eval(..., infinity) seems to consider infinity as a name (consistent with
# the first line in help(infinity) without any particular property.
# This seems to be confirmed by the value of p1 and p2 : I expected to get infinity instead
# of infinity/Pi.

p1 := eval(p, x=-infinity);
p2 := eval(p, x=+infinity);
p2 - p1;

infinity/Pi

 

infinity/Pi

 

0

(4)

# Correct "proof" :

a := limit(p, x=-infinity);
b := limit(p, x=+infinity);
b-a

infinity

 

infinity

 

undefined

(5)

# Does Maple treat 'infinity' as a number ?

infinity         - infinity;
infinity*2       - infinity*2;
infinity*(1/3)   - infinity*(1/3);
infinity*0.333   - infinity*0.333;
infinity*sqrt(2) - infinity*sqrt(2);
infinity/Pi      - infinity/Pi;

undefined

 

undefined

 

undefined

 

Float(undefined)

 

0

 

0

(6)

limit(sqrt(2)/x, x=0) - limit(sqrt(2)/y, y=0);
limit(Pi/x, x=0)      - limit(Pi/y, y=0);

undefined

 

undefined

(7)

 


 

Download Infinity.mw

Dear Users!

Hope you would be fine with everything. I have following code to generate marix A of order M by M

restart; with(LinearAlgebra); with(linalg); Digits := 30; M := 10; nu := 1;

for k1 while k1 <= M do

C[k1] := simplify(sum((-1)^(k1-1-i1)*GAMMA(k1-1+i1+2*nu)*GAMMA(nu+1/2)*x^i1/(GAMMA(i1+nu+1/2)*factorial(k1-1-i1)*factorial(i1)*GAMMA(2*nu)), i1 = 0 .. k1-1))

end do;

A := evalm(Matrix(M, M, proc (i, j) options operator, arrow; eval(C[j], x = (i-1)/(M-1)) end proc))

I want to split (or decompose) A into two parts Ad and Ab 

A = Ab + Ad

where Ad is M by M matrix of all entries of A but first and last rows of Ad shoud be zero

and Ab is M by M matrix with zero entries expect first and last rows.

For exmaple for M = 5, A, Ab and Ad are given as,

Ab := Matrix(5, 5, {(1, 1) = 1, (1, 2) = -2, (1, 3) = 3, (1, 4) = -4, (1, 5) = 5, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0, (3, 4) = 0, (3, 5) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 0, (4, 5) = 0, (5, 1) = 1, (5, 2) = 2, (5, 3) = 3, (5, 4) = 4, (5, 5) = 5});

Ad := Matrix(5, 5, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (2, 1) = 1, (2, 2) = -1, (2, 3) = 0, (2, 4) = 1, (2, 5) = -1, (3, 1) = 1, (3, 2) = 0, (3, 3) = -1, (3, 4) = 0, (3, 5) = 1, (4, 1) = 1, (4, 2) = 1, (4, 3) = 0, (4, 4) = -1, (4, 5) = -1, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 0, (5, 5) = 0});

Please help me to fix this problem.
Special request @acer @Carl Love @Kitonum @Preben Alsholm

Hi,

How can I force the command InsertContent(Worksheet(Group(Input( T )))) to display the variable eq as it appears in label (2) ?

(a screen capture of the output of InsertContent(Worksheet(Group(Input( T )))) is given after the Maple code)

restart:

interface(version)

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

(1)

with(DocumentTools):

with(DocumentTools[Layout]):

eq := piecewise(t < 1, sin(t), cos(t));

C := Cell( Textfield(style=TwoDimOutput,Equation(eq)) ):
T := Table(Column(), widthmode=percentage, width=40, Row(C)):
InsertContent(Worksheet(Group(Input( T )))):

eq := piecewise(t < 1, sin(t), cos(t))

(2)

 



Download Layout.mw

Hi!

There is a (relatively) known software code (written in C), called ." GKLS-generator" or "GKLS" to generate, according to certain user paramenters, optimization test functions. The code is available for free at the web

http://wwwinfo.deis.unical.it/%7Eyaro/GKLS.html

The download with the files of the GKLS is the following:  download

I would like to write this code in Maple. In the attached zip there is a PDF explaining how to build these functions. For now, I tried the follwoing Maple code GKLS_v4.mw

I think I'm doing something wrong, since the drawing generated by the attached Maple does not look much like the PDF in the attached zip (Fig. 1 of page 8).

Please, Can you help me with this?

Many thanks in advance for your comments.

 

 

Hi User!

Hope you would be fine with everything. I have a vector "POL" of M dimension obatined for the following expression

restart; with(LinearAlgebra); nu := 1; M := 3;
for k while k <= M do
Poly[k] := simplify(sum(x^i*GAMMA(nu+1)/(factorial(i)*GAMMA(2*nu)), i = 0 .. k-1))
end do;
POL := `<,>`(seq(Poly[k], k = 1 .. M))

and I want to construct a matrix of M by M by collocating it on the points x=i/(M-1) for i=0,1,2,...,M-1 like the following way,

For M=3 I need

Matrix(3, 3, {(1, 1) = Poly[1](0), (1, 2) = Poly[1](1/2), (1, 3) = Poly[1](1), (2, 1) = Poly[2](0), (2, 2) = Poly[2](1/2), (2, 3) = Poly[2](1), (3, 1) = Poly[3](0), (3, 2) = Poly[3](1/2), (3, 3) = Poly[3](1)});

For M=4 I need

Matrix(4, 4, {(1, 1) = Poly[1](0), (1, 2) = Poly[1](1/3), (1, 3) = Poly[1](2/3), (1, 4) = Poly[1](1), (2, 1) = Poly[2](0), (2, 2) = Poly[2](1/3), (2, 3) = Poly[2](2/3), (2, 4) = Poly[2](1), (3, 1) = Poly[3](0), (3, 2) = Poly[3](1/3), (3, 3) = Poly[3](2/3), (3, 4) = Poly[3](1), (4, 1) = Poly[4](0), (4, 2) = Poly[4](1/3), (4, 3) = Poly[4](2/3), (4, 4) = Poly[4](1)})

 

and general form is like this

[[[Poly[1](0/(M-1)),Poly[1](1/(M-1)),Poly[1]((2)/(M-2)),...,Poly[1]((M-1)/(M-1))],[Poly[2](0/(M-1)),Poly[2]((1)/(M-1)),Poly[2]((2)/(M-1)),...,Poly[2]((M-1)/(M-1))],[Poly[3]((0)/(M-1)),Poly[3]((1)/(M-1)),Poly[3]((2)/(M-1)),...,Poly[3]((M-1)/(M-1))],[...,...,...,...,...],[Poly[M]((0)/(M-1)),Poly[M]((1)/(M-1)),Poly[M]((2)/(M-1)),...,Poly[M]((M-1)/(M-1))]]];

Another problem is I want to define a vector of M dimension using a function f(x)=sin(x) and two points a=1, b=2 like the following way,

Vec:=[[[a],[f((1)/(M-1))],[f((2)/(M-1))],[f((3)/(M-1))],[...],[f((M-1)/(M-1))],[b]]]
Please fix my problem. I'm waiting for your kind response.
Special request @acer @acer @Carl Love @Kitonum @Preben Alsholm

Dear Users!

Hope you would be fine with everything. I want the simpliest for of the following expression in two step:

diff(U(X, Y, Z, tau), tau)+U(X, Y, Z, tau)*(diff(U(X, Y, Z, tau), X))+V(X, Y, Z, tau)*(diff(U(X, Y, Z, tau), Y))+W(X, Y, Z, tau)*(diff(U(X, Y, Z, tau), Z))+u[delta]*lambda[1]*(diff(U(X, Y, Z, tau), tau, tau))/L[delta]+u[delta]*lambda[1]*(diff(U(X, Y, Z, tau), tau))*(diff(U(X, Y, Z, tau), X))/L[delta]+u[delta]*lambda[1]*U(X, Y, Z, tau)*(diff(U(X, Y, Z, tau), tau, X))/L[delta]+u[delta]*lambda[1]*(diff(V(X, Y, Z, tau), tau))*(diff(U(X, Y, Z, tau), Y))/L[delta]+u[delta]*lambda[1]*V(X, Y, Z, tau)*(diff(U(X, Y, Z, tau), tau, Y))/L[delta]+u[delta]*lambda[1]*(diff(W(X, Y, Z, tau), tau))*(diff(U(X, Y, Z, tau), Z))/L[delta]+u[delta]*lambda[1]*W(X, Y, Z, tau)*(diff(U(X, Y, Z, tau), tau, Z))/L[delta];
Step 1:
diff(U(X, Y, Z, tau), tau)+U(X, Y, Z, tau)*(diff(U(X, Y, Z, tau), X))+V(X, Y, Z, tau)*(diff(U(X, Y, Z, tau), Y))+W(X, Y, Z, tau)*(diff(U(X, Y, Z, tau), Z))+u[delta]*lambda[1]*(diff(diff(U(X, Y, Z, tau), tau)+U(X, Y, Z, tau)*(diff(U(X, Y, Z, tau), X))+V(X, Y, Z, tau)*(diff(U(X, Y, Z, tau), Y))+W(X, Y, Z, tau)*(diff(U(X, Y, Z, tau), Z)), tau))/L[delta];
Step 2: (final form I need)
(1+(u[delta] lambda[1])/(L[delta]) (&PartialD;)/(&PartialD;tau)) ((&PartialD;)/(&PartialD;tau) U(X,Y,Z,tau)+U(X,Y,Z,tau) ((&PartialD;)/(&PartialD;X) U(X,Y,Z,tau))+V(X,Y,Z,tau) ((&PartialD;)/(&PartialD;Y) U(X,Y,Z,tau))+W(X,Y,Z,tau) ((&PartialD;)/(&PartialD;Z) U(X,Y,Z,tau)));
I'm waiting for your response.
Special request:
@acer @Carl Love @Kitonum @Preben Alsholm

Hi

I would like to use  the Liebniz notation that someone from the technical support posted here
Writing Derivatives at a Point Using Leibniz Notation
to display a formula that is not just a partial derivative but a more complex expression invoking partial derivatives. 
Typically an expression like this one:

2*(Diff(f(mu__1, mu__2), mu__1))^2*lambda__1^2-(Diff(f(mu__1, mu__2), mu__1))^2*mu__1^2+2*(Diff(f(mu__1, mu__2), mu__2))^2*lambda__2^2-(Diff(f(mu__1, mu__2), mu__2))^2*mu__2^2+2*(Diff(f(mu__1, mu__2), mu__1))*(Diff(f(mu__1, mu__2), mu__2))*lambda__1*lambda__2-2*(Diff(f(mu__1, mu__2), mu__1))*mu__1*(Diff(f(mu__1, mu__2), mu__2))*mu__2

Could anyone help me to do this?
Thanks in advance

(PS: I'm still using Maple 2015.2)

Dear Users!

Hoped everything going fine with you. I want to make animation of ten solutions as given bellow but fail to do that. Please see it fix the problem. I shall be very thankful to u.
SOLNSuy[1, 1] := 2.5872902469406659197*10^(-20)-.65694549571241255901*y+1.9708364871372376767*y^2-1.3138909914248251176*y^3-1.6010739356637904911*10^(-19)*y^4;
SOLNSuy[2, 1] := -4.002204462000*10^(-20)-1.7879176897079605225*y+5.3637530691192141414*y^2-3.5758353794044226250*y^3-6.8309939211286845440*10^(-12)*y^4;
SOLNSuy[3, 1] := -1.1953264450000*10^(-19)-3.2481690589079594122*y+9.7445071767154794599*y^2-6.4963381177952273213*y^3-1.2292726248071398400*10^(-11)*y^4;
SOLNSuy[4, 1] := -2.6720465500000*10^(-19)-4.9239979672954025921*y+14.771993901873204315*y^2-9.8479959345587718955*y^3-1.9029826928878336000*10^(-11)*y^4;
SOLNSuy[5, 1] := 3.416928541000*10^(-20)-6.7268498492441931137*y+20.180549547714413714*y^2-13.453699698443639810*y^3-2.6580790570532587008*10^(-11)*y^4;
SOLNSuy[6, 1] := -2.554122292000*10^(-20)-8.5884528335125514887*y+25.765358500514014457*y^2-17.176905666966875698*y^3-3.4587270427710613504*10^(-11)*y^4;
SOLNSuy[7, 1] := -9.206107680000*10^(-20)-10.456823708331499352*y+31.370471124965259849*y^2-20.913647416590986491*y^3-4.2774005353527132160*10^(-11)*y^4;
SOLNSuy[8, 1] := 1.9644186790000*10^(-19)-12.293003938471349390*y+36.879011815379230436*y^2-24.586007876856948223*y^3-5.0932823222176363520*10^(-11)*y^4;
SOLNSuy[9, 1] := -3.775112769000*10^(-19)-14.068404975282556550*y+42.205214925807397100*y^2-28.136809950465931724*y^3-5.8908824448577377280*10^(-11)*y^4;
SOLNSuy[10, 1] := 1.146281780000*10^(-19)-15.762658869974768890*y+47.287976609878780960*y^2-31.525317739837422477*y^3-6.6589592851037286400*10^(-11)*y^4;
plots[animate](plot, [SOLNSuy[A, 1], y = 0 .. 1], A = 1 .. 10);

Special request:
@acer @Carl Love @Kitonum @Preben Alsholm

Here is a little animation to wish all of you a Merry Christmas

FireWorks.mw


Hi, 

 

In help page DocumentTools:-Layout:-Font, there is an example which shows how to inser a hyperlink in a Layout.

F := Font( "Some text", size=16, color=blue, style=:-Hyperlink ):
InsertContent(Worksheet(Group(Input(Textfield( F ))))):

 

When this id done, how can we activate this hyperlink ?
5I'm presently working with Maple 2015.2 under Mac OS Mojave)

Thanks in advance

 

Hi, 

Moving the sliders clean the plot.
Does any one can show me how to fix this (PS: this piece of code is a part of a procedure whose arguments are RV and SliderRanges and I need this unusual coding to make the procedure generic ... at least I guess so)

Thanks in advance


 

restart:

interface(version);

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

(1)

with(Statistics):

RV   := RandomVariable(Normal(a, b)):
law  := [attributes(RV)][3]:
pars := law:-Parameters;

[a, b]

(2)

SliderRanges := [-5.0..5.0, 1.0..3.0]:
[seq(pars[k]=SliderRanges[k], k=1..numelems(pars))]

[a = -5.0 .. 5.0, b = 1.0 .. 3.0]

(3)

f := PDF(RV, x);
# Explore(plot(f, x=-3..3), parameters=[seq(pars[k]=SliderRanges[k], k=1..numelems(pars))]);

(1/2)*2^(1/2)*exp(-(1/2)*(x-a)^2/b^2)/(Pi^(1/2)*b)

(4)

 


 

Download Explore_Problem.mw

Hi,

Why extracting the features of the events doesn't return the good results when executed within a loop (see the pink test) ?

Thanks in advance.

PS: please, spare me  replies of the type "you can solve this equation formally"

 

restart;

interface(version);

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

(1)

sys := { diff(x(t), t) = 1, x(0) = 0 }:
evs := [ [x(t)-0.1, none],  [x(t)-0.3, none], [x(t)-0.5, none] ]:
sol := dsolve(sys, numeric, events=evs):

plots:-odeplot(sol, [t, x(t)], t=0..0.5, gridlines=true);

 

# times that fired the events

sol(1): # initialization

sol(eventfired=[1]);
sol(eventfired=[2]);
sol(eventfired=[3]);
 

[HFloat(0.1)]

 

[HFloat(0.3)]

 

[HFloat(0.49999999999999994)]

(2)

# Same times computed  within a loop

for i from 1 to 3 do
  te := op(sol(eventfired=[i]));
end do;

HFloat(0.1)

 

HFloat(0.3)

 

HFloat(0.49999999999999994)

(3)

# Values of x(t) computed  within a loop
#
# Why are calues for events 2 and 3 wrong ?
for i from 1 to 3 do
  te := op(sol(eventfired=[i]));
# xe := sol(te);             # this doesn't return the correct result,
# xe := subs(sol(te), x(t)); # this doesn't work neither
  xe := eval(x(t), sol(te)); # this doesn't work neither
end do;

HFloat(0.1)

 

HFloat(0.1)

 

HFloat(0.0)

 

HFloat(0.0)

 

HFloat(0.0)

 

HFloat(0.0)

(4)

 


 

Download Incomprehensible.mw

 

First 10 11 12 13 14 15 16 Last Page 12 of 72