## 6662 Reputation

10 years, 170 days

## Syntax?...

Try

seq(is(tm[i] < (1/6)*Diameter[rør][i]), i = 1 .. 17);

or

map(is, [seq(tm[i] < (1/6)*Diameter[rør][i], i = 1 .. 17)]);

## solve not Solve...

but this (still will not return a solution for x,y! Consider

A-B+x^y/y=0;
x^y-y=0

Now the second equation requires x^y=y. Make this substituion in the first equation to get A-B+y/y=0, ie A-B+1=0. In other words your equations are conssitent for any values of x ,y provided A=B-1

## 3D plots???...

If you actually want 3D plots, then you need to use DEplot3d().

Some possibilities are shown in the attached

dePlots.mw

## An alternate...

rlLopez response, ie

restart;
P := x + y + a*x^2 + b*x^3 + c*x*y + d*x^2*y + e*x*y^2 + y^2:
mtaylor(P,[x,y],3) - mtaylor(P,[x,y],2);

returns

a*x^2+c*x*y+y^2

when it should return

a*x^2+c*x*y+y^2+x+y

Note the last two entries in the above!

Something like

restart;
P := x + y + a*x^2 + b*x^3 + c*x*y + d*x^2*y + e*x*y^2 + y^2:
select( i->is(degree(i,x)+degree(i,y)<3), P);

returns

a*x^2+c*x*y+y^2+x+y

and is probably a better bet.

select/remove commands are very useful for this kind of exercise. For example one could achieve the same result by removing all terms with degree >=3 (rather than keeping all terms with degree<3) using

restart;
P := x + y + a*x^2 + b*x^3 + c*x*y + d*x^2*y + e*x*y^2 + y^2:
remove( i->is(degree(i,x)+degree(i,y)>=3), P);

## For loops not necessary?...

1. You could try reading the help page for  'for' by entering ?for at the Maple prompt
2. You could try reading the help page for  'if' by entering ?if at the Maple prompt
3. Given an inability to read help pages, you might consider the following
1. Maple allows the "block" assignment of contiguous entries in an indexable entity - so actually you do not need any 'for' loops at all.
2. It seems as if you indexable entity 'w' has zero-based indices (eg you refer to w[0,0]) nut all of your 'for' loops start at 1. This may (or may not) be deliberate

Bearing in mind the above (particularly item (3) ), you might want to consider the attached

nonLoops.mw

## Not exactly sure what you are trying to ...

return equations?

return assignments?

I don't get it!

Maybe something in the following will help?

returns.mw

## Not quite sure of the problem...

See the attached worksheet where I have used only the standard 'methods' returned by pdsolve().

I have been unnecessarily "verbose" in the attached, in the hope of clarity. This is probably(?) unnecessary but since I am not quite sure exactly what the issue is here - I can't be sure

pdeProb.mw

## Lots of ways to tidy up/shorten...

but you are going to have to work with me here. I can see all sorts of places whre this can be "tidied-up", but since I have no idea about your "ultimate objective" I'm going t have to go through this pretty much line by line.

I am not going to get all the way to the end of your code on a "first pass" - we start with the first few lines, and (hopefully) work on from there!

Stiffness:=Matrix(6,6):
Stiffness:=Matrix(6, 6, {(1, 1) = 20.4, (1, 2) = .537, (1, 3) = 1.01, (1, 4) = 0., (1, 5) = 0., (1, 6) = -0., (2, 1) = .537, (2, 2) = 1.59, (2, 3) = .73, (2, 4) = 0., (2, 5) = 0., (2, 6) = -0., (3, 1) = 1.01, (3, 2) = .73, (3, 3) = 2.86, (3, 4) = 0., (3, 5) = 0., (3, 6) = -0., (4, 1) = 0., (4, 2) = 0., (4, 3) = 0., (4, 4) = 1.5, (4, 5) = 0., (4, 6) = -0., (5, 1) = 0., (5, 2) = 0., (5, 3) = 0., (5, 4) = 0., (5, 5) = 2., (5, 6) = -0., (6, 1) = 0., (6, 2) = 0., (6, 3) = 0., (6, 4) = 0., (6, 5) = 0., (6, 6) = .8});

You don't have to "index" each entry separately. There are many ways to shorten Maple's matrix input: all of the shorter versions require about the same amount of typing, so I am just going to show one. The above is entirely equivalent to

Stiffness:=Matrix( 6,
6,
[  [  20.4,        .537,  1.01,  0.,   0.,  -0.   ],
[       .537,  1.59,      .73,  0.,   0.,  -0.   ],
[     1.01,      .73,    2.86,  0.,   0.,  -0.   ],
[     0.,       0.,         0.,     1.5,  0., -0   .],
[     0.,       0.,         0.,     0.,    2., -0.   ],
[     0.,       0.,         0.,     0.,    0.,    .8 ]
]
);

You may thing that the above code contains an excessive amount of indentation/spacing/whatever, but I write stuff this way because I find it much easier to read. If you want to write the above as

Stiffness:=Matrix( 6,6,[ [ 20.4,.537, 1.01, 0.,  0., -0.],[.537, 1.59,.73, 0., 0., -0.],[1.01, .73, 2.86, 0., 0., -0.],[ 0., 0., 0., 1.5, 0., -0.],[  0., 0., 0., 0., 2., -0.],[0., 0., 0., 0., 0., .8 ]] );

then that is absolutely fine with me! Either of the above solutions is waaaaay shorter than typing your original.

Next point is rotation matrices: you really, really do not have to type these explicitly, because given an axis and an angle, Maple will generate them for you ( you can check out the help for these by entering ?rotationmatrix at the Maple prompt), but basically all you need to know is the rotation angle, and the axis of rotation, so consider the following examples

with(Student[LinearAlgebra]):
R1a:=RotationMatrix(Pi/4, <1,0,0>); # rotation  Pi/4 about +ve x-axis

R1b:=RotationMatrix(Pi/4, <-1,0,0>); # rotation  Pi/4 about -ve x-axis
R1b:=RotationMatrix(-Pi/4, <1,0,0>); # rotation  -Pi/4 about +ve x-axis
R2:=RotationMatrix(Pi/4, <0,1,0>); # rotation  Pi/4 about +ve y-axis
R3:=RotationMatrix(Pi/4, <0,0,1>); # rotation  Pi/4 about +ve z-axis

So don't write ytour rotation matrices explicitly - so long as you know the angle, and the axis of rotation, then Maple will generate the matrices for you. Doesn't matter what the angel is or what the axis is, Maple will still produce the matrix, so for the following totally random angle, totally random axis, Maple will still generate the relevant matrix

Rx:=RotationMatrix(10003.754, <23.7,-15.8,17.1>);

Now you don't seem to want these rotation matrices - rather you want their transposes (no idea why!?), but then just "nest" the commands, in order to save typing, as in

with(Student[LinearAlgebra]):
T1:=Transpose(RotationMatrix(Pi/4, <1,0,0>)); # transpose of rotation  Pi/4 about +ve x-axis
T2:=Transpose(RotationMatrix(Pi/4, <0,1,0>)); # transpose of rotation  Pi/4 about +ve y-axis
R3:=Transpose(RotationMatrix(Pi/4, <0,0,1>)); # transpose of rotation  Pi/4 about +ve z-axis

Now I'd really like to shorten up the definition of your matrix R. I'm assuming that there is some kind of function/pattern, because if I could work out the general rule for how R[i,j] depended on the entries of S5, then I could make this definition much neater. But I've stared at this at your definition for a while and I can't "see" the pattern/function - so if you want this in a "short/clever" way, you are going to hav to tell me what the "pattern/function" actually is!

## If I understand the requirement...

The attached solves three different ODE systems, and plots output

First system uses a[1], b[1], c[1], d[1].
Second system uses a[2], b[2], c[2], d[2].
Third system uses a[3], b[3], c[3], d[3].

ode.mw

## Wrong argument type...

c:=[0,1];

therefore 'c' is a list. This is used with

element(s,c);

but arguments to the procedure 'element' are checked with

......proc(s::list(set), c::array(1, nonnegint))

so the second argument must be an array. You are passing a list so the parameter check will fail.

The following will work

s:=[{alpha,beta,gamma},{x,y}];
c:=array([0,1]);
element := proc(s::list(set), c::array(1..nonnegint))
local i, j;
for i to nops(s) do
c[i] := c[i] + 1;
if c[i] <= nops(s[i]) then
return [seq(s[j][c[j]], j=1 .. nops(s))];
end if;
c[i] := 1;
end do;
c[1]:=0;
FAIL;
end proc;
element(s,c);

but you should be aware that array() has been deprecated for a loonnngggg time. It may be used in the book to which you refer, but if you are using a reasonably up-to-date Maple version then such use *may* have issues

## Depends!...

If you just want to know the answer, then you can use the inbuilt function NumberTheory:-ModularLog(). In the example you provide

a:=3:
b:=64:
n:=137:
NumberTheory:-ModularLog(b,a,n);

returns 60, as expected. (note the somewhat unintuitive ordering of arguments for this function - use ?ModularLog to check the help page for clarification).

If you actually do want to write the code yourself (eg as a learning exercise) then asking someone her to write it for you would seem to defeat the object?

## Well...

I'm certain that you have some pretty significant syntax errors, but I don't really think these should have cause a kernel problem.

I am guessing that you wish to successively compute the indexable quantities X[i], Y[i]. Note that (in Maple), square brackets '[]' are used for accessing indexable quantities. Round brackets '()' are useed for simple term grouping, or to supply arguments to functions.

With this guess in mind, th following code seems to do what you wish, with no problems

m := 2;
X[0] := 14;
Y[0] := 18;
a := 1;
b := 1;
c := .1;
d := 1;
alpha := 1;
for k from 0 to m do
X[k+1] := GAMMA(k*alpha+1)*(a*X[k]-b*(add(X[s]*Y[k-s], s = 0 .. k)))/GAMMA(k*alpha+1+1);
Y[k+1] := GAMMA(k*alpha+1)*(-c*Y[k]+d*(add(X[s]*Y[k-s], s = 0 .. k)))/GAMMA(k*alpha+1+1):
end do;

## Incorrect implementation...

If you are evaluatiing the integral of f() over the range 0..1, why are you using function values such as f(2), f(3), and f(4) in your expressions?

You should have something like

f := proc (x) options operator, arrow; cos(6*exp(-x)) end proc;
S := evalf(int(f(x), x = 0 .. 1));
S1 := evalf((1/6)*(1+0)*(f(0)+4*f(1/2)+f(1)));
S2 := evalf((1/12)*(1+0)*(f(0)+4*f(1/4)+2*f(2/4)+4*f(3/4)+f(1)));

## Why complicate things?...

I'm probably going to make myself really unpopular here - but why bother using Maple at all????

If the data already exist in EXCEL, then use EXCEL to provide the plot and compute the numeric integral, because

1. It is trivial to generate the required plot in Excel
2. It is trivial to perform the required numerical integration in Excel. Assume that the 'x-values' are in column 'A' and the y-values are in column B, then construct the i-th entry in column C as (A[i]-A[i-1])*(B[i]+B[i-1])/2, which translates as bin-width multiplied by average bin value. Then just add the entries in column C using EXCEL's SUM() function, and, hey presto, you have just implemented Simpson's rule

Who needs Maple?

When in doubt, cheat! Use two cylinders, one with a +ve height and one with a -ve height, as in

with(plots):  with(plottools):
Sph := sphere([0, 0, 0], 10,   color=gold, transparency=0.4):
Cyls1 := display([seq(cylinder([0,0,0], h, sqrt(100-h^2), color=red, strips=50),
h=0..10, 0.2)], insequence):
Cyls2 := display([seq(cylinder([0,0,0], h, -sqrt(100-h^2), color=red, strips=50),
h=0..10, 0.2)], insequence):
display([Sph, Cyls1, Cyls2], style=surface, lightmodel=light1, axes=none);

 First 103 104 105 106 107 108 109 Last Page 105 of 137
﻿