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

The elements of GF(8), represented as Z_2[x]/<x^3+x+1>:
> 0, seq(Rem(x^j, x^3+x+1, x) mod 2, j = 1 .. 7);
Multiplying polynomials mod x^3+x+1:
> rem((x^2+x+1)*(x+1), x^3+x+1, x);
Doing it over Z[2]:
> Rem((x^2+x+1)*(x+1), x^3+x+1, x) mod 2;
You could also try using GF, but I find it unpleasant.
Yes, the basic shape may not depend on k, but the details of the plot do depend on k. In order to plot it, you need to give a value to k. So you can say something like
> plot(eval(f, k = 1), ...);
I agree with Georgios, but perhaps I should add a word or two of caution. Maybe you should be more concerned with developing your own mathematical skills, and avoid getting too dependent on technology. Remember that when you write exams in those college-level math courses, you will not have Maple there to help you, maybe not even a calculator. I see many students in my first-year calculus classes who have trouble because their basic algebra skills are weak. They may have done very well in high school, in many cases using graphing calculators, but when they are only allowed pencil and paper they are lost.
It seems to be a bug in LinearAlgebra, that LinearSolve doesn't work if the first argument is a Matrix with floats and the second argument is a Matrix with one column (and that's what the construction produced). This can be avoided by changing to a different method of constructing the second argument. While we're at it, for efficiency's sake we may as well keep the datatype=float[8]. Try this:
solveSystem := proc(A::Matrix(datatype=float[8]), v::Vector(datatype=float[8]))
local n, C, Ap,vp,ineqs;
uses LinearAlgebra, Optimization;
n := ColumnDimension(A);
Ap:= Matrix([[A],[Matrix([[1$n]])]], datatype=float[8]);
vp:= Vector([v,1.], datatype=float[8]);
C := LinearSolve(Ap,vp);
if indets(C) = {} then 
  return C 
end if;
ineqs := map(`>=`, convert(C, set), 0);
LPSolve(0, ineqs);
return subs(%[2], C)
end proc;
Your procedure also lacks code to handle the cases where solutions are not found. I don't know what you want to do then. There are three possibilities: (1) LinearSolve finds no solution (produces an error) (2) LinearSolve finds a unique solution, but it has some negative coefficients (returns the C containing negative coefficients) (3) LPSolve finds no feasible solution (produces an error) You might also note that due to roundoff error, you might get results with very small negative coefficients: e.g.
> solveSystem(Matrix([[1, 2,7,5], [1, 1,2,1]], datatype = float[8]), Vector([[3], [1]], datatype = float[8]));
RTABLE(159065532,MATRIX([[-.1e-14], [.66666666666667], [-0.], [.333333333333333]]),Vector[column])
Actually that should be (exp(-a)/(2*r))*(r*df/dr + df/da) i.e. the r should be in the denominator together with the 2.
> f:= g(x,y);
  S:= {x = r*exp(a), y = r*exp(-a)};
  xyderivs:= eval({diff(f,x) = `df/dx`, diff(f,y) = `df/dy`}, S);
  fS:= eval(f,S);
  eqs:= subs(xyderivs, 
     {`df/dr` = diff(fS,r), `df/da` = diff(fS,a)});
  simplify(solve(eqs, {`df/dx`, `df/dy`}));
xyderivs := {D[1](g)(r*exp(a),r*exp(-a)) = `df/dx`, D[2](g)(r*exp(a),r*exp(-a)) = `df/dy`} eqs := {`df/dr` = `df/dx`*exp(a)+`df/dy`*exp(-a), `df/da` = `df/dx`*r*exp(a)-`df/dy`*r*exp(-a)} {`df/dx` = 1/2*(r*`df/dr`+`df/da`)*exp(-a)/r, `df/dy` = 1/2*(-`df/da`+r*`df/dr`)*exp(a)/r}
Do you mean a set or list? Try this:
> P:= (L::list, V::listlist) ->
  map(S -> add(L[t],t=S), combinat[powerset](nops(L)) minus {});
But what's the V for? You didn't use it.
The "<" problem strikes again! To get "<" in this forum you have to type & lt; (without the space), otherwise whatever is between < and > is interpreted as an HTML tag. Anyway, I would use LinearSolve rather than GaussianElimination. If you use the right Matrix, this will give you a Vector orthogonal to r and s containing one parameter (perhaps _t[2]). What you have to do next is find a value of the parameter that makes your Vector have length 7. Note that the square of the length of the Vector v is
v^%T . v;
Suppose A is the matrix whose columns are the vectors, so for a linear combination you'd solve A c = v. Here you have an additional equation to solve, c[1]+...+c[n]=1. You can do that by adjoining a row of all 1's to A and an entry of 1 to v. If you're using the LinearAlgebra package (so A is an m x n Matrix and v is an m-component column Vector), you can say
> C := LinearSolve(<A, Matrix([[1$n]])>, <v,1>);
If C contains arbitrary parameters (typically _t[1,1], _t[2,1] etc) you next have to find parameter values that make all the entries of C nonnegative. If there are only one or two parameters, "solve" may be able to do this:
> ineqs:= map(`>=`,convert(C,set),0);
  solve(ineqs);
If there are lots of parameters, and it's not obvious how to choose them so that the entries of C are nonnegative, you can use LPSolve in the Optimization package:
> with(Optimization):
  LPSolve(0,ineqs);
  subs(%[2],C);
> with(plots):
  odeplot(Sol, [[t, vol(t)], [t, u(t)/1000]], 
    t = 0 .. 0.9e-4, colour = [red, green]);
Vous voyez que u(t) < 0. Pourquoi?
> VectorCalculus[Jacobian]([r*exp(a),r*exp(-a)],[r,a]);
RTABLE(158050692,MATRIX([[exp(a), r*exp(a)], [exp(-a), -r*exp(-a)]]),Matrix)
Interestingly, Maple can do this without the "abs", but can't do it as is. It also can't do limit(abs(sin(x)/x),x=infinity). Another case where Maple's strategy is different from what a human might use.
Yes, it is quite simple. It doesn't matter where the data have been imported from, it's just a question of what form they are in once they have been imported. For example, if your data are in an m x 2 Matrix A (with the x values in the first column and the y values in the second), then one thing you can do is
> A[1..m,1]:= A[1..m,1] + <(n$m)>:
I suppose what you really want to plot are the points [ka[i], va[i]] for i from 1 to N. So replace the command plot([ka,va]) with something like
pointplot([seq([ka[i],va[i]],i=1..N)]);
By the way, you really shouldn't use both linalg and LinearAlgebra packages. For most purposes, the newer LinearAlgebra is better than the older linalg, but your code is just using linalg.
I find it hard to understand your description of what you're trying to do. You say you can't make the "if statement" work the way you want it, but you don't say how you want it to work. As for the "cycle", perhaps what you're looking for is something like this:
> i:= 0: p:= 1;
  while i < 100 do
    i:= i + p;
    p:= ...
  end do;
You should either give names to your equations, or make them into sets or lists. If you want to give values to the parameters, use eval.
> eqs:= [r[R1]*w[R1]+r[S1]*w[S1] = (r[R1]+r[S1])*w[C1],
  r[R2]*w[R2]+r[S2]*w[S2] = (r[R2]+r[S2])*w[C2],
  r[R3]*w[R3]+r[S3]*w[S3] = (r[R3]+r[S3])*w[C3],
  r[R4]*w[R4]+r[S4]*w[S4] = (r[R4]+r[S4])*w[C4],
  r[R1]/r[S1] = R[1],
  r[R2]/r[S2] = R[2],
  r[R3]/r[S3] = R[3],
  r[R4]/r[S4] = R[4],
  w[C1] = w[R2],
  w[S1] = w[C2],
  w[R2] = w[C3],
  w[C3] = w[R4],
  w[S3] = w[C4]];
  dependents:= [r[R1], r[R2], r[R3], r[R4], w[C1], w[C2], 
   w[C3], w[C4], w[R2], w[R3], w[R4], w[S1], w[S3]];
Suppose you want to give values 2, 4, 6, 8 to R[1] to R[4] respectively.
> params:= zip(`=`, [R[1],R[2],R[3],R[4]],[2,4,6,8]):
  solve(eval(eqs,params), dependents);
[[r[R1] = 2*r[S1], r[R2] = 4*r[S2], r[R3] = 6*r[S3], r[R4] = 8*r[S4], w[C1] = (1/11)*w[S2]+(10/11)*w[R1], w[C2] = (8/11)*w[R1]+(3/11)*w[S2], w[C3] = (1/11)*w[S2]+(10/11)*w[R1], w[C4] = (8/99)*w[S2]+(80/99)*w[R1]+(1/9)*w[S4], w[R2] = (1/11)*w[S2]+(10/11)*w[R1], w[R3] = (5/54)*w[S2]+(25/27)*w[R1]-(1/54)*w[S4], w[R4] = (1/11)*w[S2]+(10/11)*w[R1], w[S1] = (8/11)*w[R1]+(3/11)*w[S2], w[S3] = (8/99)*w[S2]+(80/99)*w[R1]+(1/9)*w[S4]]]
First 119 120 121 122 123 124 125 Last Page 121 of 138