Kitonum

21550 Reputation

26 Badges

17 years, 124 days

MaplePrimes Activity


These are answers submitted by Kitonum

Try these examples:

with(plots):
with(plottools):
with(CurveFitting):
BS:=BSpline(2, x);
plot(BS, x=-1..3);
op(BS);
op(6,BS);
plot(%, x=1..2, view=[-1..3,0..1]);

 

First click on the big letter T on the instrument panel:

 

Addition.  What is your goal? For a presentation, this is entirely appropriate, but if you want to perform various mathematical manipulations with this double equality, it is better to write it as a set or a list of two equalities. Then, for example, you can easily plot this line, check whether the point lies on this line, etc.

Examples:

L:={(x-2)/(-3) = y+4, y+4 = (z+5)/2}: # Specification of the line as a set of two equalities
P:=[x=2, y=-4, z=-5]: # Specification of a point
is(`and`(eval(L,P))[]); # Check that the point P lies on the line L
plots:-intersectplot(L[], x=-5..5,y=-5..5,z=-5..5, thickness=2);
# The plot of the line L

Edit.

in Maple 2017.3:
 

restart;
assign(seq(a[i] = RootOf(_Z1^6-3*_Z1^2-2*_Z1+11, index = i), i = 1..6)):
ee := a[1]*a[5]+a[2]*a[6]+a[3]*a[4]:
simplify(ee);
evala(%);

RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 1)*RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 5)+RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 2)*RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 6)+RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 3)*RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 4)

 

4

(1)

restart;
assign(seq(a[i] = RootOf(_Z1^6-3*_Z1^2-2*_Z1+11, index = i), i = 1..6)):
ee := a[1]*a[5]+a[2]*a[6]+a[3]*a[4]:
simplify(ee);
evala(%);

RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 1)*RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 5)+RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 2)*RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 6)+RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 3)*RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 4)

 

4

(2)

restart;
assign(seq(a[i] = RootOf(_Z1^6-3*_Z1^2-2*_Z1+11, index = i), i = 1..6)):
ee := a[1]*a[5]+a[2]*a[6]+a[3]*a[4]:
simplify(ee);
evala(%);

RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 1)*RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 5)+RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 2)*RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 6)+RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 3)*RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 4)

 

4

(3)

restart;
assign(seq(a[i] = RootOf(_Z1^6-3*_Z1^2-2*_Z1+11, index = i), i = 1..6)):
ee := a[1]*a[5]+a[2]*a[6]+a[3]*a[4]:
simplify(ee);
evala(%);

RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 1)*RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 5)+RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 2)*RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 6)+RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 3)*RootOf(_Z^6-3*_Z^2-2*_Z+11, index = 4)

 

4

(4)

 


 

Download simp1.mw


Edit.

solve command, which is part of the core of Maple, is one of the main and frequently used commands. It is unfortunate that it can not cope with such a simple equation. I think that developers should deal with this situation.
We can still solve this equation with solve command in two steps, first solving for  sin(t) :

solve(exp(2*sin(t))-1=0, sin(t));
solve({sin(t)=%, t>=0, t<=16}, allsolutions, explicit);
                                                         
  0
                    {t = 0}, {t = Pi}, {t = 2 Pi}, {t = 3 Pi}, {t = 4 Pi}, {t = 5 Pi}
 

If you do not know which command to use to finally simplify your numerical expression, it is useful to first calculate it approximately accurately (by  evalf  command), and then, for complete certainty, select the appropriate command for symbolic simplification, in fact already knowing the result.

S:=-1/2*((-30*sqrt(3)+81*I)^(2/3)+21+2*sqrt(3)*(-30*sqrt(3)+81*I)^(1/3)-6*(-30*sqrt(3)+81*I)^(1/3)+I*sqrt(3)*(-30*sqrt(3)+81*I)^(2/3)-21*I*sqrt(3))/(-30*sqrt(3)+81*I)^(1/3);
evalf[20](S);
factor(S); 
# or
radnormal(S);
 

Your set is just one octant in 3d (in fact, all points in the space with negative coordinates) .

Download PS.mw

In this example, we generated an arbitrary polynomial of the third degree in 5 variables. But the method itself is of a general nature and it can be used to generate a polynomial of any degree and any number of variables.


 

restart;

var:=[x,y,z,t,s]: n:=nops(var): m:=3:

L:=ListTools:-Reverse(convert(map(t->(t)-~1,`union`(seq(combinat:-composition(n+i,n), i=0..m))),list));

[[3, 0, 0, 0, 0], [2, 1, 0, 0, 0], [2, 0, 1, 0, 0], [2, 0, 0, 1, 0], [2, 0, 0, 0, 1], [2, 0, 0, 0, 0], [1, 2, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 0, 1, 0], [1, 1, 0, 0, 1], [1, 1, 0, 0, 0], [1, 0, 2, 0, 0], [1, 0, 1, 1, 0], [1, 0, 1, 0, 1], [1, 0, 1, 0, 0], [1, 0, 0, 2, 0], [1, 0, 0, 1, 1], [1, 0, 0, 1, 0], [1, 0, 0, 0, 2], [1, 0, 0, 0, 1], [1, 0, 0, 0, 0], [0, 3, 0, 0, 0], [0, 2, 1, 0, 0], [0, 2, 0, 1, 0], [0, 2, 0, 0, 1], [0, 2, 0, 0, 0], [0, 1, 2, 0, 0], [0, 1, 1, 1, 0], [0, 1, 1, 0, 1], [0, 1, 1, 0, 0], [0, 1, 0, 2, 0], [0, 1, 0, 1, 1], [0, 1, 0, 1, 0], [0, 1, 0, 0, 2], [0, 1, 0, 0, 1], [0, 1, 0, 0, 0], [0, 0, 3, 0, 0], [0, 0, 2, 1, 0], [0, 0, 2, 0, 1], [0, 0, 2, 0, 0], [0, 0, 1, 2, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 0], [0, 0, 1, 0, 2], [0, 0, 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0, 0, 0]*x^2+a[1, 1, 0, 0, 0]*x*y+a[1, 0, 1, 0, 0]*x*z+a[1, 0, 0, 1, 0]*x*t+a[1, 0, 0, 0, 1]*x*s+a[0, 2, 0, 0, 0]*y^2+a[0, 1, 1, 0, 0]*y*z+a[0, 1, 0, 1, 0]*y*t+a[0, 1, 0, 0, 1]*y*s+a[0, 0, 2, 0, 0]*z^2+a[0, 0, 1, 1, 0]*z*t+a[0, 0, 1, 0, 1]*z*s+a[0, 0, 0, 2, 0]*t^2+a[0, 0, 0, 1, 1]*t*s+a[0, 0, 0, 0, 2]*s^2+a[1, 0, 0, 0, 0]*x+a[0, 1, 0, 0, 0]*y+a[0, 0, 1, 0, 0]*z+a[0, 0, 0, 1, 0]*t+a[0, 0, 0, 0, 1]*s+a[0, 0, 0, 0, 0]

(2)

 


 

polynom.mw


Edit.

 

Here is a simple procedure that solves the problem for not too large  d  and  K :

Pell:=proc(d::posint,K::posint)
local k, y, x, L;
k:=0; L:=table();
for y from 1 to K do
x:=isqrt(d*y^2+1);
if x^2-d*y^2=1 then k:=k+1; L[k]:=[x,y] fi;
od;
convert(L,list);
end proc:


Example of use:

Pell(27,1000000);

Output:
                  [[26, 5], [1351, 260], [70226, 13515], [3650401, 702520]]


Addition. Of course, much more efficient code can be written if we use  isolve  command, but I think that for a beginner the above will be enough.


Edit.

Specify the range for  x  variable explicitly:

with(DocumentTools):
A := [plot(sin(x)/x, x = -2*Pi .. 2*Pi, legend = sinc(x)), Sum(f(i), i = 1 .. N), plot3d(y^2*sin(x), x = -Pi .. Pi, y = -2 .. 2)]:
Tabulate(A, width = 60):


 

Download Tab.mw

Maximize (or Minimize) command only guarantees a local extremum, not a global one (see help for details). To get a global maximum, first plot a graph, and then narrow the range for the variable  x , that contains the maximum:


 

restart;
with(Optimization):
app := x->0.14546e-1*sin(3.141592654*x)+(-1)*0.50512e-2*sin(6.283185308*x)+0.19918e-2*sin(9.424777962*x);
ex :=x->-AiryAi(2^(2/3)*x)*(5*3^(5/6)-9*AiryBi(2^(2/3))*GAMMA(2/3))/(8*AiryAi(2^(2/3))*3^(5/6)-8*AiryBi(2^(2/3))*3^(1/3))-AiryBi(2^(2/3)*x)*(9*AiryAi(2^(2/3))*GAMMA(2/3)-5*3^(1/3))/(8*AiryAi(2^(2/3))*3^(5/6)-8*AiryBi(2^(2/3))*3^(1/3))+(1/4)*x^3+3/8;
plot(100*abs(app(x)-ex(x)), x = 0 .. 1);
Maximize(100*abs(app(x)-ex(x)), x=0.8..1);

proc (x) options operator, arrow; 0.14546e-1*sin(3.141592654*x)-0.50512e-2*sin(6.283185308*x)+0.19918e-2*sin(9.424777962*x) end proc

 

proc (x) options operator, arrow; -AiryAi(2^(2/3)*x)*(5*3^(5/6)-9*AiryBi(2^(2/3))*GAMMA(2/3))/(8*AiryAi(2^(2/3))*3^(5/6)-8*AiryBi(2^(2/3))*3^(1/3))-AiryBi(2^(2/3)*x)*(9*AiryAi(2^(2/3))*GAMMA(2/3)-5*3^(1/3))/(8*AiryAi(2^(2/3))*3^(5/6)-8*AiryBi(2^(2/3))*3^(1/3))+(1/4)*x^3+3/8 end proc

 

 

[HFloat(0.1838471711423484), [x = HFloat(0.9230341609253242)]]

(1)

 


 

Addition. In order to immediately get the global extremum, you can use DirectSearch  package, which should be downloaded from the Maple Application Center and installed on your computer

https://www.maplesoft.com/applications/view.aspx?sid=101333

 

Download Max.mw

First you need to open your file, then  ctrl+ p

Another way: menu file -> print  or  print preview

Probably a double for loop is meant for summing such terms, if  i  runs from  0  to  m  and  runs from  0  to  n . A simple procedure named  Bxy  solves the problem:

Bxy:=proc(m::nonnegint,n::nonnegint)
local S, i, j;
S:=0;
for i from 0 to m do
for j from 0 to n do
S:=S+binomial(m,j)*binomial(n,i)*x^i*(1-x)^(m-i)*y^j*(1-y)^(n-j);
od; od;
S;
end proc:

Example of use:

Bxy(3,2);

                  

 

Here is the numerical solution:

restart;
pde:=diff(u(x,t), t$2)+diff(u(x,t), x$4)=0;
bc:=u(0,t)=-12*t^2, u(1,t)=1-12*t^2, D[1,1](u)(0,t)=0, D[1,1](u)(1,t)=12;
ic:=u(x,0)=x^4, D[2](u)(x,0)=0;
sol:=pdsolve(pde, {ic,bc}, u(x,t), numeric);
sol:-plot3d(t = 0 .. 1, x = 0 .. 1, axes = boxed);

 

Use  %.  or  %*  instead of  :

sum(i %. a, i=1..3);
                                               


Another option is to use  ``(...)  construction to avoid the summation of similar terms. Then all the individual terms of the series are enclosed in parentheses, and it is convenient to compare:

sum(``(i*a), i=1..3);
                                               

 This construction is often useful in other cases. For example, if you need to clearly show the definition of the number  10!  then it can be done in 3 ways:

``(10)!=product(``(k), k=1..10);
# or
``(10)!=`%.`(seq(k, k=1..10));
# or
``(10)!=`%*`(seq(k, k=1..10));
                                          

 

Edit.                                   

Try this:

simplify(-sqrt((r-2*M)*(-r/(-r+2*M))^eta/r)*X*sqrt(-((r-2*M)/r)^eta*r/(-r+2*M))/f) assuming r>0, r-2*M>0, eta::real;


Edit.

 

First 125 126 127 128 129 130 131 Last Page 127 of 290