Carl Love

Carl Love

28070 Reputation

25 Badges

13 years, 35 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@YasH Without the parse, the cat(L[]) produces a variable name that looks like a number. You will notice that the result shows in italics in the GUI. With the parse, you actually get a number, which shows in an upright font.

(This may have changed in a recent version of Maple. I'm stuck with Maple 16 today.)

@JessyOw I think that you need to enter the string with quotes: `Hello! Bob` rather than Hello! Bob.

On the other hand, I do have sympathy for the other position: that the condition number is a precisely defined mathematical entity and that ConditionNumber should respect that. So perhaps the other number should be relegated to a command ConditionNumberEstimate or some such. And since this estimate is so crude, perhaps only its ilog10 should be reported.

@moses Look closely at the beginning of the first for loop in procedure `α__ν`. You have

for i from 1 to `n__pile ` do

It should be

for i from 1 to `n__pile` do

In other words, you have an extra space at the end of `n__pile`.

Note that there's no need to use name quotes on n__pile. If you had simply used n__pile, this error would've been advoided.

@moses If I understand you correctly, you want to evaluate the matrix that you currently have entered as alpha, with each value of S coming from the corresponding entry in the matrix S__p. Is that correct?

@pchin I figured that something like this was going on since there is no error message when trying to use colorscheme with densityplot. Can it be fixed (in the future) so that option scaletorange respects option zrange?

@Kitonum How do you get Maple's array plots (side-by-side plots) to display on MaplePrimes? It never works for me. What browser are you using and which Maple GUI?

@Kitonum The usual case is that numpoints alone isn't enough get an exact number of points. The default setting is adaptive= true, which attempts to fill in the sharp turns of a curve after fulfilling the numpoints requirement. You can read about it at ?plot,options. If you count the points in your own posted example, you'll see that there are 25, which is why I brought up this issue.

 

@acer I stumbled upon this technique myself when looking for a way to get more control over the size of 3d plots projected into the xy-plane. It's great that you've found a single command to do it.

What's the purpose of each pair of unevaluation quotes in the following line of code:

P2d:=':-PLOT'(remove(type,[op(P3d)],
     ':-specfunc(anything,{:-AXESLABELS,:-LIGHTMODEL,:-ORIENTATION})')[]):

@Bendesarts Yes, your guess as to the reason for the limited usability of the style of module that I proposed is entirely correct.

@Kitonum If you want precisely the number of points specified, then you also have to include adaptive= false, as in

plot(x^2, x= 0..2, style= point, numpoints= 20, adaptive= false);

The following worksheet shows a procedure that makes short work of the above and an example showing how one would use a typeset sentence with embedded equation in a userinfo statement.


TSprintf:= proc()
uses T= Typesetting;
     T:-mrow(seq(`if`(e::string, T:-mn(e), T:-Typeset(T:-EV(e))), e= [args]))
end proc:

EQ:= s^2-4*s+1+sqrt(u/Pi)=3:

TSprintf("The equation is  ", EQ, ".");

"The equation is  s^2-4 s+1+sqrt(u/Pi)=3."

(1)

MyProc:= proc(eq)
     (* other code *)
     userinfo(1, MyProc, NoName, print(TSprintf("The equation is  ", eq, ".")));
     (* other code *)
end proc:

infolevel[MyProc]:= 1:

MyProc(EQ);

"The equation is  s^2-4 s+1+sqrt(u/Pi)=3."

(2)

 


Download Typeset.mw

 

Would you please post the above as an attached worksheet? It'd be much easier to read and use without all the extraneous junk created by translating from 2D input to 1D input. You can use the green uparrow in the toolbar of the MaplePrimes editor to attach a file.

When I use Google Chrome, the white space is stripped, and I put it back space by space. When I use Mozilla Firefox, the white space is not stripped.

Your participation in MaplePrimes has been sorely missed.

@LaarsHelenius

Doesn't the algorithm require some way to detect unboundedness?

When I try the input that you suggest, I seem to get an infinite loop. Perhaps I didn't let it run long enough. There should be a limit on the number of iterations as a safety. So I added another keyword parameter, max_iters, which defaults to 99.

I added a userinfo statement that displays the number of iterations used. This will only execute if you give the command

infolevel[Karmarkar]:= 1:

I put coercion on the parameters A and c, so you no longer need to wrap them with evalf in the call.

So here's the new code:

Karmarkar:= proc(
     A::coerce(Matrix(datatype= float[8]), evalf),
     c::coerce(Vector[row](datatype= float[8]), evalf),
     {epsilon::positive:= 1e-4},
     {fudge_factor::realcons:= 0.9},
     {max_iters::posint:= 99}
)
uses LA= LinearAlgebra;
local
     n:= LA:-ColumnDimension(A),
     y:= Vector(n, fill= 1/n, datatype= float[8]),
     r:= evalf(1/sqrt(n*(n-1))),
     x_new:= `+`(LA:-NullSpace(A)[]),
     x,
     C:= epsilon,
     Ones:= Vector[row](n, fill= 1),
     J:= LA:-IdentityMatrix(n, datatype= float[8]),
     Diag, B, p, iter
;
     for iter to max_iters while C >= epsilon do
          x:= x_new;
          Diag:= LA:-DiagonalMatrix(x/LA:-Norm(x, 1));
          B:= <A.Diag, Ones>;
          p:= (J - B^+.(B.B^+)^(-1).B).(c.Diag)^+;
          y:= y - fudge_factor*r*p/LA:-Norm(p,2);
          x_new:= Diag.y/(Ones.Diag.y);
          C:= abs(c.(x_new - x)/(c.x))
     end do;
     if iter > max_iters then
          error
               "Didn't converge; error = %1. "
               "Increasing max_iters or epsilon may resolve this problem.",
               C
     end if;
     userinfo(1, Karmarkar, "Used", iters-1, "iterations.");
     x_new
end proc:

First 429 430 431 432 433 434 435 Last Page 431 of 709