## 20139 Reputation

15 years, 287 days

## assign...

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>;

## ranges  for the unknowns...

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;
diff(fcn1, N[3]);
```

## Both solutions are correct, as confirmed...

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

 (1)
 > interface(version);
 (2)
 > Physics:-Version();
 (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);
 (4)
 > Sol1:=simplify(dsolve(ode,[x(t),y(t)]));
 (5)
 > odetest(Sol1, ode);
 (6)
 > Sol2:=simplify(eval(Sol,[_C1=_C1*(sqrt(17)+1)/2, _C2=-_C2*(sqrt(17)-1)/2]));
 (7)
 > is(Sol2=Sol1);
 (8)
 >

## select...

```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);```

## Names and objects...

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));
 (1)
 >

## Ways...

 > 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]:
 (1)
 > soln := [solve(eqs, explicit)];
 (2)
 > # Show that each member of soln is a solution of eqs
 > andmap(t->is(`and`(seq(eval(eq,t),eq=eqs))), soln);
 (3)
 > # Show that the solutions are unique
 > is(nops(soln)=nops(convert(soln,set)));
 (4)
 >

## LinearAlgebra:-LeastSquares...

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

## Justified solution of the problem by bru...

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 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]]

## A way...

```restart;
diffr1:=x^2+y^2-1:
diffr2:=(x-2)^2+y^2-(3/2)^2:
with(plots):
P1:=implicitplot(diffr1, x=-1..1, y=-1..1, color=black, thickness=2):
P2:=implicitplot(diffr2, x=0..4, y=-2..2, color=black, thickness=2):
P3:=inequal({diffr1<0,diffr2<0}, x=-2..4, y=-2..2, color=red):
P4:=inequal({diffr1<0,diffr2>0}, x=-2..4, y=-2..2, color=yellow):
P5:=inequal({diffr1>0,diffr2<0}, x=-2..4, y=-2..2, color=green):
P6:=inequal({diffr1>0,diffr2>0}, x=-2..4, y=-2..2, color="LightBlue"):
display(P1,P2,P3,P4,P5,P6, scaling=constrained);
```

```restart;
NM1 := proc(f, xold)
local x1, x0, precision;
x0 := xold;
x1 := evalf(x0 - f(x0)/D(f)(x0));
precision := 10^(-3);
if limit(f(x),x=x0) = 0 then
error("Newton's Method cannot do the calculation");
end if;
if D(f)(x0) = 0 then
error("Newton's Method cannot do the calculation");
else
while abs(x1-x0) > precision do
x0 := x1;
print(x0);
x1 := evalf(x0 - f(x0)/D(f)(x0));
end do;
end if;

return x1;
end proc:

# Examples
NM1(x->1-x-sin(x), 0);
fsolve(1-x-sin(x)); # Check
NM1(x->1-x-sin(x), %); # Check
```

## The programm...

See the programm in the post  https://www.mapleprimes.com/posts/200677-Partition-Of-An-Integer-With-Restrictions

Examples of use:

```Partition(8, 2..8, {2,3,6,9});
Partition(9, 1..9, {2,3,6,9});
Partition(9, 3, {2,3,6,9});
```

## argument...

You are wrong in assuming that  Phi = -b . Maple returns the principal value of the argument and simplification can only be obtained by using assumptions on the parameters  a  and , for example

 > restart; z:=-a*exp(-I*b): simplify(evalc(argument(z))) ; simplify(argument(z)) assuming a>0, b0;
 (1)
 >

## geometry:-ellipse...

```restart;
with(geometry):
point(F1,[5,0]): point(F2,[0,-5]):
ellipse(p, ['foci'=[F1,F2], 'distance'=12], [x,y]);
Eq:=Equation(p);
d:=igcd(coeffs(lhs(Eq)));
Eq1:=Eq/d; # Simplified ellipse equation
plots:-implicitplot(Eq1, x=-12..12, y=-12..12, color=red, thickness=2);
```

 2 3 4 5 6 7 8 Last Page 4 of 280
﻿