Kitonum

21465 Reputation

26 Badges

17 years, 48 days

MaplePrimes Activity


These are answers submitted by Kitonum

I also do not understand why you introduce vectors, if at the beginning of your worksheet the partition is defined through lists. So I replaced vectors with the lists.

The following code on each call returns a random partition of  the number  n :

 

Partition := proc (n::posint)

local i, Integer, Sum, Partition;

Sum := 0; Partition := [ ];

for i to n-1 do

if Sum < n then Integer := RandomTools[Generate](integer(range = 1 .. n));

if Sum+Integer <= n then Partition := [op(Partition), Integer];

Sum := Sum+Integer end if end if;

end do;

`if`(Sum < n, sort([op(Partition), n-Sum]), sort(Partition));

end proc:

 

Example of use (the procedure was called 100 times):

seq(Partition(5), i = 1 .. 100);

 

 

If I understand the problem, we need to find the point at which the different curves merge. Absolutely they never merge, just very close to each other. Therefore, we set the boundary proximity  epsilon , when we think that the curves are indistinguishable. In the example below, we find  T , when the black curve merges with the red curve, setting  epsilon=0.001

restart;

Eq := x-(r+3.1*10^7*exp(-11616/(1.98*T)))/(3.1*10^7*exp(-11616/(1.98*T))+1.8*10^18*exp(-29691/(1.98*T))) = 0:

x:=unapply(rhs(isolate(Eq, x)),T,r); # is the function of  (T,r)

 R := [0, 0.1e-2, 0.1e-1, .1, 1.6]:

simplify(diff(x(T,R[5])-x(T,R[1]),T)); # Derivative is negative, thus graphs approach each other

epsilon:=0.001;

T0:=fsolve(x(T,R[5])-x(T,R[4])=epsilon); # From this value   the distance between the graphs is less than epsilon

plots[implicitplot]([seq(eval(Eq, r = R[i]), i = 1 .. nops(R))], T = 0 .. 500, x = 0 .. 2, color = [red, blue, green, yellow, black,red], thickness=[2,1$4], gridrefine = 5);

                     

                        

 

 

If your expression is a polynomial in  t, then just

expr:=0.5*t^5 * r^(-1)*V:

degree(expr, t);

                           5

 

The procedure  for more complex expressions, not only for the polynomials:

power:=proc(expr, x)  # procedure finds the maximum degree of subexpressions x^n::integer in the expression expr

local S, L, s, n;

S:=indets(expr,`^`);

L:=[];

for s in S do

n:=op(s)[2];

if op(s)[1]=x and n::integer then L:=[op(L), n] fi;

od;

max(L);

end proc:

 

Another variant - the same in Carl's style:

power:=(expr::algebraic, t::name)->max(map(s->op(s)[2], select(s->(op(s)[1]=t

and op(s)[2]::integer), indets(expr,`^`)))):

 

 

Example of use:

power(sin(t^2)+1/(1+t^3)+2^t, t);

                            3

 

My answer was edited and expanded.

@Daniel Maxin  You can use  listcontplot  command, but for this you have to rewrite your data so that it was a two-dimensional list consisting only of the  z-values corresponding to the points  (x[i], y[j]), taking by "layers". There is another problem. Maple draws the contour curves with the marks on the coordinate axes are not real values  (x[i], y[j]), and their numbers  i=1..m, j=1..n . This problem can be easily solved using a linear transformation which is the compression to the point  (1, 1), then the parallel translation.

For example, I took the values  (x[i], y[j])   in the rectangle  x=1..4  and  y=2..4  with step  0.2. Third coordinate z for these points I took by formula  z=x^2+y^2 . So I got the list  Data . Then  plots[listcontplot]  command for  Data . The color intensity increases from pink to red with increasing  z-values. Default Maple draws 8 contour lines. Their numbers and values you can adjust by levels  option.

X:=[seq(x, x=1..4, 0.2)];

Y:=[seq(y, y=2..4, 0.2)]; 

Data:=[seq([seq(x^2+y^2, x=X)], y=Y)];

P:=plots[listcontplot](Data, filledregions=true, coloring=[pink,red]):

P1:=plottools[translate](plottools[homothety](P, 1/5, [1,1]), 0, 1):

plots[display](P1, view=[-0.5..5,-0.5..5]); 

 

                           

 

 

In older versions of Maple in which there is no  parametric  option, it is useful to factorize the polynomial , then the solution is reduced to the study of the discriminant of quadratic trinomial:

factor(b^4-(2-d)*b^2-2*d*b+1+d);

discrim(op(2, %), b);

                                   

Because  for  d>0  the discriminant  of  b^2+2*b+d+1  is negative, then  b^4-(2-d)*b^2-2*d*b+1+d>0  for all  b<>1 .  So should be solved in this way, if you need a manual solution.

 

For automated solution you can simply write

solve(b^4-(2-d)*b^2-2*d*b+1+d > 0, b) assuming d > 0, d <= 1;

                   

 

 

It's probably incorrect syntax. See the example:

 

plott(x^2, x=0..1);

                             

 

If my example does not help, please provide your code for more accurate response.

 

Addition. If at first sight the command looks right, check that all the letters typed in English layout.

Probably this is an anomaly of specific version of Maple. For example I have no problem in classic worksheet Maple 12:

plot(1/cos(t), t=0..Pi/3, thickness=2, coords=polar);

                               

 

 

Addition. I remember that the problems with polar plots were in Maple 16.00

1. No need to call  plots:-shadebetween  command, as if the lower plane  z = 0 , older option  filled=true  does the same thing.

2. For an accurate representation of the shape of the body  scaling=constrained option should be used.

3. To improve the appearance  user lighting was used (by right clicking).

 

plot3d(x^2-y^2+4, x = -1 .. 1, y = 0 .. 2, filled = true, axes = normal, view = [-1.4 .. 1.4, 0 .. 2.4, 0 .. 5.4], scaling = constrained, orientation = [50, 70]);

                             

 

 

 

Eq := 544*X-228412+1836*Y-1296*Z = 0:

d := igcd(coeffs(lhs(Eq)));

d*``(lhs(Eq)/d) = 0;

                    

 

 

plots[implicitplot](1=x^2+(y-1)^2, x=-2..2, y=-1..3, color=red, thickness=2, view=[-1.5..1.5,-0.5..2.5], gridrefine=3);

                            

 

 

For plotting you must specify   h  and  b .

Example:

h:=-x:  b:=(x+3)^3:

f:=piecewise(-3 < x and x< -2, h, -2 < x and x< -1, b):

plot(f, x=-3..-1, discont, thickness=2, view=[-3.5..0.5,-0.5..3], scaling=constrained);

 

We need to find a point on the curve, in which  the normal passes through original point. The following code solves the problem for the original point  M=[0,-2] :

restart;

f:=x->1/x:

Eq:=(y=f(x0)-1/D(f)(x0)*(x-x0)):

M:=[0,-2]:

x0:=fsolve(eval(Eq, [x,y]=~M), x0=0..infinity);

A:=plot([1/x, f(x0)+D(f)(x0)*(x-x0), [t,eval(rhs(Eq),x=t), t=0..x0]], x=-2..4, -3..3, color=[red,blue,green], thickness=[2,1,2], discont):

B:=seq(plottools[disk](p,0.03,color=yellow), p=[M,[x0,f(x0)]]):

C:=plots[textplot]([[0.2,-2,"M"],[x0+0.2,f(x0)+0.1,P]], font=[TIMES,ROMAN,18]):

plots[display](A,B,C);  # Visualization - the point P is the projection of the point M onto the curve  y=1/x, x>0

 

 

 Addition: In general, the solution is not unique. But in this example, for each of the branches of the hyperbola (due to the convexity) solution is unique.

Acer method probably the shortest. Here are more 3 ways:

X := [1, 3, 8, 9, 10]:

`+`(seq(X[i]*ln(X[i]), i=1..nops(X)));

# Or

`+`(op(X*~(ln~(X)))); 

# Or in for loop

S := 0: for x in X do S := S+x*ln(x) end do: S;

 

                         21*ln(3)+24*ln(2)+10*ln(10)

                         21*ln(3)+24*ln(2)+10*ln(10)

                         21*ln(3)+24*ln(2)+10*ln(10)

To see the point of intersection, you can simply reduce the ranges of the axes at standard numpoints:

restart;

convert([92*x/790+18*x*(1-y)/1000=0.125,ln(46.59/x)=1/1.5*(ln(0.553/y)+2.5*ln((1-y)/(1-0.553)))], rational);

fsolve(%);

plots:-implicitplot(%%, x=0..1, y=0..0.05, thickness=2, color=[blue,red]);

                                  

 

 

First 216 217 218 219 220 221 222 Last Page 218 of 290