Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Dear all

My code give me the following error 
Error, (in SOR) invalid left hand side in assignment
I don't understand its origin.

coore_invalid.mw

Thank you

I'm working on finding the analytic expression of the PDF of a sum of abstract Uniform Random Variables URV).
Here "abstract" means that the supports are not numeric but litteral.

Maple is capable to find such a PDF for numeric supports but unable to determine the PDF of U1+U2 where 

U1 := RandomVariable(Uniform(a1, b1)):
U2 := RandomVariable(Uniform(a2, b2)):

A way to deal with abstract URV is to complute explicitely the convolution product of th PDFs.
Ir seems that this fails (MAPLE 2015.2) for these PDF are piecewise functions.
A workaround is to convert them first into Heaviside(s).

One done the explicit expression of the convolution product can be obtained for a sum of 2 abstract URVs, but not for a sum of a larger number of abstract URVs.

Thus the second workaround which consists in using direct and inverse Fourier transform.

The question is :
obviously, the PDF f(t ; a1...aN, b1...bN) of  U1 + ... + UN is a continuous function of t: why does discont(f(t ; ...), t) returns the non empty set of the values where the Heaviside functions are undefined ?

Here is a very simple result

u1 := RandomVariable(Uniform(-1, 1)): 
u2 := RandomVariable(Uniform(-1, 1)):
p := PDF(u1+u2, t):
discont(p, t);

print("-------------------------------------");

f1 := convert(PDF(u1, t), Heaviside):
f2 := convert(PDF(u2, t), Heaviside):
g1 := fourier(f1, t, xi):
g2 := fourier(f2, t, xi):
g  := g1*g2:
f  := invfourier(g, xi, t):
discont(f, t);

                               {}
            "-------------------------------------"
                           {-2, 0, 2}

The problem is (IMO) that discont(f, t) should return { }, but that some function (does it exists) should say that d is undefined at points t=-2, t=0, t=2.
The output of discont(f, t) doesn't seem consistent with the definition of the continuity

limit(f, t=-2, left);
limit(f, t=-2, right);
eval(f, t=-2)
                               0
                               0
                           undefined

restart:

with(inttrans);
with(Statistics):

[addtable, fourier, fouriercos, fouriersin, hankel, hilbert, invfourier, invhilbert, invlaplace, invmellin, laplace, mellin, savetable]

(1)

N := 3:
for n from 1 to N do
  U||n := RandomVariable(Uniform(a__||n, b__||n)):
end do;

_R

 

_R0

 

_R1

(2)

# Maple fails to compute the PDF of a sum of abstract (meaning with symbolic support) uniform RVS
# PDF(U1+U2, t)

# For N <=3 the computation of the convolution product is possible.
#
# For N > 4 (Maple 2015) it seems this is no longer the case. The trick used here is based on
# the fact that Fourier(Conv(f, g)) : Fourier(f)*Fourier(g)
# Thus PDF(U1+U2) = conv(PDF(U1), PDF(U2)) = invFourier(Fourier(PDF(U1)).Fourier(PDF(U1)))


for n from 1 to N do
  f||n := convert(PDF(U||n, t), Heaviside):
end do:

for n from 1 to N do
  g||n := fourier(f||n, t, xi):
end do:
g := mul(g||n, n=1..N):

hyp := seq(b__||n > a__||n, n=1..N);
f   := invfourier(g, xi, t) assuming hyp;

a__1 < b__1, a__2 < b__2, a__3 < b__3

 

((1/2)*(t-a__1-a__2-a__3)^2*Heaviside(-t+a__1+a__2+a__3)-(1/2)*(t-a__1-a__2-b__3)^2*Heaviside(-t+a__1+a__2+b__3)-(1/2)*(t-a__1-a__3-b__2)^2*Heaviside(-t+a__1+a__3+b__2)+(1/2)*(t-a__1-b__2-b__3)^2*Heaviside(-t+a__1+b__2+b__3)-(1/2)*(t-a__2-a__3-b__1)^2*Heaviside(-t+a__2+a__3+b__1)+(1/2)*(t-a__2-b__1-b__3)^2*Heaviside(-t+a__2+b__1+b__3)+(1/2)*(t-b__1-a__3-b__2)^2*Heaviside(-t+b__1+a__3+b__2)-(1/2)*(t-b__1-b__2-b__3)^2*Heaviside(-t+b__1+b__2+b__3))/((-b__1+a__1)*(-b__2+a__2)*(-b__3+a__3))

(3)

# f is obviously a continuous function of t, but I get this strange result

discont(f, t);

{a__1+a__2+a__3, a__1+a__2+b__3, a__1+a__3+b__2, a__1+b__2+b__3, a__2+a__3+b__1, a__2+b__1+b__3, b__1+a__3+b__2, b__1+b__2+b__3}

(4)

# note that this "error" also appears if the a__n's and b__n's are numeric

r := rand(0. .. 1.):
P := convert(indets(g, name) minus{xi}, list):
E := NULL:
for n from 1 to N do
  a := r():
  b := a + r():
  E := E, a__||n = a, b__||n = b
end do:
E := [E];

G := eval(g, E):
f := invfourier(G, xi, t);
discont(f, t);

[a__1 = .3055679837, b__1 = .7906643786, a__2 = .8311025583, b__2 = .9857257095, a__3 = .4223879539, b__3 = .7034757826]

 

0.1333206533e-8*(-0.1000000000e11*t+0.1136670542e11)*Heaviside(-t+1.136670542)+0.1333206533e-8*(0.1000000000e11*t-0.1291293693e11)*Heaviside(-t+1.291293693)+0.1333206533e-8*(0.1000000000e11*t-0.1621766937e11)*Heaviside(-t+1.621766937)+0.1333206533e-8*(-0.1000000000e11*t+0.1776390088e11)*Heaviside(-t+1.776390088)

 

{1.136670542, 1.291293693, 1.621766937, 1.776390088}

(5)

u1 := RandomVariable(Uniform(-1, 1)):
u2 := RandomVariable(Uniform(-1, 1)):
p := PDF(u1+u2, t):
discont(p, t);

print("-------------------------------------");

f1 := convert(PDF(u1, t), Heaviside):
f2 := convert(PDF(u2, t), Heaviside):
g1 := fourier(f1, t, xi):
g2 := fourier(f2, t, xi):
g  := g1*g2:
f  := invfourier(g, xi, t):
discont(f, t);
 

{}

 

"-------------------------------------"

 

{-2, 0, 2}

(6)

limit(f, t=-2, left);
limit(f, t=-2, right);
eval(f, t=-2);

print("-------------------------------------");

limit(f, t=0, left);
limit(f, t=0, right);
eval(f, t=0)

0

 

0

 

undefined

 

"-------------------------------------"

 

1/2

 

1/2

 

undefined

(7)

 

Download Sum_of_Uniform_RVs.mw

Please show me how to enter "positive infinity" value in the dialog box of "Maple Tutors". Thanks!i

Hi.  I am using the linux version of Maple.  I seem to experience more bombs in Maple/Linux vs MathCad/Windows.  The program just froze as I was entering text.  Just text.  It is not a disaster since I make very frequent saves.  But it is very annoying.  I was a heavy user of MathCad from about 2005 to 2019.  In the early days, it bombed a lot.  But I do not recall that it ever bombed when I was entering text.  Any suggestions?  Would there be a limition on the number of text characters?  Is it Linux?  Other than this problem, it is a great program.

I made an error by trying to multiply two nonconformable matrices. I think, I should receive an error message. But in this example this did not occur.

Strange.mw

restart; with(LinearAlgebra); alias(`&bigotimes;` = LinearAlgebra:-KroneckerProduct); interface(rtablesize = 16); kernelopts(version); interface(version)

`&bigotimes;`

[10, 10]

`Maple 2021.2, X86 64 LINUX, Nov 23 2021, Build ID 1576349`

`Standard Worksheet Interface, Maple 2021.2, Linux, November 23 2021 Build ID 1576349`

Matrices nonconformable, Maple should give error message:

`&bigotimes;`(Matrix(1, 4, 1), IdentityMatrix(4)); Dimension(%); M := Matrix(4, 4, shape = symmetric, symbol = m); Dimension(%)

Matrix([[1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]])

4, 16

M := Matrix(4, 4, {(1, 1) = m[1, 1], (1, 2) = m[1, 2], (1, 3) = m[1, 3], (1, 4) = m[1, 4], (2, 2) = m[2, 2], (2, 3) = m[2, 3], (2, 4) = m[2, 4], (3, 3) = m[3, 3], (3, 4) = m[3, 4], (4, 4) = m[4, 4]}, storage = triangular[upper], shape = [symmetric])

4, 4

MatrixMatrixMultiply(`&bigotimes;`(Matrix(1, 4, 1), IdentityMatrix(4)), DiagonalMatrix(Diagonal(M)))

Matrix([[m[1, 1], 0, 0, 0], [0, m[2, 2], 0, 0], [0, 0, m[3, 3], 0], [0, 0, 0, m[4, 4]]])

`&bigotimes;`(Matrix(1, 4, 1), IdentityMatrix(4)).DiagonalMatrix(Diagonal(M))

Matrix([[m[1, 1], 0, 0, 0], [0, m[2, 2], 0, 0], [0, 0, m[3, 3], 0], [0, 0, 0, m[4, 4]]])

KroneckerProduct(Matrix(1, 4, 1), IdentityMatrix(4)).DiagonalMatrix(Diagonal(M))

Matrix([[m[1, 1], 0, 0, 0], [0, m[2, 2], 0, 0], [0, 0, m[3, 3], 0], [0, 0, 0, m[4, 4]]])

(Matrix(4, 16, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 1, (1, 6) = 0, (1, 7) = 0, (1, 8) = 0, (1, 9) = 1, (1, 10) = 0, (1, 11) = 0, (1, 12) = 0, (1, 13) = 1, (1, 14) = 0, (1, 15) = 0, (1, 16) = 0, (2, 1) = 0, (2, 2) = 1, (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (2, 6) = 1, (2, 7) = 0, (2, 8) = 0, (2, 9) = 0, (2, 10) = 1, (2, 11) = 0, (2, 12) = 0, (2, 13) = 0, (2, 14) = 1, (2, 15) = 0, (2, 16) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1, (3, 4) = 0, (3, 5) = 0, (3, 6) = 0, (3, 7) = 1, (3, 8) = 0, (3, 9) = 0, (3, 10) = 0, (3, 11) = 1, (3, 12) = 0, (3, 13) = 0, (3, 14) = 0, (3, 15) = 1, (3, 16) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 1, (4, 5) = 0, (4, 6) = 0, (4, 7) = 0, (4, 8) = 1, (4, 9) = 0, (4, 10) = 0, (4, 11) = 0, (4, 12) = 1, (4, 13) = 0, (4, 14) = 0, (4, 15) = 0, (4, 16) = 1})).DiagonalMatrix(Diagonal(M))

Matrix([[m[1, 1], 0, 0, 0], [0, m[2, 2], 0, 0], [0, 0, m[3, 3], 0], [0, 0, 0, m[4, 4]]])

`&bigotimes;`(Matrix(1, 4, 1), IdentityMatrix(4)).Matrix(4, 4, shape = diagonal, symbol = m)

Matrix([[m[1, 1], 0, 0, 0], [0, m[2, 2], 0, 0], [0, 0, m[3, 3], 0], [0, 0, 0, m[4, 4]]])

whattype(`&bigotimes;`(Matrix(1, 4, 1), IdentityMatrix(4))); Dimension(`&bigotimes;`(Matrix(1, 4, 1), IdentityMatrix(4)))

Matrix

4, 16

whattype(DiagonalMatrix(Diagonal(M))); Dimension(M)

Matrix

4, 4

hereafter results are correct: Matrices

nonconformable, therefore error messages appear.

`&bigotimes;`(Matrix(1, 4, 1), IdentityMatrix(4)).M

Error, (in LinearAlgebra:-Multiply) first matrix column dimension (16) <> second matrix row dimension (4)

`&bigotimes;`(Matrix(1, 4, 1), IdentityMatrix(4)).Matrix(4, 4, shape = symmetric, symbol = m)

Error, (in LinearAlgebra:-Multiply) first matrix column dimension (16) <> second matrix row dimension (4)

Download Strange.mw

Hi! This is probably simple, but
I would like to know if there's an specific algorithm to do this:

let B = {x[i], i=1..n} in such a way that:

f( B ) = Sum(a[i]*b[i], i=1..N); a_i in R; b_i in B; N>n.

so Linearcomb: f->V(R).

Linearcomb( f ) =

 (Sum(a[j],j in J))*x[1]+(Sum(a[k],k in K))*x[2] + ... +(Sum(a[z],z in Z))*x[n].

with V(R) a vector space; R the Real numbers, and B the base. Neither the "factorize", nor the "simplify" are proving useful to this. Is there something i'm missng?

Please answer the commented questions in the uploaded worksheet.

Binary_search.mw

Hi everyone 

I have a problem with an animation that I dont know how to solve. 

Let's say I have three sets of coordinates. (one static and two moving dependet on time)

1:= [x1;z1]

2:= [x2(t);z2(t)]

3:= [x3(t);z3(t)]

Now I want out of these 3 points two lines that are connected  with each other like this:

line 1:= 1 and 2

line 2:= 2 and 3

These lines should move over time in the 2d space. The only point that doesnt move is point 1. In the animation there should only be the 2 lines visible for each frame. (not a trace or something like this) 

does anyone have an idea how I solve this?

Hi

I'm trying to automate this production of doubles combinations with a set scoreline in between. The minimum is 4 players, but we could have many more players, producing many combinations. 

example: 4 players, set score 2-0 for each match

with(combinat):
DBL:=choose([Novice,Weak_Intermediate,Strong_Intermediate,Advanced], 2);
DBL[1],2,DBL[6],0;DBL[2],2,DBL[5],0;DBL[3],2,DBL[4],0

#and the reverse
DBL[6],2,DBL[1],0;DBL[5],2,DBL[2],0;DBL[4],2,DBL[3],0
 

#the output contains square brackets. How do I remove them?

I have an Array A which I wanted to convert to Matrix. Doing B:=convert(A,Matrix); displays different on the screen than if A is first converted to list, then the list is next converted to Matrix.

Also the dimension in the first case if not the same as the dimension of the matrix done using the list conversion first. I expected both to give same dimension which is 10 by 3 in this example.

Should not both be the same? Does this to convert an Array to Matrix, one first needs to convert it to list, then convert the list to Matrix?

ps. thinking more about this, I think this seems to work as designed. I just expected convert to Matrix to generate the standard 2 dimensional matrix  10 by 3 automatically from the Array, but I see now that it probably does need that extra conversion to a list first.

 


 

interface(version);

`Standard Worksheet Interface, Maple 2022.1, Windows 10, May 26 2022 Build ID 1619613`

restart;

A:=Array(1..0);
for i from 1 to 10 do
   A ,= [i, i+1, i+2]
od:
B:=convert(A,Matrix);
whattype(B);
LinearAlgebra:-Dimension(B);

A := Vector[row](0, {})

Matrix(%id = 36893490060059048044)

Matrix

1, 10

restart;
A:=Array(1..0);
for i from 1 to 10 do
   A ,= [10-i, i+1, i+2]
od:
B:=convert(A,list);
B:=convert(B,Matrix);
whattype(B);
LinearAlgebra:-Dimension(B);

A := Vector[row](0, {})

B := [[9, 2, 3], [8, 3, 4], [7, 4, 5], [6, 5, 6], [5, 6, 7], [4, 7, 8], [3, 8, 9], [2, 9, 10], [1, 10, 11], [0, 11, 12]]

Matrix(%id = 36893490060058557844)

Matrix

10, 3

 

 


 

Download oct_25_2022.mw

Hi everyone 

I solve several differential equations using dsolve. Now I want to change one initial condition a little bit: 

before: u0n := u0*ms/(ms + mn)

new: u0n := u0*ms/(ms + m(t)

When solving the new system I am getting the error message: Error, (in dsolve/numeric/process_input) unknown piecewise(0 < 16-(xn(t)^2+(zn(t)-16)^2)^(1/2), 16-(xn(t)^2+(zn(t)-16)^2)^(1/2), 0) present in ODE system is not a specified dependent variable or evaluatable procedure

I am guessing this has to do with a function in an initial condition. 

Has anyone an idea how to solve this problem?

I added the maple file for the whole overview.

Thanks in advance!

Fractional part of a negative number is always positive. But maple command frac(-7.8) gives -0.8 instead of 0.2. Why is this? Though we can find it by using 1-frac(x), maple command may be there to give fractional part for all real numbers as per definition.

Like frac(9.8)=0.8 and frac(-9.8)=0.2.

Is there a command in maple?

Thanks. Ramakrishnan V

Dear all

I have the following code, that solves a linear system 
But I get the error 

Error, (in rtable/Sum) invalid arguments

code.mw

Thank you for any help 

Good day everyone,

I am trying to rotate the plots of pde solution using transplot, but it is giving me errors. Anyone with better suggestions should help. The code is attached below. Thanks

Transplot_not_working.mw

First 146 147 148 149 150 151 152 Last Page 148 of 2097