acer

32333 Reputation

29 Badges

19 years, 323 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Are you using the stock Physics package that comes with your Maple version, or an update from the Maple cloud?

@Joe Riel I agree very much with the approach of using external text files (Maple source). I prefer having separate files for each part (eg. procedures, submodules, etc), using Maple's $include directive within the text source for the body of the module.

One of the important reasons for my preferring text source files is that common version control tools can be used.

@mmcdara Thanks, maybe you'll come across it later.

I don't really understand the purpose or advantage of defining the procedures P1,P2,P3 outside of the module body. Perhaps there is more going on in your actual examples.

I changed your Post into a Question.

A := exp(I*x):                                
simplify(conjugate(A),power) assuming x::real;

              exp(-I x)

@Carl Love It seems likely that \134n is intended there as the octal (ASCII) escape sequence in which \134 encodes backslash and \134n encodes \n (eventually interpreted as new line).

@ianmccr First, the Help page I cited earlier is about using 2D Input (and not any Typesetting package or extra facilities.) It's stock stuff, and probably ought to be perused by anyone using Maple's 2D Input mode.

Second, I don't know what your rfloor and lfloor commands are supposed to do. Do you know that you can use the special name `&lfoor;` as an infix operator? Do you know that it will pretty-print? (With a bit of work it could be made to render in upright Roman instead of italics when used thusly, I suspect.)

You seem to now be asking about something very different from your original query in this thread. If you have some scenario involving using that symbol (as input, or to get it as desired output) in a pretty-printed way then you could ask that in a separate Question.

@tomleslie [edited] After taking a second look (thanks) I don't know how he managed to get that result of 4. (Perhaps that was the result of some accidental editing of the code after execution...) His issue seems resolved now.

@AmirHosein Sadeghimanesh The colon-dash makes it be a reference to the global name b, instead of the parameter name b of the test1 procedure.

In your example the uneval quotes are not strictly necessary, since you didn't also assign to the global name b. I put in those single-quotes to make it work if you happened to also assign to the global name b (eg. at the top-level). Below, the first example works as you'd intended, but the second does not.

restart;

b := 17:

test1:=proc(a::posint, {b::posint:=1})::posint:
        return a + b:
end proc:

test2:=proc(a::posint, {b::posint:=1} )::posint:
        return a*test1(a, ':-b' = b);
end proc:

test2(2, 'b'=3);

10

restart;

b := 17:

test1:=proc(a::posint, {b::posint:=1})::posint:
        return a + b:
end proc:

test2:=proc(a::posint, {b::posint:=1} )::posint:
        return a*test1(a, :-b = b);
end proc:

test2(2, 'b'=3);

6

Download colondash.mw

ps. The second bullet point on the Help page for topic colondash describes this meaning. Unfortunately that page's Examples section doesn't include a terse but easily understandable example of this situation. Yours is a common question.

@Joe Riel I suppose that you are referring to this entry on the mint Help page:

13

"These local variables were used but

 

never assigned a value:"

 

 

 

Indicates that a local variable's value was used,

 

but that no value was ever assigned to it,

 

suggesting a coding error.

 

Note that if a variable is intended to be used only

 

as a symbol in a procedure, and is not to be assigned,

 

declaring it as type nothing will avoid this error.

Your conditional

   if ls[1] = 0 then

is only going to succeed once, since that branch of the conditional makes this assignment to global ls:

   ls := [1,t]:

and your don't reset that between ArgK calls in your seq attempt.

That's a programming mistake, and is the major cause of why your code isn't acting as you expected.

Next, your expectation about what should happen at 2*Pi seems strange. Perhaps you meant 3*Pi?

@romanrieme The Optimize command returns a list of two things, which can be accessed separately using indexing. The value of the expression is the first item in the list.

Eg,

solmax := Optimization:-Maximize(180*arccos(temp(t))/Pi, t = 0 .. 2);
   [22.00633969122702, [t = 0.6180259177597804]]

valmax := solmax[1];
    22.00633969122702

2*valmax;
    44.01267938245404

eval(t, solmax[2]);
    0.6180259177597804

evalv_max_ac2.mw

minor note: I prefer to pick off the t-value using the eval command instead of rhs (on the indexed second item of the list returned by Optimize), consistent with how I earlier picked off individually the procedures returned by dsolve. I prefer using eval instead of rhs since in the case of multiple equations (in the list) there's no unnecessary dependence on the position of the particular one that I want. I find the consistency more readily understandable -- to use the same method even when there is only one item in the list.

@Carl Love I think that step is not done automatically (by convert to unit_free) in Maple 2015.2.

That's a reason I added it.

@mehdi jafari Are you saying that you thing that the optimization problem you originally posted here is convex?

What do you think about the kind of values I showed?

You wrote, "...using NLPSolve to find the minimum", which makes it sound as if you expect that to find a global optimum. But NLPSolve  may only provide a local optimum in general (ie. excepting certain classes of convex problem, etc, in which I don't believe your problem resides).

Note that your integrand may be considerably simplified. Cursory expermentation shows that for some parameter values the simplified integrand is more accurately computed at default working precision (ie. Digits) than is your unsimplified integral.

Why are you forcing the iterated (single-dimensional integral) use of the _d01ajc method? I'd expect you to have good reason for doing so. Your forced approach to the numeric integration appears to fail (if actually done properly as its purpose appears, with that method forced) for some values of the parameters.

note: for the following values of the parameter I suspect that the integral is approximately -3.138e31,
   w1=0.679949675982879, w2=0.320050330607794, x1=8.53586396320054,
   x2=9.83742482177618, x3=9.83742482526372

but you may need to be careful about attaining that accurately. I found that in the domain:
   w1=0..1, w2=0..1, x1=7..10, x2=5..10, x3=1..10

Are you very certain about the parameter ranges you gave? Ie,
   w1=0..1,w2=0..1,x1=1..10,x2=1..10,x3=1..10
I suspect that the integral is approximately -1.98e35 for some parameter values near,
  w1=0.926925636074863, w2=0.0730743639256177, x1=3.19833303943214,
  x2=1.44032123393708, x3=3.19833303916852

Are those kind of values (negative and large) what you are expecting? I am not claiming that those are global optima within the respective ranges. But to me it's not entirely clear what problem you are trying to solve.

I ask all this because I wouldn't want to waste time accidentally on the wrong problem. Do you expect your integration to be finite for all possible values of the parameters in those ranges?

First 94 95 96 97 98 99 100 Last Page 96 of 591