MaplePrimes Questions

I know you can call python from Maple, I am thinking if there is the other way around. That is use Maple (and its toolbox) as backend engine to do calculations (e.g. Global Optimization), and say manipulate the data in Python as the front-end.

This is an ode from text book.  The little tricky part on this is the right hand has abs on the dependent variable, otherwise it is trivial.

restart;
ode:=diff(y(x),x) = abs(y(x))+1;
sol:=dsolve(ode,y(x))

Gives

I am not able to get odetest to give zero on either of the two solutions.  

odetest(sol[1],ode);
odetest(sol[2],ode);

None give zero. I tried assumptions on x>0, x<0 and tried simplify(...,symbolic), nothing gives zero.

Now the book gives the solutions without constant of integration, which is strange. This is what the book gives as solution

                 y(x) = exp(x)-1   x>=0
                 y(x) = 1-exp(-x) x<0

Which is the same as Maple's solution, but without the constant of integration! So when I removed _C1 from both solutions and added the assumptions on x, then I got zero

odetest(subs(_C1=1,sol[1]),ode) assuming x<0;
                      0

odetest(subs(_C1=1,sol[2]),ode) assuming x>=0
                      0

I solved this by hand, and got same solution as Maple actually (may be I made the same mistake as Maple? :) 

But the above shows these solution are not correct? I do not now know what happend to the constant of integration in the book solution since it only shows final solution. It looks like book just used C=1 for the constant of integration. But Maple also thinks the book solution is correct.

fyi, the implicit solution by Maple does verify with no problem:

ode:=diff(y(x),x)=abs(y(x))+1;
sol:=dsolve(ode,y(x),'implicit');
odetest(sol,ode)

             0

Any one can shed some light what is going on? Is Maple solution correct? If so, why it does not verify? Should Maple have given the book solution?

this is problem 9, page 15, "Elementary differential equations" by William F. Trench, 2001

Maple 2019.1

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.]

First 663 664 665 666 667 668 669 Last Page 665 of 2433