Robert Israel

6577 Reputation

21 Badges

18 years, 211 days
University of British Columbia
Associate Professor Emeritus
North York, Ontario, Canada

MaplePrimes Activity


These are answers submitted by Robert Israel

Apparently not: e.g.:

> PDE:= diff(u(x,t),t) = diff(u(x,t),x$2);
   IBC:= {u(x,0)= 1, u(0,t) = I, u(1,t) = 0};
   pdsolve(PDE,IBC, u(x,t), numeric);

Error, (in intrep/StatSeq) too many levels of recursion

However, you could use a system of two PDE's, one for the real part and one for the imaginary part.

> PDE:= {diff(ur(x,t),t) = diff(ur(x,t),x$2), diff(ui(x,t),t) = diff(ui(x,t),x$2)};
   IBC:= {ur(x,0)= 1, ui(x,0) = 0, ur(0,t) = 0, ui(0,t) = 1, ur(1,t) = 0, ui(1,t)=0};
   pdsolve(PDE, IBC, {ur(x,t), ui(x,t)}, numeric);

 

 

The obvious way would be to get all k x k submatrices, and take the determinant of each.  Do you really want all binomial(n,k)^2 minors of that size?  You could do something like this, if A is your Matrix:
 

> with(LinearAlgebra): 
  S:= combinat[choose](n, k);
  seq(seq(Determinant(SubMatrix(A, r, c)), r = S), c = S);

If you're using Sylvester's Criterion for positive definiteness, you only need to check the principal minors.  Then it would be
 

> seq(Determinant(SubMatrix(A, 1..k, 1..k)), k=1..n);


 

 

For plotting the points you can use plot3d.  For plotting a surface through these points, if the points form a rectangular grid (i.e. in rows and columns with the same number of points in each column), you can use surfdata.  For example, consider the following data (forming 3 rows and 4 columns) which might be in a file "c:\test\data.txt":

85 21 114
71 39 96
49 53 92
21 61 100
161 39 49
134 74 35
92 100 32
40 116 37
236 57 21
196 108 13
135 147 11
59 170 14
 

Read in the data, with 3 numbers per line

> M := readdata("c:/test/data.txt", 3);

Plot the points (and save the plot):

> with(plots):
  pointplot3d(M, colour=black, symbol=circle);
  P1:= %:

Put it in an Array, and plot a surface with contours.

> A:= Array(1..4,1..3,1..3,(i,j,k) -> M[i+4*(j-1),k],datatype=float[8]);
  surfdata(A, style=patchcontour);
     P2:= %:

Show the two plots together, with some axes.

> display([P1,P2], axes=frame, tickmarks=[5,5,5]);

 

 

Streamlines are the trajectories of the system of differential equations corresponding to the vector field.  You might use
DEplot in the DEtools package for a 2-dimensional vector field, or DEplot3d for a 3-dimensional one.

You might try optimize in the codegen package.

AFAIK there is no such error as "undetermined loop".  Show us the actual code and we'll be able to find your error.  Or at least copy the actual error message.

Which do you want to do, unassign the values or set them to 0?  To unassign them, the simplest way is

> unassign(K);

To set them all to 0,

> for i from 0 to 1000 do K[i]:= 0 end do:

 

No, rationals are not automatically converted to floats.  The most likely ways to get a float are to start with (or input) a float, or use evalf.  If you showed us your actual code, we could probably figure out where your floats are coming from.


For a curve joining the points (assuming the x coordinates are in increasing order), you might try Spline in the CurveFitting package. And to put several plots together, use display in the plots package.  For example:

> M1 := <<0|3>,<1|1>,<2|4>, <3|1>,<4|5>,<5|9>,<6|2>>;
  M2:= <<0|2>,<2|7>,<4|1>,<6|8>>;
  with(CurveFitting):
  with(plots):
  P1:= pointplot(M1, colour=red, symbolsize=15):
  P2:= plot(Spline(M1,x),x=0..6,colour=red):
  P3:= pointplot(M2, colour=blue, symbolsize=15):
  P4:= plot(Spline(M2,x),x=0..6,colour=blue):
  display([P1,P2,P3,P4]);

 

Use the save command to save it in a file.  Then you can read the file when you want that procedure.

If you end a for loop statement with : rather than ;, no output will ordinarily be printed.  That includes plots.  But you may not want the output from other statements in the loop.  In that case you can use print to show only the outputs you want, including plots.  For example,

> for i from 1 to n do
       ...
       p := polygonplot(...);
       print(p);
       ....
    end do:

 

It ought to be possible using one of several types of embedded component (e.g. a Meter).  However, it seems these update only when control returns to top level, not when the value is changed (see the thread www.mapleprimes.com/forum/howperformimmediateoutputprocedure from last year).  You could try a Maplet.  For example:

> G:= proc(s,t)  
   local i;
   for i from s to t do
      ****  do something time-consuming depending on the index i ******
      if i - s mod 10000 = 0 then     
         Maplets:-Tools:-Set(SL1(value)=round(100*(i-s)/(t-s)));
      end if
   end do;
 end;
with(Maplets[Elements]):
 maplet := Maplet([
    [Label("Progress indicator")],
    [Slider['SL1'](0..100,showticks,'majorticks'=10, 'minorticks'=5)],
    [Button("Press to Start",Action(Evaluate('function'='G(1,1000000)'),Shutdown(`Done!`)))]
    ]):
> Maplets[Display](maplet); 

 

Yes, certainly you can do it.   Just like this:

  if k mod 1000000 = 0 then gc() end if;

 

In old versions of Maple, various contortions had to be used to prevent "premature evaluation" in sums.  It looks to me like all these quotes are a remnant of that.
In more recent versions, the add function is available: it is much better when you want to actually add a given number of terms together (rather than sum an infinite series or find a closed-form formula for a sum with variable bounds).  I suspect that this piece of code will work if you remove all the quotes and replace sum by add.

I'm also a fan of that show, but I don't recall seeing Mathematica actually mentioned or shown on the show.  If it ever happens, you can be sure that some money has changed hands: the phrase is "product placement".

By the way, your link doesn't work.  Try it without the "www".


First 69 70 71 72 73 74 75 Last Page 71 of 138