Joe Riel

9660 Reputation

23 Badges

20 years, 17 days

MaplePrimes Activity


These are replies submitted by Joe Riel

That [put the entire thing in a module ... ] is what I would most likely do. Part of that assumes that when complete you'll have something that you want to save to a library so that it can be reused. Note that global variables are evaluated differently than local variables inside Maple; global variables are fully evaluated with each use. 

The inclusion of maptype is curious.  Near as I can tell it is not used in any Maple library code. 

Learning about bind won't be easy--it isn't documented. A loosely related and also undocumented procedure is _pexports.

The process package is deprecated.

Slightly shorter is the equivalent

F3 := proc (opt, par) 
local vars,i;
    vars := {seq(`if`(par[i]=-1,opt[i],NULL), i=1..nops(opt))};
    return map(l -> `if`(not l::list, l, remove(member, l, vars)), opt);
end proc:

Slightly shorter is the equivalent

F3 := proc (opt, par) 
local vars,i;
    vars := {seq(`if`(par[i]=-1,opt[i],NULL), i=1..nops(opt))};
    return map(l -> `if`(not l::list, l, remove(member, l, vars)), opt);
end proc:

@alex_01 Good questions are essential and make this site useful.  Your rating is well earned.

@John Fredsted Yes, that was what I used.  While I don't think it matters, I tested with a linux version of Maple. I do recall reproducing the problem [on Linux] when you originally posted it. I currently don't have a copy of Maple 12 to verify.

If I understand the problem, then the tabbing issue appears to be resolved in Maple13+.  That is, I inserted the code you suggested (in the original post), went to the second line, which is indented with a tab, pressed the "end" key, and the cursor moved to the end of the line.

@hirnyk There is a bug in the randompoint algorithm; it chooses a random point using uniform distributions of theta and phi.  That does not lead to a uniform distribution over the surface.  Use the method suggested by Robert Israel.  I'll submit an SCR against this.

@hirnyk There is a bug in the randompoint algorithm; it chooses a random point using uniform distributions of theta and phi.  That does not lead to a uniform distribution over the surface.  Use the method suggested by Robert Israel.  I'll submit an SCR against this.

I believe the objective function f2 isn't quite right.  That is, you don't want to minize the distance to the center, but rather the distance to the circle. Consider the simpler case of fitting a 0-dimensional circle (two points) to a set of points on a line. Specifically, assume the data consists of [-1, 1, 1]  (the 1 is repeated).  The best fit is clearly the two points -1 and 1 (i.e. the "circle" with unit radius centered at 0).  Fitting to the center of mass of these points gives a nonideal result.

An interesting presentation of techniques.  Here's an alternative using the complex plane (which makes rotating simple, just multiply by the imaginary unit).

Given two points, p1 and p2

p1 := x1+I*y1:
p2 := x2+I*y2:

Compute a parameterized form for the perpendicular bisector of [p1,p2]:

z := evalc((p1+p2)/2 + t*I*(p2-p1));
              x1     x2                  / y1     y2               \
        z := ---- + ---- - t y2 + t y1 + |---- + ---- + t x2 - t x1| I
              2      2                   \ 2      2                /

To get an implicit form, equate the real and imaginary parts to x and y, then eliminate t

eqs := [x,y] =~ evalc([Re,Im](z));
                  x1     x2                      y1     y2
     eqs := [x = ---- + ---- - t y2 + t y1, y = ---- + ---- + t x2 - t x1]
                  2      2                       2      2
imp := eliminate(eqs,t)[2][];
                                   2     2              2              2
       imp := -2 y y2 + 2 y y1 - y1  + y2  - 2 x2 x + x2  + 2 x1 x - x1

For an explicit form, solve for x or y

solve(imp, {y});
                         2     2              2              2
                      -y1  + y2  - 2 x2 x + x2  + 2 x1 x - x1
               {y = - ----------------------------------------}
                                    2 (-y2 + y1)

It will be tough to post a shorter useful response.  I'll wait for the moment when "." is apropos.

It will be tough to post a shorter useful response.  I'll wait for the moment when "." is apropos.

That does appear to be the same value.  To approximate the original I tried

sum(1/k/trunc(m/k), k=1..m) = sum(1/k/trunc(m/k), 1<=k<m/2) + sum(1/k/trunc(m/k), m/2<=k<=m)
                            = sum(1/k/trunc(m/k), 1<=k<m/2) + sum(1/k, m/2<=k<=m)

As m goes to infinity the second sum goes to ln(2).  If m is prime then the summand of the first sum on the average is m-k/2.  Transforming and taking the limit gives 2*ln(4/3). So the total is ln(2) + 2*ln(4/3) ~ 1.2685...

That does appear to be the same value.  To approximate the original I tried

sum(1/k/trunc(m/k), k=1..m) = sum(1/k/trunc(m/k), 1<=k<m/2) + sum(1/k/trunc(m/k), m/2<=k<=m)
                            = sum(1/k/trunc(m/k), 1<=k<m/2) + sum(1/k, m/2<=k<=m)

As m goes to infinity the second sum goes to ln(2).  If m is prime then the summand of the first sum on the average is m-k/2.  Transforming and taking the limit gives 2*ln(4/3). So the total is ln(2) + 2*ln(4/3) ~ 1.2685...

First 88 89 90 91 92 93 94 Last Page 90 of 195