acer

32490 Reputation

29 Badges

20 years, 9 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Here's a couple of ideas. # replace with your procedure... `#mo("∇")`:=proc(V::Vector) map(sin,V); end proc: `#mo("∇")`:=`#mo("∇")`: Then after each time you grab the nabla from the Common Symbols palette (or cut and paste it) you would have to select the inserted symbol (only) with the mouse, and use the Context Menu action, 2D Math -> Convert To -> Atomic Identifer In this way, I was able to get it to look like a Del/nabla and act like a function on a Vector. I had to use round brackets though, like for any other procedure. Another way that worked for me was to issue, unprotect(VectorCalculus:-Nabla); After that, I could use the symbol from the palette without having to do Context Menu toggling each time. But even this way I couldn't get it to work without using brackets in order apply it, without receiving the error, Error, (in Typesetting:-delayGradient) unable to compute gradient until a co-ordinate system has been defined (see ?VectorCalculus:-SetCoordinates) I don't know if there's a clever workaround for that. acer
1) with(LinearAlgebra): A:=RandomMatrix(2): B:=RandomMatrix(2): X:=Vector(2,(i)->convert(cat("x",i),name)): Y:=LinearSolve(B,A.X); A.X-B.Y; 2) LinearAlgebra[GenerateMatrix]([x1-x3,x1+x2-x4, x1+x2, x3+x4],[x1,x2,x3,x4]); 3) evals:=Eigenvalues(evalf(A)); `+`( seq(`if`(Im(x)=0.0,signum(Re(x)),NULL),x in evals) ); acer
Here's my exam tip. When you do indefinite integrations, don't forget to add the constant (+ C). Those docked half-points add up. Do it like Maple does dsolve({diff(f(x),x)=x}) , not like it does f(x)=int(x,x) . acer
The colon at the end of a statement will instruct maple to suppress the printed or displayed output. A semicolon will not suppress the output. Your last three assignments ended with colons. acer
a:=n->1/((2*n-1)*(2*n+1)); # nth term in sum s:=(n)->n/(2*n+1); # proposed sum formula Is s(1) correct? Does s(N)+a(N+1) = s(N+1) ? acer
You are so close. Two things must match. The value the line attains at x=x1 must be equal to the value that f attaints at x=x1. That's because they touch. The value of the slope of the line must be equal to the value of the slope of f, at the point where they touch. (Not true of all functions, but true of "nice" or "smooth" functions. Not true if f has a "pointy" change of direction or cusp.) So, the first of those two matchings you can probably figure out. Evaluate both the equation of the line and of f, when x=x1. To get the second, you need formulas for the slope of f and for the slope of the line. You got the slope of f, as f'(x). Great. Now, what's the slope of the line? acer
If you issue ?Chebyshev in Maple then you should see suggestions from the help system. Those should include references to parts of the numapprox and orthopoly packages. Consider looking at ?numapprox,Chebyshev . I hope that I've understood what you're after. acer
There are lots of ways to program this. Some are easy to set up, but are probably not optimal for performance. Here are two easy ones. IR := n -> ArrayTools:-FlipDimension(LinearAlgebra:-MatrixScalarMultiply(LinearAlgebra:-IdentityMatrix(n,compact=false),-1,inplace=true),2); seq(IR(n), n=1..5); IR2:=n->Matrix(n,n,(i,j)->`if`(i=n-j+1,-1,0)); seq(IR2(n), n=1..5); acer
First things first. If you want to use < and > symbols in your posts, then enter then (without spaces or quotes) as "& l t ;" and "& g t ;". That's for marked up HTML posts here, which is the default. Alternatively, click on "Input format" just below the entry box and select a plain text format for the post. Now, the Optimization package does purely numeric computation. So rather than have function V attempt a symbolic integral for every (E,a) pair, you can set it up to do purely numeric quadrature from the get go. It'd likely be more efficient. Below, I set up OptE as a procedure that is gentle for plot(). If any particular Maximize() call returns unevaluated (as can possibly happen) then OptE returns the value undefined. plot() should handle that OK. Of course, if you wish to use the solutionmodule output method of Maximize, then all type checking I have to test that it has actually returned a numeric value would need to look slightly different. Notice also that I put so-called unevaluation quotes around the V call, inside OptE. That's because otherwise the Maximize() routine would try to evaluate V(E,a) before finding out what any values of E were. It would then stop, with an error message. There are other ways of working around that issue.

V := (E,a) -> evalf(Int(-1/2*E*(-r+E)/r*((1/2*r)^(-1+a)*(1-1/2*r)^(-1+a)/Beta(a,a)),r = E .. 2,digits=10));

V(1,1);

OptE:=proc(a)
global V;
local result;
  result := Optimization[Maximize]('V'(E,a),E=0..2);
  if type(result,list) and type(rhs(op(op(2,result))),numeric) then
    result := rhs(op(op(2,result)));
  else
    result := undefined;
  end if;
end proc:

plot(OptE,0.5..1.0);

If you aren't concerned about plot() and handling any problematic return values from Maximize() then you could use simply this,
OptE:=a->rhs(op(op(2,Optimization[Maximize]('V'(E,a),E=0..2))));
If a V() call returns unevaluated (as could happen if the quadrature failed) then Maximize() would throw an error. You could guard against that by putting the Maximize() call within a try..catch:..end try clause and by having OptE return undefined in such a case. acer
You assign to U,S, and Vt within the procedure. And doubtless those variables are declared as locals of the procedure (either explicitly by you, or implicitly, alongside a warning, by maple at the procedure creation moment). But in that case, when U, S, and Vt are locals, they cannot be used in the SingularValues call as part of the 'output' options. The options processing of the SingularValues routine won't recognize them as valid. But you should be able to use the global names instead. That is, use them like so, output = [':-U', ':-S', ':-Vt'] You did the right thing, by quoting them, because those global names might have been assigned values, elsewhere. (For example, by running your example multiple times, outside of any procedure.) It would be nice if the help-pages gave more examples where this was done. acer
Your simpleftilde(x,0) will call ftilde(x,0), not f(x,0) as you seem to suggest. And ftilde(x,0) will call f(0,0). But your defn of f has, inside it, 1/(x+lambda). So when x and lambda are both zero, evaluating that causes that exception. acer
No, that notation does not usually mean that the function is linear. It might be linear, but it does not have to be. Instead, it usually means that it is a scalar function from the reals to the reals. The domain is in the reals, and range is in the reals. The sine function is an example, of an f:R->R. acer
You might also find these of interest, RootFinding:-Analytic(x^3-exp(x),x=-10-0.0001*I..10+0.0001*I); Student:-Calculus1:-Roots(x^3-exp(x),numeric=true); acer
f:=t->t^2: solve({f(x)=4},x); solve({f(x)=4,x>0},x); acer
Several of those LinearAlgebra calls are not being done "in-place". So unnecessary Matrices are being produced, which is more garbage requiring collection than is necessary. Note that every time one sees those "bytes used" messages in TTY Maple (or the bottom counters get updated in the GUI) there is garbage collection occuring. When bytesused goes up much faster than bytealloc, it usually means that a great deal of garbage is being produced. Garbage collection is relatively expensive, and very expensive compared to hardware numeric operations doen externally. Also, the use of that RandomTools routine as the Matrix initializer doesn't seem best. I believe that using it (as posted, originally) involves many procedure calls. Maple procedure calls are very expensive. And those would return software float scalars, which will all become more garbage. But the Statistics package can populate a hardware datatype Vector, using compiled external code to generate the random numbers. And then ArrayTools may be used to copy such random hardware data (again using compiled external code) into the complex[8] Matrix, without any software floats being produced. It may be possible to use ArrayTools:-Alias, as an alternative to some of my ArrayTools use below. Does this code do the same thing? (I may have made mistakes.) Feynman_random_rho := proc(N::posint, d::posint:=2)::'Matrix'(complex[8]); local rho, temp, X, a, rtemp, temp2; X := Statistics:-RandomVariable(Normal(0,1)): temp := Matrix(d^N, d^N,datatype=complex[8]); a:=Statistics:-Sample(X,d^N * d^N): rtemp := ArrayTools:-ComplexAsFloat(temp); ArrayTools:-Copy(d^N * d^N, a, 0 , 1, rtemp, 0, 2); temp2 := Matrix(d^N, d^N,datatype=complex[8]); a:=Statistics:-Sample(X,d^N * d^N): rtemp := ArrayTools:-ComplexAsFloat(temp2); ArrayTools:-Copy(d^N * d^N, a, 0 , 1, rtemp, 0, 2); LinearAlgebra[Add](temp, temp2, 1,I,inplace=true); rho := LinearAlgebra[HermitianTranspose](temp).temp; LinearAlgebra:-MatrixScalarMultiply(rho,1/LinearAlgebra[Trace](rho),inplace=true); end proc: acer
First 325 326 327 328 329 330 331 Last Page 327 of 337