Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

The solve function is able to solve inequalities and return solutions that satisfy the inequalities. Unfortunately, it appears that for some toy problems, this command does not always perform efficiently
 

restart;

eqns__1 := {x >= 0, y >= 0, z >= 0, x*y*z+x^2+y^2+z^2 <= 2*(x*y+x*z+y*z), 2*(x^2+y^2+z^2) < x^2*y+x*z^2+y^2*z-27}

eqns__2 := {x > 0, y > 0, z > 0, x*y*z+x^2+y^2+z^2 <= 2*(x*y+x*z+y*z), 2*(x^2+y^2+z^2) <= x^2*y+x*z^2+y^2*z-27}

timelimit(0.1e2, :-solve(eqns__1, [x, y, z], AllSolutions))

timelimit(0.1e2, :-solve(eqns__2, [x, y, z], AllSolutions))

Error, (in RegularChains:-TRDcadEvalBox) time expired

 

Error, (in RegularChains:-TRDexquo) time expired

 

timelimit(0.1e2, MTM:-solve(eqns__1[], [x, y, z][]))

timelimit(0.1e2, MTM:-solve(eqns__2[], [x, y, z][]))

Warning, solving 5 equations for 3 variables

 

Error, (in sdmp:-mul) time expired

 

Warning, solving 5 equations for 3 variables

 

Error, (in RegularChains:-TRDcadMultiplyInterval) time expired

 

timelimit(0.1e2, RealDomain:-solve(eqns__1, [x, y, z]))

timelimit(0.1e2, RealDomain:-solve(eqns__2, [x, y, z]))

Error, (in RegularChains:-TRDcadIsIntervalNormal) time expired

 

Error, (in RegularChains:-TRDnext_sub_resultant2) time expired

 

timelimit(0.1e2, PDEtools:-Solve(eqns__1, [x, y, z]))

timelimit(0.1e2, PDEtools:-Solve(eqns__2, [x, y, z]))

Error, (in RegularChains:-TRDsub_resultant_chain_monomial_basis) time expired

 

Error, (in modp1/DistDeg) time expired

 

plots['implicitplot3d']([x*y*z+x^2+y^2+z^2 <= 2*(x*y+x*z+y*z), 2*(x^2+y^2+z^2) < x^2*y+x*z^2+y^2*z-27], x = 0 .. 6, y = 0 .. 6, z = 0 .. 6, lightmodel = "light1", orientation = [125, 105, 180], style = "patchnogrid")

 


 

Download x=y=z=3.mw

So none of them is capable of giving a complete description of the region defined by or  with a time limit of "ten seconds". (I believe that completing the evaluation may take a much long time; actually, if there is no constraint on the real time allowed, the symbolic solver will be stuck.) (Note that here it is not hard to find individual instances of values of variables that satisfy them (for example, via the 3-D region boundary plot above), yet they provide less insight into all solutions that exist.)
But in my view,  are too long for these two special systems.

Can Maple solve them more quickly at present? 

> eqns__1 := {x^2+y^2+z^2+x*y*z <= 2*(y*z+z*x+x*y), 2*(x^2+y^2+z^2) < y^2*z+z^2*x+x^2*y-27, x >= 0, y >= 0, z >= 0};
> eqns__2 := {x^2+y^2+z^2+x*y*z <= 2*(y*z+z*x+x*y), 2*(x^2+y^2+z^2) <= y^2*z+z^2*x+x^2*y-27, x > 0, y > 0, z > 0};

(It seems that a potential difficult part for Maple is likely attributable to proving completeness of the solution ….)

Some texts distinguish between unary and binary negation signs, using short dashes for unary negation and a longer dash for binary subtraction. How important is this distinction to users of Maple?

Some earlier versions of Maple used to have short dashes for negation (in some places). Maple 2023 has apparently abandoned the short dash for unary negation, and all such signs are now a long dash.

How about math books? Do all texts make this short-long distinction? The typesetters for my 2001 Advanced Engineering Math book also opted for all long dashes and that book was set from the LaTeX exported from Maple 20+ years ago. But I also have texts in my library that use a short dash for unary negation, on the grounds that -a, the additive inverse of "a" is a complete symbol unto itself, the short dash being part of the symbol for that additive inverse.

Apparently, this issue bugs me. Am I making a tempest in a teapot?

Hi,

I am testing a graph with the annotation option. In example.1, When I hover over the curve of 'f,' the expression appears instead of the name.

Ideas ? thanks

AnnotationDérivées.mw

(While using Maple 2015 this question concerns any other Maple versions)

I hesitated on the title to write and my first idea was to write "How to modify a built-in functions without making a mess?".
I finally changed my mind in order not to orient the answers in a wrong way.

So this question is about the construction of multi-variate distributions and concerns only the Statistics package.
Here are some of the attributes of a univariate random variable that Maple recognizes, and it is quite normal to expect that the construction of a multi-variate random variable (MVRV for short) distribution should get, at least, some of them.

X := RandomVariable(Normal(a, b)):
map(a -> printf("%a\n", a), [exports(attributes(X)[3])]):
Conditions
ParentName
Parameters
CharacteristicFunction
CDF
CGF
HodgesLehmann
Mean
Median
MGF
Mode
PDF
RousseeuwCrouxSn
StandardDeviation
Support
Variance
CDFNumeric
QuantileNumeric
RandomSample
RandomSampleSetup
RandomVariate
MaximumLikelihoodEstimate

If the distribution is continuous the PDF is fundamental in the sense it enables constructs all the other statistics (=attributes) of a MVRV.
But it is nice to use integrated functions, such as Mean, Support, PDF, and so on, to get the expressions or values of these statistics instead of computing them from this PDF.
Let's that I prefer doing this

MyNormal := proc(m, v)
  description "Reparameterized Normal randomvariable, m=mean, v=variance":
  Distribution(
    PDF = (t -> exp(-1/2*(x-m)^2/v)/sqrt(2*Pi*v))
    , Conditions = [Sigma > 0]
    , Mean =m
  )
end proc:

X := RandomVariable(MyNormal(mu, Sigma)):
Mean(X)
                              m

than doing this

MyNormal := proc(m, v)
  description "Reparameterized Normal randomvariable, m=mean, v=variance":
  Distribution(
    PDF = (t -> exp(-1/2*(x-m)^2/v)/sqrt(2*Pi*v))
    , Conditions = [Sigma > 0]
  )
end proc:

X := RandomVariable(MyNormal(mu, Sigma)):
Mean(X);  # of course undefined
mean := int(PDF(X, x), x=-infinity..+infinity) assuming Sigma > 0
                           undefined
                           mean := 1

So, while all the statistics can be recover from the CDF (provided it exists), it's nicer to define these statistics within the Distribution structure (as in the first construction above).

Now some problems appear when you want to construct the Distribution structure for a MVRV.
The attached file contains the construction of MVRV whose ecah components are mutually independent (to keep the things simple) and both have a Unifom distribution.

MV_Uniform.mw

Here are some observations:

  • Defining a multi-variate PDF goes without problems.
  • Defining the Mean (or many other algebraic or numeric statistics) presents a difficulty related to the type of the arguments the build-in function Mean is aimed to recieve.
    But a workaround, not very elegant, can be found.
  • The case of the Support seems unsolvable: I wasn't able to find any workaround to define the support of a MVRV.
  • I did not consider the Conditions attribute, but I'm not sure that, in the case of, let's say, a bi-gaussian random variable I would be capable to set that the variance is a symmetric positive-definite matrix?

I feel like the main restriction to define such MVRV distributions is the types used in the buid-in functions used in the Distribution structure.

Does anyone have an idea to tackle this problem?

  • Are we doomed to use workarounds like the one I used for defining the MVRV mean?
  • Can we modify the calling sequence of some build-in functions without making a mess and keep them working on build-in distributions?
  • Must we overload the construction of these build-in functions?
    Doing for instance:
    restart:
    with(Statistics):
    local Mean:
    Mean := proc(...) ... end proc

Thanks in advance for any suggestion and help.

I’m on a Mac running Ventura 13.4.1 and Maple 2022. 

My plots now have axes and labels that are tiny. It seems like that possibly happened with one of the recent OS updates
Below is a graph of
with(plots): implicitplot3d(3x+2y+4z=2);

It renders the same if I use 
implicitplot3d(3x+2y+4z=2, axesfont=["TimesNewRoman", 12], labelfont = ["TimesNewRoman", 12]);

I can to change the 12 to much larger to see them. But I never used to have to do that before. Does anyone know if this is an OS issue? Is there a global setting I can change? 

So far I have only noticed them for special functions.

For the case of Airy in 2D: Is possible the get for the input Ai(x) the output Ai(x) and not AiryAi(x)?

 For the command LieAlgebras[RootSpaceDecomposition] I don't understand what the command return, I read the help and see the examples but still not understanding.

 

for example it returns:

RSD := RootSpaceDecomposition(CSA);

RSD := table([[-2, -1] = E31, [2, 1] = E13, [1, 2] = E23, [1, -1] = E12, [-1, 1] = E21, [-1, -2] = E32])

I don't understand what means [-2, -1] even they said that is the root but I know that a root is in h* so it must be only a number not a vector.

Hi, please can someone help on how non-dimensionalize PDEs. 

I have tried the following, but is not working:

restart:
eqn := (diff(theta(x, z, t), x))^2*(K[1]-K[3])*cos(theta(x, z, t))*sin(theta(x, z, t))+(diff(theta(x, z, t), x))*((diff(theta(x, z, t), z))*(-K[1]*cos(2*theta(x, z, t))+K[3]*cos(2*theta(x, z, t)))-(1/2)*gamma[1]*(4*sin(theta(x, z, t))^2*u(x, z, t)+2*u(x, z, t)*cos(2*theta(x, z, t))))+(diff(theta(x, z, t), z))^2*(K[3]-K[1])*cos(theta(x, z, t))*sin(theta(x, z, t))-(1/2)*gamma[1]*(diff(theta(x, z, t), z))*(4*sin(theta(x, z, t))^2*v(x, z, t)+2*v(x, z, t)*cos(2*theta(x, z, t)))+(diff(theta(x, z, t), z, x))*(-2*K[1]+2*K[3])*cos(theta(x, z, t))*sin(theta(x, z, t))-(diff(u(x, z, t), z))*((1/2)*gamma[2]*cos(2*theta(x, z, t))+(1/2)*gamma[1]*(2*sin(theta(x, z, t))^2+cos(2*theta(x, z, t))))-(diff(v(x, z, t), x))*((1/2)*gamma[2]*cos(2*theta(x, z, t))+(1/2)*gamma[1]*(-2*sin(theta(x, z, t))^2-cos(2*theta(x, z, t))))-(1/2)*gamma[1]*(4*sin(theta(x, z, t))^2*(diff(theta(x, z, t), t))+2*(diff(theta(x, z, t), t))*cos(2*theta(x, z, t)))+((diff(u(x, z, t), x))*gamma[2]-(diff(v(x, z, t), z))*gamma[2])*cos(theta(x, z, t))*sin(theta(x, z, t))+f[2](theta(x, z, t))*(diff(theta(x, z, t), x, x))+f[1](theta(x, z, t))*(diff(theta(x, z, t), z, z));

varchange := {t = T*tau, u = xi*h^2*U/alpha[4], v = xi*h^2*V/alpha[4], x = X*h, z = Z*h, K[3] = K[1]*k[3], f[1] = K[1]*F[1], f[2] = K[1]*F[2], gamma[1] = mu*Gamma[1], gamma[2] = mu*Gamma[2]};

PDEtools:-dchange(varchange, eqn, [tau, U, V, X, Z, k[3], F[1], F[2], GAMMA[1], GAMMA[2]]);

Sometimes this information is not needed. Example

(Int = int)(1/x, x = a .. 2, 'AllSolutions')

I had a look at help(interface).

Hi,
I want to find (w/k)^2 from the following Eq. by Maple. How do I do it?
(u0b, mu,deltab,sigma and A are fixed parameters)

Eq.mw

Hello community,

Could I please get help on how to invert a probability distribution (reciprocal of) and add the location and scale parameters? The distribution in question is from the built-in (Statistics package) of ChiSquare(n) transformed into a scaled inverse Chi Square with location (shift) parameters.

I have tried the following which results in verified (correct) empirical (sampled) data, but have not been equally successful in the theoretical moments and its quantiles.

 

restart;
st:=time():

with(Statistics):

 

InvChi2:=proc(a,b,n)
        description "inverse chisquare distribution with a=location, b=scale, n=degrees of freedom";


        local CHI := RandomVariable(ChiSquare(n)):
        
        Distribution(
                CDF = unapply(CDF(b*n/CHI+a,t),t),
                PDF = unapply(PDF(b*n/CHI+a,t),t),
                Mean = a+~Mean(b*n/CHI),
                Median = a+~Median(b*n/CHI),
                Variance = simplify(CentralMoment(a+b*n/CHI,2)),
                Skewness = simplify(CentralMoment(b*n/CHI, 3) / CentralMoment(b*n/CHI,2)^(3/2)),
                Kurtosis = simplify(CentralMoment(b*n/CHI, 4) / CentralMoment(b*n/CHI,2)^2),
                Conditions = [b > 0],
                RandomSample = proc(N::nonnegint)
                                a+~Sample(b*n/CHI,N)
                        end proc
                );
        end proc:

 

T:= RandomVariable(InvChi2(2,4.32,3))

 

 

_R0

(1)

evalf(Median(T))

FAIL

(2)

evalf(Mean(T))

14.96000000

(3)

Variance(T)

Float(infinity)

(4)

Skewness(T)

Float(undefined)

(5)

Kurtosis(T)

Float(undefined)

(6)

Quantile(T,.25)

FAIL

(7)

A:=Sample(T,10^5):

Median(A)

HFloat(7.509476657413067)

(8)

Mean(A)

HFloat(14.419072346310452)

(9)

Variance(A)

HFloat(2692.8025716746843)

(10)

Skewness(A)

HFloat(47.59107730088799)

(11)

Quantile(A,.25)

HFloat(5.177452862452726)

(12)

Quantile(A,.75)

HFloat(12.76851658170427)

(13)

printf("Time to execute worksheet = %a seconds", time() - st)

Time to execute worksheet = 2.813 seconds

 

 


Download invChi2.mw

Thank you

How to randomly generate a matrix with the given determinant?

Many thanks!

Hello everyone
I have this equation (3+2*x+3*x2)n=Sum(bi*xi,i=0..2*n)
I want to determine the bi values for any n in N how to do that ?

I thank you in advance.

This isn't particularly complicated. Varying the span generates graphs that are smooth or have an obvious bug. Not sure why.

This also happens if you vary the C_I_CentLim or the C_Inventory. I created this example so it is clearly happening.
The graph gets a sharp jag down, then returns to normal.

Something weird with density of points? I played with it for hours and can't get it to go away.
=============================================
restart;
L := 0;
C_Inventory := 1500;
C_I_CentLim := 0.001;
C_I_StartLim := C_Inventory*C_I_CentLim;
C_InV := Matrix(1000, 3);  # This is so you  can see values created only bobble slightly where the graph has a giant deviation.
iCounter := 0;
P_ScLdt := proc(t) local x, k; global L, C_Inventory, iCounter, C_InV; x := 0; k := 0.08; iCounter := iCounter + 1; L := C_Inventory*C_I_CentLim; x := 4.8 + L/(1 + exp(-k*(t - 2060))) + 0.050; C_InV[iCounter, 1] := L; C_InV[iCounter, 2] := C_Inventory; C_InV[iCounter, 3] := x; if 0 < x then C_Inventory := C_Inventory - x; return x; else return 0; end if; end proc;

# Show results 1800-2100  Problem.
pP_ScLdt := plot('P_ScLdt'(x), x = 1800 .. 2100, linestyle = dash, color = red, thickness = 3, axis = [gridlines = [colour = black, majorlines = 2]], legend = "Pg");

# Re-initialize.
L := 0;
C_Inventory := 1500;
C_I_CentLim := 0.001;
C_I_StartLim := C_Inventory*C_I_CentLim;
C_InV := Matrix(1000, 3);
iCounter := 0;
# Show  that problem happens with a little shorter span
pP_ScLdt := plot('P_ScLdt'(x), x = 1850 .. 2100, linestyle = solid, color = black, thickness = 1, axis = [gridlines = [colour = black, majorlines = 2]], legend = "Pg");

# Re-initialize
L := 0;
C_Inventory := 1500;
C_I_CentLim := 0.001;
C_I_StartLim := C_Inventory*C_I_CentLim;
C_InV := Matrix(1000, 3);
iCounter := 0;
# Show problem goes away with a different interval 1900-2200
pP_ScLdt := plot('P_ScLdt'(x), x = 1900 .. 2200, linestyle = dash, color = blue, thickness = 3, axis = [gridlines = [colour = black, majorlines = 2]], legend = "Pg");

# Re-initialize
L := 0;
C_Inventory := 1500;
C_I_CentLim := 0.001;
C_I_StartLim := C_Inventory*C_I_CentLim;
C_InV := Matrix(1000, 3);
iCounter := 0;
# Enlarge the working interval of 1900-2200 to 1900-2300 and the problem returns, in a different place.
pP_ScLdt := plot('P_ScLdt'(x), x = 1900 .. 2300, linestyle = dash, color = blue, thickness = 3, axis = [gridlines = [colour = black, majorlines = 2]], legend = "Pg");


# Re-initialize
L := 0;
C_Inventory := 2000;
C_I_CentLim := 0.001;
C_I_StartLim := C_Inventory*C_I_CentLim;
C_InV := Matrix(1000, 3);
iCounter := 0;

# Enlarge the interval and it causes a larger set of jaggie deviations.
pP_ScLdt := plot('P_ScLdt'(x), x = 1800 .. 2800, linestyle = solid, color = blue, thickness = 1, axis = [gridlines = [colour = black, majorlines = 2]], legend = "Pg");

k                  

∏(2ⁿ-1)

n=1               

First 187 188 189 190 191 192 193 Last Page 189 of 2217