Kitonum

21530 Reputation

26 Badges

17 years, 84 days

MaplePrimes Activity


These are answers submitted by Kitonum

Here is an example of solving the problem. The method is of a general nature and can be used for any curves given by parametric equations. In the example, the red curve is a broken line, and the blue one is a straight line.

restart;
d:=(P,Q)->sqrt((P[1]-Q[1])^2+(P[2]-Q[2])^2);
P:=piecewise(s>=0 and s<0.3,[s,s/3+0.3],s>=0.3 and s<0.5,[s,-s+0.7],s>=0.5 and s<0.7,[s,7/2*s-1.55],s>=0.7 and s<=1,[s,-s/3+17/15]);
Q:=[t,t];
A:=plot(piecewise(seq(op([op(P)[2*n-1],op(P)[2*n][2]]), n=1..nops([op(P)])/2)), s=0..1,color=red, thickness=3):
B:=plot(t, t=0..1, color=blue, thickness=3):
epsilon:=0.3;
C:=plots:-inequal({d(P,Q)<=epsilon}, s=0..1, t=0..1, optionsfeasible = [color = "WhiteSmoke"], optionsexcluded = [color = "DarkGrey"], view=[0..1,0..1]):
plots:-display(<plots:-display(A,B) | C>, scaling=constrained); # This is "free space diagram"

If the curve is given by a conventional equation, for example  y=f(x) , so you must specify it as the list  [x, f(x)]

FD.mw

Edit.

Try  
A.C;
  # dot product 
# or  
expand(A.C); 

Type this ( ) as an ordinary dot on the keyboard. I use 1d-math input. In 2d-math input (which you use) , this will look like a fat dot in the middle.

For real domain use  discont  command instead of  singular  (the output is empty set):

discont(ln(y^2+1), y);
                                         
 { }

You are not right. Maple calculates everything correctly. Should be

combinat:-numbcomb(n, m) = binomial(n, m)  

See help on this command.

For example  combinat:-numbcomb(7, 3) = (7*6*5)/3! = 35

The mapping of the square  [0,1] x [0,1]  with 2d-grid:

restart;
f:=(r,t)->[r*exp(t),r*exp(-t)];
S:=plot([seq([x,t,t=0..1],x=0..1,0.1),seq([t,y,t=0..1],y=0..1,0.1)], color=red, size=[200,200]):
F:=plottools:-transform(f):
T:=plots:-display(F(S), size=[400,400]):
plots:-display(<S | T>, scaling=constrained);


                       

Edit.
                        

 


 

Try use inert multiplication for this:

A:=x%*y=y%*x + 2*z;
expand(subs(A, w*x%*y));
                              

 

 

Sum is an inert form for sum, when the summation is simply shown on the display, but not calculated in any closed form. See the following example:

Sum(1/n^2, n=1..infinity) = sum(1/n^2, n=1..infinity);


Addition. To avoid possible errors, end each line of code with delimiters (;  or  : ).

In the beginning: 

restart; 
# and so on

Here is another solution. Perhaps for a not very experienced user it will be clearer:

F:=proc(M::Matrix,N::Matrix,a::nonnegint)
local m1, m2, n1, n2, k, i, j, S;
if not a in convert(M, set) then error cat(a, " is not an element of M") fi;
m1, m2 :=op([1,1],M), op([1,1],N);  # Row dimensions of M and N
n1, n2 :=op([1,2],M), op([1,2],N);  # Column dimensions of M and N
if m1<>m2 or n1<>n2 then error "Matrices M and N should be the same size" fi;
k:=0;
for i from 1 to m1 do
for j from 1 to n1 do
if M[i,j]=a then k:=k+1; S[k]:=N[i,j] fi;
od; od;
convert(S, list);
end proc:


 

I did not understand what you are trying to do with this bunch of parameters. If the parameter values are known from the very beginning, then you can simply assign them these values. Then simplify the resulting equation and solve it (separately for positive and negative  x ):


 

restart; b1 := 0; b2 := 0; v1 := 0; v2 := 0; s1 := 0; s2 := .175; j2 := .28; tau := 20; th1 := 0; th3 := 0

0

 

0

 

0

 

0

 

0

 

.175

 

.28

 

20

 

0

 

0

(1)

EQN := s1-s2+(2*b2-2^(1/2)*(2*j2^2*x^2-b1^2+b2^2+2*j2*v1-2*j2*v2)^(1/2))^3/(48*j2^2)-(-j2*x+b1)^3/(6*j2^2)+(v1+(-j2*x+b1)^2/(2*j2)+(1/2)*j2*x^2-b1*(-j2*x+b1)/j2)*(tau-x-(2*b2-2^(1/2)*(2*j2^2*x^2-b1^2+b2^2+2*j2*v1-2*j2*v2)^(1/2))/(2*j2)+(-j2*x+b1)/j2+2^(1/2)*(2*j2^2*x^2-b1^2+b2^2+2*j2*v1-2*j2*v2)^(1/2)/(2*j2))+(1/3)*j2*x^3+x*(v1+(-j2*x+b1)^2/(2*j2)-b1*(-j2*x+b1)/j2)+(2*b2-2^(1/2)*(2*j2^2*x^2-b1^2+b2^2+2*j2*v1-2*j2*v2)^(1/2))*(v1-(j2^2*x^2+j2*v1-j2*v2-(1/2)*b1^2+(1/2)*b2^2)/(2*j2)+(-j2*x+b1)^2/(2*j2)+(1/2)*j2*x^2-b1*(-j2*x+b1)/j2)/(2*j2)-v1*(-j2*x+b1)/j2+2^(1/2)*(2*j2^2*x^2-b1^2+b2^2+2*j2*v1-2*j2*v2)^(3/2)/(24*j2^2)+b1*(-j2*x+b1)^2/(2*j2^2)+2^(1/2)*(2*b2-2^(1/2)*(2*j2^2*x^2-b1^2+b2^2+2*j2*v1-2*j2*v2)^(1/2))^2*(2*j2^2*x^2-b1^2+b2^2+2*j2*v1-2*j2*v2)^(1/2)/(16*j2^2)-2^(1/2)*(v1+(-j2*x+b1)^2/(2*j2)+(1/2)*j2*x^2-b1*(-j2*x+b1)/j2)*(2*j2^2*x^2-b1^2+b2^2+2*j2*v1-2*j2*v2)^(1/2)/(2*j2); EQN1 := `assuming`([simplify(EQN)], [positive]); EQN2 := `assuming`([simplify(EQN)], [negative])

-.175+0.1e-10*2^(1/2)*(x^2)^(3/2)+.2800000000*x^3+.2800000000*x^2*(20-2.000000000*x+1.414213562*2^(1/2)*(x^2)^(1/2))-.1979898988*2^(1/2)*(x^2)^(1/2)*x^2

 

-.175-0.3e-9*x^3+5.600000000*x^2

 

-.175-.5599999997*x^3+5.600000000*x^2

(2)

Rx1 := select(proc (r) options operator, arrow; 0 < r end proc, [solve(EQN1, x)]); Rx2 := select(proc (r) options operator, arrow; r < 0 end proc, [solve(EQN2, x)])

[.1767766953, 0.1866666667e11]

 

[-.1752477756]

(3)

``


 

Download Polynom_Calculation_new.mw

The loop variable  m  starts to take values starting from 1. But as soon as m = 2, the loop exits.

It's easy to do without calling  LinearAlgebra  package like in the example below:

A:=<1,2; 3,4>; # Matrix of the system 
x:=<x1, x2>; # Vector of unknowns
b:=<5,6>; # Vector of constant terms

System:=convert(A.x=~b, list);  # The system


Presentation in the traditional form:

%piecewise(seq(op([``,System[i]]), i=1..nops(System)));
                    


Edit.

 

a := x+2*y = 3:
plot(solve(a, y), x = -5 .. 5, -5 .. 5, style = point, symbol=solidcircle, symbolsize=15, numpoints=10, adaptive=false);
                 

 

You can solve your task by analogy with the following simpler examples:

plots:-implicitplot([seq(y=a*x^2, a=[1,2,3])], x=-1..1, y=0..3, color=[red,blue,green], scaling=constrained);
plot([seq([t, a*t^2, t=-1..1], a=[1,2,3])], color=[red,blue,green], scaling=constrained);


Pay attention to  seq  command. This is one of the most useful and often used commands in Maple.
 

plots:-implicitplot3d(x=y, x= 0..0.01, y= 0..0.01, z=0..100, style=surface, color=grey, transparency= 0.4); 
# Or
plots:-display(plottools:-polygon([[0,0,0],[0,0,100],[0.01,0.01,100],[0.01,0.01,0]], color=grey, transparency= 0.4));
 

Using the symmetry of the ball, the problem reduces to counting the number of points with integer coordinates in the first octant (the result is multiplied by 8).
The procedure named  Onion  returns 2 numbers: the first number is the total number of pieces, the second number is the number of cubes.

The code:

Onion:=proc(R::positive)
local R0, N, n, x, y, z;
R0:=`if`(R::integer,R-1,floor(R));
N:=0; n:=0;
for x from 0 to R0 do
for y from 0 to R0 do
for z from 0 to R0 do
if x^2+y^2+z^2<R^2 then N:=N+1;
if (x+1)^2+(y+1)^2+(z+1)^2<=R^2 then n:=n+1;
fi; fi;
od: od: od:
8*N, 8*n;
end proc:


Examples of use:

Onion(2);
Onion(2.5);
Onion(3);
Onion(10);
Onion(100);
                                 


                                 

 

First 113 114 115 116 117 118 119 Last Page 115 of 290