Kitonum

21665 Reputation

26 Badges

17 years, 183 days

MaplePrimes Activity


These are answers submitted by Kitonum

To plot arrows at the ends of the axes, as well as for labels for the axes (near the ends of the axes), you can use the tools of the  plots  package:

restart;
with(plots):
y:=x->1/abs(x):
arrow_x:=arrow([4.7,0],[0.01,0], width=0, head_width=0.2, head_length=0.3, shape=arrow):
arrow_y:=arrow([0,5.7],[0,0.01], width=0, width=0, head_width=0.3, head_length=0.2, shape=arrow):
label_x:=textplot([4.5,-0.3,"x"], font=[times,bold,16]):
label_y:=textplot([-0.5,5.5,"y"], font=[times,bold,16]):
display(plot(y, -4.7..4.7, -0.7..5.7, color=red, thickness=2), arrow_x, arrow_y, label_x, label_y);

                               

 


To avoid labels for the axes that Maple builds by default, we used the operator form of specifying the function  plot(y, -4.7 .. 4.7, ... )

Edited.

Maple already has such a built-in procedure called the  combinat:-randperm  (random permutation).

Example of use:

restart;
randomize():
n:=70: m:=30:
combinat:-randperm([1$n, 0$m]);

 [1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0]

As a possible alternative to the  surd  command, you can call the RealDomain package first:

restart;
with(RealDomain):
plot(x^(1/3), x=-10..10);

 

A linear polynomial  x - (-8.0)^(1/3)  has a single root. It is called the principal value of a root. To find all the roots (numerically and symbolically) do

fsolve(x^3-(-8.0), complex);
solve(x^3-(-8));

                                  -2., 1.-1.73205080756888*I, 1.+1.73205080756888*I
                                           -2, 1-I*sqrt(3), 1+I*sqrt(3)

I don't see a worksheet here. 0.*I  can be simplified like this

restart;
simplify(0.*I, zero);
convert(%, rational);

You can use the  assign  command for this:

restart;
L:=<<1 | 2 | 3>; <4 | 5 | 6>>; 
assign(seq('L'[q,  q+1]=0 , q=1..2)):
L;

 
Addition:  You can specify the matrix L shorter by  L := <1,2,3; 4,5,6>;                                         

To obtain a real solution, it can be useful to indicate ranges  for the unknowns:

fsolve({eq1, eq2, eq3}, {A = -1000 .. 1000, B = -1000 .. 1000, P = -1000 .. 1000});
   

 {A = -433.53753742943393337,   B = 851.37601658861368581,   P = 2.6078455290044397554}

Maple does not understand arbitrary sums with an incomprehensible number of terms. The sum must be specific. For such sums the  add  command should be used:

An example:

restart;
fcn1:=add(N[i]*z[i]^2, i=1..10):
diff(fcn1, N[3]);

                                                   

 

Both solutions are correct, as confirmed by the  odetest  command. One solution is obtained from another simply by replacing arbitrary constants:

``

(1)

interface(version);

`Standard Worksheet Interface, Maple 2018.2, Windows 10, October 23 2018 Build ID 1356656`

(2)

Physics:-Version();

"C:\Program Files\Maple 2018\lib\update.mla", `2018, October 24, 4:22 hours, version in the MapleCloud: unable to determine, version installed in this computer: not installed`

(3)

restart;

ode :=[diff(x(t), t) = (3*x(t))/2 + 2*y(t), diff(y(t), t) = x(t)/2 + y(t)];
Sol:=dsolve(ode);
odetest(Sol, ode);

[diff(x(t), t) = (3/2)*x(t)+2*y(t), diff(y(t), t) = (1/2)*x(t)+y(t)]

 

{x(t) = _C1*exp((1/4)*(5+17^(1/2))*t)+_C2*exp(-(1/4)*(-5+17^(1/2))*t), y(t) = (1/8)*_C1*exp((1/4)*(5+17^(1/2))*t)*17^(1/2)-(1/8)*_C2*exp(-(1/4)*(-5+17^(1/2))*t)*17^(1/2)-(1/8)*_C1*exp((1/4)*(5+17^(1/2))*t)-(1/8)*_C2*exp(-(1/4)*(-5+17^(1/2))*t)}

 

[0, 0]

(4)

Sol1:=simplify(dsolve(ode,[x(t),y(t)]));

{x(t) = -(1/2)*_C2*(17^(1/2)-1)*exp(-(1/4)*(-5+17^(1/2))*t)+(1/2)*_C1*exp((1/4)*(5+17^(1/2))*t)*(17^(1/2)+1), y(t) = _C1*exp((1/4)*(5+17^(1/2))*t)+_C2*exp(-(1/4)*(-5+17^(1/2))*t)}

(5)

odetest(Sol1, ode);

[0, 0]

(6)

Sol2:=simplify(eval(Sol,[_C1=_C1*(sqrt(17)+1)/2, _C2=-_C2*(sqrt(17)-1)/2]));

{x(t) = -(1/2)*_C2*(17^(1/2)-1)*exp(-(1/4)*(-5+17^(1/2))*t)+(1/2)*_C1*exp((1/4)*(5+17^(1/2))*t)*(17^(1/2)+1), y(t) = _C1*exp((1/4)*(5+17^(1/2))*t)+_C2*exp(-(1/4)*(-5+17^(1/2))*t)}

(7)

is(Sol2=Sol1);

true

(8)

 

Download why_solution_changes_nov_27_2023_new.mw

Expr:=3/16-3/16*m2^2-m2/4*tanh(2*k-2*c)+m2/16*tanh(4*k+2*c)-m2/4*tanh(2*k+2*c)+3*m2/8*tanh(2*c);
select(t->has(t,tanh), Expr);

You use the same name to create different objects: a point in 3d and a procedure. Use a different name, for example:

restart;
with(geom3d):
Point:=(a,b,c)->point(P, a,b,c);
detail(Point(1,2,3));

Point := proc (a, b, c) options operator, arrow; geom3d:-point(P, a, b, c) end proc

 

Geom3dDetail(["name of the object", P], ["form of the object", point3d], ["coordinates of the point", [1, 2, 3]])

(1)

 


 

Download Point.mw


 

restart;

eqs := [u     + v     + w     = 1,
        u*x   + v*y   + w*z   = 1/2,
        u*x^2 + v*y^2 + w*z^2 = 1/3,
        u*x^3 + v*y^3 + w*z^3 = 1/4,
        u*x^4 + v*y^4 + w*z^4 = 1/5,
        u*x^5 + v*y^5 + w*z^5 = 1/6]:

[u+v+w = 1, u*x+v*y+w*z = 1/2, u*x^2+v*y^2+w*z^2 = 1/3, u*x^3+v*y^3+w*z^3 = 1/4, u*x^4+v*y^4+w*z^4 = 1/5, u*x^5+v*y^5+w*z^5 = 1/6]

(1)

soln := [solve(eqs, explicit)];

[{u = 4/9, v = 5/18, w = 5/18, x = 1/2, y = 1/2+(1/10)*15^(1/2), z = 1/2-(1/10)*15^(1/2)}, {u = 4/9, v = 5/18, w = 5/18, x = 1/2, y = 1/2-(1/10)*15^(1/2), z = 1/2+(1/10)*15^(1/2)}, {u = 5/18, v = 4/9, w = 5/18, x = 1/2+(1/10)*15^(1/2), y = 1/2, z = 1/2-(1/10)*15^(1/2)}, {u = 5/18, v = 4/9, w = 5/18, x = 1/2-(1/10)*15^(1/2), y = 1/2, z = 1/2+(1/10)*15^(1/2)}, {u = 5/18, v = 5/18, w = 4/9, x = 1/2+(1/10)*15^(1/2), y = 1/2-(1/10)*15^(1/2), z = 1/2}, {u = 5/18, v = 5/18, w = 4/9, x = 1/2-(1/10)*15^(1/2), y = 1/2+(1/10)*15^(1/2), z = 1/2}]

(2)

# Show that each member of soln is a solution of eqs

andmap(t->is(`and`(seq(eval(eq,t),eq=eqs))), soln);

true

(3)

# Show that the solutions are unique

is(nops(soln)=nops(convert(soln,set)));

true

(4)

 


 

Download eq-soln-verify_new.mw

To solve such systems, which are usually inconsistent, the least squares method is used. See help on the LinearAlgebra:-LeastSquares  command.

The  DirectSearch  package often solves problems of discrete optimization incorrectly. For this, see the discussion in the post  https://www.mapleprimes.com/posts/201020-About-DirectSearch 
Therefore, the result obtained above, although true, cannot be considered justified. An justified solution can be easily obtained by brute-force method, if you notice that no variable  x1 ... x9 can be greater than 10, since 8*(-5)^3+11^3>0

restart;
R:=[0,[0$9]]:
for x1 from -5 to 10 do
for x2 from x1 to 10 do
for x3 from x2 to 10 do
for x4 from x3 to 10 do
for x5 from x4 to 10 do
for x6 from x5 to 10 do
for x7 from x6 to 10 do
for x8 from x7 to 10 do
for x9 from x8 to 10 do
if add(x||i^3, i=1..9)=0 then d:=add(x||i, i=1..9);
if d>R[1] then R:=[d, [seq(x||i, i=1..9)]] fi; fi;
od: od: od: od: od: od: od: od: od:
R; 

                                  [12, [-5, -4, 3, 3, 3, 3, 3, 3, 3]]

 

First 12 13 14 15 16 17 18 Last Page 14 of 291