Robert Israel

6577 Reputation

21 Badges

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

MaplePrimes Activity


These are answers submitted by Robert Israel

>  G:=[
  [[1,0],[0,1]], # 1
  [[0,1],[-1,0]], # j
  [[-1,0],[0,-1]], #-1
  [[0,-1],[1,0]],# -j
  [[I,0],[0,-I]], # i
  [[0,-I],[-I,0]], # -k
  [[-I,0],[0,I]], # -i
  [[0,I],[I,0]] # k
  ]: 
  Gnames:= [1,j,-1,-j,i,-k,-i,k]:
  GM:= map(Matrix,G):
  A:= Matrix(8,8):
  for ii from 1 to 8 do
    B:= GM[ii];
    for C in GM do
      Bp:= C . B . C^(-1);
      member(convert(Bp,listlist), G, 'jj');
      A[ii,jj]:= 1;
  end do end do:
  CC:= convert(convert(A,listlist),set):
  map(t ->  subs(0=NULL,zip(`*`,t,Gnames)),CC);

{[-1], [1], [i, -i], [j, -j], [-k, k]}

 

There are only a few topics in the Student[Calculus1] package for which single-step solutions are available.  Solving differential equations is not one of them.  Although this is sometimes called "integration", it is not the same thing as integrating a function. 

If that's all you know about the a[k], there's no way to find a formula for the sum. 
Perhaps the real question is whether the infinite sum converges.
Well, the given conditions are not enough to decide that either.  For example, with a[k] = k it doesn't,
with a[k] = sqrt(k) it does.

To get the values of the BSpline function corresponding to a given list of values of the variable (q in your case), you can do something like this.

> c1 := BSplineCurve(SoilT, q); 

This returns a list of three elements: the first is the expression for the x coordinate, the second the expression for the y coordinate, the third is of the form q = a .. b.

> a, b := op(rhs(c1[3]));   

This extracts a and b.  Now suppose you want N values of q, evenly distributed from a to b.  I'll take N = 100.

 

> N := 100;
  Q:= [seq(a + (b-a)/(N-1)*j, j = 0 .. N-1)]:

This gives you the list of points on your curve corresponding to those Q values.

>  L:= map(unapply(c1[1..2],q), Q);

Now you might want to output this to a file for use by Excel or other programs, like this:

> ExportMatrix("c:/myfolder/BSpline.csv", Matrix(L, datatype=float[8]), 
    target=delimited,delimiter=",");

Your procedure is missing something: I get

Error, `}` unexpected

and I don't know exactly what you're trying to plot, but my guess is that you're running into severe roundoff
error.

For example:

> S:= series(tan(x)*log(1+x)/x, x, 10);

Replace 10 by some other number to get a different number of terms in the series.

For plotting, you have to use convert(S, polynom).  Thus:

> plot([convert(S,polynom), tan(x)*log(1+x)/x], x = 0 .. Pi/2, -2 .. 2, 
      colour=[red,blue]);

Note that I specified a range for the y axis, in this case -2 to 2, because the function goes to infinity as x -> Pi/2, and also the approximation can get quite large.  Also note that it's Pi, not pi.

> with(VectorCalculus):
   g:= PositionVector([s,s^3]);
   N:= simplify(PrincipalNormal(g,s,normalized)) assuming s::real;
   R:= simplify(RadiusOfCurvature(g,s)) assuming s::real;
   R1:= eval(R, s = 1/2);
   C:= g + R*N; 
   C1:= eval(C, s = 1/2);
   Plot1:= plot([g[1],g[2],s=-1..1]):
   Plot2:= plottools[circle](convert(C1,list), R1):
   plots[display](P1,P2, scaling=constrained);

 

 

Maple can't find a symbolic solution for this system.  You could try for a numerical solution, however, with the numeric option.  By the way, you want sigma := 1, not sigma = 1.

First of all, you'd need the initial conditions to specify values of the variables, not their derivatives.

> eval(convert(sys,D),t=0);

[D(A)(0) = 6*B(0)-A(0), D(B)(0) = A(0)*I-.5*I*A(0)*omega(0)-B(0), D(omega)(0) = -I*A(0)*B(0)-0.5*omega(0)]

> subs(IBC,%);

[1 = 6*B(0)-A(0), 0 = A(0)*I-.5*I*A(0)*omega(0)-B(0), 0 = -I*A(0)*B(0)-0.5*omega(0)]

> solve(%,{A(0),B(0),omega(0)});

{A(0) = 1.154940522+1.928073613*I, B(0) = .3591567537+.3213456022*I, omega(0) = 2.127231435+.4095465748*I},

{A(0) = -2.130395435-1.769292354*I, B(0) = -.1883992391-.2948820590*I, omega(0) = 1.923097451+.2407353869*I},

{A(0) = -.2454508764e-1-.1587812588*I, B(0) = .1625758187-.2646354313e-1*I, omega(0) = -.5032888632e-1+.1638470482e-1*I}

I don't know which of these you want to take as initial conditions.  Let's say the first one.

> S:= dsolve([op(sys), op(%[1])], numeric);

                  S := proc(x_rkf45)  ...  end proc
 

And then, for example,

> S(1);

[t = 1., A(t) = 1.87660400473298+1.79465650172983*I, B(t) = .398587604272181+.224675474979909*I, omega(t) = 2.21358761255581+.205562055307344*I]

You can expect severe roundoff error problems in this kind of calculation: in computing an off-diagonal element of the matrix product you are likely to be adding large numbers that should cancel exactly, but won't due to roundoff error.  If the terms in the sum are on the order of 10^n, then at Digits = 10 you might expect the roundoff error in the result to be on the order of 10^(n-10).  And this is true even if the inverse is exactly correct.

 

It may be more efficient to use lists, or maybe even better Arrays.  You can get the y values in an Array by using the output option to dsolve(..., numeric).  Note that if you do use plot, the default is adaptive plotting which might end up evaluating your function at a large number of points (on the other hand, it may produce a smoother-looking curve).

K := [A, B, C, D, E, F, G, H, I];    

subsop(3=NULL,6=NULL,8=NULL,K);

 

> Bx:= ((-2*E)^0.5 *F(x)+diff(F(x),x))*exp(-10*(-2*E)^0.5 )/(2*(-2*E)^0.5);
  eval(Bx, dsol(10));

 

It should be evalf(%) not value(%).  With value it's trying to calculate a symbolic answer (as if you used int)..  With evalf, it takes my computer (Core 2 Duo P8400, 2.26 GHz, Windows Vista) 0.015 seconds.

 

 

Maybe we could have some suggestions if you told us what your program was supposed to do.


This is a type of knapsack problem.  See also "Subset Sum problem".  The field of mathematics is called combinatorial optimization.

Here is a solution using dynamic programming.

> Knapsack:= proc(L::posint, S::set(posint))
    local A,i,j, n, T, R;
    n:= nops(S);
    A[0]:= {0};
    for i from 1 to n do A[i]:= `union` (seq(map(`+`,A[i-1],j*S[i]),j=0..floor(L/S[i]))) end do;
    if not member(L, A[n]) then return NULL end if;
    T:= L; R:= NULL;
    for i from n to 1 by -1 do
      for j from floor(T/S[i]) to 0 by -1 do
          if member(T - j*S[i], A[i-1]) then
             T:= T - j*S[i]; R:= R, S[i]$j; break
          end if
      end do
    end do;
    R;
    end proc;

> Knapsack(46, {56,38,20,12,4, 1});
 

                                 38, 4, 4
 

A somewhat more challenging one:

> Knapsack({10311, 11203, 12055, 13121, 15144, 16505, 17995, 19386, 19390, 19810});


             19810, 19386, 15144, 11203, 10311
First 63 64 65 66 67 68 69 Last Page 65 of 138