Items tagged with maximize

The commands below are from a response by Carl Love to a question posed on February 27, 2016.

Variable t is not mentioned in the plot of f. Does t assume one or more particular values in the construction of the plot?

When t is given a specific value before executing the plot command, the resulting plot appears to be independent of t's value.

What is the logic behind the plot's construction?

f:= cos(2*t/m) + cos(2*(t+5)/m):
plot('maximize'(f), m= 1..10);

Let us consider 

maximize(int(exp(-x^4), x = k .. 3*k), location);

Error, (in maximize) invalid input: iscont expects its 1st argument, f, to be of type algebraic, but received x = k .. 3*k
whereas the expected output is 

[(2*((1/40)*GAMMA(1/4, (1/80)*ln(3))*5^(1/4)*ln(3)^(3/4)-(1/40)*GAMMA(1/4, (81/80)*ln(3))*5^(1/4)*ln(3)^(3/4)))*5^(3/4)*(1/ln(3))^(3/4), [k = (1/10)*10^(3/4)*ln(3)^(1/4)]]

as Mma 11 produces. The following 

RealDomain:-solve(diff(int(exp(-x^4), x = k .. 3*k), k));
  -(1/10)*5^(3/4)*ln(3)^(1/4), (1/10)*5^(3/4)*ln(3)^(1/4)

is not a workaround because of 

int(exp(-x^4), x = (1/10)*5^(3/4)*ln(3)^(1/4) .. (3/10)*5^(3/4)*ln(3)^(1/4));


Both the commands 

maximize(x*sin(t)+y*sin(2*t), t = 0 .. 2*Pi)assuming x>=0,y>=0;
minimize(x*sin(t)+y*sin(2*t), t = 0 .. 2*Pi)assuming x>=0,y>=0;

output 0. Simply no words.

Consider the following expression obtained from the solve command: Note that this uses the two variable arctan function.

p:=arctan((-cos(theta)^3-(1/2)*cos(theta)^2-(1/2)*cos(theta)*((2*cos(theta)+1)*(2*cos(theta)-3)*(cos(theta)+1)^2)^(1/2)+2*cos(theta)-(1/2)*((2*cos(theta)+1)*(2*cos(theta)-3)*(cos(theta)+1)^2)^(1/2)+3/2)^(1/2), -(1/2)*cos(theta)-1/2-(1/2)*((2*cos(theta)+1)*(2*cos(theta)-3)*(cos(theta)+1)^2)^(1/2)):

#ploting the expression shows a non-zero value at theta = Pi,  however if I convert p to a function using


# then f(Pi);  gives a value of 0

#On the other hand maximize(p,theta=3*Pi/4..5*Pi/4,location); shows a non-zero value of 4*Pi/5 at theta = Pi,  which agrees with the plot of p, namely, it returns:


{[{theta = Pi}, -arctan((10-2*5^(1/2))^(1/2)/(5^(1/2)+1))+Pi]}

Is this a bug? Or what?



Can you tell me the signification of the number 5 in output below.

Input: maximize(x^2+3,x=-1..2,location)

Output: 7,{[{x=2},5]}




When I put maximize(cos(t)), everything is fine.

When I put maximize(cos(Pi)), everything is fine.

When I put maximize(cos(t*Pi)), it says invalid limiting point??? What went wrong?


Hi all,

I have a function f(x) and want to know at which x-value it attains its supremum.

Tried this, but it doesn't work (or at least hasn't been able to solve the equation in 10+ min):

M := maximize(f, x = 0 .. 1);

solve(f = M, x);

Does anyone know a way to do this?



a := 1; w0 := 1; w1 := 3; K := 10; h0 := .25; A := 3; alpha := .7; b := .6; c := .2

f := A*x^(b*alpha)*(alpha*A*x^(b*alpha)/(a+w0*h0+(x-h0)*w1))^(alpha/(1-alpha))-(alpha*A*x^(b*alpha)/(a+w0*h0+(x-h0)*w1))^(1/(1-alpha))




M := maximize(f, x = 0 .. 1)



solve(f = M, x)

Warning,  computation interrupted



plot(f, x = 0 .. 1)






I've got this huge chunk of code which leads to an optimiazation at the very last line (Bestangles:=minimize(maximize()-minimize))). This minization is taking a very long time (havent solved it yet) and I would very much like to reduce that time. As I've understood maple does optimization by differentiating and then finding all extremes and comparing. Would this mean that since I minimize and optimize within a minimization command, it differentiates a ton of times? And if this is the case, can I somehow do the differentiation beforehand, since it is the same function being differentiate all the time? Or is there some other way I can improve the code? 
Thanks alot!

Heres the full code:

I am not sure how/why, but here is the worksheet.


The function evalutes fine and can be used for sequence. But it does not seem to be working with plot or Maximize.

V is assumed to between 0 and 1.

Need some help.






  I have the following input

maximize(f, x=0..100,location);

 Maple gives me the location is x=1.25. However, how should I do to obtain this position?  If I write


a:=maximize(f, x=0..100,location);


  Seems it do not work :(


  I may try fsolve at the maximum value, but it seems to be awkward..


Thank you very much!


Hi there,

I am trying to maximize a function given a set of values to a parameter in the function. The function is an differential equation belonging to a system of two differential equations.

I have a for loop to state different values to the parameter.

Maple yields the error:

Error, (in Optimization:-NLPSolve) cannot evaluate the solution further right of 0.17757507e-4, probably a singularity

When trying to maximize the function.

Supposed that I was doing something wrong in the loop, if I reproduce the contents of the loop outside, and set a value for the parameter. If I plot the solution of the ordinary differential equation, I can see where the maximum lies.

Having plot it, the Optimizamtion:-Maximize works as expected.

However, omitting the plot has a weird effect: I only get the same result depending on the bounds I set for the Maximization:

de1 := diff(A(t), t) = r*m*(1-g)*A(t)-piecewise(t < 8, r*A(t), t >= 8, (r+k)*A(t));
de2 := diff(G(t), t) = r*m*g*A(t)-l*G(t);

ics := A(0) = 25.0, G(0) = 0.;
num := dsolve({de1, de2, ics}, {A(t), G(t)}, type = numeric, output = listprocedure, parameters = [g]);

num(parameters = [g = .15]);
val := eval(G(t), num);

# odeplot(val, [t, G(t)], t = 0 .. 100);

Error, (in Optimization:-NLPSolve) cannot evaluate the solution further right of 0.17757507e-4, probably a singularity

val2 := Maximize(val);

Error, (in Optimization:-NLPSolve) cannot evaluate the solution further right of 0.17757507e-4, probably a singularity

val3 := Maximize(val(t), t = 0 .. 60);

  [10267.824035766165, [t = 8.25727747134303]]

val4 := Maximize(val(t), t = 0 .. 100);

[6.863211343195069e-9, [t = 59.84184367042171]]


The right answer is [10267.824035766165, [t = 8.25727747134303]]: Why do I get two different answers even if in that range there is only one relative maximum?

I ignore whether the way I am specifying the arguments for the Maximize function is correct. val is a procedure.


What am I missing?

Attached is the worksheet:




I want to solve maximize of equation,but the maximize failed to solve it,who can help me.thanks.

c[1] := (1/8)*w*{(1/((x+y+z)^2+1))^(3/2)+(1/((x+y)^2+1))^(3/2)+(1/((x+z)^2+1))^(3/2)+(1/((y+z)^2+1))^(3/2)+(1/(x^2+1))^(3/2)+(1/(y^2+1))^(3/2)+(1/(z^2+1))^(3/2)+1}+(1/8)*{x/((x+y+z)^2+1)+x/((x+y)^2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}+(1/8)*{x/((x+y+z)^2+1)+x/((x+y)^2+1)+x/((x+z)^2+1)+x/(x^2+1)})


subs(w = -(1/((x+y+z)^2+1)-y*(2*x+2*y+2*z)/((x+y+z)^2+1)^2+1/((x+y)^2+1)-y*(2*x+2*y)/((x+y)^2+1)^2+1/((y+z)^2+1)-y*(2*y+2*z)/((y+z)^2+1)^2+1/(y^2+1)-2*y^2/(y^2+1)^2)/(-(3/2)*(1/(x^2+2*x*y+2*x*z+y^2+2*y*z+z^2+1))^(1/2)*(2*x+2*y+2*z)/((x+y+z)^2+1)^2-(3/2)*(1/(x^2+2*x*y+y^2+1))^(1/2)*(2*x+2*y)/((x+y)^2+1)^2-(3/2)*(1/(y^2+2*y*z+z^2+1))^(1/2)*(2*y+2*z)/((y+z)^2+1)^2-3*(1/(y^2+1))^(1/2)*y/(y^2+1)^2), c[2]);



"#"Iwant to maximize the equation (5)and (6),under the conditon of x,y,z are negative or positive at the same time.





I want to find the greatest value of this expression 


with x>0, y>0 , z>0,x+y+z=3.

I tried



DirectSearch[GlobalOptima](f(x,y,z), {x>0, y>0 , z>0,x+y+z=3},maximize);

I got the output

[HFloat(infinity), [x = .591166078050740e52, y = .183647204560715e52, z = .786638021216969e52], 1249]



Hi all


I am trying to maximize a function f(x,y,z,w) in terms of x. (Only x is treated as a variable, and the others are treated as parameters).

However, all I know is that y,z,w they are parameters and they are non-negative. I have already tried with the "optmization help page" from maplesoft's website, and it looks like it will search the range of x,y,z,w, and it will return numerical values at which this function is maximized. 



However, what I want is instead a close-form solution of x=g(y,z,w) that will maximize the function.   In other words, I would like to keep the parameter in symbolic forms. 


Can Maple do that?

1 2 3 Page 1 of 3