tomleslie

13876 Reputation

20 Badges

15 years, 163 days

MaplePrimes Activity


These are replies submitted by tomleslie

@Wolfgang Gellien 

for asny given expression, the two operations simplify(expression) and solve(expression=0) are not the same. In the OP's case, the first operation results in the expression b-1, and the second results in the equation b=1,

@jalal 

A quick search with your favourite search engine will show that the the "principal' angle is in the range 0..360. If you really want angles in the range -180..180, then all you need to do is subtract Pi from and of the methods I gave previously, as in the attached


 

  restart;
  randomize():
 

  L1:= [ seq( modp(j,360)*2*Pi/360,
              j=-720..-30, 15
            ),
         seq( modp(j,360)*2*Pi/360,
              j=30..720, 15
            )
       ]:
  r1:= rand(1..numelems(L1)):
  Da:= L1[r1()]-Pi;

-(2/3)*Pi

(1)

  L2:= [ seq( j,
              j=-720..-30, 15
            ),
         seq( j,
              j=30..720, 15
            )
       ]:
  r2:= rand(1..numelems(L2)):
  Da:= modp( L2[r2()], 360)*2*Pi/360-Pi;

(3/4)*Pi

(2)

  L3:= [ seq( j*2*Pi/360,
              j=30..360, 15
            )
       ]:
  r3:= rand(1..numelems(L3)):
  Da:= L3[r3()]-Pi;

(5/12)*Pi

(3)

 


 

Download ang2.mw

To perfom numeric integration 'n' must be given a numeric value!

But there are other issues, such as

  1. the integrand is infinite when x=1, because of the term (x-1) in the denominator
  2. depending on the value of 'n', the argument of the ln() function can be negative for part of the range x=0..1, meaning that ln() will be complex

@lcz 

'positive' just means >0, doesn't have to be an integer. 'posint' means >0 and must be an integer. So type(2.1, positve) will return true because 2.1>0, but type(2.1, posint) will return false because 2.1 is not an iinteger.

You can define new types interms of MAple's existing types. See this exerpt from the Maple help (my highlighting) as well as the attached

Definition of a Type in Maple
Description

  • By definition, a type in Maple is any expression that is acceptable as the second argument to the procedure type, and that, for any choice of first argument to type causes it to return either true or false. For example, in type(expr, typexpr), expr is of type typexpr if and only if the first expression evaluates to true.
  • Any particular type belongs to one of the following four categories:
  1. A system type: a type which is a name that is defined in the kernel of the Maple system. System types usually correspond to primitive algebraic or data structure concepts, such as integer, float, list, and relation.
  2. A procedural type where the type is a name, for example abc, and there is a procedure `type/abc` which will perform the type analysis of the argument and will return true or false accordingly. This procedure may be available from the global Maple environment or from a library (for the latter case it is automatically loaded into the environment). This is one of the mechanisms to define new types in Maple. For example, monomial, algnum, and specindex are presently implemented as Maple library procedures.
  3. An assigned type where the type is a name, such as abc, and the global name `type/abc` is assigned a type expression. The type evaluation proceeds as if the type checking were done with the expression assigned to `type/abc`. Thus

`type/intargs` := [algebraic, {name,name=algebraic..algebraic}];

....:

if not type([args],intargs) then error ...;

  The type last_name_eval is presently implemented as an assigned structured type in the library.

     4. A type expression which is a general Maple expression as described in type/structured.
 

  restart;
  f:= s -> type(s, posint)
           and
           type(log2(s), posint):
  f~([0, 4, -2]);

[false, true, false]

(1)

#
# An aside, what are the 'operands' associated
# with "simple" numbers in Maple
#
  op([0..], 2);
  op([0..], 2.0);
  op([0..], evalf(Pi));

Integer, 2

 

Float, 20, -1

 

Float, 3141592654, -9

(2)

#
# Difference between type::positive and type::posint
#
  type(2.1, positive);
  type(2.1, posint);

true

 

false

(3)

#
# Add/use new type
#
 `type/myType`:=And(posint, satisfies(s -> type(log2(s), posint))):
  type(2.1, myType);
  type(2, myType);

false

 

true

(4)

 

Download posType2.mw

 

 

@JAMET 

see the output in the attached, whihc clearly identifies the Maple version as

`Standard Worksheet Interface, Maple 18.02, Windows 7, October 20 2014 Build ID 991181`

 

If you are still having trouble, I  can only suggest that you actually do what I suggested previously - that is

 

  1. download the attached worksheet (use the link at the bottom of this post)
  2. run the attached worksheet using the !!! icon in the Maple toolbar
  3. save the resulting worksheet (with output) to a filename of your choosing
  4. upload the worksheet obtained at (3) above to this site using the big green up-arrow in the Mapleprimes toolbar

 

  restart;
  interface(version);
  a:= [3*t-7, -2*t+4, 3*t+4]:
  b:= [m+1, 2*m-9, -m-12]:
  c:= {x = -200/29-2*t, y = 114/29+3*t, z = 119/29+4*t}:
  doPlot:= proc( v )
                 uses geom3d:
                 local pName, j:
                 for j from 1 by 1 to 3 do
                     pName:=`union`(indets~(v[j])[])[]:
                   #
                   # The 3D line
                   #
                     line( cat(l, 4*j-3), v[j], pName);
                   #
                   # Projection of line on to x=0
                   #
                     line(cat(l, 4*j-2), [0, v[j][2], v[j][3]], pName);
                   #
                   # Projection of line on to y=0
                   #
                     line(cat(l, 4*j-1), [v[j][1], 0, v[j][3]], pName);
                   #
                   # Projection of line on to z=0
                   #
                     line(cat(l, 4*j), [v[j][1], v[j][2], 0], pName);
                 end do:
               #
               # The plane x=0
               #
                 plane(pl1, x=0, [x,y,z]);
               #
               # The plane y=0
               #
                 plane(pl2, y=0, [x,y,z]);
               #
               # The plane z=0
               #
                 plane(pl3, z=0, [x,y,z]):
               #
               # Draw everything
               #
                 draw( [ l1(color=black, thickness=4, linestyle=1),
                         l2(color=blue, thickness=2, linestyle=1),
                         l3(color=red, thickness=2, linestyle=1),
                         l4(color=green, thickness=2, linestyle=1),
                         l5(color=black, thickness=4, linestyle=3),
                         l6(color=blue, thickness=2, linestyle=3),
                         l7(color=red, thickness=2, linestyle=3),
                         l8(color=green, thickness=2, linestyle=3),
                         l9(color=black, thickness=4, linestyle=4),
                         l10(color=blue, thickness=2, linestyle=4),
                         l11(color=red, thickness=2, linestyle=4),
                         l12(color=green, thickness=2, linestyle=4),
                         pl1(color=yellow, style=surface, transparency=0.8),
                         pl2(color=yellow, style=surface, transparency=0.8),
                         pl3(color=yellow, style=surface, transparency=0.8)
                       ],
                       axes=normal,
                       scaling=constrained
                     );
           end proc:

`Standard Worksheet Interface, Maple 18.02, Windows 7, October 20 2014 Build ID 991181`

(1)

 doPlot([a, b, rhs~(convert(c,list))]);

 

 

Download drawLines3.mw

@Dr Jean-Michel Collard 

It took about 20 minutes.

And when you have retired, sometimes you find you have too much time, so don't knock it!

@tomleslie 

with the year at 2022, obviously both dates are in the future - I'd still check my systemTime/date from the control panel though

that (depending exactly on what you are trying to achieve) you *might* be able to "work around" this problem by using the plots:-pointplot() command. This will allow you to assign individual colors to each point (and it seems to work!), although you are restricted to using the same 'symbol' and 'symbolsize' for alll poinrts

See the attached
 

  restart;
  with(geom3d):
  point(A, [1, 2, 3]):
  point(B, [-2, 3, -1]):
  point(C, [0,-3, 1]):
  plots:-pointplot3d( [ coordinates(A),
                        coordinates(B), coordinates(C)
                      ],
                      color=[red, blue, green],
                      symbolsize=24,
                      symbol=solidsphere,
                      axes=none
                  );;

 

 

 

 

 


Download geomCol2.mw

and the impression given by PDE textbooks, most  PDEs cannot be solved analytically. It may be possible to solve your particular problem numerically, although this will require you to suppy numeric values for all parameters (alpha, beta, sigma) as well as another couple of boundary/initial conditions

in the Mapleprimes toolbar to upload your worksheet.

It is unlikely that anyone here will retype your worksheet in order to work on it.

@aniknam 

have you tried so far?

My previous posts have shown how to define all the lines you need and all the annotations you might ever want. All you have to do is understabd them and apply them

Or do you think this site exists so that someone will write code which you are too lazy/incompetent to do?

@aniknam 

Is that what looks "good" to you might not look "good" to me. The attached annotates the figure with most(?) of what you seem to want. But you may want to change, say, font sizes, font styles, colors etc,, etc

  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=1,
            color=blue
        ):
#
# eq2 from the intersection point to x=1
#
  l4:=line(  IP,
             [1, rhs(eval(eq2, x=1))],
             thickness=4,
             color=blue
          ):
#
# Construction line from the intersection point to
# the x-axis
#
  l5:=line( [IP[1], 0],
            IP,
            linestyle=dot,
            color=black
          ):
#
# A whole lot of "aesthetic" annotation
#
  yax1:=line( [0,0], [0,5]):
  yax2:=line( [1,0], [1,5]):
  xax:=line( [0,0], [1.1,0]):
  cl1:=line( [0,0], [0,-1], linestyle=dot):
  cl2:=line( [rhs(isolate(eval(eq2, y=0), x)), 0], [rhs(isolate(eval(eq2, y=0), x)), -1], linestyle=dot):
  cl3:=line( [1,0], [1,-1], linestyle=dot):
  labels:= textplot( [ [ 0, 5,
                         "income",
                         font=["times","italic",14],
                         align= above
                       ],
                       [ 1.1, 0,
                         "ability",
                         font=["times","italic",14],
                         align= right
                       ],
                       [ IP[1]/2, (rhs(eval(eq1, x=0))+IP[2])/2,
                         typeset( I__t^u),
                         font=["times","bold",14],
                         color=red,
                         align=[above, left]
                       ],
                       [ (IP[1]+1)/2, (rhs(eval(eq2, x=1))+IP[2])/2,
                         typeset( I__t^s),
                         font=["times","bold",14],
                         color=blue,
                         align=[above, left]
                       ],
                       [ 1, 5,
                         typeset( conjugate(w)*A__t),
                         font=["times","bold",14],
                         align=right
                       ],
                       [ 1, rhs(eval(eq1, x=1)),
                         typeset( conjugate(w)*A__t,"(1-",delta*g__t,")"),
                         font=["times","bold",14],
                         align=right
                       ],
                       [ 0, rhs(eval(eq1, x=0)),
                         typeset( conjugate(w)*A__t,"(1-",delta*g__t,")(1-", delta*g__t, ")"),
                         font=["times","bold",14],
                         align=left
                       ],
                       [ rhs(isolate(eval(eq2, y=0), x)), 0,
                         typeset( g__t,"(1-", g__t, ")"),
                         font=["times","bold",14],
                         align=below
                       ],
                       [ IP[1], 0,
                         typeset( a, "*(", g__t,")"),
                         font=["times","bold",14],
                         align=below
                       ],
                       [ 0, 0,
                         "0",
                         font=["times","bold",14],
                         align=below
                       ],
                       [ 1, 0,
                         "1",
                         font=["times","bold",14],
                         align=below
                       ],
                       [ 0.25, -0.5,
                         "Unskilled workers",
                         font=["times","bold",14]
                       ],
                       [ 0.75, -0.5,
                         "Skilled workers",
                         font=["times","bold",14]
                       ]
                     ]
                   ):


  display( [l1,l2, l3, l4, l5, yax1, yax2, xax, labels, cl1, cl2, cl3],
           axes=none,
           size=[700, 500],
           gridlines=false
         );

 

 

 


 

Download lines2.mw

@vv 

but why bother? The OP's original  calculation can be reduced to that shown in the attached

  restart;

  sol := [ [0, 0, 0, 0, 0, 0, 1],
           [0, 0, 1, 1, 0, 0, 0],
           [0, 1, 0, 0, 1, 0, 0],
           [0, 2, 1, 0, 0, 0, 0],
           [1, 0, 0, 0, 0, 1, 0],
           [1, 0, 2, 0, 0, 0, 0],
           [1, 1, 0, 1, 0, 0, 0],
           [1, 3, 0, 0, 0, 0, 0],
           [2, 0, 0, 0, 1, 0, 0],
           [2, 1, 1, 0, 0, 0, 0],
           [3, 0, 0, 1, 0, 0, 0],
           [3, 2, 0, 0, 0, 0, 0],
           [4, 0, 1, 0, 0, 0, 0],
           [5, 1, 0, 0, 0, 0, 0],
           [7, 0, 0, 0, 0, 0, 0]
         ]:
  RSP2:= proc(L)
              local j:
              return add( j*L[j-1], j=2..nops(L))!
                     /( (1+add( (j-1)*L[j-1], j=2..nops(L)))!
                        *
                        mul( L[j-1]!, j=2..nops(L))
                      )  
         end proc:
#
# Examples
#
  RSP2(sol[12]);
  RSP2(sol[3]);
#
# or even
#
  RSP2~(sol);

990

 

9

 

[1, 9, 9, 45, 9, 45, 90, 165, 45, 495, 165, 990, 495, 1287, 429]

(1)

 

Download newProc.mw

 

@Detlef Hoyer 

is free to submt an SCR, so woh am I to object?

This one however will be ignored,because Maple is doing what it s designed to do. The fact that you dislike Naple's designed behaviour is somewhat irrelevant

@Detlef Hoyer 

I regard the use of 2D Math input as "dangerous", which is why I never use it (except for fixing problems posted on this site).

You can find more details of the vagaries(?) of 2D Math input by typing 'worksheet/documenting 2DMath' (without quotes) in the Maple Help search box - then follow the link '2-D Math Details'. There are a few interesting comments on this page, for example (my highlighting)

  1. 2-D math input allows for some implicit multiplication, that is, writing a multiplication operation without requiring a multiplication sign. For example, a space is used between x and x to mean multiplication:
  2. Exceptions to this rule include cases where it is clear that only multiplication can be implied. Then a space is not necessary:

I think your example of epsilon[3]b (ie with no space) may be covered by the second comment above - because what else could it mean?. Note that if you type epsilon[3]b in 1D Math input, Maple produces an error message

First 29 30 31 32 33 34 35 Last Page 31 of 207