Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I am working on a project in dynamical system and I am to apply Pontryagins maximum principle of control. i have coded the control equations but it shows an error message "Error, (in dsolve/numeric/bvp/convertsys) too few boundary conditions: expected 7, got 6". What could be the possible problem?

I wish to add tick marks to a 3D plot of a matrix.

B:=Matrix(10, 10, [[0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0]]):

Below, I draft a plot of this adjacency matrix B . I have adjusted  the position of the domain graph ticks for the x and y axes to be letters at the midpoints of the matrix elements:

tickList := [1.5 = "W", 2.5 = "P", 3.5 = "K", 4.5 = "C", 5.5 = "Y", 6.5 = "F", 7.5 = "X", 8.5 = "H", 9.5 = "T", 10.5 = "E"];

tickmarks = [tickList, tickList, tickList];

matrixplot(B, axes = [0 .. 12, 0 .. 12, 0 .. 12], heights = histogram, axes = boxed, title = "Above adjacency matrix B - axis order 1-10 \n Basis set: {W,P,K,C,Y,F,X,H,T,E}", labels = ["from", "to", ""], orientation = [0, 0, 0], tickmarks = [tickList, tickList, tickList]);

BUT I would like the z-axis not to be the above letters but instead the real (or integer) values of the matrix elements.  How should I do this, while retaining the x and y axes labels as letters located at the ticklist above.

Please can someone help?

Melvin

Hi,

I use the plots:-shadebetween( ) command quite a bit to visualize volume under a surface over a planar rectangular region. Is there a way, using this same command, to see said volume over a non-rectangular region? For example, the region bounded above by z = x^2 + y^2, having a triangle base 0<=x<=1, 0<=y<=x. If this command does not allow for this, is there some other solution?

Thanks!

Not sure why I need to invoke the simplify command here, shouldn't the immediate simplification occur?


                  

simplify(%)
                   

However, it does work algebraically


                 

                    

 

My goal is to generate incremental values of a function to plot using dataplot. Why does the first example generate numeric values in the Vector and the second example does not?

fenq := f -> 2.1^(f+1):
pf := Vector(5, fenq)
                             [  4.41   ]
                              [  9.261  ]
                         pf := [ 19.4481 ]
                              [40.84101 ]
                             [85.766121]
fseqn := (Se, f) -> Se^(f+1):
psf := Vector(5, fsenq(2.1, j))
 

I can plot the first data set using dataplot(pf). I cannot plot the second data set.

Hi, I have been looking at various questions which are similar. But, I could not exactly what I am looking for.

https://www.mapleprimes.com/questions/99679-Removing-Elements-In-A-List

In the above link it is useful to remove elemets of specific type(identical in two lists). I am looking for removing elements from list with specific Index.

L := [1,1,a,c,1];
indexList:=[3,5]

Now based on IndexList I would like to remove the elements from L. That is I want to delete L[IndexList[1]] and L[indexList[2]]. I have tried to do it using

remove(has, L, L[indexList]);  

It is working when there are no identitical elements. In my case it fails to delete exact exlemens.

subs(seq(A[indexList[i]] = NULL, i = 1 .. nops(indexList)), A); Both are working in same way. Not suitable when having identical elements in a list
How one could delete(remove) elements based on index??

Hi,

I'm very new at maple and trying to understand its engine, but it is really hard sometimes when it doesn't make sense what it is doing. I have a function that gives me

com2(e,e,f)=eh+he

and then I would like to substitute eh into <1,0> and he into <0,1>, so I write

subs({eh=<1,0>, he=<0,1>}, com2(e,e,f))

which gives me the following answer

eh+he

Here comes the confusing part. When I plug in eh+he directly into the subs thing I get

<1,1>

Why are these two outputs different from each other? To clarify, why is subs({eh=<1,0>, he=<0,1>}, com2(e,e,f))=/=subs({eh=<1,0>, he=<0,1>}, eh+he)?

Is there a way to program this:

I have to write an equation like this (x1+x2)*(x1+x3)*(x2+x3)=0. Left side is a combination, k=2 and n=3 so the number of terms is 3. For small number of terms this is not a problem to type, but if I have x1,x2,x3,x4,x5,x6, the number of combinations is 15 so it is complicated. Is there a way how to program something like this in Maple or I have to do it manually?

Thanks!

Hello,

I have two function :

And

 

A={g(R,L)=1}=

(I will call that L : L0=h(R))

 

 

So I want to represent f(A) in 3D

So I tried 

It does not work, and I do not see how I could do otherwise...

 

Thank's in advance !

hi.

According to the fhgure attaceh how i can gain the equation (2-27) . I write the equation (2-26) in maple but I couldnot to gain that result.

If possible to reach equation via maple?

Thanks

diff.mw
 

restart

FC := (1/2)*W_m^2*(c1*x^2+c2*y^2)+(E.(h^2))*W_m^2*(sum(An*((sinh(n*Pi/lambda)+n*Pi*cosh(n*Pi/lambda)/lambda)*cosh(2*n*Pi*y/a)-2*n*Pi*y*sinh(n*Pi/lambda)*sinh(2*n*Pi*y/a)/a)*cos(2*n*Pi*x/a)/(n^2*(sinh(n*Pi/lambda)*cosh(n*Pi/lambda)+n*Pi/lambda))+Bn*((sinh(n*Pi*lambda)+n*Pi*lambda*cosh(n*Pi*lambda))*cosh(2*n*Pi*x/b)-2*n*Pi*x*sinh(n*Pi*lambda)*sinh(2*n*Pi*x/b)/b)*cos(2*n*Pi*y/b)/(lambda^2*n^2*(sinh(n*Pi*lambda)*cosh(n*Pi*lambda)+n*Pi*lambda)), n = 1 .. n))

Warning,  computation interrupted

 

S := diff(FC, x); SS := diff(S, x)

g := subs(x = (1/2)*a, SS)

0

(1)

coeff(g, sinh(n*Pi/lambda))

0

(2)

``


 

Download diff.mw

The command print placed within a while loop does not produce any printout. How do I  make MAPLE to produce  it?

I am trying to animate two variables in a 3D plot. Basically I would like to combine these two animations into one simultaneous animation:

animate(plot3d, [[y, x, (1/3)*Pi], x = 0 .. 2*Pi, y = 0 .. R, coords = spherical, scaling = constrained], R = 0 .. 5)

and

animate(plot3d, [[y, x, (1/3)*Pi], x = 0 .. p, y = 0 .. 5, coords = spherical, scaling = constrained], p = 0 .. 2*Pi)

so that both animations start and end simultaneously. Is this possible?

Thanks in advance.

Hi
I appreciate your help forfinding the best fitting line for a discrete series.

Starting with 1978 as base year and counting by two's the five year overage global temperature. where 

the temperature is given by the data : x[0],...,x[12] 

1) Find the best  fitting line : x[n+1]=a*x[n]+b
2) Assuming we can extrapolate, find the predicted value x[30]

 

Fitting_best_line.mw

 

Many thanks for your help.

 

Hi everybody, i want to plot the intersection volume of three inequality, how can i do it?

 

restart

d1:=3:d2:=3:d3:=5:

plots:-implicitplot3d([x^2+y^2+z^2<d1^2,(x-3)^2+y^2+z^2<d2^2,x^2+y^2+(z-4)^2<d1^2],x=-5..5,y=-5..5,z=-5..5,style= wireframe)

 

 


 

Download plot.mw

The procedure presented here does independence tests of a contingency table by four methods:

  1. Pearson's chi-squared (equivalent to Statistics:-ChiSquareIndependenceTest),
  2. Yates's continuity correction to Pearson's,
  3. G-chi-squared,
  4. Fisher's exact.

(All of these have Wikipedia pages. Links are given in the code below.) All computations are done in exact arithmetic. The coup de grace is Fisher's. The first three tests are relatively easy computations and give approximations to the p-value (the probability that the categories are independent), but Fisher's exact test, as its name says, computes it exactly. This requires the generation of all matrices of nonnegative integers that have the same row and column sums as the input matrix, and for each of these matrices computing the product of the factorials of its entries. So, there are relatively few implementations of it, and perhaps none that do it exactly. (Could some with access check Mathematica please?)

Our own Joe Riel's amazing and fast Iterator package makes this computation considerably easier and faster than it otherwise would've been, and I also found inspiration in his example of recursively counting contingency tables found at ?Iterator,BoundedComposition

ContingencyTableTests:= proc(
   O::Matrix(nonnegint), #contingency table of observed counts 
   {method::identical(Pearson, Yates, G, Fisher):= 'Pearson'}
)
description 
   "Returns p-value for Pearson's (w/ or w/o Yates's continuity correction)" 
   " or G chi-squared or Fisher's exact test."
   " All computations are done in exact arithmetic."
;
option
   author= "Carl Love <carl.j.love@gmail.com>, 27-Oct-2018",
   references= (                                                           #Ref #s:
      "https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test",         #*1
      "https://en.wikipedia.org/wiki/Yates%27s_correction_for_continuity",  #*2
      "https://en.wikipedia.org/wiki/G-test",                               #*3
      "https://en.wikipedia.org/wiki/Fisher%27s_exact_test",                #*4
      "Eric W Weisstein \"Fisher's Exact Test\" _MathWorld_--A Wolfram web resource:"
      " http://mathworld.wolfram.com/FishersExactTest.html"                 #*5
   )
;
uses AT= ArrayTools, St= Statistics, It= Iterator;
local
   #column & row sums: 
   C:= AT:-AddAlongDimension(O,1), R:= AT:-AddAlongDimension(O,2),
   r:= numelems(R), c:= numelems(C), #counts of rows & columns
   n:= add(R), #number of observations
   #matrix of expected values under null hypothesis (independence):
   #(A 0 entry would mean a 0 row or column in the original, which is not allowed.)
   E:= Matrix((r,c), (i,j)-> R[i]*C[j], datatype= 'positive') / n,
   #Pearson's, Yates's, and G all use a chi-sq statistic, each computed by 
   #slightly different formulae.
   Chi2:= add@~table([
       'Pearson'= (O-> (O-E)^~2 /~ E),                     #see *1
       'Yates'= (O-> (abs~(O - E) -~ 1/2)^~2 /~ E),        #see *2
       'G'= (O-> 2*O*~map(x-> `if`(x=0, 0, ln(x)), O/~E))  #see *3
   ]), 
   row, #alternative rows generated for Fisher's
   Cutoff:= mul(O!~), #cut-off value for less likely matrices
   #Generate recursively all contingency tables whose row and column sums match O.
   #Compute their probabilities under independence. Sum probabilities of all those
   #at most as probable as O. (see *5, *4)
   #Parameters: 
   #   C = column sums remaining to be filled; 
   #   F = product of factorials of entries of contingency table being built;
   #   i = row to be chosen this iteration
   AllCTs:= (C, F, i)->
      if i = r then #Recursion ends; last row is C, the unused portion of column sums. 
         (P-> `if`(P >= Cutoff, 1/P, 0))(F*mul(C!~))
      else
         add(
            thisproc(C - row[], F*mul(row[]!~), i+1), 
            row= It:-BoundedComposition(C, R[i])
         )
      fi      
;
   userinfo(1, ContingencyTableTests, "Table of expected values:", print(E));
   if method = 'Fisher' then AllCTs(C, 1, 1)*mul(R!~)*mul(C!~)/n!
   else 1 - St:-CDF(ChiSquare((r-1)*(c-1)), Chi2[method](O)) 
   fi   
end proc:

The worksheet below contains the code above and one problem solved by the 4 methods


 

 

DrugTrial:= <
   20, 11, 19;
   4,  4,  17
>:

infolevel[ContingencyTableTests]:= 1:

ContingencyTableTests(DrugTrial, method= Pearson):  % = evalf(%);

ContingencyTableTests: Table of expected values:

Matrix(2, 3, {(1, 1) = 16, (1, 2) = 10, (1, 3) = 24, (2, 1) = 8, (2, 2) = 5, (2, 3) = 12})

exp(-257/80) = 0.4025584775e-1

#Compare with:
Statistics:-ChiSquareIndependenceTest(DrugTrial);

hypothesis = false, criticalvalue = HFloat(5.991464547107979), distribution = ChiSquare(2), pvalue = HFloat(0.04025584774823787), statistic = 6.425000000

infolevel[ContingencyTableTests]:= 0:
ContingencyTableTests(DrugTrial, method= Yates):  % = evalf(%);

exp(-1569/640) = 0.8615885805e-1

ContingencyTableTests(DrugTrial, method= G):  % = evalf(%);

exp(-20*ln(5/4)+4*ln(2)-11*ln(11/10)-4*ln(4/5)-19*ln(19/24)-17*ln(17/12)) = 0.3584139703e-1

CodeTools:-Usage(ContingencyTableTests(DrugTrial, method= Fisher)):  % = evalf(%);

memory used=0.82MiB, alloc change=0 bytes, cpu time=0ns, real time=5.00ms, gc time=0ns

747139720973921/15707451356376611 = 0.4756594205e-1

 


 

Download FishersExact.mw

First 626 627 628 629 630 631 632 Last Page 628 of 2097