tomleslie

13876 Reputation

20 Badges

15 years, 164 days

MaplePrimes Activity


These are answers submitted by tomleslie


although I think you might want to add some prettitying options to the "arrows" (PS the gridlines don't appear in the Maple worksheet, so the plot *looks* a bit cleaner

   restart;
   potfeld := (x, y) -> 1/sqrt(y^2+x^2):

   for i to 5 do
       for j to 3 do
           if   `and`( sqrt(i^2+j^2) <> 0,
                       sqrt((i-2)^2+j^2) <> 0,
                       evalf(potfeld(i, j)) < 3
                     )
           then P[i, j]:= plots:-arrow(`<,>`(i, j),
                                       `<,>`( (D[1](potfeld))(i, j),
                                              (D[2](potfeld))(i, j)
                                            )
                                      );
           else Pfeil[i, j]:= plots:-arrow( `<,>`(i, j),
                                            `<,>`(.1, .1)
                                          )
           end if;
       end do;
   end do;
   Pseq:= [ seq
            ( seq
              (  P[k, l],
                 k = 1 .. 5
              ),
              l = 1 .. 3
            )
          ]:
    plots:-display( Pseq,
                    view = [1 .. 5, 1 .. 3],
                    scaling = constrained
                  );

 

 

 


 

Download pfield.mw

The attached code will prodduce a specific Lissajou  animation - for others you will need to adjust the values of the paramerters 'a', 'b' and delta. The Wikipedia page at https://en.wikipedia.org/wiki/Lissajous_curve is helpful for showing the possibilities

  restart;
  with(plots):
  params:= [ A=2,
             B=3,
             a=3,
             b=2,
             delta=Pi/2
           ]:
  xy:= A*sin(a*t+delta),
       B*sin(b*t):
  p1:=plot( eval
        ( [ xy,
            t=0..2*Pi
          ],
          params
        ),
        -3..3,
        -3..3,
        scaling=constrained
      ):
  animate( pointplot,
           [ eval
             ( [ xy ],
                params
             ),
             style=point,
             symbol=solidcircle,
             symbolsize=20,
             color=blue
           ],
           t=0..2*Pi,
           scaling=constrained,
           background=p1,
           frames=100
         );

 

 

Download Lissajou.mw

is twofold

  1. Just how much work do you want to do
  2. What I think looks "pretty" may not be what you think looks "pretty"

Bearing in mind the above, the attached

  1. is about as much work as I would be prepared to do
  2. looks OK - probably could be better, but I'm not prepared to put more effort in

I should point out thta the plot *looks* better in a Maple worksheet than it renders on this site - honest! I think this site has somewhat "scrunched" it horizontally

  restart;
  with(plots):
  with(plottools):
  P1:= [ rhs(solve(  [d/(d-2)=3*d/(3-d), d>0])[]),
         eval( d/(d-2), solve(  [d/(d-2)=3*d/(3-d), d>0])[] )
       ]:
  P2:= [ rhs(solve(  [d/(d-1)=3*d/(3-d), d>0])[]),
         eval( d/(d-1), solve(  [d/(d-1)=3*d/(3-d), d>0])[] )
       ]:
  display( [ plot( d/(d-2),
                   d=2..3,
                   color=red,
                   thickness=4
                 ),
             plot( 3*d/(3-d),
                   d=0..3,
                   color=black,
                   thickness=4
                 ),
             plot( d/(d-1),
                   d=1..3,
                   color=blue,
                   thickness=4
                 ),
             line( [P1[1], 0],
                   P1,
                   color=black,
                   linestyle=dot
                 ),
             line( [P2[1], 0],
                   P2,
                   color=black,
                   linestyle=dot
                 ),
             shadebetween( 1,
                           0,
                           d=0..3,
                           color=blue,
                           transparency=0.8
                         ),
             shadebetween( P2[2],
                           1,
                           d=0..P2[1],
                           color=red,
                           transparency=0.8
                         ),
             shadebetween( d/(d-1),
                           1,
                           d=P2[1]..3,
                           color=red,
                           transparency=0.8
                         ),
             shadebetween( 3*d/(3-d),
                           d/(d-1),
                           d=P2[1]..P1[1],
                           color=green,
                           transparency=0.8
                         ),
             shadebetween( d/(d-2),
                           d/(d-1),
                           d=P1[1]..3,
                           color=green,
                           transparency=0.8
                         ),
             textplot( [1.93, 12, "NS Curve: a=d/(d-2) --->"],
                       font=[times, bold, 14],
                       color=red
                     ),
             textplot( [1.35, 10, "<---BP Curve: a=d/(d-1)"],
                       font=[times, bold, 14],
                       color=blue
                     ),
             textplot( [1.65, 5.5, "PD Curve: a=3d/(3-d) --->"],
                       font=[times, bold, 14],
                       color=black
                     ),
             textplot( [1.4, 1.6, "d=3/2 --->"],
                       font=[times, bold, 14],
                       color=black
                     ),
             textplot( [2.15, 5.5, "d=9/4 --->"],
                       font=[times, bold, 14],
                       color=black
                     ),
             textplot( [2.6, 3, typeset(Omega[E3]^S2)],
                       font=[times, bold, 14],
                       color=black
                     ),
             textplot( [2, 3, typeset(Omega[E3]^S1)],
                       font=[times, bold, 14],
                       color=black
                     ),
             textplot( [1.7, 1.6, typeset(Omega[E2]^S)],
                       font=[times, bold, 14],
                       color=black
                     ),
             textplot( [1.25, 0.5, typeset(Omega[E1]^S)],
                       font=[times, bold, 14],
                       color=black
                     )
           ],
           view=[1..3, 0..14],
           size=[900,500],
           labels=[d,a],
           labelfont=[times, bold, 20],
           gridlines=false           
         );

 

 

Download prettyPlot.mw

 

whihc may be more flexible if you are really looking to construct "molecules" from a limited number of different types of "atoms" is shown n the attached

  getSph:=proc( pos::list, typ::name )
                uses plottools:
                if   typ=carbon
                then sphere( pos, 0.2, color=black, style=surface):
                elif typ=hydrogen
                then sphere( pos, 0.1, color=red, style =surface):
                elif typ=oxygen
                then sphere( pos, 0.2, color=blue, style =surface):
                fi;
          end proc:
   plots:-display( [ getSph( [1,1,1], carbon ),
                     getSph( [1,2,1], hydrogen),
                     getSph( [2,2,1], hydrogen),
                     getSph( [0,1,2], oxygen)
                   ],
                   scaling =constrained,
                   axes=none
                );              

 

 


 

Download pltSph.mw

 

is that my system time and date is set correctly for my geographic region

The date 6/9/2022 is "in the future" if interpreted as a UK date format (sixth of september), but is "in the past" if interpreted as a US date format (ninth of June)

 

Having  done some experimentation, I came to the following conclusions

  1. It only affects the geom3d() package, the (2D) geometry() package appears to behave correctly
  2. In the geom3d() package, it seems that only "points" are affected. Local/global options (including color/colour for all other geometric options appear to be handled correctly
  3. For "points" in the geom3d() package, all local/global options except for color/colour appear to be handled correclty.
  4. This problem has been around for a long time. I checked it all the way back to Maple 18 (that's Maple 18, not Maple 2018), and the same problem exists in all of them
  5. I have submitted an SCR, although I have no idea if/when this will be fixed

see the attached

  restart;
  with(geom3d):
  point(A, [1, 2, 3]):
  point(B, [-2, 3, -1]):
  point(C, [0,-3, 1]):
  segment(S1, A, B):
  segment(S2, A, C):
  draw( [ A(symbol=solidsphere, symbolsize=30, colour=green),
          B(symbol=box, symbolsize=30, colour=green),
          C(symbol=asterisk, symbolsize=30, colour=black),
          S1(thickness=4, color=red),
          S2(thickness=4, color=blue)
        ]
      );
  draw( [ A(symbol=solidsphere, symbolsize=30),
          B(symbol=box, symbolsize=30),
          C(symbol=asterisk, symbolsize=30),
          S1(thickness=4, color=red),
          S2(thickness=4, color=blue)
        ],
        color=green
      );

 

 

 

 

Download geomCol.mw

 

 

as in the attached, which plots three lists of points  with various options,  Doing just one list of points is even easier!

Download usePlot3.mw

That I understand the requirement completely - maybe something like the attached?

  restart;
  myFun:= proc(g, z)
               if   _npassed=2
               then return z;
               else return g(_passed[2..-1]);
               fi:
          end proc;
  myFun(`%+`, floor(5 %/ (2 %* 3 %* 5)));
  myFun(`%+`, floor(5 %/ (2 %* 3 %* 5)),1,2);
  myFun(`%*`, floor(5 %/ (2 %* 3 %* 5)));
  myFun(`%*`, floor(5 %/ (2 %* 3 %* 5)),1,2);

proc (g, z) if nargs = 2 then return z else return g(args[2 .. -1]) end if end proc

 

floor(`%/`(5, `%*`(`%*`(2, 3), 5)))

 

`%+`(floor(`%/`(5, `%*`(`%*`(2, 3), 5))), 1, 2)

 

floor(`%/`(5, `%*`(`%*`(2, 3), 5)))

 

`%*`(floor(`%/`(5, `%*`(`%*`(2, 3), 5))), 1, 2)

(1)

 

Download inFun.mw

I agree with 'vv' that the point 'D' is not the middle of the segment BC, as 'mmcdara' assumes.

The followwing uses the geom3d() package along with the angle bisector theorem to obtain the same answers as 'vv'. just to shw that there is always more than one way to do it!)


 

  restart;
  local D:
  with(geom3d):
  point( A, [-2, 3, -5]):
  point( B, [-6, 1,-1]):
  point( C, [2, -3, 7]):
  segment( AB, [A, B]):
  segment( AC, [A, C]):
  segment( BC, [B, C]):
#
# Using the angle bisector theorem, see
#
#   https://en.wikipedia.org/wiki/Angle_bisector_theorem
#
  OnSegment( D, B, C, distance(A, B)/distance(A, C)):
  simplify~(coordinates(D));
  segment( AD, [A, D]):
#
# Parametric equation of the line AD
#
  eql:= Equation(line(ad, [A, D]), t);
  draw( [ A(symbol=solidsphere, symbolsize=20),
          B(symbol=solidsphere, symbolsize=20),
          C(symbol=solidsphere, symbolsize=20),
          D(symbol=solidsphere, symbolsize=20),
          AB(color=red, thickness=4),
          AC(color=red, thickness=4),
          BC(color=red, thickness=4),
          AD(color=black, thickness=4)
       ]
     );

[-18/5, -1/5, 7/5]

 

[-2-(8/5)*t, 3-(16/5)*t, -5+(32/5)*t]

 

 

 

 


 

Download bisAng.mw

I fixed a couple of things in the attached

  1. You explictly assign 'a' as a function in the first example, then subsequently use it as unevaluated function - hence the unassign() statement
  2. fixed the same type as mentioned by acer

restart;

DDS := a(n+1) = (1+.12*(1/12))*a(n)+1000

a(n+1) = 1.010000000*a(n)+1000

(1)

rsolve({DDS, a(0) = 0}, a(n)); a := unapply(%, n)

100000*(101/100)^n-100000

 

proc (n) options operator, arrow; 100000*(101/100)^n-100000 end proc

(2)

plot(a(n), n = 0 .. 100)

 

pts := {seq([k, a(k)], k = 0 .. 24)}; plot(pts, style = point, title = "Savings Account with Monthly Deposit")

 

unassign(a); rsolve({a(0) = 497.5124378, a(n+1) = -1.01*a(n)+1000}, a(n))

-(11/1005000000)*(-101/100)^n+100000/201

(3)

plot([-(11/1005000000)*(-101/100)^n+100000/201], n = 0 .. 20, a = 0 .. 1000)

 

solve(ev = -1.01*ev+1000, ev)

497.5124378

(4)

rsolve({a(n+1) = .5*a(n)+16}, a(n))

a(0)*(1/2)^n+32-32*(1/2)^n

(5)

rsolve({a(0) = 10, a(n+1) = .5*a(n)+16}, a(n))

-22*(1/2)^n+32

(6)

smartplot(-22*(1/2)^n+32)

 

rsolve({a(0) = 20, a(n+1) = .5*a(n)+16}, a(n))

-12*(1/2)^n+32

(7)

smartplot(-12*(1/2)^n+32)

 

rsolve({a(0) = 32, a(n+1) = .5*a(n)+16}, a(n))

32

(8)

rsolve({a(0) = 50, a(n+1) = .5*a(n)+16}, a(n))

18*(1/2)^n+32

(9)

smartplot(18*(1/2)^n+32)

 

solve(ev = .5*ev+16, ev)

32.

(10)

solve(ev = .5*ev+64, ev)

128.

(11)

rsolve({a(0) = A, a(n+1) = .5*a(n)+64}, a(n)); a := unapply(%, [A, n])

A*(1/2)^n-128*(1/2)^n+128

(12)

inits := [0, 50, 100, 150, 200]

gen := proc (i, j) options operator, arrow; evalf[4](a(inits[j], i)) end proc

proc (i, j) options operator, arrow; evalf[4](a(inits[j], i)) end proc

(13)

DrugConcTable := Matrix(10, 5, gen)

Matrix(%id = 36893488147956667324)

(14)

``

NULL

NULL


 

Download adv.mw

a variable name using concatenation, there are a couple of things you should be aware of

  1. use of the '||' construct is deprecated.  From the help page for '||', it states clearly -  Note: The use of this operator is discouraged. Where possible the function cat should be used.
  2. Also from the same help page - Any name returned from the concatenation operator will be a global variable

The second of these causes your problem. The first time you execute the procedure 'RSP' none pf the global names exist, so everything "works". The second time you run the procedure the names m2, m3, m4, m5, m6, m7 all exist and have been assigned values in the global namespace. So when you "create" the names again, they will automatically be assigned to the values which you created previously.

I see no reason to create these variable names, becuase m2=L[1], m3=L[2].. and so on. Why create a whole new set of variable names such as m2, m3, m4, m5, m6, m7 when these are always identical to L[1], L[2], L[3], L[4], L[5], L[6]. Ther whole exercise is just  superfluous

the figure shown in the attached?

restart

sigma := 7.500*10^7+2.005*10^7*sinh(22985.642*z)-2.097*10^7*cosh(22985.642*z)

75000000.00+20050000.00*sinh(22985.642*z)-20970000.00*cosh(22985.642*z)

(1)

sigma_debond := 5.403*10^7

54030000.00

(2)

mid := 0.1653e-3

0.1653e-3

(3)

L := 0.2184e-3

0.2184e-3

(4)

p1 := plot(sigma, z = mid .. L)

p2 := plot(sigma_debond, z = 0 .. mid)

plots:-display([p1, p2])

 

 


Download combinePlots.mw

the attached?

  restart;
  with(plottools):
  with(plots):
#
# Four parameters: note it must be true that
#
#        m1>0
#        c1>0
#        m2>0
#        c2<0
#
  m1:=1: c1:=2: m2:=10: c2:=-5:
#
# Two equations
#
  eq1:=y=m1*x+c1:
  eq2:=y=m2*x+c2:
#
# The intersection point
#
  IP:=rhs~(solve([eq1, eq2], [x, y])[]):
#
# eq1 from x=0 to the intersection point
#
  l1:=line( [0, rhs(eval(eq1, x=0))],
            IP,
            thickness=4,
            color=red
          ):
#
# eq1 from the intersection point to x=1
#
  l2:=line(  IP,
             [1, rhs(eval(eq1, x=1))],
             thickness=1,
             color=red
          ):
#
# eq2 from the x-axis to the interesection point
#
  l3:=line( [rhs(isolate(eval(eq2, y=0), x)), 0],
            IP,
            thickness=4,
            color=blue
        ):
#
# eq2 from the intersection point to x=1
#
  l4:=line(  IP,
             [1, rhs(eval(eq2, x=1))],
             thickness=1,
             color=blue
          ):
#
# Construction line from the intersection point to
# the x-axis
#
  l5:=line( [IP[1], 0],
            IP,
            linestyle=dot,
            color=black
          ):
  display([l1,l2, l3, l4, l5]);

 

;

 


 

Download lines.mw

when using 2D-input (a+b)(c+d) ths will be parsed as applying the functions 'a' and 'b' to the argument (c+d), so will expand to a(c+d)+b(c+d)

The 2-D input (a+b) (c+d), ie with a space between the two terms will be regarded as an (implied) multiplication of two terms and will expand to a b+a d+b c+b d

the "safest" method of writing such an input expression is probably to use an explicit mulitplication sign, ie the '*' on the keyboard, so the expression will then appear as (a+b).(c+d), except that the '.' character will be on the centreline rather than the baseline

See the attached in which I have inseted the multiplication sign in you expression, and implemented th toy example shown above for information

A := simplify(-1-(`&epsilon;`[3]-1)*(a*b*`&epsilon;`[2]/(r*(b*`&epsilon;`[1]+a))+a+b)/(2*r))

(1/2)*((-2*b*epsilon[1]-2*a)*r^2-(epsilon[3]-1)*(a+b)*(b*epsilon[1]+a)*r-a*b*epsilon[2]*(epsilon[3]-1))/(r^2*(b*epsilon[1]+a))

(1)

B := simplify(-1-(`&epsilon;`[3]-1)*(a*b*`&epsilon;`[2]/(r*(b*`&epsilon;`[1]+a))+a+b)/(2*r))

(1/2)*((-2*b*epsilon[1]-2*a)*r^2-(epsilon[3]-1)*(a+b)*(b*epsilon[1]+a)*r-a*b*epsilon[2]*(epsilon[3]-1))/(r^2*(b*epsilon[1]+a))

(2)

simplify(A-B)

0

(3)

expand((a+b)(c+d)); expand((a+b)*(c+d)); expand((a+b)*(c+d))

a(c+d)+b(c+d)

 

a*c+a*d+b*c+b*d

 

a*c+a*d+b*c+b*d

(4)

 

Download implicit.mw

The only way I can replicate the behaviour which you are seeing is to change the interface(displaythreshold) setting. By default, this shoud be -1. Although not obvious from your worksheet, youu appear to have set it to 6 - maybe in an init file?

You can comment/uncomment the lines

interface(displaythreshold=-1);
interface(displaythreshold=6);

in the attachedto observe the impact. In the attached I have also changed all occurrences of the variable name 'varepsilon' to 'epsilon', otherwise your worksheet doesn't even execute!

ifdispl.mw

First 42 43 44 45 46 47 48 Last Page 44 of 207