## 15379 Reputation

12 years, 110 days

## Ways...

You can re-use the  series  command to an already existing series to obtain the desired simplification.

An example:

```A:=series(ln(1+x), x);
series(A/x, x);
```

If you need to programmatically extract the exponent of   in the term  O(x^n) , then do so:

```A:=series(ln(1+x), x):
op(-1,A);
```

6

Here's an example of another way:

`applyrule(O(x^n::posint)/x=O(x^(n-1)), O(x^11)/x);`

## combinat:-choose...

Use  combinat:-choose  command for this. An example:

`combinat:-choose({\$1..10}, 3);`

{{1, 2, 3}, {1, 2, 4}, {1, 2, 5}, {1, 2, 6}, {1, 2, 7}, {1, 2, 8}, {1, 2, 9}, {1, 2, 10}, {1, 3, 4}, {1, 3, 5}, {1, 3, 6}, {1, 3, 7}, {1, 3, 8}, {1, 3, 9}, {1, 3, 10}, {1, 4, 5}, {1, 4, 6}, {1, 4, 7}, {1, 4, 8}, {1, 4, 9}, {1, 4, 10}, {1, 5, 6}, {1, 5, 7}, {1, 5, 8}, {1, 5, 9}, {1, 5, 10}, {1, 6, 7}, {1, 6, 8}, {1, 6, 9}, {1, 6, 10}, {1, 7, 8}, {1, 7, 9}, {1, 7, 10}, {1, 8, 9}, {1, 8, 10}, {1, 9, 10}, {2, 3, 4}, {2, 3, 5}, {2, 3, 6}, {2, 3, 7}, {2, 3, 8}, {2, 3, 9}, {2, 3, 10}, {2, 4, 5}, {2, 4, 6}, {2, 4, 7}, {2, 4, 8}, {2, 4, 9}, {2, 4, 10}, {2, 5, 6}, {2, 5, 7}, {2, 5, 8}, {2, 5, 9}, {2, 5, 10}, {2, 6, 7}, {2, 6, 8}, {2, 6, 9}, {2, 6, 10}, {2, 7, 8}, {2, 7, 9}, {2, 7, 10}, {2, 8, 9}, {2, 8, 10}, {2, 9, 10}, {3, 4, 5}, {3, 4, 6}, {3, 4, 7}, {3, 4, 8}, {3, 4, 9}, {3, 4, 10}, {3, 5, 6}, {3, 5, 7}, {3, 5, 8}, {3, 5, 9}, {3, 5, 10}, {3, 6, 7}, {3, 6, 8}, {3, 6, 9}, {3, 6, 10}, {3, 7, 8}, {3, 7, 9}, {3, 7, 10}, {3, 8, 9}, {3, 8, 10}, {3, 9, 10}, {4, 5, 6}, {4, 5, 7}, {4, 5, 8}, {4, 5, 9}, {4, 5, 10}, {4, 6, 7}, {4, 6, 8}, {4, 6, 9}, {4, 6, 10}, {4, 7, 8}, {4, 7, 9}, {4, 7, 10}, {4, 8, 9}, {4, 8, 10}, {4, 9, 10}, {5, 6, 7}, {5, 6, 8}, {5, 6, 9}, {5, 6, 10}, {5, 7, 8}, {5, 7, 9}, {5, 7, 10}, {5, 8, 9}, {5, 8, 10}, {5, 9, 10}, {6, 7, 8}, {6, 7, 9}, {6, 7, 10}, {6, 8, 9}, {6, 8, 10}, {6, 9, 10}, {7, 8, 9}, {7, 8, 10}, {7, 9, 10}, {8, 9, 10}}

## Numerically...

I think that all your questions can be answered only numerically with the specified parameter values. Here is an example:

```restart;
A:=x->mue+(mun/gama)+(u0^2)-mud*x-mue*exp(x)-(mun/gama)*exp(gama*x)-(u0^2)*(1-2*x/u0^2)^(1/2):

mue:=1/(1+alpha+beta):
mun:=alpha/(1+alpha+beta):
mud:=beta/(1+alpha+beta):
u0:=(mue+mun*gama)^(-1/2):

A1:=eval(A(x),[alpha=0.2,beta=0.3,gama=17]);
r:=solve(op([1,1],indets(A1,sqrt))>=0); # The domain of A1
plot(A1, x=-0.4..op(2,r), size=[800,400]);
fsolve(A1,x=-0.1..0.1); # The first root
fsolve(A1,x=0.1..op(2,r));  # The second root
fsolve(diff(A1,x),x=0.1..op(2,r));  # The root of first derivative
```

To investigate the dependence of the results on the parameters, see the  Explore command in the help.

## Numerical calculation...

```restart;
int(tanh(x)/sqrt(x^2+1), x=1..100, numeric);```

4.344661055

## numpoints...

You have taken too little value for numpoints  (n=100). Try

`plot3d( [V,0], 0..2*Pi, 0..2*Pi, numpoints=40000);`

## Sum...

Use the inert sum, that is  Sum  instead of  sum :

```restart;
X := x->Sum((-1)^m*((1/2)*x)^(2*m+n)/(factorial(m)*factorial(m+n)), m = 0 .. infinity);
diff(X(x), x);  # The derivatives series
applyop((combine@expand),1,%,2*m+n); # Simplification
```

Edit.

## @@...

```f:=x->sqrt(1+x);
(f@@6)(x);```

## Procedure for this...

```restart;

Pbc:=proc(n::posint)
local Ind, Var1, Var2;
uses combinat;
Ind:=permute([0\$n,1\$n],n):
Var1:=[seq(x||i,i=0..n-1)]: Var2:=[seq(y||i,i=0..n-1)]:
{seq(seq(inner(Var1,ind1)*inner(Var2,ind2), ind1=Ind), ind2=Ind)};
end proc:
```

Examples of use (for n = 2 the result coincides with Carl's one):
Pbc(1);
Pbc(2);
Pbc(3);

## General solution...

There will be infinitely many such vectors. All of them belong to a plane perpendicular to the original vector. Therefore, the set of all solutions depends on two parameters:

```restart;
PV:=(a,b,c)->solve(a*x+b*y+c*z=0,{x,y,z}):

# Examples of use:
V:=<1,2,3>;
PV(V[1],V[2],V[3]);
V1:=eval(<x,y,z>, %); # General solution
V.V1; # Check
V2:=eval(V1,[y=1,z=1]);  # One of the solutions
```

## functions as procedures...

Define functions as procedures, not expressions:

```restart;
h:=x->1/(1+exp(-x));
hh:=(w,x,b)->ln(h(w*x + b));
diff(hh(w,x,b), w);  # Or  D[1](hh)(w,x,b);
normal(expand(%));
```

I always refer to previous objects using their names or by  %  and so on.

Edit.

## IntegrationTools:-Change...

Here is a more traditional way:

```restart;
IntegrationTools:-Change(int(arccos(x)*arcsin(x),x), x=sin(t));
eval(%, sin(t)=x);```

```restart;
b:=proc(n)
option remember;
if n=0 then return 0 elif n=1 then return 1
else
(b(n-1)+b(n-2))/2:
fi;
end proc:

# Examples of use:

S:=seq(b(n),n=0..10);
plot([\$ 0..10],[S]);```

You can obtain an explicit formula for the nth member by  rsolve  command:

```restart;
# The formula for nth term
rsolve({b(n)=(b(n-1)+b(n-2))/2,b(0)=0,b(1)=1}, b(n));
```

## bug...

This is certainly a bug. Do

```with(geometry):
point(o, 0, 0);
point(A, 0, 1);
point(d, 0, 2);
point(F, 0.8944271920, 1.4472135960);
line(lOD, [o, d]);
line(lAF, [A, F]);
alpha1 := FindAngle(lOD, lAF);
alpha:=min(alpha1,Pi-alpha1);```

alpha := 1.107148718

## @@ operator...

```f:=y->sqrt((1+y)/2):
cos(Pi/2)=0:
cos(Pi/2^n)=(f@@(n-1))(0):

# Examples
cos(Pi/16)=(f@@3)(0);
cos(Pi/64)=(f@@5)(0);
```

## Workaround...

Any command, if you add the  %  symbol in front of it, becomes inert. If we replace  Sum  with  %sum , then the bug disappears. See below