19675 Reputation

26 Badges

15 years, 146 days

MaplePrimes Activity

These are replies submitted by Kitonum

@das1404  Of course I was wrong. There is no second error in your code. However, in principle this statement  "Strings can not act as names" is true, for example:

"x" := 2;
    Error, invalid left hand side of assignment

@adxters  This procedure allows us to sort the sublists of some list by increasing the first element in the sublists. See an example:

L:=[[2,1], [1,3], [0,2]]:
sort(L, (a,b)->a[1]<=b[1]);
 [[0, 2], [1, 3], [2, 1]]

@abhilashun  You can easily calculate the volume of this body numerically, using the Monte Carlo method (of course with low accuracy):

evalf(Int(`if`(f1<=0 and f2<=0 and f3<=0 and f4<=0, 1, 0), [x=-2..2, y=-2..2, z=-2..2], method = _MonteCarlo, epsilon=0.001));


plots:-implicitplot3d(max(f1,f2,f3,f4)=0,  x=-2..2, y=-2..2,z=-2..2, style=surface, axes=normal, scaling=constrained, lightmodel=light3, numpoints=1000000); 



@Deank1905  You should more clearly formulate your problem and also download (or give a link) the worksheet.

@acer  I think your approach will be too difficult for a beginner. Because we already know that  f(1)=0 , then we can just write

f := x -> 2*x^2-2;

or if we do not know the value of  x  in  y=f(x)  for  y=0 :

f := x -> 2*x^2-2;
x:=eval(x, solve({f(x)=0, x>=0})) ;

@amrramadaneg Try the following way. We have about 100 points  on every side of the square:

a:=2: b:=5:
plot([[0,t,t=-a..a], [t,a,t=0..b], [b,t,t=-a..a], [t,-a,t=0..b]], style=point, color=red,scaling=constrained, symbol=circle, symbolsize=3, numpoints=100, adaptive=false, size=[1000,600]);

@RElax  Sorry that did not answer your questions right away, I was pretty busy. I answer for each item. I note at once that this is not a recursive procedure, because In the body of the procedure, we do not refer anywhere to the name of the procedure.

1. In the first line we declare the name of the procedure, i.e. Sierpinski, and in parentheses after that we declare the names of formal parameters and their types.
2. In the next line, we declare the names of local variables. Outside the body of the procedure these are just symbols.
3. The sub-procedure  named  Step  plays a key role in Sierpinski procedure. It reproducts triangles for one step, i.e. to each element from a list  L (the element is a list of vertices of a triangle), it associates three new triangles. For example, triangles AEG, EBF, GFC, where E, F, G are the midpoints of the sides AB, BC, AC, will be associated with the triangle ABC.
4. In  A  we simply fill the interior of the resulting triangles, and in  B  we draw their vertices in the form of small circles.
5. display command depicts everything together.


1. I did not understand what you mean "...starting from "16" ".

2. Circles at the tops of the Sierpinski triangle:

local Step, A, B;
uses plottools, plots;
Step:=L->map(t->op([[t[1],(t[1]+t[2])/2,(t[1]+t[3])/2],[(t[1]+t[2])/2,t[2],(t[2]+t[3])/2],[(t[1]+t[3])/2,(t[2]+t[3])/2,t[3]]]), L);
B:=map(t->plot(t,style=point,color=C, symbol=circle, symbolsize=8),(Step@@n)([T]));
display(A,B, axes=none, scaling=constrained, size=[600,600]);
end proc:

Example of use:

Sierpinski1([[-1,0],[0,1.73],[1,0]], 5);



@mehdi jafari  Here is another way in which the substitution  S  is done separately in the numerator and in the denominator:



@Adam Ledger  This does not contradict what I wrote. You have defined the sequence of names explicitly with already known number of members.

@Adam Ledger  Just Maple is so designed that the formal parameters of the procedure can be a name or a sequence of names (specified explicitly) or nothing. If you have a sequence with an undefined number of terms, you can just give it a name and then reference it. You can even not specify formal parameters at all, but in the body of the procedure refer to them using  args  and  nargs  commands. Here is a simple example of these two ways. Two procedures below calculate the arithmetic mean of several numbers:

Mean1:=a->add(a)/nops(a); # First way
Mean2:=()->`+`(args)/nargs; # Second way

Mean1([1,2,3,4]);  # Examples of use


@Adam Ledger  Of course, I know this wonderful formula for calculating the number of lucky tickets. Maple can calculate by this formula, but it takes 20 times longer than using  NestedSeq  procedure:

t:=time(): 1/Pi*int((sin(10*x)/sin(x))^6, x=0..Pi); time()-t;
t:=time(): `+`(NestedSeq(`if`(i+j+k=l+m+n,1,0), [i,j,k,l,m,n]=~0..9)); time()-t;


@Muhammad Usman Sorry, I did not notice that degrees are required, not radians. Correct as showed to you by tomleslie.


convert(sum(ln(k), k=1..m), factorial)  assuming m::posint;


First 39 40 41 42 43 44 45 Last Page 41 of 126