vv

13922 Reputation

20 Badges

10 years, 10 days

MaplePrimes Activity


These are replies submitted by vv

@emendes 

If your list L and expressions are really huge, I recommend to apply the function not to L but to

map(addressof,L)

because identical expressions will have (in principle) the same memory address.

@Carl Love 

So, f5 is the champion.

@Carl Love 

Strangely, ff with tables seems to be a bit faster than f4
restart;
R:= rand(1..9):
L:= ['R()' $ 99999]:
r1:= CodeTools:-Usage(
     {entries(((x-> x[2])~)~(ListTools:-Classify(x-> x[1], `[]`~(L, [$1..nops(L)]))), nolist)},iterations=10
):
memory used=31.09MiB, alloc change=47.02MiB, cpu time=315.10ms, real time=316.10ms, gc time=63.96ms
f4:= proc(a)
local T, u;
     for  u in `[]`~(a, [$1..nops(a)]) do T[u[1]][u[2]]:= () od;  #use NULL instead of () in math 2D
     {indices}~({entries(T, nolist)}, nolist)
end proc:
CodeTools:-Usage(f4(L),iterations=10):
memory used=22.67MiB, alloc change=0 bytes, cpu time=193.40ms, real time=193.50ms, gc time=51.48ms

fff:=proc(a)
local aa,T,u;
aa:=zip(`[]`,a,[$1..nops(a)]);
for u in aa do T[u[1]][u[2]]:=NULL od;
[indices]~([entries(T, nolist)], nolist)
end:
CodeTools:-Usage(fff(L),iterations=10):
memory used=21.90MiB, alloc change=0 bytes, cpu time=173.20ms, real time=173.90ms, gc time=43.68ms

@Carl Love 

Yes, I know that using tables is faster than appending. The main purpose was simplicity, the speed was just a by-product.

But indeed f4 seems to be both simple and fast, I like it :-)

@asa12 

arctan(x)=-Pi/2 does not have solutions in R or C. [However x=-infinity is an "extended" solution]

@asa12 

tan((45+270)*Pi/180) = -1

L:=seq( [t*cos(t),t*sin(t)],t=0..8.*Pi,Pi/36.):
plot([L],style=point);

 

@asa12 

If you insist in not using polar coordinates, try:

L:=NULL;
kmax:=0; # increase it to see more of the spiral
for ii from 0 by 5 to 365 do
print('ii'=ii);
for k from 0 to kmax do
eq1 := sqrt(x^2 + y^2) - arctan(y,x) = 2*k*Pi;
eq2 := y = evalf((-Pi/4 - ii*Pi/180)/Pi)*(-1.0)*x;
xy := fsolve({eq1, eq2});
#print(xy):
L:=L,eval([x,y],xy);
od:od:
plot([L],style=point);

@acer 

I do not think that it is very useful to use Maple as a funky typewriter. It is very nice that Maple offers the possibility to use true mathematical notations (as in the Physics or DifferentialGeometry packages). But here the mathematics involved is close to 0.

There are so many things to be done mathematically in Maple! For presentations, we have LaTeX, and a better export to it would be nice. The vector 3d graphics should also have a higher priority.

 

@Markiyan Hirnyk 

It is easy to modify convexhull to work properly with irrationals.
I did it, but I don't post here because in the past such code was deleted motivated by copyright.

You forgot with(geometry).

@Markiyan Hirnyk 

Solid people try showstat(convexhull).

@Markiyan Hirnyk 

 

In convexhull the coordinates are converted to floats, so the irrationals are not treated properly.

My favorite  "Next Number" Puzzle:

1  2  4   8  16  ?

"Correct" answer: 31

Proof:

with(CurveFitting):
PolynomialInterpolation([[0,1],[1,2],[2,4],[3,8],[4,16]], x):
eval(%,x=5);
      31

@taro 

In an ideal world, simplify (and a fortiori simplify(...,size)  which is now the default) should be enough.

First 140 141 142 143 144 145 146 Last Page 142 of 176