Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

How to use collect() or coeffs() on random variables instead of standard variables?

I need to re-organize a linear combination of RVs nu[1], nu[2], u[1], u[2], u[3] by collecting the coefficients on each of these 5 RVs. Note that the Xs are correlated with each other and the Ys are correlated with each other (but Xs and Ys are uncorrelated).

For example, nu is a 2D gaussian vector where nu[1] and nu[2] are defined in terms of _R1, _R2, means, standard deviations and correlation coefficient. They are quite "nested" and the 3D gaussian vector u is even worse, so when these enter a linear combination it becomes hard to identify them back as simply nu[1], nu[2], u[1], u[2], u[3].

Is there a way to "isolate" them in a linear combination by using collect()-like or coeffs()-like functions (i) directly on the RVs or (ii) indireclty on the explicit expressions of _Rs, means, standard devs, correlation coeffs? 

(I already checked the answers to these two somewhat similar questions but did not help for my case:

https://mapleprimes.com/questions/235215-Reduce-Length-Of-Sum-Of-Products

https://mapleprimes.com/questions/234292-Re-How-To-Collect-Using-A-Term-By-Multiplication

)

See my script below: 

For example, I would want collect() on nu[1] (or equivalently on _R1*sigma__v[1]+nu__0[1]) to give me X__1+X__3 (as you easily see from my definition of Omega).

# 2.2.1 Define the Omega random variable as Omega__1+Omega__2+Omega__3:

`Ω__1` := X__1*(nu[1]-`μ__1`-`λ__1`*(u[1]+X__1)); `Ω__2` := X__2*(nu[2]-`μ__2`-`λ__2`*(u[2]+X__2)); `Ω__3` := X__3*(nu[1]+nu[2]-`μ__3`-`λ__3`*(u[3]+X__3)); Omega := `Ω__1`+`Ω__2`+`Ω__3`

X__1*(sigma__v[1]*_R1+nu__0[1]-mu__1-lambda__1*(_R3*sigma__u[1]+X__1))+X__2*(sigma__v[2]*rho__v[1, 2]*_R1+(-rho__v[1, 2]^2+1)^(1/2)*sigma__v[2]*_R2+nu__0[2]-mu__2-lambda__2*(rho__u[1, 2]*sigma__u[2]*_R3+(-rho__u[1, 2]^2+1)^(1/2)*sigma__u[2]*_R4+X__2))+X__3*(sigma__v[1]*_R1+nu__0[1]+sigma__v[2]*rho__v[1, 2]*_R1+(-rho__v[1, 2]^2+1)^(1/2)*sigma__v[2]*_R2+nu__0[2]-mu__3-lambda__3*(rho__u[1, 3]*sigma__u[3]*_R3-sigma__u[3]*(rho__u[1, 2]*rho__u[1, 3]-rho__u[2, 3])*_R4/(-rho__u[1, 2]^2+1)^(1/2)+((-2*rho__u[1, 2]*rho__u[1, 3]*rho__u[2, 3]+rho__u[1, 2]^2+rho__u[1, 3]^2+rho__u[2, 3]^2-1)/(rho__u[1, 2]^2-1))^(1/2)*sigma__u[3]*_R5+X__3))

(1)

# 2.2.2 Simplify and re-arrange the Omega RV to obtain the easy-to-read version (a,b,c,d,e,f are the coefficients):
#Omega__* = a + b*nu[1] + c*nu[2] + d*u[1] + e*u[2] + f*u[3];
# How to do it? Collect() does not work...simplify() doesn't make it any easier...

`Ω__*` := collect(Omega, [_R1*`σ__v`[1]+`ν__0`[1], `σ__v`[2]*`ρ__v`[1, 2]*_R1+sqrt(-`ρ__v`[1, 2]^2+1)*`σ__v`[2]*_R2+`ν__0`[2], `σ__u`[1]*_R3, `σ__u`[2]*`ρ__u`[1, 2]*_R3+sqrt(-`ρ__u`[1, 2]^2+1)*`σ__u`[2]*_R4, `σ__u`[3]*`ρ__u`[1, 3]*_R3-`σ__u`[3]*(`ρ__u`[1, 2]*`ρ__u`[1, 3]-`ρ__u`[2, 3])*_R4/sqrt(-`ρ__u`[1, 2]^2+1)+sqrt((-2*`ρ__u`[1, 2]*`ρ__u`[1, 3]*`ρ__u`[2, 3]+`ρ__u`[1, 2]^2+`ρ__u`[1, 3]^2+`ρ__u`[2, 3]^2-1)/(`ρ__u`[1, 2]^2-1))*`σ__u`[3]*_R5])

Error, (in collect) cannot collect _R1*sigma__v[1]+nu__0[1]

 

`Ω__col` := collect(Omega, [nu[1], nu[2], u[1], u[2], u[3]])

Error, (in collect) cannot collect _R1*sigma__v[1]+nu__0[1]

 

 

Download collect.mw

Is there a mathematical reason why Maple does not allow expansion point for solving an ode using series solution to be different than where initial conditions are located?

I do not see why this restriction is there. Here is first order ode, where expansion point is x=1 and initial condiitons are also at x=1

restart;
ode:=diff(y(x),x)=x^3;
dsolve([ode,y(1)=1],y(x),'series',x=1)

            y(x) = (1 + (x - 1)) + 3/2*(x - 1)^2 + (x - 1)^3 + 1/4*(x - 1)^4 + O((x - 1)^6)

No problem. But when expansion point at x=0, it complains

restart;
ode:=diff(y(x),x)=x^3;
dsolve([ode,y(1)=1],y(x),'series',x=0)

Error, (in dsolve/SERIES) conflicting specifications of the series expansion point: 1 v.s. 0

I know help mentions that it uses initial conditions point for expansion if given, and if no IC is given, then it uses x=point if given and if no x=point is given then it default to x=0.

But my question is, why it does not handle the case when the expansion point is given explicitly and is at a different location than where IC are given? Is this simply just a feature missing that could be added in a future release if needed, or is it due to some mathematical reason that I do not see?

I would have expected it to first find the series solution around the given expansion point, then use the IC to determine the unknown constant after that, just like we normally do when solving an ode using standard methods not using series expansion.

I am using Maple 2023

S := t -> tanh(ln(1 + t^2))

diff(S(t), t $ n)=1/GAMMA(1-n)-1/4*pochhammer(-n,n)*Sum(_alpha^3*(t-_alpha)^(-1-n),_alpha =RootOf(_Z^4+2*_Z^2+2))

why the root of? its easy to see the roots are given by

solve(_Z^4 + 2*_Z^2 + 2 = 0);

(-1-I)^(1/2), -(-1-I)^(1/2), (-1+I)^(1/2), -(-1+I)^(1/2)

its equivalent to the roots of (z^2 + 1)^2 + 1

it seems very weird that maple stops here rather than turning it into a 4-element array

I read the article "ONEOptimal: A Maple Package for Generating One-Dimensional Optimal System of Finite Dimensional Lie Algebra", and also searched out in Maplesoft website, but couldn't found. Does anyone have the package?

I am trying to see if there is a way to submit maple code as a worksheet and get results back as worksheets in a cluster. 

The following 2D integrals of 0 are seemingly trivial and one would expect them to evaluate to zero, but Maple evaluates them to undefined

int(0, x=0..infinity, y=0..1) # undefined
int(0, x=0..1, y=0..infinity) # undefined

When the 2D integral is split into two 1D integrals, it does evaluate to zero, as the following examples show

int(0,x=0..infinity) # 0
int(int(0,x=0..infinity), y=0..1) # 0
int(int(0,x=0..1),y=0..infinity) # 0

If infinity is replaced by a variable (say 'c'), the first two integrals are also evaluated to zero.

It may be connected by the following

int(a, x=0..infinity, y=0..1) # a*infinity
int(a, x=0..1, y=0..infinity) # a*infinity
int(a,x=0..infinity) # signum(a)*infinity

So for the 1D integrals the signum is applied to 'a' when the interval is infinite, but not for the 2D integrals. I'm not sure about this difference.

if i solved two integral seperately..it solved.. but i can't solve together..what's wrong...please help

restart

"al_eq:=`D__11`*(∫)[0]^(a)((ⅆ)^2)/((ⅆ)^( )x^2) A*((ⅆ)^2)/((ⅆ)^( )x^2) A ⅆx (∫)[0]^(b)B*B ⅆy;"

Error, invalid product/quotient

"al_eq:=`D__11`*(∫)[0]^a((ⅆ)^2)/((ⅆx)^2) A*((ⅆ)^2)/((ⅆx)^2) A ⅆx (∫)[0]^bB*B ⅆy;"

 

``

B^2*b

(1)

``

Download 2.mw

i want to sovle this problem ..but i dont' know how to start..please help me.how to solve this eqution?

how to solve for lamda and r in this equtaions...please help

restart

with(LinearAlgebra):

solve(cos(lambda[i])*cosh(lambda[i]) = 1);

Warning, solutions may have been lost

 

0

(1)

evalf(%);

0.

(2)

lambda[i];

lambda[i]

(3)

r[i] := (cos(lambda[i])-cosh(lambda[i]))/(sin(lambda[i])-sinh(lambda[i]));

(cos(lambda[i])-cosh(lambda[i]))/(sin(lambda[i])-sinh(lambda[i]))

(4)

``

Download 1.mw

Is it possible to read in specific parts of a bmp image? 

TODAY I GOT AN INSPIRATION TO CREATE 3D GRAPH EQUATION OF WALKING ROBOT (ED-209) IN CARTESIAN SPACE USING ONLY WITH SINGLE IMPLICIT EQUATION.

ENJOY...

 

How to Create Graph Equation of Wankel Engine on Cartesian Plane using Single Implicit Function run by Maple Software

Enjoy...

 

what is the homology matrix that plates the ABCE square on the NPCM square
I think it may bi find out with the rotation angle, the vector of translation and the homothety ratio.
restart;  
with(geometry):  
with(plots):  
_EnvHorizontalName = 'x':  _EnvVerticalName = 'y':

point(A, 0, 1):
point(B, 1, 1):
point(C, 1, 0):
point(E, 0, 0):
square(Sq, [A, B, C, E]):
Phi := (1 + sqrt(5))/2:
point(N, (2 - Phi)/(Phi - 1), 1):
line(BE, [B, E]):
MakeSquare(s1, [N, C, 'diagonal']):
point(M, (3 - sqrt(5))/(2*sqrt(5) - 2), (3 - sqrt(5))/(2*sqrt(5) - 2)):
point(P, (1 + sqrt(5))/(2*sqrt(5) - 2), (3*sqrt(5) - 5)/(2*sqrt(5) - 2)):
T:=<simplify(coordinates(midpoint(O1,E,B))-coordinates(midpoint(O2,M,P)))>:
simplify(distance(O1,O2)):
line(MN,[M,N]):eq:=Equation(%,[x,y]):sol:=solve(eq,y):
Ang:=Pi/2-arctan(diff(sol,x)):
r:=simplify(distance(N,M)):
line(MP,[M,P]):eq:=Equation(%,[x,y]):subs(y=0,%):point(Q,solve(%,x),0):
line(PQ,[P,Q]):
homology(Sq1, Sq, C, Ang, 'clockwise', r):


display(draw([A(color = black, symbol = solidcircle, symbolsize = 12), 
B(color = black, symbol = solidcircle, symbolsize = 12), 
C(color = black, symbol = solidcircle, symbolsize = 12), 
E(color = black, symbol = solidcircle, symbolsize = 12), 
N(color = black, symbol = solidcircle, symbolsize = 12), 
Sq(color = red, filled = true, transparency = 0.9), 
BE(color = green), 
PQ(color = black),
 Sq1(color = black), 
s1(color = red, filled = true, transparency = 0.8)]), 
textplot([[coordinates(A)[], "A"], 
[coordinates(B)[], "B"], 
[coordinates(E)[], "E"], 
[coordinates(N)[], "N"], 
[coordinates(P)[], "P"], 
[coordinates(M)[], "M"], 
[coordinates(Q)[], "Q"], 
[coordinates(C)[], "C"]], 
align = [above, right]), view = [-0.6 .. 1.5, 0 .. 1], axes = none);
 

Given a constant gamma, gaussian random variables S[1] and S[2], and a linear combination of gaussian random variables Omega, I need to compute Exp[ Omega | S[1], S[2] ] - (gamma/2)*Var[ Omega | S[1], S[2] ]. I am not experienced in Maple. In the attached script I include many step-by-step details on what I need to do, as well as some notes where I get stuck:

150423_OptimizationProblem.mw

It would be convenient if you could directly fix this and share the working version. Thanks!

The conditional means and variance terms are calculated according to the 2D version of the script 3_gaussian_mmcdara.mw provided by @mmcdara.

Here is a string, and I want to treat consecutive single digits as a single number and extract them. I can process it using regular expressions in Python. I'm not sure if Maple can handle it in a similar way.

import re
sstr1 = "124e34e243e45e56e76f34e45e23ea12e98e34e43"
num=re.findall(r'\d+', sstr1)
s=list(map(int, num))
print(s)

[124, 34, 243, 45, 56, 76, 34, 45, 23, 12, 98, 34, 43]

Is there an equivalent regular expression method in Maple?

As usual, I have a tricky question. There is an integral that Maple can take numerically

R0 := 1/(a-sqrt(b+c*cos(x)));

Now let's put the coefficients, e.g.

 a := 0.9; b := 4.5; c :=0.1

and take the integral from 0 to 2*Pi

R1 := evalf(int(R0, x = 0 .. 2*Pi));

Also, there is an exact analytical result that Maple gives (I give it after simplifying it to avoid division by zero for the limit x=0 and x=2*Pi)

R2:=-4*((a^2-b+c)*EllipticK(sqrt(-2*c/(b-c)))-a^2*EllipticPi(2*c/(a^2-b+c), sqrt(-2*c/(b-c))))/((a^2-b+c)*sqrt(b-c));

As it turns out, the results are completely different. In the first case -5.145818656, while for the second case -3.612771378+0.I

Moreover, If we change the coefficients to a := 0.9; b := 4.5; c := -4 then I obtain Float(undefined)+3.662506136*I and -2.362349457+3.662506117*I , respectively.

My question: how to avoid this descepancy?

First 208 209 210 211 212 213 214 Last Page 210 of 2218