## 20374 Reputation

16 years, 34 days

## Try to swap...

In the code try to swap   c = 0 .. 4  and  xT = .8 .. 1 .

## Solution...

assume(a+b>c,  a+c>b,  b+c>a):

p:=(a+b+c)/2:

S:=sqrt(p*(p-a)*(p-b)*(p-c)):

`cos(A)`:=(b^2+c^2-a^2)/2/b/c:

`cos(B)`:=(a^2+c^2-b^2)/2/a/c:

`cos(C)`:=(b^2+a^2-c^2)/2/b/a:

`tan(A/2)`:=sqrt((1-`cos(A)`)/(1+`cos(A)`)):

`tan(B/2)`:=sqrt((1-`cos(B)`)/(1+`cos(B)`)):

`tan(C/2)`:=sqrt((1-`cos(C)`)/(1+`cos(C)`)):

r:=S/p:  R:=a*b*c/4/S:

is(p*(`tan(A/2)`+`tan(B/2)`+`tan(C/2)`)=r+4*R);

true

## If you use Bonnet's recursion formula fr...

If you use Bonnet's recursion formula from wiki, the program can be obtained very simple:

LegPol:=proc(n)

local P, i, f;

P[0]:=1: P[1]:=x:

if n>=2 then for i to n-1 do

P[i+1]:=((2*i+1)*x*P[i]-i*P[i-1])/(i+1);

od; fi;

f:=expand(P[n]);

f/lcoeff(f);

end proc;

Example:

for k from 0 to 9 do

LegPol(k);

od;

You get the same polynomials as above.

## One line...

Your problem can be solved in one line. However, my previous comment fully applies and to this decision:

extrema(sqrt((X-x)^2+(Y-y)^2+(Z-z)^2),{x^2 + y^2 + z^2-2*x+4*y+2*z-3=0, 2*X-Y+2*Z-14=0},{X,Y,Z,x,y,z},'s'),  s;

## Almost correct...

Your solution is correct, if the sphere does not intersect with the plane. Otherwise, the smallest distance is equal to 0. Therefore, the code should include verification of this fact!

## Automatically...

In the Maple there is no need to write code to calculate the Legendre polynomials. This is done automatically in the package orthopoly. They are different from yours only leading coefficients.

Example of calculation of the first 10 polynomials:

with(orthopoly):

for k from 0 to 9 do

sort(P(k,x)/lcoeff(P(k,x)));

od;

## Another way...

Different variant is to use surd command.

Compare:

surd(-8,3);  simplify((-8)^(1/3));

-2

1+sqrt(3)*I

solve(surd(x+24,3)+sqrt(12-x) = 6);

-88, -24, 3

## Another way by algsubs...

simplify(algsubs(1-sin(x)^2=cos(x)^2,cos(x)^2+cos(4*x) + cos(x)^4 + sin(x)^4 + cos(x)^6 + sin(x)^6), {expand(cos(2*x))=t});

## Solution in Maple...

This example , of course, can be easily solved by hand, but if you deal with Maple, you can write:

simplify(expand(cos(x)^2+cos(4*x)), {expand(cos(2*x))=cos(2*x)});

## The region must be defined in terms...

The region must be defined in terms of Cartesian coordinates, where x=Re(z) , y=Im(z) .

An example of building the region  {|z|>=1, |z|<=2, Pi/4<=Arg(z)<=5*Pi/4} :

plots[implicitplot]((x^2+y^2-4)*(x^2+y^2-1)<=0, x = -3..3, y = x..3, coloring=[blue, white], filledregions = true,numpoints = 10000);

## Two basic elements...

You have two basic elements g and g1. All the rest are obtained from them by  translate command.

g := plottools[curve]([seq([cos(2*Pi*i*(1/3)), sin(2*Pi*i*(1/3))], i = 0 .. 3)], color = brown, thickness = 5):

g1 := plottools[rotate](g, (1/3)*Pi, [cos(2*Pi*(1/3)), sin(2*Pi*(1/3))]):

plots[display](g, g1, scaling = constrained);

Different variant:

g := plottools[curve]([seq([cos(Pi/2+2*Pi*i*(1/3)), sin(Pi/2+2*Pi*i*(1/3))], i = 0 .. 3)], color = brown, thickness = 5):

g1 := plottools[rotate](g, (1/3)*Pi, [0, 1]):

plots[display](g, g1, scaling = constrained);

## Procedure...

The procedure Hexlat builds a hexagonal lattice consisting of regular hexagons. Formal arguments: the first two numbers (m and nspecify the size of the lattice, the list L specifies the color of the borders and interior, the last number t specifies the thickness of the borders.

Code of the procedure:

Hexlat:=proc(m, n, L, t)

local g,g1,p,p1,A,A1,B,B1,C,C1;

g:=plottools[curve]([seq([cos(Pi*i/3),sin(Pi*i/3)],i=0..6)],color=L[1],thickness=t);

g1:=plottools[translate](g,3/2,-sqrt(3)/2);

p:=plottools[polygon]([seq([cos(Pi*i/3),sin(Pi*i/3)],i=1..6)],color=L[2]);

p1:=plottools[translate](p,3/2,-sqrt(3)/2);

A:=seq(plottools[translate](g,0,sqrt(3)*k),k=0..m-1);

A1:=seq(plottools[translate](g1,0,sqrt(3)*k),k=0..m-1);

B:=seq(plottools[translate](p,0,sqrt(3)*k),k=0..m-1);

B1:=seq(plottools[translate](p1,0,sqrt(3)*k),k=0..m-1);

C:=plots[display](A,B,A1,B1,scaling=constrained);

C1:=plots[display](A,B,scaling=constrained);

if is(n,even) then print(plots[display](seq(plottools[translate](C,3*k,0),k=0..(n-2)/2),scaling=constrained,axes=none)) fi;

if is(n,odd) then plots[display](seq(plottools[translate](C,3*k,0),k=0..(n-3)/2), plottools[translate](C1,3*(n-1)/2,0),scaling=constrained,axes=none) fi;

end proc:

An example:

Hexlat(7,11,[brown,yellow],5);

## New names...

You need at each step of the loop for all new objects to assign new names, , like this:

restart:

k := 0:

ode := diff(U(t), t) = -((0.01/365)+((0.01/365)*U(t)))*U(t):

ic[0] := U(365*k) = 1000:

sol[0] := dsolve({ic[0], ode}, U(t), numeric):

sigma := 1.5:

for k to 10 do

tk:=365*k:

V := rhs(sol[k-1](tk)[2]):

ic[k] := U(tk) = sigma*V:

sol[k] := dsolve({ic[k], ode}, U(t), numeric):

end do:

Plotting the first five decisions, from the points corresponding to the initial conditions:

A:=seq(plots[odeplot](sol[i],[t,U(t)],365*i..2000,thickness=2,color=[red,blue,green,brown,black][i+1]),i=0..4):

plots[display](A);

## Without discriminant...

Your problem 3 can be easily solved if we use the geometric properties of the graph of a cubic polynomial.

Code of solution:

f:=x->x^3 -3*m*x^2 +3*(m^2 - 1)*x -m^2 +1:

S:=[solve(D(f)(x)=0, x)]:

f1:=%[1]: f2:=%[2]:

op(simplify([solve({f(0)<0, min(S)>0, f(min(S))>0, f(max(S))<0})]));

{m<1+sqrt(2), sqrt(3)<m}

The idea of ​​the solution is clearly seen from the figure:

## The solution on the whole real axis...

Due to the singularity at the origin  the decision for x>0 can not be extended uniquely to the left of 0. So if you want to get the suitable solution, then you need to "glue" it by two solutions: for x <0 and for x> 0:

eq:=x*diff(y(x),x)=2*y(x):

ini1:=[y(-1)=2]:  ini2:= [y(1)=2]:

A:=DEtools[DEplot](eq,y(x),x=-3..0,y=-1..5,[ini1]):

B:=DEtools[DEplot](eq,y(x),x=0..3,y=-1..5,[ini2]):

plots[display](A,B);

 First 275 276 277 278 279 280 281 Page 277 of 282
﻿