tomleslie

13876 Reputation

20 Badges

15 years, 174 days

MaplePrimes Activity


These are answers submitted by tomleslie

contains no GridPlot() command - expecting someone here to retype it for you is not a good idea

The attached fixes all the errors in your original workheet (and includes the required GridPlot() command )

It is generally a bad idea to create/load a DataFrame, then

  1. access Dataseries within the DataFrame using DataFrame['DataSeries'] then
  2. halfway through the worksheet use with(DataFrame), so that one can now access DataSeries within the frame using only the series name. Having two different ways to access the same information in  a single worksheet is just confusing

Note: the output of the GridPlot() command does not appear in the worksheet embedded here - not sure why. except that every time an array of plots is involved, this site seems to have a problem. The relevant plot does however appear iin the worksheet - so just download the latter and check

restart

with(Statistics)

Les Iris de Fisher

 

Les données utilisées ici sont célèbres. Elles ont été collectées par Edgar Anderson . Ce sont les mesures en centimètres des variables suivantes :

1. 

 longueur du sépale (Sepal.Length),

2. 

largeur du sépale (Sepal.Width),

3. 

longueur du pétale (Petal.Length)

4. 

 largeur du pétale (Petal.Width)

pour trois espèces d’iris :

1-Iris setosa,

2-Iris versicolor

3-Iris.virginica.
Sir R.A. Fisher a utilisé ces données pour construire des combinaisons linéaires des variables permettant de séparer au mieux les trois espèces d’iris

 

``

``

 

 

 

 

 

 

Accès aux données internes

 

NULL

Pour connaître  les données de la distribution de base :

kernelopts(datadir); FileTools:-ListDirectory(FileTools:-JoinPath([kernelopts(datadir), "datasets"]))

"C:\Program Files\Maple 2018\data"

 

["air_passengers.csv", "builtin.db", "canada_crimes.csv", "fertility_rates.csv", "iris.csv", "sunspots.csv"]

(2.1)

Afficher les données

 

IrisData := Import(FileTools:-JoinPath(["datasets", "iris.csv"], base = datadir))

_m583337856

(3.1)

Describe(IrisData)

IrisData :: DataFrame: 150 observations for 5 variables

Sepal Length:  Type: anything  Min: 4.30  Max: 7.90
Sepal Width:   Type: anything  Min: 2.00  Max: 4.40
Petal Length:  Type: anything  Min: 1.00  Max: 6.90
Petal Width:   Type: anything  Min: 0.10  Max: 2.50
Species:       Type: anything  Tally: ["virginica" = 50, "versicolor" = 50, "setosa" = 50]

 

CLabels := ColumnLabels(IrisData)

[`Sepal Length`, `Sepal Width`, `Petal Length`, `Petal Width`, Species]

(3.2)

SunSpotsData := Import(FileTools:-JoinPath(["datasets", "sunspots.csv"], base = datadir))

Describe(SunSpotsData)

SunSpotsData :: DataFrame: 314 observations for 2 variables

Date(Date:-year,Date:-month,Date:-day,Date:-hour,Date:-minute,Date:-second,timezone = Date:-timezone,coefficient = Date:-coeff):  Type: anything  Min: 1700.00  Max: 2013.00
Mean Sunspot Number:                                                                                                              Type: anything  Min: 0.00  Max: 190.20

 

FertilityData := Import(FileTools:-JoinPath(["datasets", "fertility_rates.csv"], base = datadir))

Describe(FertilityData)

FertilityData :: DataFrame: 36 observations for 1 variables

Fertility Rate - 2015:  Type: anything  Min: 1.31  Max: 1.96

 

PassengersData := Import(FileTools:-JoinPath(["datasets", "air_passengers.csv"], base = datadir))

Describe(PassengersData)

PassengersData :: DataFrame: 144 observations for 1 variables

Monthly Passengers:  Type: anything  Min: 104.00  Max: 622.00

 

CrimeData := Import(FileTools:-JoinPath(["datasets", "canada_crimes.csv"], base = datadir))

Describe(CrimeData)

CrimeData :: DataFrame: 13 observations for 5 variables

Violent Crime:          Type: anything  Min: 786.62  Max: 7934.95
Property Crime:         Type: anything  Min: 2100.84  Max: 23171.26
Other Criminal Code:    Type: anything  Min: 450.29  Max: 13834.45
Criminal Code Traffic:  Type: anything  Min: 211.57  Max: 1689.95
Federal Statute:        Type: anything  Min: 215.34  Max: 1331.87

 

Manipulation de IrisData

 

IrisData

_m583337856

(4.1)

IrisData[Species]

_m575883456

(4.2)

convert(%, set)

{"setosa", "versicolor", "virginica"}

(4.3)

IrisData[`Sepal Length`]

_m575889024

(4.4)

IrisData[`Sepal Width`]

_m575882016

(4.5)

IrisData[1 .. 4]

_m600907616

(4.6)

IrisNum := IrisData[() .. -2]

_m595974240

(4.7)

IrisData[() .. -3]

_m582933984

(4.8)

Sommaire statistique

 

interface(displayprecision = 4)

DataSummary(IrisNum, summarize = embed)

NULL

Normaliser les données et Histogrammes

 

Median(IrisNum)

_m562409472

(6.1)

Histogram(IrisData[`Sepal Width`], discrete)

 

scaled := Scale(IrisData[`Sepal Length`])

_m586565792

(6.2)

Mean(scaled), StandardDeviation(scaled)

HFloat(-1.3796371452675278e-15), HFloat(0.9999999999999989)

(6.3)

Histogram(scaled, discrete)

 

scaled2 := Scale(IrisData[`Sepal Length`], center = Median, scale = MedianDeviation)

_m581417120

(6.4)

Median(scaled2), MedianDeviation(scaled2)

HFloat(0.0), HFloat(1.0)

(6.5)

Histogram(scaled2, discrete)

 

allscaled := Scale(IrisNum)

_m600898208

(6.6)

Histogram(allscaled[1], discrete)

 

Aggregate

 

Aggregate(IrisData, Species)

_m469051392

(7.1)

Aggregate(IrisData, Species, function = StandardDeviation, tally)

_m585862528

(7.2)

Aggregate(IrisNum, `Petal Width`, bounds = quantiles(0, 1/3, 2/3, 1), tally)

_m600049664

(7.3)

Visualisation

 

with(IrisData)

[`Sepal Length`, `Sepal Width`, `Petal Length`, `Petal Width`, Species]

(8.1)

LineChart(`Sepal Length`)

 

LineChart(IrisNum)

 

AreaChart(`Sepal Length`, markers = false)

 

AreaChart(IrisNum, datasetlabels = [`$`(``, 150)], markers = false)

 

SpeciesColors := map(proc (t) options operator, arrow; piecewise(t = "setosa", "DarkGreen", t = "versicolor", "MediumSlateBlue", t = "virginica", "MediumVioletRed") end proc, convert(Species, Vector)); GridPlot(IrisData[1 .. 4], upper = ['plots:-pointplot', color = SpeciesColors], lower = 'proc (x) options operator, arrow; Statistics:-PieChart([" " = abs(x), " " = 1-abs(x)], color = ["CornflowerBlue", "WhiteSmoke"], title = evalf[3](x), size = [100, 100]) end proc', correlation = [false, true, false], width = 600, widthmode = pixels)

"Tabulate"

(8.2)


 

Download doData.mw

that shown in the attached??


 

 

 Write the expression in textarea and click the button to see the plot in plot area and expression in math container

      NULL

 

 

``

NULL


 

Download animPlot.mw

the help at ?Typesetting:-Suppress

in the "displayed" output, rather than the values which have actually been "computed"

The attached plays a few tricks with the Maple ouput display, without affecting actual computed values.

You should probably also be aware that Maple's finance package (see help at ?Finance) has mnay in-built functions for pricing options


 

 restart:

#
# Following two commands are just for convenience
# of "displaying" output
#
  interface(rtablesize=20):
  interface(displayprecision=3):
  r := 0.23e-1: T := 90*(1/365): q := 0: K := 55: X := 148:
  M := 10: N := 10: Deltat := T/N: DeltaX := X/M:  sigma := .2:
  f := Array(0..N, 0..M):
  for j from 0 to M do
      f[N, j] := max(DeltaX*j-K, 0)
  end do:
  for j from 0 to M do
      a[j] := -(1/2*(r-q))*j*Deltat+(1/2)*sigma^2*j^2*Deltat+r*Deltat:
      b[j] := -Deltat*j^2*sigma^2+Deltat*r+1:
      c[j] := (1/2*(r-q))*j*Deltat+(1/2)*sigma^2*j^2*Deltat+r*Deltat
  end do:
  for i from N-1 by -1 to 0 do
      for j to M-1 do
          f[i, j] := a[j]*f[i+1, j-1]+b[j]*f[i+1, j]+c[j]*f[i+1, j+1]
      end do:
      f[i, 0] := b[0]*f[i+1, 0]+c[0]*f[i+1, 1]:
      f[i, M] := a[M]*f[i+1, M-1]+b[M]*f[i+1, M]
  end do:
#
# Display the Array 'f' as a matrix, just because it
# *looks* prettier that way
#
  convert(f, Matrix);
#
# reset the output display to default and check a few
# values in the array 'f'
#
  interface(displayprecision=-1):
  f[0,0],f[2,3], f[2,4], f[2,5];

Matrix(11, 11, {(1, 1) = 0.1247000000e-7, (1, 2) = 0., (1, 3) = 0.4e-2, (1, 4) = .267, (1, 5) = 5.346, (1, 6) = 19.789, (1, 7) = 34.893, (1, 8) = 49.998, (1, 9) = 64.501, (1, 10) = 73.279, (1, 11) = 56.773, (2, 1) = 0.7458000000e-8, (2, 2) = 0., (2, 3) = 0.3e-2, (2, 4) = .238, (2, 5) = 5.235, (2, 6) = 19.706, (2, 7) = 34.782, (2, 8) = 49.865, (2, 9) = 64.496, (2, 10) = 74.170, (2, 11) = 59.077, (3, 1) = 0.4130000000e-8, (3, 2) = 0., (3, 3) = 0.2e-2, (3, 4) = .210, (3, 5) = 5.123, (3, 6) = 19.624, (3, 7) = 34.672, (3, 8) = 49.730, (3, 9) = 64.463, (3, 10) = 75.021, (3, 11) = 61.587, (4, 1) = 0.2059000000e-8, (4, 2) = 0., (4, 3) = 0.2e-2, (4, 4) = .182, (4, 5) = 5.010, (4, 6) = 19.542, (4, 7) = 34.562, (4, 8) = 49.591, (4, 9) = 64.403, (4, 10) = 75.821, (4, 11) = 64.328, (5, 1) = 0.8794000000e-9, (5, 2) = 0., (5, 3) = 0.1e-2, (5, 4) = .155, (5, 5) = 4.897, (5, 6) = 19.462, (5, 7) = 34.452, (5, 8) = 49.451, (5, 9) = 64.316, (5, 10) = 76.552, (5, 11) = 67.329, (6, 1) = 0.2922000000e-9, (6, 2) = 0., (6, 3) = 0.1e-2, (6, 4) = .128, (6, 5) = 4.783, (6, 6) = 19.382, (6, 7) = 34.342, (6, 8) = 49.310, (6, 9) = 64.205, (6, 10) = 77.197, (6, 11) = 70.622, (7, 1) = 0.5824000000e-10, (7, 2) = 0.4124000000e-6, (7, 3) = 0., (7, 4) = .101, (7, 5) = 4.668, (7, 6) = 19.304, (7, 7) = 34.233, (7, 8) = 49.168, (7, 9) = 64.071, (7, 10) = 77.734, (7, 11) = 74.246, (8, 1) = 0, (8, 2) = 0.1027000000e-6, (8, 3) = 0., (8, 4) = 0.75e-1, (8, 5) = 4.552, (8, 6) = 19.226, (8, 7) = 34.125, (8, 8) = 49.025, (8, 9) = 63.918, (8, 10) = 78.136, (8, 11) = 78.243, (9, 1) = 0, (9, 2) = 0, (9, 3) = 0., (9, 4) = 0.50e-1, (9, 5) = 4.436, (9, 6) = 19.150, (9, 7) = 34.016, (9, 8) = 48.883, (9, 9) = 63.750, (9, 10) = 78.373, (9, 11) = 82.662, (10, 1) = 0, (10, 2) = 0, (10, 3) = 0, (10, 4) = 0.25e-1, (10, 5) = 4.318, (10, 6) = 19.074, (10, 7) = 33.908, (10, 8) = 48.741, (10, 9) = 63.575, (10, 10) = 78.409, (10, 11) = 87.559, (11, 1) = 0, (11, 2) = 0, (11, 3) = 0, (11, 4) = 0, (11, 5) = 21/5, (11, 6) = 19, (11, 7) = 169/5, (11, 8) = 243/5, (11, 9) = 317/5, (11, 10) = 391/5, (11, 11) = 93})

 

0.1246911958e-7, .2099594306, 5.122869406, 19.62374146

(1)

 

 


 

Download callOpt.mw

works for me

Download doubleInt.mw

In the pdf you supplied, the number of terms in the Bernstein summation was 10. To get a *really* good fit, the number of terms should be much higher (ideally "infinite").

The attached shows the Schubert function, and its approximation using Bernstein polynomials with 100 terms in the summation. Overall the fit is much better, although the vertical scale is still a bit "off".

This took about as long (~2 minutes) as I was prepared to wait


 

#
# Define/plot the Shubert function
#
  f:=x-> add
         ( i*cos((i+1)*(-2+4*x[1])+i),
           i=1..5
         )
         *
         add
         ( i*cos((i+1)*(-2+4*x[2])+i),
           i=1..5
         );
  plot3d( f([x,y]),
          x=0..1,
          y=0..1,
          numpoints=10000
        );

proc (x) options operator, arrow; add(i*cos((i+1)*(-2+4*x[1])+i), i = 1 .. 5)*add(i*cos((i+1)*(-2+4*x[2])+i), i = 1 .. 5) end proc

 

 

#
# Define/plot the approximation of the Shubert function
# using Bernstein polynomials. To get a really good fit
# number of terms in the summation should be infinite:
# OP used 10 which gave a poor fit; with 100 terms in
# the summations, the fit isn't *too* bad and took about
# as long as I was prepared to wait!
#
  N:=100:
  M:=100:
  p:= (j,s,z)-> binomial(s,j)*z^j*(1-z)^(s-j);
  B:= x-> add
          ( add
            ( f([i/N, k/M])*p(i,N,x[1])*p(k,M,x[2]),
              i=0..N
            ),
            k=0..M
          );
  plot3d( B([x,y]),
          x=0..1,
          y=0..1,
          numpoints=10000
        );

proc (j, s, z) options operator, arrow; binomial(s, j)*z^j*(1-z)^(s-j) end proc

 

proc (x) options operator, arrow; add(add(f([i/N, k/M])*p(i, N, x[1])*p(k, M, x[2]), i = 0 .. N), k = 0 .. M) end proc

 

 

 


 

Download bernstein.mw

the attached


 

  restart;
  getSign:= proc(x::Vector)
                 if   {entries(x, nolist)}={-1}
                 then return "maximum"
                 elif {entries(x, 'nolist')}={1}
                 then return "minimum"
                 elif {entries(x, 'nolist')}={-1, 1}
                 then return "saddle"
                 else return "inconclusive"
                 end
           end proc:
  EigenValues:= [ [-.381966011250105+0.*I, -2.61803398874989+0.*I],
                  [.414213562373095+0.*I, -2.41421356237309+0.*I],
                  [0, 2]
                ];
  ans:=signum~(simplify~(convert(EigenValues, Matrix), zero));
  getSign~( [LinearAlgebra:-Row(ans,1..-1)])

EigenValues := [[-.381966011250105+0.*I, -2.61803398874989+0.*I], [.414213562373095+0.*I, -2.41421356237309+0.*I], [0, 2]]

 

Matrix(%id = 18446744074218228182)

 

["maximum", "saddle", "inconclusive"]

(1)

 


 

Download doSigns.mw

I can work out what the OP's intention is, from the supplied code - but in this case I can't. I strongly recommend that the OP upload a complete worksheet, using the big green up-arrow (rather than using any kind of cut+paste).

So I'm just going to make a few observations about "likely problems"

  1. Use of the range operator `..` Maple will interpret two or more successive '.' characters as a range operator. However `.. .` ie three `.` characters will not be interpreted as a range operator (at least not in the way expected!). OP uses three dots (with an intervening space) almost everywhere a range operator is required - eg Array() specification, add() specication and seq() specification. None of these are going to do what OP expects.
  2. Difference between names, functons and indexed variables.  OP has multiple assignments like

  s1(x):=exp(-(x/(m1))^((m1/(sigma1))));
  s1(x+1):=exp(-((x+1)/(m1))^((m1/(sigma1))));
  s2(x):=1-exp(-(x/(m2))^((-m2/(sigma2))));
  s2(x+1):=1-exp(-((x+1)/(m2))^((-m2/(sigma2))));
  s3(x):=exp(exp(-m3/(sigma3))-exp((x-m3)/(sigma3)));
  s3(x+1):=exp(exp(-m3/(sigma3))-exp((x+1-m3)/(sigma3)));
  s(x):=(psi1*s1(x)+psi2*s2(x)+psi3*s3(x));
  s(x+1):=(psi1*s1(x+1)+psi2*s2(x+1)+psi3*s3(x+1));
  qtopi(x):=1-((s(x+1))/(s(x)));

To the 'uninitiated', these may 'look' like a function definitions - but they are not! In each case the left-hand-side of the assignment is interpreted as a simple, literal 'name'. None of these are function definitions accepting a value for the argument 'x' (or 'x+1'), and returning an 'appropriate value' from the rhs of the assignment.

This problem is exacerbated when the OP uses some/all of these definitions in 'indexed' expressions such as

fungsikerugian := add((1-qtopi(x)/q[x])^2, x = 0 .. 110);

In this last expression, qtopi(x), is interpreted as the function qtopi(), evaluated at the 'index' values. However the function qtopi() does not exist, it has not been defined anywhere, although the name qtopi(x) does exist. The name qtopi(x) and the function qtopi(), evaluated at the index variable 'x', are two completely different things

The confusion between names, functions and indexed variables makes it very difficult to work out the OP's intent

 

The previous code I posted was for the routine "Anova2s" in the pdf which you referenced.

The attached contains the code for the routine "Anova2m" in the same reference.

Both of these routines exactly reproduce the results shown in the reference

  restart;

  Anova2m:= proc( D::listlist )
                  uses Statistics:
                  local a:= nops(D),
                        b:= nops(D[1]),
                        c:=nops(D[1][1]),
                        SSTO:= 0,
                        SSA:= 0,
                        SSB:= 0,
                        SSAB:=0,
                        SSE:= 0,
                        FCDF:= (x, y, z)-> CumulativeDistributionFunction( FRatio(x,y), z),
                        RowMean:= Array(1..a),
                        ColMean:= Array(1..b),
                        CellMean:= Array(1 .. a, 1 .. b),
                        GrandMean:=0,
                        i, j, k ,MSA, MSB, MSAB, MSE, PVR, PVC,PVInt ;
                  description "Two factor ANOVA (multiple obs. per cell)";
                  for i to a do
                      RowMean[i] := 0:
                      for j to b do
                          for k to c do
                              RowMean[i] := RowMean[i]+D[i][j][k]
                          end do:
                      end do;
                      RowMean[i] := RowMean[i]/b/c
                  end do;
                  for j to b do
                      ColMean[j] := 0;
                      for i to a do
                          for k to c do
                              ColMean[j] := ColMean[j]+D[i][j][k]
                          end do
                      end do;
                      ColMean[j] := ColMean[j]/a/c
                  end do;
                  for i to a do
                      for j to b do
                          CellMean[i,j] := 0;
                          for k to c do
                              CellMean[i,j] := CellMean[i,j]+D[i][j][k]
                          end do;
                          CellMean[i,j] := CellMean[i,j]/c
                      end do
                  end do;
                  for i to a do
                      for j to b do
                          for k to c do
                              GrandMean := GrandMean+D[i][j][k]
                          end do
                      end do
                  end do;
                  GrandMean := GrandMean/a/b/c;
                  for i to a do
                      for j to b do
                          for k to c do
                              SSTO := SSTO+(D[i][j][k]-GrandMean)^2;
                              SSE := SSE+(D[i][j][k]-CellMean[i,j])^2;
                          end do:
                      end do:
                  end do;
                  for i to a do
                      SSA := SSA+(RowMean[i]-GrandMean)^2:
                  end do;
                  for j to b do
                      SSB := SSB+(ColMean[j]-GrandMean)^2:
                  end do;
                  SSA := b*c*SSA;
                  SSB := a*c*SSB;
                  SSAB := SSTO-SSA-SSB-SSE;
                  MSA := SSA/(a-1);
                  MSB := SSB/(b-1);
                  MSAB := SSAB/(a-1)/(b-1);
                  MSE := SSE/a/b/(c-1);
                  PVR := 1-FCDF(a-1,a*b*(c-1),MSA/MSE);
                  PVC := 1-FCDF(b-1,a*b*(c-1),MSB/MSE);
                  PVInt := 1-FCDF((a-1)*(b-1),a*b*(c-1),MSAB/MSE);
                  printf("  ------------------------------------------------------------------\n");
                  printf("             Sum of\n ");
                  printf("            Squares    Degrees of     Mean Sq\n");
                  printf("  Source     (SS)        Freedom        (MS)      F-Ratio    p-value\n");
                  printf("  ------------------------------------------------------------------\n");
                  printf("  Row(A)  %10.4f    %5d      %10.4f   %8.4f   %8.4f\n",
                          SSA, a-1, MSA,  MSA/MSE, PVR);
                  printf("  Col(B)  %10.4f    %5d      %10.4f   %8.4f   %8.4f\n",
                          SSB, b-1, MSB, MSB/MSE,PVC);
                  printf("  Int(AB) %10.4f    %5d      %10.4f   %8.4f   %8.4f\n",
                          SSAB, (a-1)*(b-1), MSAB, MSAB/MSE, PVInt
                        );
                  printf("  Error   %10.4f    %5d      %10.4f\n",
                          SSE, a*b*(c-1), MSE
                        );
                  printf("  Total   %10.4f    %5d\n",
                         SSTO, a*b*c-1);
                  printf("  ------------------------------------------------------------------\n");
             end proc:

  N11 := [21, 14, 16, 18]:
  N12 := [16, 20, 15, 21]:
  N13 := [15, 19, 14, 14]:
  N14 := [17, 17, 18, 20]:
  N21 := [20, 19, 20, 18]:
  N22 := [15, 16, 17, 19]:
  N23 := [16, 13, 18, 16]:
  N24 := [18, 17, 21, 19]:
  N31 := [14, 13, 16, 17]:
  N32 := [17, 18, 16, 16]:
  N33 := [15, 16, 17, 18]:
  N34 := [16, 16, 17, 18]:
  N := [ [ N11, N12, N13, N14 ],
         [ N21, N22, N23, N24 ],
         [ N31, N32, N33, N34 ]
       ]:

  Anova2m(N);

  ------------------------------------------------------------------
             Sum of

             Squares    Degrees of     Mean Sq
  Source     (SS)        Freedom        (MS)      F-Ratio    p-value
  ------------------------------------------------------------------
  Row(A)     15.7917        2          7.8958     2.1992     0.1256
  Col(B)     23.0625        3          7.6875     2.1412     0.1121
  Int(AB)    34.8750        6          5.8125     1.6190     0.1703
  Error     129.2500       36          3.5903
  Total     202.9792       47
  ------------------------------------------------------------------

 

NULL

Download Anova2m.mw

the attached?

restart;
mg:=78.54*7.85*1e-9*1000*9.81;l:=10000;l0:=12000;h:=0;H := 28.399;
eta:=mg*l/(2*H);
zeta:=arcsinh(mg*h/(2*H*sinh(eta)))-eta;
z:=H/mg*(cosh(mg/H*x+zeta)-cosh(zeta));
p:=plot(z,x=0..l);
f:=plottools:-transform((x, y)->[H*arcsinh(x)-x, y]):
plots:-display( f(p) );

0.6048247590e-2

 

10000

 

12000

 

0

 

28.399

 

1.064869818

 

-1.064869818

 

4695.409634*cosh(0.2129739635e-3*x-1.064869818)-7618.851743

 

 

 

 


 

Download plottrans.mw

on whether you just wish Maple to "display" the function with a restricted number of digits, in which case  setting

interface(displayprecision=4);

ought to help. This has no impact on calculations, just controls the number of digits displayed in any calculation results

If your problem is actually with "print" statements, then all you have to do is use the appropriate format code. For example check the difference between

printf( "%10.8f", Pi);
printf( "%10.4f", Pi);

 

doing it with vectors,

v1:=[seq( RootedVector( root=[cos(t), sin(t)], [-sin(t),cos(t)]), t=0..evalf(2*Pi), 0.2)]:
a1:=[seq( RootedVector( root=[cos(t), sin(t)], [-cos(t),-sin(t)]), t=0..evalf(2*Pi), 0.2)]:
p1:= plot( [sin(t), cos(t), t=0..2*Pi], color=red, thickness=5):
p2:= PlotVector(v1, color=blue, width=0.02):
p3:= PlotVector(a1, color=green, width=0.02):
plots:-display( [p1, p2, p3],scaling=constrained );

 

 


 

Download vecPlot.mw

 

ie

http://www.math.hope.edu/tanis/MapleManual.pdf

then I was able to reproduce the code on pp247-248, and generate the results table shown on p248.

Note that in order to do this, I had to make an "educated guess" about the definition of the function FCDF(), which I have taken to be the CDF of the Fisher F-distribution. This identification is suggested in the referenced pdf, but is nowhere (that I can find!) stated explicitly.

Use the attached with care

#
# Initialise and define the procedure Anova2(s)
#
  restart;
  Anova2s:= proc( D::listlist )
                  uses Statistics:
                  local a:= nops(D),
                        b:= nops(D[1]),
                        tot:= 0,
                        SSTO:= 0,
                        SSA:= 0,
                        SSB:= 0,
                        SSE:= 0,
                        FCDF:= (x, y, z)-> CumulativeDistributionFunction( FRatio(x,y), z),
                        RowMean:= Array(1..a),
                        ColMean:= Array(1..b),
                        i,     j, GrandMean, MSA, MSB,
                        MSE, PVR, PVC;
                   description "Two factor ANOVA*(one obs. per cell)";
                   for j to b do
                       ColMean[j]:= 0
                   end do;
                   for i to a do
                       for j to b do
                           tot:= tot+D[i][j]
                       end do
                   end do;
                   GrandMean:= tot/a/b;
                   for i to a do
                       RowMean[i]:= Mean(D[i])
                   end do;
                   for j to b do
                       for i to a do
                           ColMean[j]:= ColMean[j]+D[i][j]
                       end do;
                       ColMean[j]:= ColMean[j]/a
                   end do;
                   for i to a do
                       for j to b do
                           SSTO:= SSTO+(D[i][j]-GrandMean)^2
                       end do
                   end do;
                   for i to a do
                       SSA:= SSA+(RowMean[i]-GrandMean)^2
                   end do;
                   for j to b do
                       SSB:= SSB+(ColMean[j]-GrandMean)^2
                   end do;
                   SSA:= b*SSA;
                   SSB:= a*SSB;
                   SSE:= SSTO-SSA-SSB;
                   MSA:= SSA/(a-1);
                   MSB:= SSB/(b-1);
                   MSE:= SSE/(a-1)/(b-1);
                   PVR:= 1-FCDF(a-1,(a-1)*(b-1),MSA/MSE);
                   PVC:= 1-FCDF(b-1,(a-1)*(b-1),MSB/MSE);
                   printf( "             Sum of\n"):
                   printf( "             Squares   Degrees of   Mean Sq\n"):
                   printf( "  Source      (SS)      Freedom      (MS)      F-Ratio     p-value\n");
                   printf( "  --------------------------------------------------------------\n");
                   printf( "  Row(A)  %10.4f   %5d     %10.4f   %8.4f   %8.4f\n",
                           SSA, a-1, MSA, MSA/MSE, PVR);
                   printf( "  Col(B)  %10.4f   %5d     %10.4f   %8.4f   %8.4f\n",
                              SSB, b-1, MSB, MSB/MSE, PVC
                         );
                   printf( "  Error   %10.4f   %5d     %10.4f\n",
                              SSE, (a-1)*(b-1), MSE
                         );
                   printf( "  Total   %10.4f   %5d\n",
                           SSTO, a*b-1
                         );
                   printf( "  --------------------------------------------------------------\n");
              end proc:

#
# Supply data and run the procedure
#
  M:= [[16, 18, 21, 21], [14, 15, 18, 17], [15, 15, 18, 16]];
  Anova2s(M)

[[16, 18, 21, 21], [14, 15, 18, 17], [15, 15, 18, 16]]

 

             Sum of
             Squares   Degrees of   Mean Sq
  Source      (SS)      Freedom      (MS)      F-Ratio     p-value
  --------------------------------------------------------------
  Row(A)     24.0000       2        12.0000    18.0000     0.0029
  Col(B)     30.0000       3        10.0000    15.0000     0.0034
  Error       4.0000       6         0.6667
  Total      58.0000      11
  --------------------------------------------------------------

 

 

 

 

NULL

Download ANOVA2.mw

 

 

what vv has said,

The attached shows your code with the two 'relevant' lines converted to 1-D input. The difference is really obvious.

Now exactly why do you choose to use 2-D math input ?

NULL

restart; with(LinearAlgebra)

kernelopts(version)*interface(version)

`Maple 2018.2, X86 64 WINDOWS, Nov 16 2018, Build ID 1362973`*`Standard Worksheet Interface, Maple 2018.2, Windows 7, November 16 2018 Build ID 1362973`

(1)

A := Matrix(4, 4, symbol = a, shape = symmetric)

B := Matrix(4, 4, symbol = b, shape = symmetric)

R1 := Matrix(4, 4); R1[1, 1] := 1; R2 := Matrix(4, 4); R2[2, 2] := 1; R3 := Matrix(4, 4); R3[3, 3] := 1; R4 := Matrix(4, 4); R4[4, 4] := 1

Determinant*(R1 . B+R2 . B+R3 . B+R4 . A);

Error, (in LinearAlgebra:-Multiply) invalid arguments

 

Determinant(R1 . B+R2 . B+R3 . B+R4 . A);

-a[1, 4]*b[1, 2]*b[2, 3]*b[3, 4]+a[1, 4]*b[1, 2]*b[2, 4]*b[3, 3]+a[1, 4]*b[1, 3]*b[2, 2]*b[3, 4]-a[1, 4]*b[1, 3]*b[2, 3]*b[2, 4]-a[1, 4]*b[1, 4]*b[2, 2]*b[3, 3]+a[1, 4]*b[1, 4]*b[2, 3]^2+a[2, 4]*b[1, 1]*b[2, 3]*b[3, 4]-a[2, 4]*b[1, 1]*b[2, 4]*b[3, 3]-a[2, 4]*b[1, 2]*b[1, 3]*b[3, 4]+a[2, 4]*b[1, 2]*b[1, 4]*b[3, 3]+a[2, 4]*b[1, 3]^2*b[2, 4]-a[2, 4]*b[1, 3]*b[1, 4]*b[2, 3]-a[3, 4]*b[1, 1]*b[2, 2]*b[3, 4]+a[3, 4]*b[1, 1]*b[2, 3]*b[2, 4]+a[3, 4]*b[1, 2]^2*b[3, 4]-a[3, 4]*b[1, 2]*b[1, 3]*b[2, 4]-a[3, 4]*b[1, 2]*b[1, 4]*b[2, 3]+a[3, 4]*b[1, 3]*b[1, 4]*b[2, 2]+a[4, 4]*b[1, 1]*b[2, 2]*b[3, 3]-a[4, 4]*b[1, 1]*b[2, 3]^2-a[4, 4]*b[1, 2]^2*b[3, 3]+2*a[4, 4]*b[1, 2]*b[1, 3]*b[2, 3]-a[4, 4]*b[1, 3]^2*b[2, 2]

(2)

NULL

Download anothr2DIssue.mw

is trivial. See the attached

#
# Initialize
#
  restart;
#
# Set parameters
#
  J:= 0.01: b:=0.1: K:= 0.01: R:=1: L:=1:
#
# Define ODEs
#
  eq1:=J*diff(theta(t),t,t)+b*diff(theta(t),t)=K*i(t):
  eq2:=L*diff(i(t),t)+R*i(t)=V-K*diff(theta(t),t):
#
# Define ICs
#
  ICs:= theta(0)=0, D(theta)(0) = 0, D(theta)(0) = 0, i(0) = 0:
#
# Obtain *exact* solution
#
  sol:=dsolve({eq1,eq2,ICs}):
#
# Evaluate exact solution for a few particular
# values of the parameter V
#
  vVals:=[1, 2, 5, 10]:
  for v in vVals do
      ans:=eval~(sol, V=v):
    #
    # plot i(t) versus t and theta(t) versus t
    #
      plot( [ rhs(ans[1]), rhs(ans[2])],
            t=0..10,
            color=[red,blue],
            title=typeset( "i(t) and theta(t) versus t for V=", v),
            titlefont=[time, bold, 20]
          );
    #
    # plot i(t) versus theta(t) over the same range
    #
      plot( [ rhs(ans[2]), rhs(ans[1]),
            t=0..10 ],
            title=typeset( "i(t) versus theta(t) for V=", v),
            titlefont=[time, bold, 20]
          );
  od;

{i(t) = -(5/46046)*(5*506^(1/2)+92)*exp((1/10)*(-55+2*506^(1/2))*t)*506^(1/2)-(5/46046)*(5*506^(1/2)-92)*exp(-(1/10)*(55+2*506^(1/2))*t)*506^(1/2)-(225/92092)*(5*506^(1/2)+92)*exp((1/10)*(-55+2*506^(1/2))*t)+(225/92092)*(5*506^(1/2)-92)*exp(-(1/10)*(55+2*506^(1/2))*t)+1000/1001, theta(t) = -(25/46046)*(5*506^(1/2)+92)*exp((1/10)*(-55+2*506^(1/2))*t)/(-11/2+(1/5)*506^(1/2))+(25/46046)*(5*506^(1/2)-92)*exp(-(1/10)*(55+2*506^(1/2))*t)/(-11/2-(1/5)*506^(1/2))+(100/1001)*t-10000/91091}

 

 

 

{i(t) = -(5/23023)*(5*506^(1/2)+92)*exp((1/10)*(-55+2*506^(1/2))*t)*506^(1/2)-(5/23023)*(5*506^(1/2)-92)*exp(-(1/10)*(55+2*506^(1/2))*t)*506^(1/2)-(225/46046)*(5*506^(1/2)+92)*exp((1/10)*(-55+2*506^(1/2))*t)+(225/46046)*(5*506^(1/2)-92)*exp(-(1/10)*(55+2*506^(1/2))*t)+2000/1001, theta(t) = -(25/23023)*(5*506^(1/2)+92)*exp((1/10)*(-55+2*506^(1/2))*t)/(-11/2+(1/5)*506^(1/2))+(25/23023)*(5*506^(1/2)-92)*exp(-(1/10)*(55+2*506^(1/2))*t)/(-11/2-(1/5)*506^(1/2))+(200/1001)*t-20000/91091}

 

 

 

{i(t) = -(25/46046)*(5*506^(1/2)+92)*exp((1/10)*(-55+2*506^(1/2))*t)*506^(1/2)-(25/46046)*(5*506^(1/2)-92)*exp(-(1/10)*(55+2*506^(1/2))*t)*506^(1/2)-(1125/92092)*(5*506^(1/2)+92)*exp((1/10)*(-55+2*506^(1/2))*t)+(1125/92092)*(5*506^(1/2)-92)*exp(-(1/10)*(55+2*506^(1/2))*t)+5000/1001, theta(t) = -(125/46046)*(5*506^(1/2)+92)*exp((1/10)*(-55+2*506^(1/2))*t)/(-11/2+(1/5)*506^(1/2))+(125/46046)*(5*506^(1/2)-92)*exp(-(1/10)*(55+2*506^(1/2))*t)/(-11/2-(1/5)*506^(1/2))+(500/1001)*t-50000/91091}

 

 

 

{i(t) = -(25/23023)*(5*506^(1/2)+92)*exp((1/10)*(-55+2*506^(1/2))*t)*506^(1/2)-(25/23023)*(5*506^(1/2)-92)*exp(-(1/10)*(55+2*506^(1/2))*t)*506^(1/2)-(1125/46046)*(5*506^(1/2)+92)*exp((1/10)*(-55+2*506^(1/2))*t)+(1125/46046)*(5*506^(1/2)-92)*exp(-(1/10)*(55+2*506^(1/2))*t)+10000/1001, theta(t) = -(125/23023)*(5*506^(1/2)+92)*exp((1/10)*(-55+2*506^(1/2))*t)/(-11/2+(1/5)*506^(1/2))+(125/23023)*(5*506^(1/2)-92)*exp(-(1/10)*(55+2*506^(1/2))*t)/(-11/2-(1/5)*506^(1/2))+(1000/1001)*t-100000/91091}

 

 

 

 

Download odeSol.mw

Now you *seem* to be suggesting that 'V' is not a parameter, but a function dependent on 't' - and somewhere you have a file which defines values of 'V' at particular values of  't'. If this is the case then the best(?) solution method would probably be to curveFit the data of V versus t, producing a piecewise function, and then solve the ODE system for the resultant  fitted function. Since you do not supply this fitting data (assuming that it actually is fitting data), then there is little anyone here can do to help

First 114 115 116 117 118 119 120 Last Page 116 of 207