acer

32313 Reputation

29 Badges

19 years, 312 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Thanks for that, about mint. I don't know what I could have been thinking.

Yes, there are some gotchas when using code based on Maple 11's parameter-processing but within a Maple 10 session.

acer

It looks like the result of your last transform() call is, in Maple 8, a PLOT3D rather than a PLOT call. But the data within it looks like 2-dimensional plotting data.

So try this..

zzz := transform((x,y,z)->[x,y])(FG):
type(zzz,specfunc(anything,PLOT3D));
PLOT(op(zzz));

acer

Since freeof is not protected and may have been assigned a value by the user, or may be used alongside a local of the same same from within a procedure, that call would be better as,

select(type,expr,':-freeof'(vars)):

It bothers me a little, that the help-pages like ?type,freeof don't show it being used that way. That's also a general complaint I have about many help-pages -- the lack of uneval quotes in examples where they may be necessary in a general context. I also wonder why mint doesn't complain about this example.

 

acer

Since freeof is not protected and may have been assigned a value by the user, or may be used alongside a local of the same same from within a procedure, that call would be better as,

select(type,expr,':-freeof'(vars)):

It bothers me a little, that the help-pages like ?type,freeof don't show it being used that way. That's also a general complaint I have about many help-pages -- the lack of uneval quotes in examples where they may be necessary in a general context. I also wonder why mint doesn't complain about this example.

 

acer

I've never been able to decide whether I liked codegen[JACOBIAN]. On the one hand it often makes something which is easier to evalhf (or use Compiler:-Compile on, after maybe transcribing and editing). But on the other hand it's awkward if it fails on some of the procs, or if the input/output of data doesn't match. And I don't like how it can create workspaces internally, as I like to be able to cut out that sort of collectible garbage production.

So these days I tend to use `D`, and the newer `fdiff` routine, and the nice way that evalf(D(...)) can call fdiff.

Sometimes I use those together, evalf and D, but in two steps so that D can actually produce an explicit result for the easier procedures. Something like,

J:=unapply(Matrix(nops(funlist),numvars,(i,j)->D[j](funlist[i])(a,b)),[a,b]);

followed shortly afterwards by something like,

evalf(J(seq(X[count-1][jj],jj=1..numvars)))

So the above has that nice aspect, that the D can actually produce a new proc whose body is explicitly differentiated from the original proc. (I mention this for others here, not you of course, Robert.) And then whichever entries of J come back as unevaluated `D` calls will then get hit by evalf and the evalf(D(..)) will become fdiff calls. It's almost the best of both worlds. The only thing that I don't like about it is that it creates quite a few new Matrices, each time the Jacobian is updated with new point X, which can be inefficient even if those Matrices are collectible garbage.

So sometimes I do it instead like this,

funlist:=[f,g]:
numvars:=2: # or use nops([op(3,eval(f))])
dummyseq:=seq(dummy[i],i=1..numvars);
J:=Matrix(nops(funlist),numvars,
  (i,j)->unapply(fdiff(funlist[i],[j],[dummyseq]),[dummyseq]));
thisJ := Matrix(nops(funlist),numvars,datatype=complex(float)):

and then each iteration through I have it assign,

thisJ[i,j] := J[i,j](currXseq);

in a double-loop where,

currXseq:=seq(X[count-1][jj],jj=1..numvars);

I have an somewhat decent routine for Newton's method for procs, that works this way. Maybe I can dust it off and post it as a blog item.

acer

I've never been able to decide whether I liked codegen[JACOBIAN]. On the one hand it often makes something which is easier to evalhf (or use Compiler:-Compile on, after maybe transcribing and editing). But on the other hand it's awkward if it fails on some of the procs, or if the input/output of data doesn't match. And I don't like how it can create workspaces internally, as I like to be able to cut out that sort of collectible garbage production.

So these days I tend to use `D`, and the newer `fdiff` routine, and the nice way that evalf(D(...)) can call fdiff.

Sometimes I use those together, evalf and D, but in two steps so that D can actually produce an explicit result for the easier procedures. Something like,

J:=unapply(Matrix(nops(funlist),numvars,(i,j)->D[j](funlist[i])(a,b)),[a,b]);

followed shortly afterwards by something like,

evalf(J(seq(X[count-1][jj],jj=1..numvars)))

So the above has that nice aspect, that the D can actually produce a new proc whose body is explicitly differentiated from the original proc. (I mention this for others here, not you of course, Robert.) And then whichever entries of J come back as unevaluated `D` calls will then get hit by evalf and the evalf(D(..)) will become fdiff calls. It's almost the best of both worlds. The only thing that I don't like about it is that it creates quite a few new Matrices, each time the Jacobian is updated with new point X, which can be inefficient even if those Matrices are collectible garbage.

So sometimes I do it instead like this,

funlist:=[f,g]:
numvars:=2: # or use nops([op(3,eval(f))])
dummyseq:=seq(dummy[i],i=1..numvars);
J:=Matrix(nops(funlist),numvars,
  (i,j)->unapply(fdiff(funlist[i],[j],[dummyseq]),[dummyseq]));
thisJ := Matrix(nops(funlist),numvars,datatype=complex(float)):

and then each iteration through I have it assign,

thisJ[i,j] := J[i,j](currXseq);

in a double-loop where,

currXseq:=seq(X[count-1][jj],jj=1..numvars);

I have an somewhat decent routine for Newton's method for procs, that works this way. Maybe I can dust it off and post it as a blog item.

acer

I'd like to clarify a few things in that paragraph,

The condition number is a common measure of the closeness of a matrix to being singular. In general, we want to keep the condition number small but there is no firm limit to what small means.

The first is that conditioning is generally a quality of numerical computations, but it so happens that the condition number associated with solving linear systems (or doing matrix inversion) accurately turns out to be a property entirely of the matrix. The number which estimates the condition of this problem is often known as the condition number of a matrix.

The situation where that condition number is infinity is a usual definition of a matrix's being singular. Numbers can also be found to estimate the conditioning of some other linear algebra computations such as eigen-solving and singular value estimation.

For this particular condition number of system solving there is a firm limit of how small it may be, which is 1. What's not firm is how far from 1 the condition number must be for the term ill-conditioned to be applicable to the matrix.

acer

I'd like to clarify a few things in that paragraph,

The condition number is a common measure of the closeness of a matrix to being singular. In general, we want to keep the condition number small but there is no firm limit to what small means.

The first is that conditioning is generally a quality of numerical computations, but it so happens that the condition number associated with solving linear systems (or doing matrix inversion) accurately turns out to be a property entirely of the matrix. The number which estimates the condition of this problem is often known as the condition number of a matrix.

The situation where that condition number is infinity is a usual definition of a matrix's being singular. Numbers can also be found to estimate the conditioning of some other linear algebra computations such as eigen-solving and singular value estimation.

For this particular condition number of system solving there is a firm limit of how small it may be, which is 1. What's not firm is how far from 1 the condition number must be for the term ill-conditioned to be applicable to the matrix.

acer

Nice.

Apologies, but I couldn't resist a small modification which (I think) works, and to make it a procedure. You are right, of course, that the centroid should lie in the least squares plane.

> Data:= Matrix([[1.33, 2.57, 2.24], [3.68, 5.27, 6.99],
>                [0.92, -0.98, 0.27], [-0.72, -0.74, 0.8],
>                [0.29, -0.31, -0.77], [-0.93, -0.2, -0.4],
>                [0.69, 0.44, 0.67]]):
>
> LineFit := proc(data::Matrix)
>   local n,Avg,M,S,Vt;
>   use LinearAlgebra in
>     n:= RowDimension(Data);
>     Avg := (Vector[row](n,1/n).data);
>     M := data - Vector(n,1) . Avg;
>     Vt := SingularValues(M,output=[':-Vt']);
>     Transpose(Avg), Transpose(Vt[1,1..-1]);
>   end use;
> end proc:
>
> LineFit(Data);
                [0.751428571428571446]  [-0.382423377977291923]
                [                    ]  [                     ]
                [0.864285714285714102], [-0.598085455692940360]
                [                    ]  [                     ]
                [1.39999999999999991 ]  [-0.704305436344918045]

It would make a good Task Template.

acer

Nice.

Apologies, but I couldn't resist a small modification which (I think) works, and to make it a procedure. You are right, of course, that the centroid should lie in the least squares plane.

> Data:= Matrix([[1.33, 2.57, 2.24], [3.68, 5.27, 6.99],
>                [0.92, -0.98, 0.27], [-0.72, -0.74, 0.8],
>                [0.29, -0.31, -0.77], [-0.93, -0.2, -0.4],
>                [0.69, 0.44, 0.67]]):
>
> LineFit := proc(data::Matrix)
>   local n,Avg,M,S,Vt;
>   use LinearAlgebra in
>     n:= RowDimension(Data);
>     Avg := (Vector[row](n,1/n).data);
>     M := data - Vector(n,1) . Avg;
>     Vt := SingularValues(M,output=[':-Vt']);
>     Transpose(Avg), Transpose(Vt[1,1..-1]);
>   end use;
> end proc:
>
> LineFit(Data);
                [0.751428571428571446]  [-0.382423377977291923]
                [                    ]  [                     ]
                [0.864285714285714102], [-0.598085455692940360]
                [                    ]  [                     ]
                [1.39999999999999991 ]  [-0.704305436344918045]

It would make a good Task Template.

acer

Would simply a scaling change of variable suffice? If so then you might try using `subs` on the expressions to replace one variable with a scaled replacement.

acer

Would simply a scaling change of variable suffice? If so then you might try using `subs` on the expressions to replace one variable with a scaled replacement.

acer

The documentation of initialization files and their platform dependent details (eg. name and location) could be much better. These are basic things, and should be documented so that every new user to maple, who as yet knows almost nothing about Maple, should be able to find easily and use them easily.

In Maple 11, issuing  ?initialization or ?mapleinit or ?startup all take one to the help-page for "The Maple Command and Command-line Options". Since most Windows and OSX users only ever start Maple via an icon or launcher button, that page isn't really appropriate for all those help queries. Moreover, that help-page references the ?worksheet,reference,initialization page only very far down, and not in either section dealing with the -i or -s options, and not in the See Also section.

I really don't find it useful when longer help-pages don't include in their See Also section all the cross-references that appear ealier in the page.

Also, the help page name ?worksheet,reference,initialization is a misnomer. It's contents are not specific to the graphical worksheet interfaces.

On Unix the resource file for the GUI may have a name like ~/.maple/11/maplerc which is fine because it has nothing in common with the user initialization file ~/.mapleinit . But on Windows the resource file has a name like maple11.ini while the initialization file is called maple.ini , and their locations can be close (depending on the single- vs multi-user mode). Those similar names are just asking for trouble, and of course now and then we see here a post by someone who attempts to put startup maple commands in the wrong file.

Lastly, where is the simple help query to get instruction and description of the contents of the GUI resource file, that maple11.ini file? (See this blog entry for a nice -- if slightly outdated w.r.t Unix filename and location -- bit of detail on this resource file.)

acer

The documentation of initialization files and their platform dependent details (eg. name and location) could be much better. These are basic things, and should be documented so that every new user to maple, who as yet knows almost nothing about Maple, should be able to find easily and use them easily.

In Maple 11, issuing  ?initialization or ?mapleinit or ?startup all take one to the help-page for "The Maple Command and Command-line Options". Since most Windows and OSX users only ever start Maple via an icon or launcher button, that page isn't really appropriate for all those help queries. Moreover, that help-page references the ?worksheet,reference,initialization page only very far down, and not in either section dealing with the -i or -s options, and not in the See Also section.

I really don't find it useful when longer help-pages don't include in their See Also section all the cross-references that appear ealier in the page.

Also, the help page name ?worksheet,reference,initialization is a misnomer. It's contents are not specific to the graphical worksheet interfaces.

On Unix the resource file for the GUI may have a name like ~/.maple/11/maplerc which is fine because it has nothing in common with the user initialization file ~/.mapleinit . But on Windows the resource file has a name like maple11.ini while the initialization file is called maple.ini , and their locations can be close (depending on the single- vs multi-user mode). Those similar names are just asking for trouble, and of course now and then we see here a post by someone who attempts to put startup maple commands in the wrong file.

Lastly, where is the simple help query to get instruction and description of the contents of the GUI resource file, that maple11.ini file? (See this blog entry for a nice -- if slightly outdated w.r.t Unix filename and location -- bit of detail on this resource file.)

acer

On Unix, the startup file is ~/.mapleinit , and on Windows it is maple.ini .

See the help-page  ?worksheet,reference,initialization

These initialization files also get reread when one issues a restart within a Maple session.

acer

First 550 551 552 553 554 555 556 Last Page 552 of 591