## 20444 Reputation

16 years, 62 days

## MaplePrimes Activity

### These are answers submitted by Kitonum

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

## Solution...

Consider 2 points   A(0,0)  and  B(1,0) . The line  BC  has the equation  y=tan(100*Pi/180)*(x-1) . We assume that the points  С  and  D   lie above the axis  Ox , and the length of the  BC  is equal to 1. Then we get  C(1+cos(100*Pi/180), sin(100*Pi/180)) . The slope of the straight line  CD  will be equal to  tan(100*Pi/180+70*Pi/180) .

 > restart; local D: A:=[0,0]: B:=[1,0]: C:=[1+cos(100*Pi/180),sin(100*Pi/180)]: D:=eval([x,y],solve({y=tan(120*Pi/180)*x, y=C[2]+tan(100*Pi/180+70*Pi/180)*(x-C[1])})); P:=plottools:-curve([A,B,C,D,A], color=red, thickness=2): T:=plots:-textplot([[A[],"A"],[B[],"B"],[C[],"C"],[D[],"D"]], font=[times,20], align=[left,below]): plots:-display(P,T, scaling=constrained, axes=none);
 >

 >
 >
 >
 (1)
 >
 (2)
 >
 (3)
 >

## More...

There are other ways to solve the problem. For example, you can use the  seq  command, or just loop through the set  , applying the appropriate condition:

```restart;
A := {3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101};

{seq(`if`(modp(a,3)=1,a,NULL), a=A)}; # The second way

k:=1:  # The third way
for a in A do
if modp(a,3)=1 then k:=k+1; B[k]:=a fi;
od:
convert(B, set);
```

## D operator, unapply command , continuou...

 > restart;
 > f := x->a*x/(4*x^2+b); g:=D(f);
 (1)
 > h:=unapply(int(f(t),  t=0..x, continuous), x); h(x);
 (2)
 >

 >
 >
 (1)
 >
 (2)
 >
 (3)
 >
 >

## eval...

The  simplify  command is redundant here and can be dispensed with using the  eval command:

```restart;
diff(f(x,y),x)+diff(f(x,y),y);
eval(%, f(x,y)=f(x,y0));
```

## convert(... , exp)...

In older versions of Maple, the  simplify  command does not help (I'm using Maple 2018). The  convert  command does the job:

```Expr:=sin(theta)^(A - 2)*cos(theta)^2 - sin(theta)^(A - 2) + sin(theta)^A:
convert(Expr, exp);
```

0

## In one go in Maple 2018...

```restart;
eqn := y(x)*(2*x*(diff(y(x), x))+y(x)*((diff(y(x), x))^2-1)) = -1:
dsolve(eqn);```

## Solution...

You can easily solve this system numerically if you give numerical values for the parameters alpha, a[1], a[2], a[3] .

The example:

 > restart; eq1 := diff(f(x), x, x, x)+(1/2)*cos(alpha)*x*(diff(f(x), x, x))+(1/2)*sin(alpha)*f(x)*(diff(f(x), x, x)) = 0: eq2 := diff(g(x), x, x)+diff(g(x), x)+(diff(g(x), x))*(diff(h(x), x))+cos(alpha)*x*(diff(g(x), x))+sin(alpha)*f(x)*g(x) = 0: eq3 := diff(g(x), x, x)+diff(h(x), x, x)+1/2*(cos(alpha)*x+sin(alpha)*f(x)) = 0: ics := f(0) = 0, (D(f))(0) = 1, ((D@@2)(f))(0) = a[1], g(0) = 1, (D(g))(0) = a[2], h(0) = 1, (D(h))(0) = a[3]: alpha:=Pi/4: a:=[1,2,3]: dsolve({eq1,eq2,eq3,ics}, numeric); plots:-odeplot(%, [[x,f(x)],[x,g(x)],[x,h(x)]], x=0..3, color=[red,blue,green]);
 >

## A way...

Suppose you want to write the following expression  Expr  in powers of  x-1 . You can do it like this:

 > restart; Expr:=x^2-3*x+5: eval(Expr, x=y+1); subs(y=``(x-1),expand(%)); # Desired form expand(%); # Check
 (1)
 >

## Solution...

Since the curve  f(x)  is symmetrical about the Oy axis, the circle must also be symmetrical about the Oy axis and touch the lower branch in the point  (0,-1) . So the upper semicircle will be  y=sqrt(R^2-x^2)+R-1 . In general, we have 5 points of intersection. If we impose the condition  R^2-2*R = 0 , then we have 3 points of intersection:

 > restart; solve(sqrt(R^2-x^2)+R-1=(x^2+1)/(x^2-1), x); R:=solve(R^2-2*R=0)[2]; plots:-display(plot((x^2+1)/(x^2-1), x=-4..4, -4..4, color=blue), plots:-implicitplot(x^2+(y-(R-1))^2=R^2, x=-4..4, y=-4..4, color=red));
 >