tomleslie

6232 Reputation

17 Badges

10 years, 102 days

MaplePrimes Activity


These are answers submitted by tomleslie

See the attached

  restart:
  P:= 12: M:= 6: q:= 2: BC:= 2: Q:= q*BC: CN:= (1/2)*BC:
  NB:= CN: AK:= 1: KC:= AK*evalf(cot((1/6)*Pi)): KN:= KC+CN: BK:= NB+KN:
  eq1:= x1 = (P*evalf(cos((1/6)*Pi))-Q*sin((1/6)*Pi))/sin((1/6)*Pi):
  eq2:= x2 = AK*P+BK*x1+KN*Q+M:
  sol:= solve( {eq1, eq2},
               {x1, x2}
             );
  B:= eval
       ( Vector
         ( 2,
           [ (P*evalf(cos((1/6)*Pi))-Q*sin((1/6)*Pi))/sin((1/6)*Pi),
              AK*P+BK*x1+KN*Q+M
           ]
         ),
         sol
       );
  A:= Matrix( 2, 2,
               [ [1, 0],
                 [0, 1]
               ]
            );
  C:= 1/A;
  x:= C.B;

sol := {x1 = 16.78460970, x2 = 91.56921942}

 

Vector(2, {(1) = 16.78460970, (2) = 91.56921942})

 

Matrix(2, 2, {(1, 1) = 1, (1, 2) = 0, (2, 1) = 0, (2, 2) = 1})

 

Matrix(2, 2, {(1, 1) = 1, (1, 2) = 0, (2, 1) = 0, (2, 2) = 1})

 

Vector[column](%id = 18446744074403721814)

(1)

 


 

Download assn.mw

there are some syntax problems in your original code, and at least one logical error. The attached fixes these - although it is still a "complicated" way to perform fsolve(x^-2).

Anyhow, for what it is worth - check out the attached

restart

E := 1.0*10^(-5); S := 1.0*10^(-5); f := proc (x) options operator, arrow; x^2-2 end proc; a := 1; b := 2

while `or`(b-a >= S, `and`(abs(f(a)) >= E, abs(f(b)) >= E)) do if f(x[a])-f(x[b]) = 0 then printf("Method  fail\n"); break end if; c := b-f(b)*(b-a)/(f(b)-f(a)); if abs(f(c)) < E then break elif f(a)*f(c) < 0 then b := c else a := c end if end do

4/3

 

7/5

 

24/17

 

41/29

 

140/99

 

239/169

 

816/577

(1)

evalf(c); evalf(abs(f(c)))

1.414211438

 

0.6007286839e-5

(2)

 


 

Download rtFind.mw

is given in the attached.

  restart:
  with(LinearAlgebra):
#
# OP should change fpath to whatever is appropriate
# for his/her machine
#
  fpath:="C:/Users/TomLeslie/Desktop/":
  B:=Matrix(2,2, [[6+7*I, 8+5*I],[I,5]]);

Matrix(2, 2, {(1, 1) = 6+7*I, (1, 2) = 8+5*I, (2, 1) = I, (2, 2) = 5})

(1)

  B.B;

Matrix(2, 2, {(1, 1) = -18+92*I, (1, 2) = 53+111*I, (2, 1) = -7+11*I, (2, 2) = 20+8*I})

(2)

  ExportMatrix( cat(fpath, "test.txt"), B);

16

(3)

  A:=parse~(ImportMatrix(cat(fpath, "test.txt"), datatype=string));

Matrix(2, 2, {(1, 1) = 6+7*I, (1, 2) = 8+5*I, (2, 1) = I, (2, 2) = 5})

(4)

A.A

Matrix(2, 2, {(1, 1) = -18+92*I, (1, 2) = 53+111*I, (2, 1) = -7+11*I, (2, 2) = 20+8*I})

(5)

 


 

Download impMat.mw

 

" Maple formerly accepted " - which version? when?

Because in the command

rule1 := forall(string(y), TD(y) = D(y)):

the function string() will do absolutley nothing other than return unevaluated (unless you have define a function/procedure called 'string' which you are not sharing with us).

Now you might(?) be referring to the Maple function String() (note the capitalisation) - but I can't reaaly see any way the output of this command would work with  a 'forall()' construct either:. The command 'String()' will pretty much convert anything it is given into a single string which sort of defeats the purpose of the forall() command - which expects its first argument to be a 'name' or list of names, not a single string.

And don't even get me started on the second argument (aka predicate) provided to the forall() command: again you  might want to consider providing whatever the function/procedure TD() actually is, as well as the contents of the name 'y'. The D(y) part of this predicate is possibly(?) OK provided that it is an expression containing a single unknown

 

The read() command will 'read' either

  1. Maple internal format files (assuming the file extension is '.m') or
  2. Maple language format (assuming the file extension is '.mpl' - which is more-or-less a plain text fomet), or
  3. If the file extension is anything else, will try to make a "good guess" on what you want

The simplest way to solve your problem is if you upload the file to be read using the big green up-arrow in the Mapleprimes toolbar.

Then someone here will fihgure out how best to read it.

Maple now has two "modes" (Worksheet and Document) and two "input methods" (1D input and 2D input) - so overall you have four choices of "user interface".

Two of these are commonly(?) used - namely

Document Mode +2D-Input
Worksheet Mode+1D-input

Each of these two possibilities have pluses and minuses, (and you can start a small war on this site by claiming that one is "better" than the other)

Maple functionality is essentially unaffected by which "mode" and which "input format" you select. The only things which change are the appearance of your worksheets,and some details about how you enter Maple commands.

If you used Maple "years ago" then you were probably(?) using Worksheet Mode +1D-input. Nothing to stop you setting this up as your current default. (This is how I use generally use Maple). You can set this using menu entries

Tools-->Options->Display->Input Display: - make sure this is set to "Maple Notation" rather than "2D Math Notation"

Tools->Options->Interface->Default interface for new worksheets: - make sure this is set to "Worksheet" rather than "Document"

Then use "Apply globally" on the bottom of the Tools->Options pop-up

 

For reasons which escape me, the pdsolve() command syntax for solving pdes analytically and numerically is slightly different. (I personally keep being caught out by this, and it is really annoying!).

The syntax for analytic solutions is that the pdes+bcs/ics are given as a single set/list as in

pdsolve( [PDEs, BCs/ICs], ...some options)

whereas the syntax for solving pdes numerically is that the pdes ans ics are given as two separate sets/lists as in

pdsolve( [PDEs], [BCs/ICs], numeric ...some options)

Note that the syntax for ODEs is "consistent", because for analytic problems, it is

dsolve( [ODEs, BCs/ICs], ...some options)

and for numeric solutions, it is

dsolve( [ODEs, BCs/ICs], numeric ...some options)

So the pdsove/numeric case is a bit of an "oddity".

However, even if you get the syntax correct, the Maple limitation described by rlopez kicks in - but at least you will get the somewhat "more informative" error message

Error, (in pdsolve/numeric) unable to handle elliptic PDEs

 

See the attached

restart;
with(GraphTheory):
graphsof4 := NonIsomorphicGraphs(4, output = graphs, outputform = graph):
DrawGraph(graphsof4[1]);
ChromaticNumber(UnderlyingGraph(graphsof4[1]));

 

1

(1)

restart;
with(GraphTheory):
g1:=Graph(4):
DrawGraph(g1);
ChromaticNumber(g1);

 

1

(2)

 


 

Download grph1.mw

A quick check for 'mm' files shows that there are at least three possible types of files which commonly use this extension - which one are you referring to?

As far as I know, none of these can be opened using Maple

Filetypes wihch are supported by Maple can be seen by typing ?formats at the command prompt

 

to check if you had uploaded a complete, executable, worksheet using the big green up-arrow in the Mapleprimes toolbar.

In the absence of this information I have constructed a "toy" example in the attached, whihc shows that although three matrices may 'look' the same when prettyprinted as output, they are in fact different

You can probably check your own case by using the elementwise 'whattype' command - otherwise upload the complete worksheet

  restart:
  a:=Matrix([1,2]): b:=Matrix([3,4]):
  c:=Vector[row]([1,2]):d:=Vector[row]([3,4]):
  e:=[1,2]: f:=[3,4]:
  M1:=Matrix(1,2):
  M1[1,1]:=a:M1[1,2]:=b:
  M2:=Matrix(1,2):
  M2[1,1]:=c:M2[1,2]:=d:
  M3:=Matrix(1,2):
  M3[1,1]:=e:M3[1,2]:=f:
  M1; M2; M3;

Vector[row](2, {(1) = Vector[row](2, {(1) = 1, (2) = 2}), (2) = Vector[row](2, {(1) = 3, (2) = 4})})

 

Vector[row](2, {(1) = Vector[row](2, {(1) = 1, (2) = 2}), (2) = Vector[row](2, {(1) = 3, (2) = 4})})

 

Matrix(%id = 18446744074332734158)

(1)

#
# Are these matrices equal? No!
#
  LinearAlgebra:-Equal(M1,M2);
  LinearAlgebra:-Equal(M1,M3);
  LinearAlgebra:-Equal(M2,M3);
#
# Quick way to check
#
  whattype~(M1);
  whattype~(M2);
  whattype~(M3);

false

 

false

 

false

 

Vector[row](2, {(1) = Matrix, (2) = Matrix})

 

Vector[row](2, {(1) = Vector[row], (2) = Vector[row]})

 

Matrix(%id = 18446744074385765190)

(2)

 


 

Download matProb.mw

to do this, one of which
 

  restart;
  with(plots):
  p1:=plot( 1,
            theta=0..2*Pi,
            color=grey,
            coords=polar,
            axes=none,
            thickness=3
          ):
  animate( pointplot,
           [ [1,theta],
             coords=polar,
             symbol=solidcircle,
             symbolsize=30,
             color=red,
             axes=none
           ],
           theta=0..2*Pi,
           trace=40,
           frames=40,
           paraminfo=false,
           background=p1
         );

 

 

 


 

Download anim.mw

is shown in the attached

 

 

You need to supply the name of the dependent variable (ie 'y(t)'), as well as a range for the independent variable ('t'). See the att

  restart;
  with(DEtools):
  DEplot( diff(y(t), t$2)-3*(diff(y(t), t))+2*y(t) = exp(t),
          y(t),
          t=0..1,
          [[y(0) = 0, (D(y))(0) = 2]],
          stepsize = .1,
          linecolor = black,
          thickness = 2
        );

 

 


 

Download deplt.mw

ached

 

you are trying to achieve, but maybe(?) something in the attached will help.

NB the final "really pretty" table does not render on this site, but it does in the actua worksheet - which you will have to download to verify

NULL

 

Example: Verifying Inverse Functions Numerically

 

"ex17f6(x):=(x-5)/(2):"

"ex17g6(x):=2 x+5:"

y3:

ex17f6(ex17g6(x))

x

(1.1)

y4:

ex17g6(ex17f6(x))

x

(1.2)

````

 

Table 1: Table of Values

x

x

(1.3)

y3

y4

-2

-2

(1.4)

-2

-2

(1.5)

-2

-2

(1.6)

-1

-1

(1.7)

-1

-1

(1.8)

-1

-1

(1.9)

0

0

(1.10)

0

0

(1.11)

0

0

(1.12)

1

1

(1.13)

1

1

(1.14)

1

1

(1.15)

2

2

(1.16)

2

2

(1.17)

2

2

(1.18)

3

3

(1.19)

3

3

(1.20)

3

3

(1.21)

4

4

(1.22)

4

4

(1.23)

4

4

(1.24)

 

``

#
# If you just want to know the results
# then this will suffice
#
  ex17g6~(ex17f6~([$-2..5]));
  ex17f6~(ex17g6~([$-2..5]))

[-2, -1, 0, 1, 2, 3, 4, 5]

 

[-2, -1, 0, 1, 2, 3, 4, 5]

(1.25)

#
# On the other hand if you want to make
# the output look "pretty", then you could
# use
#
  DF:=DataFrame( < ex17g6~(ex17f6~(<$-2..5>)) | ex17f6~(ex17g6~(<$-2..5>)) >,
               columns=[y3,y4],
               rows=[$-2..5]
             );
#
# Or if you are desperate to have the output
# look even "prettier" then maybe this will
# help
#
  Tabulate(DF, width=50):

DataFrame(Matrix(8, 2, {(1, 1) = -2, (1, 2) = -2, (2, 1) = -1, (2, 2) = -1, (3, 1) = 0, (3, 2) = 0, (4, 1) = 1, (4, 2) = 1, (5, 1) = 2, (5, 2) = 2, (6, 1) = 3, (6, 2) = 3, (7, 1) = 4, (7, 2) = 4, (8, 1) = 5, (8, 2) = 5}), rows = [-2, -1, 0, 1, 2, 3, 4, 5], columns = [y3, y4])

(1.26)

 


 

Download dataTab.mw

as in the attached

f:=(x,y)->sin(x)*cos(y);
g:=(x,y)->sin(y)*cos(x);
v:=unapply( combine((f-g)(x,y), trig), [x,y]);

proc (x, y) options operator, arrow; sin(x)*cos(y) end proc

 

proc (x, y) options operator, arrow; sin(y)*cos(x) end proc

 

proc (x, y) options operator, arrow; sin(x-y) end proc

(1)

 

Download combFunc.mw

 

I fixed a lot of syntax errors - mainly

  1. consistent use of subscripts eg alpha[1] and alpha__1 may "look" the same inboth 2-D input and pretty-printed output, but represent two completely differetn quantities. I have change all of your subscripted variables to use inert subscripts (ie the 'name__number' approach
  2. bcs and ics have to use 'D' operator notation.

I didn't understand the initial conditions which use C(0,x)=C0(x) and then C(0)=13.0 so in the attached I have used C(0,,x)=13.0. Similar problem/solution with B(0,x), so check these ICS carefully

With these changes I get the attached - and the function B(t,x) doesn't seem to do anything interesting.

restart

`&sigma;__1` := .1*10^(-5)`&alpha;__1` := 3.0k__1 := 1.1k__2 := 0.1e-1`&sigma;__2` := .1*10^(-5)`&alpha;__2` := 4.0k__3 := 0.1e-1k__4 := .12`&beta;__1` := .2`&beta;__2` := 0.2e-1

0.1000000000e-5

 

3.0

 

1.1

 

0.1e-1

 

0.1000000000e-5

 

4.0

 

0.1e-1

 

.12

 

.2

 

0.2e-1

(1)

pdes := [diff(C(t, x), t) = `&sigma;__1`*(diff(C(t, x), x, x))+`&alpha;__1`*C(t, x)^k__1+`&alpha;__1`*C(t, x)^k__2*B(t, x)^k__3-`&beta;__1`*C(t, x), diff(B(t, x), t) = `&sigma;__2`*(diff(B(t, x), x, x))+`&alpha;__2`*B(t, x)^k__3+`&alpha;__2`*C(t, x)^k__2*B(t, x)^k__4-`&beta;__2`*B(t, x)]

[diff(C(t, x), t) = 0.1000000000e-5*(diff(diff(C(t, x), x), x))+3.0*C(t, x)^1.1+3.0*C(t, x)^0.1e-1*B(t, x)^0.1e-1-.2*C(t, x), diff(B(t, x), t) = 0.1000000000e-5*(diff(diff(B(t, x), x), x))+4.0*B(t, x)^0.1e-1+4.0*C(t, x)^0.1e-1*B(t, x)^.12-0.2e-1*B(t, x)]

(2)

bcs := [(D[2](C))(t, 0) = 0, (D[2](C))(t, 1) = 0, (D[2](B))(t, 0) = 0, (D[2](B))(t, 1) = 0, C(0, x) = 13.0, B(0, x) = 300]

[(D[2](C))(t, 0) = 0, (D[2](C))(t, 1) = 0, (D[2](B))(t, 0) = 0, (D[2](B))(t, 1) = 0, C(0, x) = 13.0, B(0, x) = 300]

(3)

sol := pdsolve(pdes, bcs, numeric)

_m686543712

(4)

sol:-plot3d([C(t, x), B(t, x)], t = 0 .. 1, x = 0 .. 1)

 

 

 


 

Download pde_prob.mw

1 2 3 4 5 6 7 Last Page 2 of 131