vv

13790 Reputation

20 Badges

9 years, 304 days

MaplePrimes Activity


These are answers submitted by vv

The error given by Maximize is clear:
Error, (in Optimization:-NLPSolve) no feasible point found for the linear constraints

Indeed, C_1, and C_2 imply:

C12:=op(C_1 union C_2):
solve(C12[1]);solve(C12[2]);

                  [36571.46530, infinity)

               (-infinity, 27143.30624]

so, disjoint intervals, no common point (i.e. no feasible point).

 

Re(term2) assuming real;
combine(%);

        

 

It is not possible to use an index this way:
a[i] := expr;
==> a table named a is constructed and the entry i is defined.
If i is symbolic, all the other entries such as a[1], a[2], ... remain undefined.

It is possible to use a procedure

a := i -> expr;

and use paranteses a(1), a(2), ...

 

Here is a method to define a function using your infinite product.

 

restart

# An approximation

N:=100:
f:=t -> local n;  evalf(mul(2*cos(t/2^n)-1, n=1..N));

proc (t) local n; options operator, arrow; evalf(mul(2*cos(t/2^n)-1, n = 1 .. N)) end proc

(1)

plot(f, -5..5);

 

# Exact computation; Maple is not able to obtain it. We have to use the brain or (maybe) IA.

F:= t -> sin(3*t/2)/3/sin(t/2);

proc (t) options operator, arrow; (1/3)*sin((3/2)*t)/sin((1/2)*t) end proc

(2)

plot(F-f, -5..5)

 


Download inf-prod-vv.mw

A table has special evaluation (to a name). So, use:

eval(T1["1"]);

Also, print(T1["1"]); confirms.

restart;

limit( cos(Pi*sqrt(x^2+x+1)), x=infinity);

-1 .. 1

(1)

 

The limit does not exist for a function, but it exists for a sequence.

 

L := Limit(cos(Pi*sqrt(n^2+n+1)), n=infinity); # assuming n::integer

Limit(cos(Pi*(n^2+n+1)^(1/2)), n = infinity)

(2)

f := asympt(sqrt(n^2+n+1),n,2, oterm=false);

n+1/2+(3/8)/n

(3)

simplify(cos(f*Pi)) assuming n::posint;

L=limit(%, n=infinity);

-sin((3/8)*Pi/n)*(-1)^n

 

Limit(cos(Pi*(n^2+n+1)^(1/2)), n = infinity) = 0

(4)

 

 

See the 2018 post  add, floats, and Kahan sum - MaplePrimes.

Note that since 2021, the add command has the pairwise option, see Pairwise summation - Wikipedia.

 

 

Let us check the provided manual solution.

 

de := Diff(a(x)*Diff(u(x),x),x) = -1;

Diff(a(x)*(Diff(u(x), x)), x) = -1

(1)

bc := u(-1)=0, u(1)=0;

u(-1) = 0, u(1) = 0

(2)

a := x -> 1 + 2*Heaviside(x);

proc (x) options operator, arrow; 1+2*Heaviside(x) end proc

(3)

c := int(x/a(x),x=-1..1) / int(1/a(x),x=-1..1) ;

-1/4

(4)

U:=int((c-xi)/a(xi), xi=-1..x); # the "solution" u(x) = U

-(1/4)*x+(1/6)*x*Heaviside(x)-(1/2)*x^2+(1/3)*x^2*Heaviside(x)+1/4

(5)

eval(U, x=1), eval(U, x=-1);  # bc, OK

0, 0

(6)

U is continuous everywhere, differentiable except at x=0.

value(eval(lhs(de), u(x)=U)) assuming x<0;
value(eval(lhs(de), u(x)=U)) assuming x>0

-1

 

-1

(7)

So, the provided solution U, is continuous in [-1,1],  not differentiable at 0 but C^2 in [-1,1] \ {0} and satisfies the de  here.
It seems to be a "generalized" solution, but the exact sense is not mentioned. Distributional sense maybe?

 

Unfortunately the documentation for dsolve is silent about this type of ode.
Is this solution acceptable for you?

Anyway, it is not a big surprise that dsolve has problems.

 

[edited]

 

RD := (S::set) -> {ListTools:-MakeUnique([S[]], 1, LinearAlgebra:-Equal)[]}:

RD( {Matrix([1])} union {Matrix([1])} union {Matrix([1]), Matrix([2])} );

        

fn must be declared as procedure, not function

f1:=proc(t::numeric, fn::procedure)::numeric;

sin()  and sin(x)  do not have the type procedure; their type is function in Maple.

So, sin  or sin()  are functions mathematically, but for Maple, sin is a procedure and sin() gives an error because the procedure sin cannot be called with 0 arguments.
You may check whattype('sin()');

whattype(sin);
whattype(sin(x));

                           procedure
                           function

The "interrupt current operation" button is in the bottom left corner of the screen, but it usually does not work.
The new interface has many bugs ...
Better use the "old" Screen Readers one. 

restart;

f:=(x1,x2)->(x1-1/2)^4+x1*x2+2*x2^2-1;  
g:=(x1,x2)->(x1-sin(x1))^2+(x2-sin(x2))^2-1;

proc (x1, x2) options operator, arrow; (x1-1/2)^4+x1*x2+2*x2^2-1 end proc

 

proc (x1, x2) options operator, arrow; (x1-sin(x1))^2+(x2-sin(x2))^2-1 end proc

(1)

Find the circle of maximum radius that is tangent to both curves f=0, g=0.

 

Here is an approach using Optimization:-Maximize

It gives local maxima.

For a global maxima we must play with the intervals for variables and/or their initialpoint (using rand(...) conditions).

 

with(plottools):

pfg:=plots:-implicitplot([f(x,y),g(x,y)], x=-2..2,y=-2..2);

 

EQ:=
f(a,b)=0, g(c,d)=0, r2=(u-a)^2+(v-b)^2, r2=(u-c)^2+(v-d)^2,
D[1](f)(a,b) * (v-b) - D[2](f)(a,b) * (u-a) = 0,
D[1](g)(c,d) * (v-d) - D[2](g)(c,d) * (u-c) = 0:
rnd:=rand(-2. .. 2.):

unassign('a','b','c','d','u','v','r2');
sol:=Optimization:-Maximize( r2, {EQ}, u=-2..-1, v=-1.5..2, a=-5..0, b=-1..0, c=-2..-1, d=-2..-1, r2=0..3,
     initialpoint={u=0.7, v=0.5} )[2];
assign(sol);r:=sqrt(r2):
plots:-display(pfg,circle([u,v],r), plot([[a,b],[u,v]],color=red),plot([[c,d],[u,v]],color=blue),
               scaling=constrained,title=("Local max radius"=r));

[a = HFloat(-0.3036274461741274), b = HFloat(-0.46927384815579104), c = HFloat(-1.910428572753095), d = HFloat(-1.1755927491183271), r2 = HFloat(0.8409103269146442), u = HFloat(-1.0), v = HFloat(-1.0659107504612695)]

 

 

 

unassign('a','b','c','d','u','v','r2');
solglobmax:=[r2=0]:
to 200 do
ok:=true;
try
  sol:=Optimization:-Maximize( r2, {EQ}, initialpoint={u=rnd(), v=rnd()} )[2];
  catch:
  ok:=false;
end try;
if not ok then next fi;  
if eval(r2,sol)>eval(r2,solglobmax) then solglobmax:=sol fi;
od:
assign(solglobmax);r:=sqrt(r2):

plots:-display(pfg,circle([u,v],r), plot([[a,b],[u,v]],color=red),plot([[c,d],[u,v]],color=blue),
               scaling=constrained, title=("Global max radius"=r));

Warning, limiting number of major iterations has been reached

 

Warning, limiting number of major iterations has been reached

 

Warning, limiting number of major iterations has been reached

 

Warning, limiting number of major iterations has been reached

 

Warning, limiting number of major iterations has been reached

 

Warning, limiting number of major iterations has been reached

 

Warning, limiting number of major iterations has been reached

 

Warning, limiting number of major iterations has been reached

 

Warning, limiting number of major iterations has been reached

 

Warning, limiting number of major iterations has been reached

 

 

 

 

Download 2curves-vv.mw
(edited for Global max).

The constraints must be included in a set.

Optimization:-NLPSolve( TP_T(p1, p2), {C1, C2}, assume = nonnegative,  maximize );

 

diff( c * x / (1+x), x);

Optimization:-Maxima computes only local maxima.
In your case when computing the max in the interval {256.9131467 <= Pc, Pc <= 1436.173707},
Pc = 256.9131467  is a local maximal point. The global maximal point is of course Pc = 1436.173707.
If you want a global max (1-dimensiomal only!) you must use NLPSolve (and also method=branchandbound,   but it seems to be the default here).

When you meet such an aparent discrepancy you should look at a simple example; it is also much better to post a minimal example and with standard notations. Here is such an example:

f:=(x-2)^2:
Optimization:-Maximize(f, {1 <= x, x <= 5});
Optimization:-NLPSolve(f, x=1..5, maximize); # method=branchandbound);
plot(f, x=0..5);

                         [1., [x = 1.]]

                         [9., [x = 5.]]

C := C1 - C2 is a rational function (with 15 indeterminates). It will be enough to compute the minimal value for C and - C.
This can be obtained with the command  DirectSearch:-GlobalOptima(C, vars);
Here DirectSearch is a package which can be downloaded at https://www.maplesoft.com/Applications/Detail.aspx?id=101333

Actually, both min values are < 0, so, the answer to your question is that C1<C2 and C2<C1  are both false.
This can be seen directly (without DirectSearch) using:

P:=numer(normal(C1-C2)) / (lambda*varphi):
eval(-P, {Cm = 1, Cr = 10, Pu = 1, U = 2, a = 9, beta = 9, k = 10, lambda = 10, p1 = 1, tau0 = 10, upsilon = 10, varphi = 10, w = 10, varepsilon = 10, U[0] = 10});
#                     -63035971982554554000

eval(P, {Cm = 89, Cr = 65, Pu = 81, U = 50, a = 37, beta = 43, k = 44, lambda = 0, p1 = 85, tau0 = 74, upsilon = 75, varphi = 59, w = 62, varepsilon = 48, U[0] = 41});
#                       -19372211411803488

 

1 2 3 4 5 6 7 Last Page 1 of 120