MaplePrimes Questions

The following differential equation:

sy := (dsolve({T*diff(y(x), x, x) + rho*omega^2*y(x) = 0, y(0) = 0, y(L) = 0}, y(x)) assuming (0 < T, 0 < omega, 0 < rho))

                                                                 sy:=y(x)=0

Maple only returns the trivial solution. Should return other expressions:
Thank you

Hello,

My question is mathematical in nature, so it might be a little out of place but I though I would give it a shot. 

You have a series of chebyshev coefficients in two connecting subdomains lets say S1 = [0,0.5] and S2=[0.5,1]. So far you are still in the spectral space. If you want to compute the solution in real space you can sum the coefficients with the Chebyshev polynomials. 

Now imagine you change the interval to S1 = [0,0.6] and S2 = [0.6,1]. Is there a way to manipulate the Chebyshev coefficients from both initial subdomains to create a new set of Chebyshev coefficients that fit the solution in the new subdomains. 

The brute force method would be to create the real solution of Chebyshev polynomials and then use that to form a new set of Chebyshev coefficients. Or you can use Clenshaw to compute the solution at several points, and then use the points to create new Chebyshev coefficients.

But what if we can stay in spectral space and create the new chebyshev coefficients. Is that possible? If so, how?

step := t −> piecewise(t sum( (−1)∧n * step(t−n) , n=0..50);

Consider the following forced D.E. L d 2x dt2 + R dx dt + 1 C x = 200 ∗ f(t/3)

where R = 20 , C = 0.01 , L = 10 , x(0) = 10 , x 0 (0) = 0.

a. Graph the solution curve in the phase plane on Maple.

b. Graph x(t) over the interval 0 ≤ t ≤ 25 on Maple .

 

 

For the DE solution below, Maple returns only one option. I can't get the others. Can anyone help?

wW := unapply(piecewise(0 <= x and x < L/2, 0, L/2 <= x and x <= L, w[0]), x):

eq := k*diff(y(x), x$4) = wW(x):

dsolve({eq, y(0) = 0, y'(0) = 0, y''(L) = 0, y'''(L)=0}, y(x)) assuming 0 < L

          y(x) = -L*w[0]*x^3/(6*k) + L^2*w[0]*x^2/(4*k) + w[0]*x^4/(24*k)

Obrigado.
Oliveira

Hello interested parties!

I wish to measure the distance between points in the Cartesian plane and then export the results to Excel using a data frame routine. For the sake of example: suppose there are 2 points, A and B and 6 more points, a,b,c,d,e and f whose coordinates are known.

I am interested in measuring the distance from A to a, b, c, d, e, f and from B to a, b, c, d, e, f. So, a matrix is constructed (see attached) giving the linear separation between eack of the 8 points ... and that's ok. 

However, instead of six points of interest, suppose that the number of points becomes very large (e.g. 1,000) and I still need to export to Excel.

Does anyone know of an efficient routine that produces a rectangular matrix to produce a 2 x 6 data frame so that, in the case of large-scale problems the data frame is not overburdened?

Thanks for reading and thanks in advance for any suggestions.

Mapleprimes_Matrix.mw

given an expression such as expr:=-1/2*x*(y^2-1) which in tree form will be

I can get -1/2 using op(1,expr).   I need command to return the "rest" of the right side of the tree, all of it, not matter how big.

I tried op(2..nops(expr),expr) and that returns x, y^2 - 1 

Is there a way to return directly x*(y^2-1)*etc....  so I do not have to play around with the above expression sequence?  Another option is to type

           expr/op(1,expr)

to get the right side of the tree. But this seems like a hack. Do not like to divide. worry about zero.

The same thing if the type was `+`, I want to get  the whole right side in one command.

Again, I can do  expr-op(1,expr) to get the whole right side. But this also seems like  a hack, altought not as bad as with  the case above

Any hints on how to best do these things?

Maple 2019.1

 

 

 

Hello,

I am trying to define a statespace object. Here my code reads:

with(DynamicSystems):

 

aSys≔StateSpace(⟨⟨1,2⟩∣∣⟨3,4⟩⟩,⟨⟨2,3⟩⟩,⟨⟨1,0⟩∣∣⟨0,1⟩⟩,⟨⟨0,0⟩⟩):

Error, (in DynamicSystems:-StateSpace) unsupported type of index, t

I do not have any clue what is wrong with my code.

 

Any help will be really appreciated.

Thanks

I never used applyrule before. Seems like a good command. I was trying to tell Maple to rewrite

as

I could not find one command to do it.  Collect does not work. The only way I figure to it, is by replacing 

by a new single unused symbol, and then use collect on the symbol, then use subs again to replace the symbol with orginal  expression. like this

restart;
expr:=(x^2 - 1)/x^2*y + (x^2 - 1)/x^2;
r:=(x^2 - 1)/x^2; #this is what I want to collect
applyrule(r=Z,expr);
collect(%,Z);
subs(Z=r,%)

In the above code, if I replace applyrule by algsubs, it does not work. Why?

restart;
expr:=(x^2 - 1)/x^2*y + (x^2 - 1)/x^2;
r:=(x^2 - 1)/x^2;
algsubs(r=Z,expr);

You see, it did not replace (x^2-1)/x by Z, like applyrule does:

restart;
expr:=(x^2 - 1)/x^2*y + (x^2 - 1)/x^2;
r:=(x^2 - 1)/x^2;
applyrule(r=Z,expr);

I will learn applyrule now more to do this. I was just wondering why algsubs failed, and if applyrule is the better tool to do this. Or may be there is a better way to do this whole thing?

Maple 2019.1

after running the command  DocumentTools:-Tabulate  as you can see it in the example below in Maple 2018.2:

DocumentTools:-Tabulate(Matrix(2, [a, b, c, d]), width=20);

Output:
                                  

 

 

I expect this proc to return a matrix of all ones but it returns a matrix of all zeros.  Why does it do that?

doit := proc()  
  local i, j, M;                                     
  M := Matrix(3,3);                    
  for i from 1 to 3 do  
    for j from 1 to 3 do  
      M[i][j] := 1;                                      
    end do;                             
  end do;              
  return M;  
end proc:                                           

doit();                            
                                 [0    0    0]
                                 [           ]
                                 [0    0    0]
                                 [           ]
                                 [0    0    0]

 

I am putting pictures into Maple 2019 Document to facilitate/document of analysis being done.  Would very much like to move pictures/images around document?  Once I place them, I can resize them, but I cannot seem to move them.  This is very restrictive.

Is there a solution?

Thank you in advance for your help.

In equation(19), the value for F = 14.616.. is wrong. It was produced by a bult execution of the whole program. However, executing only equation(19) in one step results in the correct answer F=24.665. The values for SSE,SSR, which are 1 x 1 matrices, are correct. Indices(1x1) provide access to the elements as constants so that arithmetic operations can be performed.

The correct result follows an execution at eqn(19) as a stand alone. An incorrect result follows execution of the entire program.

  restart:               

interface(rtablesize = 50); with(LinearAlgebra); with(plots); with(Statistics); with(ArrayTools);

Y := Matrix(12, 1, [2, 3, 2, 7, 6, 8, 10, 7, 8, 12, 11, 14]); n := ArrayNumElems(Y);

This is the data, with n rows and one column.

                                [2 ]

                                [  ]

                                [3 ]

                                [  ]

                                [2 ]

                                [  ]

                                [7 ]

                                [  ]

                                [6 ]

                                [  ]

                                [8 ]

                           Y := [  ]

                                [10]

                                [  ]

                                [7 ]

                                [  ]

                                [8 ]

                                [  ]

                                [12]

                                [  ]

                                [11]

                                [  ]

                                [14]

                            n := 12

type(Y, Matrix);

                              true

X := Matrix(12, 3, [1, 0, 2, 1, 2, 6, 1, 2, 7, 1, 2, 5, 1, 4, 9, 1, 4, 8, 1, 4, 7, 1, 6, 10, 1, 6, 11, 1, 6, 9, 1, 8, 15, 1, 8, 13]); k := NumElems(X)/n;

                             [1  0  2 ]

                             [        ]

                             [1  2  6 ]

                             [        ]

                             [1  2  7 ]

                             [        ]

                             [1  2  5 ]

                             [        ]

                             [1  4  9 ]

                             [        ]

                             [1  4  8 ]

                        X := [        ]

                             [1  4  7 ]

                             [        ]

                             [1  6  10]

                             [        ]

                             [1  6  11]

                             [        ]

                             [1  6  9 ]

                             [        ]

                             [1  8  15]

                             [        ]

                             [1  8  13]

                             k := 3

Xprimed := Transpose(X);

                                                                                                                                                                                                     Calculate Multiple Linear Regression in x1, and x2

                 [1  1  1  1  1  1  1  1   1   1  1   1 ]

                 [                                      ]

      Xprimed := [0  2  2  2  4  4  4  6   6   6  8   8 ]

                 [                                      ]

                 [2  6  7  5  9  8  7  10  11  9  15  13]

XprimedX := Xprimed . X;

                              [12   52   102 ]

                              [              ]

                  XprimedX := [52   296  536 ]

                              [              ]

                              [102  536  1004]

XprimedXinverse := MatrixInverse(XprimedX);

                      [   309          77              145 ]

                      [   ---          ---      uminus0--- ]

                      [   317          317             634 ]

                      [                                    ]

                      [    77          411             141 ]

   XprimedXinverse := [   ---         ----      uminus0----]

                      [   317         2536             1268]

                      [                                    ]

                      [       145         141       53     ]

                      [uminus0---  uminus0----      ---    ]

                      [       634         1268      634    ]

XprimedY := Xprimed . Y;

                                   [90 ]

                                   [   ]

                       XprimedY := [482]

                                   [   ]

                                   [872]

Betahat := XprimedXinverse . XprimedY;

                               [   1704   ]

                               [   ----   ]

                               [   317    ]

                               [          ]

                               [   3819   ]

                    Betahat := [   ----   ]

                               [   1268   ]

                               [          ]

                               [       815]

                               [uminus0---]

                               [       634]

Betahat := convert(Betahat, float);

                          [    5.375394322     ]

                          [                    ]

               Betahat := [    3.011829653     ]

                          [                    ]

                          [&uminus0;1.285488959]

 We choose the Null Hypothesis that Y= β0+Β1*x1+Β2*x2+ϵ . 

Performing multiple linear regression leads to the best fit linear equation:  

  Y= 5.38+3.01*x1-1.29x2

fit := plot3d(5.38+3.01*X1-1.29*X2, X1 = 0 .. 8, X2 = 2 .. 15);

data := pointplot3d({[0, 2, 2], [2, 5, 7], [2, 6, 3], [2, 7, 2], [4, 7, 10], [4, 8, 8], [4, 9, 6], [6, 9, 12], [6, 10, 7], [6, 11, 8], [8, 13, 14], [8, 15, 11]}, axes = normal, color = red, symbol = soliddiamond, symbolsize = 40, scaling = unconstrained, title = `\` Data vs Best Fit ' `);

display({data, fit});

                                                                                                               Comparison of Data and Best Fit

 

Yprimed := Transpose(Y); YprimedY := Yprimed . Y; BetahatPrime := Transpose(Betahat);

      Yprimed := [2  3  2  7  6  8  10  7  8  12  11  14]

                       YprimedY := [840]

BetahatPrime := [5.375394322  3.011829653  &uminus0;1.285488959]

SSE := YprimedY-BetahatPrime . XprimedY; SampleVariance := (YprimedY-BetahatPrime . XprimedY)/(n-k-1);

                   SSE := [25.4589905220000]

              SampleVariance := [3.18237381525000]

SSE (below) is a 1x1 vector which has been changed into a constant                                                  Covariance of β                                                                                                                                                     

`cov&beta;` := Typesetting[delayDotProduct](SSE(1, 1), XprimedXinverse, true);

cov&beta; := [

 

  [24.8164923384795, 6.18404501638486, &uminus0;5.82263978815458], 

 

  [6.18404501638486, 4.12604302229574, &uminus0;2.83100762113723], 

 

  [&uminus0;5.82263978815458, &uminus0;2.83100762113723, 

 

  2.12827523291167]]

SSR := Transpose(Betahat) . Transpose(X) . Y-n*MeanY(1, 1)^2;

                   SSR := [139.541009478000]

SST := SSR+SSE; F := SSR(1, 1)*(n-k-1)/(k*SSE);

F is found in textbook eqn (8.5)

                         SST := [165.]

                    F := [14.6160295824160]

RsquaredNonCentered := Determinant(SSR)/Determinant(SST); R := sqrt(%);

            RsquaredNonCentered := 0.845703087745454

                     R := 0.919621165342259

MeanY := Mean(Y);

                  MeanY := [7.50000000000000]

RsquaredCentered := `~`[`.`](Transpose(Betahat) . Transpose(X) . Y-n*MeanY(1, 1)^2, 1/(Yprimed . Y-n*MeanY(1, 1)^2));

            RsquaredCentered := [0.845703087745454]

                                                                                                         We note the same value for R -data not centered, and that for R-data which is centered.

 

Transpose(Betahat) . Transpose(X) . Y; MeanY(1, 1)^2; Yprimed . Y;

# Compare SSR, Mean of Y (data), and SST to results in the book. 

                       [814.541009478000]

                        56.2500000000000

                             [840]

                                                     Table 8.2 on Page 189 of textbook

                                    ANOVA for Overall Regression Test for Data in Table 7.1

________________________________________________________________________________________________________

 Source           df                                                   SS                                                        MS                                                 F

 _________________________________________________________________________________________________________

 Include β1    2                                        139.5410                                    69.7705                                24.665

Error           9                                          25.4590                                      2.8288

         Total                                             165.0000

_________________________________________________________________________________________

and from calculations using the defining equations in step(12) through step(13) and summarized in Step(19):

 

F := SSR(1, 1)*(n-k-1)/(k*SSE(1, 1)); SSE, SSR, SSR+SSE; Total := Yprimed . Y-n*MeanY(1, 1)^2;

                     F := 14.6160295824160

         [25.4589905220000], [139.541009478000], [165.]

                        Total := [165.]

Hi, 

When creating a user random variable, I would like to instanciate some of its attributes, for instance ParentName.
But it seems that it's not always possible.

​​​​​​​Is it a Maple's limitation or am I not doing the things correctly ?
​​​​​​​
Example:
 

restart:

with(Statistics):

U := RandomVariable(Uniform(0, 1)):

interface(warnlevel=0):

A := attributes(U)[3]

_ProbabilityDistribution

(1)

AllAttributes := with(A);

[CDF, Conditions, HodgesLehmann, InverseSurvivalFunction, MGF, MaximumLikelihoodEstimate, Mean, Median, Mode, PDF, Parameters, ParentName, Quantile, RandomSample, RandomSampleSetup, RandomVariate, RousseeuwCrouxSn, Support, Variance]

(2)

A:-ParentName

UniformDistribution

(3)

# Define a user random variable

v := Distribution(PDF = (z -> piecewise(0 <= t and t < 1, 1, 0))):
V := RandomVariable(v):
A := attributes(V)[3];
AllAttributes := with(A);
A:-Conditions;

_ProbabilityDistribution0

 

[Conditions, PDF]

 

[]

(4)

# its definition can be augmented by adding some recognized attributes...
# even if the result returned by Mean is strange

v := Distribution(PDF = (z -> piecewise(0 <= t and t < 1, 1, 0)), 'Mean'=1/Pi, 'Median'=exp(-1)):
V := RandomVariable(v):
A := attributes(V)[3];
AllAttributes := with(A);
[Median, Mean](V)

_ProbabilityDistribution1

 

[Conditions, Mean, Median, PDF]

 

[exp(-1), 1/Pi(_R1)]

(5)

# but not all the recognized attributes seem to be able to be instanciated:

v := Distribution(PDF = (z -> piecewise(a <= t and t < b, 1/(b-a), 0)), 'Parameters'=[a, b]);
v := Distribution(PDF = (z -> piecewise(a <= t and t < b, 1/(b-a), 0)), 'ParentNames'=MyDistribution);

Error, (in Statistics:-Distribution) invalid input: too many and/or wrong type of arguments passed to NewDistribution; first unused argument is Parameters = [a, b]

 

Error, (in Statistics:-Distribution) invalid input: too many and/or wrong type of arguments passed to NewDistribution; first unused argument is ParentNames = MyDistribution

 

 

 


 

Download Attributes.mw

How to get a plot for different values of Mh.

like Mh=[1 2 3 4]

Code:

restart;
with(DEtools,odeadvisor);

m:=10;H:=1;Mh:=1;b:=0.02; a:=0.05;V:=array(0..m); V[0]:=1-exp(-t);

for k from 1 to m do

if k=1 then chi:=0;

 chi:=1;

 fi;

 p:=0;

 for j from 0 to k-1 do

   p:=p+(V[k-1-j]*diff(V[j],t$2)-diff(V[k-1-j],t)*diff(V[j],t)-a*(2*diff(V[k-1-j],t)*diff(V[j],t$3)-diff(V[k-1-j],t$2)*diff(V[j],t$2)-V[k-1-j]*diff(V[j],t$4)));  od;

p:=(p+diff(V[k-1],t$3)-b*(diff(V[k-1],t$2)+t*diff(V[k-1],t$3))-Mh*diff(V[k-1],t))*h*H;

p:=factor(p);

V[k]:=(-int(p,t)+0.5*exp(t)*int(exp(-t)*p,t)+0.5*exp(-t)*int(exp(t)*p,t)+chi*V[k-1]+C1+C3*exp(-t));

v:=unapply(V[k],t);

V[k]:=frontend(expand,[V[k]]);  V[k]:=subs(C3=solve(eval(subs(t=0,diff(V[k],t))),C3),V[k]); V[k]:=frontend(expand,[V[k]]);

V[k]:=subs(C1=solve(eval(subs(t=0,-V[k]-diff(V[k],t))),C1),V[k]);

od:

appr:=0;

for k from 0 to m do

 appr:=appr+V[k];

od:

u_appr:=unapply(appr,(h,t)):

u_appr_1:=unapply(diff(u_appr(h,t),t),(h,t)):

evalf(u_appr_1(-0.4,t)):

with(plots);

plot([u_appr_1(-0.4,t)],t=0..4,0..1.2,color=[black],axes=frame):

 

 

this plot for Mh=1:

 

First 405 406 407 408 409 410 411 Last Page 407 of 2176