Jarekkk

439 Reputation

13 Badges

14 years, 164 days

MaplePrimes Activity


These are replies submitted by Jarekkk

I have no idea if this is the "best" solution, but it looks a lot simpler to me:

with(plots):
with(plottools):

A := polygon([[(1/4)*sqrt(2), (1/4)*sqrt(2)], [-(1/4)*sqrt(2), (1/4)*sqrt(2)], [-(1/4)*sqrt(2), -(1/4)*sqrt(2)], [(1/4)*sqrt(2), -(1/4)*sqrt(2)]], color = "DarkMagenta"):
B := implicitplot([x^2+y^2 = 1/4], x = -1/2 .. 1/2, y = -1/2 .. 1/2, coloring = ["Crimson", "HotPink"], filledregions = true, axes = none):
C := implicitplot([x^2+y^2 = 1/2], x = -(1/2)*sqrt(2) .. (1/2)*sqrt(2), y = -(1/2)*sqrt(2) .. (1/2)*sqrt(2), coloring = ["IndianRed", "DarkOrange"], filledregions = true, axes = none):
E := implicitplot([x^2+y^2 = 1], x = -1 .. 1, y = -1 .. 1, coloring = ["gold", "yellow"], filledregions = true, axes = none):

F := curve([[1, -1], [1, 1], [-1, 1], [-1, -1], [1, -1]], style = line, thickness = 2):
G := curve([[(1/2)*sqrt(2), -(1/2)*sqrt(2)], [(1/2)*sqrt(2), (1/2)*sqrt(2)], [-(1/2)*sqrt(2), (1/2)*sqrt(2)], [-(1/2)*sqrt(2), -(1/2)*sqrt(2)], [(1/2)*sqrt(2), -(1/2)*sqrt(2)]], style = line, thickness = 2):
H := curve([[1/2, -1/2], [1/2, 1/2], [-1/2, 1/2], [-1/2, -1/2], [1/2, -1/2]], style = line, thickness = 2):


and then

display(A,B,C,E);

or

display(A,B,C,E,F,G,H);

I have no idea if this is the "best" solution, but it looks a lot simpler to me:

with(plots):
with(plottools):

A := polygon([[(1/4)*sqrt(2), (1/4)*sqrt(2)], [-(1/4)*sqrt(2), (1/4)*sqrt(2)], [-(1/4)*sqrt(2), -(1/4)*sqrt(2)], [(1/4)*sqrt(2), -(1/4)*sqrt(2)]], color = "DarkMagenta"):
B := implicitplot([x^2+y^2 = 1/4], x = -1/2 .. 1/2, y = -1/2 .. 1/2, coloring = ["Crimson", "HotPink"], filledregions = true, axes = none):
C := implicitplot([x^2+y^2 = 1/2], x = -(1/2)*sqrt(2) .. (1/2)*sqrt(2), y = -(1/2)*sqrt(2) .. (1/2)*sqrt(2), coloring = ["IndianRed", "DarkOrange"], filledregions = true, axes = none):
E := implicitplot([x^2+y^2 = 1], x = -1 .. 1, y = -1 .. 1, coloring = ["gold", "yellow"], filledregions = true, axes = none):

F := curve([[1, -1], [1, 1], [-1, 1], [-1, -1], [1, -1]], style = line, thickness = 2):
G := curve([[(1/2)*sqrt(2), -(1/2)*sqrt(2)], [(1/2)*sqrt(2), (1/2)*sqrt(2)], [-(1/2)*sqrt(2), (1/2)*sqrt(2)], [-(1/2)*sqrt(2), -(1/2)*sqrt(2)], [(1/2)*sqrt(2), -(1/2)*sqrt(2)]], style = line, thickness = 2):
H := curve([[1/2, -1/2], [1/2, 1/2], [-1/2, 1/2], [-1/2, -1/2], [1/2, -1/2]], style = line, thickness = 2):


and then

display(A,B,C,E);

or

display(A,B,C,E,F,G,H);

@Alejandro Jakubi Thank you for this comment. I think many users would like to be able to turn the automatic simplification off sometimes.

@Alejandro Jakubi Thank you for this comment. I think many users would like to be able to turn the automatic simplification off sometimes.

Thank you for this possibility, however it would be nice if it could look like this:

some_simplifications(5^2 * 5^(1/2)) = 5^(5/2)

Thank you for this possibility, however it would be nice if it could look like this:

some_simplifications(5^2 * 5^(1/2)) = 5^(5/2)

I found similar question asked earlier where Robert Israel gave this solution. I remember I saw it somewhere else some time ago. Since then I am using it from time to time (it is also the second solution I had put into the question). I wondered why implicitplot is so ineffective. Never mind, for me it means to use plottols[transform] to color the regions.

I found similar question asked earlier where Robert Israel gave this solution. I remember I saw it somewhere else some time ago. Since then I am using it from time to time (it is also the second solution I had put into the question). I wondered why implicitplot is so ineffective. Never mind, for me it means to use plottols[transform] to color the regions.

and it gets even worse (the color of both "parts" is the same in this case).

and it gets even worse (the color of both "parts" is the same in this case).

In Maple 15 it works fine and I get

However, in Maple 16 I get

In Maple 15 it works fine and I get

However, in Maple 16 I get

@dohashi May I ask why I am getting the following timmings?

1) Using your first code:

restart;
p1 := proc(N)
      local i, result;
 
      for i from 1 to N
      do
          result[i] := 2*i-1
      end;
 
      op(result);
 end:
 
 p2 := proc(N)
      local i, result;
 
      for i from 1 to N
      do
          result[i] := 2*i;
      end;
 
      op(result);
 end:
 
 st:=time():
 Threads:-Task:-Start( passed, Task=[p1,10^5], Task=[p2,10^5] ):
 time()-st;

                            
1.592

2) Doing it sequentially:

restart;
st := time():
for i to 10^5 do results[i] := 2*i-1 end do:
for i from 10^5+1 to 2*10^5 do results[i] := 2*i end do:
op(result):
time()-st;
                            
0.858

 

My computer has 4 cores, Win 7 (64bit) and Maple 15.01. I would expect the timmigs vice versa.

Edit: OK, I now probably understand from your last sentence in the previous comment. However, I tried this approach to solve a different problem (5000 independent cycles in a for-loop) and got similar timmings (around 500s sequentially, around 800s parallel). A little disappointing...

@dohashi May I ask why I am getting the following timmings?

1) Using your first code:

restart;
p1 := proc(N)
      local i, result;
 
      for i from 1 to N
      do
          result[i] := 2*i-1
      end;
 
      op(result);
 end:
 
 p2 := proc(N)
      local i, result;
 
      for i from 1 to N
      do
          result[i] := 2*i;
      end;
 
      op(result);
 end:
 
 st:=time():
 Threads:-Task:-Start( passed, Task=[p1,10^5], Task=[p2,10^5] ):
 time()-st;

                            
1.592

2) Doing it sequentially:

restart;
st := time():
for i to 10^5 do results[i] := 2*i-1 end do:
for i from 10^5+1 to 2*10^5 do results[i] := 2*i end do:
op(result):
time()-st;
                            
0.858

 

My computer has 4 cores, Win 7 (64bit) and Maple 15.01. I would expect the timmigs vice versa.

Edit: OK, I now probably understand from your last sentence in the previous comment. However, I tried this approach to solve a different problem (5000 independent cycles in a for-loop) and got similar timmings (around 500s sequentially, around 800s parallel). A little disappointing...

1 2 3 4 5 6 7 Last Page 1 of 15