tomleslie

6814 Reputation

17 Badges

10 years, 226 days

MaplePrimes Activity


These are answers submitted by tomleslie

p1 := pds:-plot(x = .16, t = 0 .. 10, numpoints = 10000, color = red);
p2 := pds:-plot(x = .21, t = 0 .. 10, numpoints = 10000, color = blue);
plots:-display([p1, p2]);

Obviusly you may want a different range for t, or more/fewer point for "smoothness"

It seems that you have to define the foci option using 'points' rather than a simple list of values, as in

restart;
with(geometry):
point(A, 0,1);
point(B, 4,1);
ellipse(e1,['foci'=[A,B], 'MajorAxis' = 8],[x,y]);
detail(e1);

Manual does say (my emphasis)

foi is a list of two points which are the foci of the ellipse

 

  1. It is perfectly possible for a procedure to update 'global' values - although whether you regard this as 'acceptable' programmng practice will get you into deep "philosophical" discussion. There are people who regard the use of 'global' parameters as completely unacceptable - makes code difficult to 'comparementalise', 're-use' and debug, etc, etc, etc. Personally I prefer to avold the use of global variables, but I don't get too "fundamentatlist" over it. I do recommend using a 'global' statement within a procedure, whenever global values in the calling code are necessary. This is never strictly required but serves as a reminder, that the correct execution of the procedure may depend on the correct definition of variables outwith the procedure
  2. When returning values from a procedure, the default is to return the output of the last statement executed. However if you have multiple conditional statements (or other similar structures) it can be difficult to determine where the return points actually are (especially a week or so after you have written the code!). For this reason, I tend to use the explicit 'return' command. So far as I am aware this is never absolutely necessary. On the other hand if I look at a procedure with half a dozen 'return' statements then I know that there are exactly half a dozen way for this procedure to exit. This aids debug/reuse (at least for me)
  3. The argument(s) for a return statement can be pretty much anything - eg a single value (which may be a list of multiple values) or a sequence of multiple values. In the case of the latter, the only thing you have to ensure is that the calling statement contains enough arguments for the outputs to be assigned. For example consider the "toy" example

  powers:= proc(x)
                       return x, x^2, x^3:
                end proc;

          along with the calling sequence

  a,b,c:=powers(2);

          Then 'a' will be assigned to 2, 'b' to 4 and 'c' to 8.

          An alternative would be to write the procedure to return a single list, as in

          powers:= proc(x)
                               return [x, x^2, x^3]:
                        end proc;

          With the calling sequence

          a:=powers(2);

          In which case 'a' is the list [2, 4, 8] and you can subsequently access values as a[1], a[2] etc.

Determining the 'best' way to return multiple values from a procedure is never an 'absolute' - it depends on subjective criteria such as readability, debuggability, reusability etc

I think it is easier to see what is goiing on if you plot, B[1](t), B[2](t), and C(T) separately as functions of t. You can see that B[1]() asymtotes to about 0.29, B2() asymptotes to about 0.17 and C(T) asymptotes to about 100. This makes the output of your DEPlot3D command easier (for me at least to interpret).

In one of your equations you had B[1], rather than B[1](t) - I have corrected this. Check out the following

restart;
Model := [diff(B[1](t), t) = k[a1]*C(t)*(R-B[1](t)-B[2](t))-k[d1]*B[1](t),
          diff(B[2](t), t) = k[a2]*C(t)*(R-B[1](t)-B[2](t))-k[d2]*B[2](t),
          diff(C(t), t) = (-(k[a1]+k[a2])*C(t)*(R-B[1](t)-B[2](t))+k[d1]*B[1](t)+k[d2]*B[2](t)+k[m]*((I)(t)-C(t)))/h
         ];
DissMod := subs((I)(t) = 0, Model);
AssMod := subs((I)(t) = C[T], Model);


Pars := [k[a1] = 6*10^(-4), k[d1] = 7*10^(-3), k[a2] = 5*10^(-4), k[d2] = 10^(-2), R = .5, k[m] = 10^(-4), C[T] = 100, h = 10^(-6)];

DETools:-DEplot3d(subs(Pars, AssMod), [B[1](t), B[2](t), C(t)], t = 0 .. 1000, number = 3, B[1] = 0 .. .5, B[2] = 0 .. .5, [[B[1](0) = 0, B[2](0) = 0, C(0) = 0]], scene = [B[1](t), B[2](t), C(t)], maxstep = .1, maxfun = 0);
desys:=[subs(Pars, AssMod)[],B[1](0) = 0, B[2](0) = 0, C(0) = 0];
sols:=dsolve( desys, numeric, maxfun=0)
plots:-odeplot(sols,[t, B[1](t)], t=1..1000);
plots:-odeplot(sols,[t, B[2](t)], t=1..1000);
plots:-odeplot(sols,[t, C(t)], t=1..1000);

Try this

restart:
Pars := [k[a1] = 6*10^(-4), k[d1] = 7*10^(-3), k[a2] = 5*10^(-4), k[d2] = 10^(-2), R = .5, k[m] = 10^(-4), C[T] = 100, h = 10^(-6)];
eqns:=[C = -(k[d2]*B[2]+C[T]*k[m]+k[d1]*B[1])/((B[1]+B[2]-R)*k[a1]+(B[1]+B[2]-R)*k[a2]-k[m]),

       C = k[d1]*B[1]/(k[a1]*(R-B[1]-B[2]))
      ];
eqns2:=eval(eqns, Pars);
p1:=plots:-implicitplot3d(eqns2[1], B[1]=0..0.5, B[2]=0..0.5, C=0..100, style=patchnogrid, color=red, grid=[50,50,50], transparency=0.5):
p2:=plots:-implicitplot3d(eqns2[2], B[1]=0..0.5, B[2]=0..0.5, C=0..100, style=patchnogrid, color=blue, grid=[50,50,50], transparency=0.5):
p3:=plots:-intersectplot(eqns2[1],eqns2[2], B[1]=0..0.5, B[2]=0..0.5, C=0..100, thickness=6,color=black):
plots:-display([p1,p2,p3])

The following code provides a partial answer

restart:
Pars := [k[a1] = 6*10^(-4), k[d1] = 7*10^(-3), k[a2] = 5*10^(-4), k[d2] = 10^(-2), R = .5, k[m] = 10^(-4), C[T] = 100, h = 10^(-6)];
eqns:=[C = -(k[d2]*B[2]+I*k[m]+k[d1]*B[1])/((B[1]+B[2]-R)*k[a1]+(B[1]+B[2]-R)*k[a2]-k[m]),

       C = k[d1]*B[1]/(k[a1]*(R-B[1]-B[2]))
      ];
eqns2:=eval(eqns, Pars);
plots:-implicitplot3d(eqns2[1], B[1]=0..0.5, B[2]=0..0.5, C=0..100);
plots:-implicitplot3d(eqns2[2], B[1]=0..0.5, B[2]=0..0.5, C=0..100);

The reason that nothing is plotted for eqns2[1] is that your first equation contains 'I' which will be interpreted as the square root of -1. Is that intentional?

then try

T:=1..18;
TB:={1,2,3,4,7,8,15,18};
DD:={5,7,11,12,14,15,17};
e:=1..9;
K:=1..17;
add( add( add( `if`( j=i, 0, x[i,j,k]+x[j,i,k] ), i in TB), j in TB), k in DD);
add( add( add( `if`( i=2*j-1, 0, x[2*j-1,i,k] ), i in T), j in e), k in K);

You have two dependent variables - U(r,t) and eta(r,t)

You have one PDE.

Which part of

"Error,   (in pdsolve/numeric/process_PDEs)  number of dependent variables and number of PDE must be the same"

don't you understand?

I don't really see much wrong with the 2d-output, once you learn to recognise the script capital 'I' which Maple uses for imaginary part.

One thing you can do is just select (a portion of the) output  - standard mouse click-and-drag. then copy it (ctrl-c, ctrl-v) to a Maple prompt. This will 'magically' convert it to a form which looks very like the output of lprint.

One 'advantage' of this method is that you can select a small piece of a more complex expression

Just becuase there's always more than one way to it!

f1:=1/2*(-8*R*d1^2*r^2*C+10*d1*r^2*C*R+5*d1*r^3*C+2*r*L*d1^2-2*C*r^3+2*R*L*d1^2-R*L*d1^3-r*L*d1^3-4*C*r^2*R+2*R*d1^3*r^2*C-4*r^3*d1^2*C+r^3*d1^3*C+sqrt(26*r^6*d1^4*C^2+41*r^6*d1^2*C^2-44*r^6*d1^3*C^2-20*C^2*r^6*d1+16*C^2*r^5*R-16*C*r^4*L-176*r^5*d1^3*C^2*R+164*r^5*d1^2*C^2*R-74*r^4*d1^4*C*L+136*r^4*d1^3*C*L-136*r^4*d1^2*C*L-80*C^2*r^5*d1*R+72*C*r^4*L*d1-64*C*r^3*R*L+104*R^2*d1^4*r^4*C^2-176*R^2*d1^3*r^4*C^2+164*R^2*d1^2*r^4*C^2-8*r^6*d1^5*C^2+r^2*L^2*d1^6-4*R^2*L^2*d1^5+104*r^5*d1^4*C^2*R+40*r*L*R^3*d1^5*C-72*r*L*R^3*d1^4*C+56*r*L*R^3*d1^3*C-16*r*L*R^3*d1^2*C+R^2*L^2*d1^6+20*r^4*L*C*d1^5-32*r^4*d1^5*C^2*R^2+2*R*L^2*d1^6*r-2*r^4*L*d1^6*C+4*R^2*d1^6*r^4*C^2+4*R*d1^6*r^5*C^2-306*r^3*d1^4*C*R*L+548*r^3*d1^3*C*L*R-544*r^3*d1^2*C*R*L+288*C*r^3*L*d1*R+16*C^2*r^4*R^2+4*R^2*L^2*d1^4-16*R^2*L*d1^6*r^2*C-10*R*L*d1^6*r^3*C+r^6*d1^6*C^2-32*r^5*d1^5*C^2*R-4*r^2*d1^5*L^2-352*R^2*d1^4*r^2*C*L+580*R^2*d1^3*r^2*C*L-552*R^2*d1^2*r^2*C*L-80*d1*r^4*C^2*R^2-8*R^3*d1^6*L*C*r+88*r^3*L*C*d1^5*R+116*r^2*L*R^2*d1^5*C+4*C^2*r^6-8*r*R*L^2*d1^5+288*d1*r^2*C*R^2*L-64*C*r^2*R^2*L+8*r*L^2*d1^4*R+4*r^2*L^2*d1^4)^(1/2))/(-3*r^2*d1*L*C-6*R*d1*L*C*r+2*L*C*r^2+r^2*d1^2*L*C+4*L*C*r*R+2*R*d1^2*L*C*r);
#
# The expression form is
#
#  k*(A+B)
#
# where 'k' is a ratio, A is a sum of terms
# and B is a fourth root, these can be extracted
# as
#
  k:= op(1,f1)*op(3,f1);
  A:= add(op([2,1..-2],f1));
  B:= op([2,-1],f1);

Well if I fix syntax errors and typos using more-or-less guesswork (some of which) may be wrong, I can come with the attached worksheet

badplot.mw

Suggest you read the comments in this to determine whether or not my guesses were correct.

This takes about a minute to execute on my machine, and the final plots are not really very interesting :-(

I didn't really understand your question, but luckily the Wikipedai page at

https://en.wikipedia.org/wiki/Four-bar_linkage

seems to have a pretty clear description.

The attached worksheet implements the 'Classification' section of that Wikipedia entry. I suggest you check it very carefully, becuase with this many conditions, it would be very easy for typos to occur

Grashof.mw

Maple can only numerically solve PDEs with two (or fewer) independent variables. You have three.

The attached will compute the solution over the range of time specified by tRange, and steps of tStep. Since I have no idea what these values are I just used

tRange:=0..10

tStep:=0.1

You can change these settings in the attached to anything you want and everything should still work.

You will also have to adjust the fileName in the

ExcelTools:-Export()

command to something appropriate for your machine

odeToExcel.mw

If you change the colon at the end of the line

Eff:=[seq([k1z[i],alpha0[i]],i=1..t)]:

to a semicolon, you will see that each entry in Eff, has three components - you should only have two! See below

Eff := [[-1.566422551*10^20, 1.566422551*10^20, 30[1]], [-1.566422551*10^20, 1.566422551*10^20, 30[2]], [-1.566422551*10^20, 1.566422551*10^20, 30[3]], [-1.566422551*10^20, 1.566422551*10^20, 30[4]], [-1.566422551*10^20, 1.566422551*10^20, 30[5]], [-1.566422551*10^20, 1.566422551*10^20, 30[6]]]

No idea what you mean by 30[1], 30[2], 30[3] etc

First 116 117 118 119 120 121 122 Last Page 118 of 140