acer

32343 Reputation

29 Badges

19 years, 327 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

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?

@one man If you are allowed the somewhat ad hoc use of 1.*10^(-10) as a starting point for NextZero then one could use fsolve similarly, ie, where you called NextZero in the loop (after instantiating with numeric values for ns):

   fsolve(eqn, 1.*10^(-10)..infinity)

For example,

restart;
N := 60: L := 10: a := 2*10^(-12):
ns := [.9603, .9647, .9691]:
eqn := proc (A) options operator, arrow; ns[i]-1+(N/A+(A*L)^(L/(1-L)))^((1-L)/L)*(2+a*exp((N/A+(A*L)^(L/(1-L)))^(1/L))/(A*L*(N/A+(A*L)^(L/(1-L)))^((L-1)/L)+a*exp((N/A+(A*L)^(L/(1-L)))^(1/L))))/(A*L) end proc:
for i to nops(ns) 
do 
  fsolve(eqn, 1.*10^(-10)..infinity);
end do;

        9.300682773*10^(-10)   
        3.054144319*10^(-9)  
        1.172662805*10^(-8)  

I'll note that at default Digits=10 not all the NextZero results you showed are accurate to ten digits.

@golnaz The conditions under which the different computational path is taken by fsolve here is a bit complicated.

The following happens to handle both your equations. And fortunately it's not horribly expensive for these examples. I am not saying that it will handle all other possible examples. There is one internal solving method (one of the constructed inverse iterators) which happens to work for these two examples. But its construction depends on the form into which the algebraic expression is cast.

restart:

N := 60: L := 10: a := 2*10^(-12):

eqn1 := ns=1-((((N/A)+((A*L)^(L/(1-L))))^((1-L)/L))/(A*L))*(2+(a*exp((((N/A)+((A*L)^(L/(1-L)))))^(1/L)))/((A*L*(((N/A)+((A*L)^(L/(1-L))))^((L-1)/L)))+((a*exp((((N/A)+((A*L)^(L/(1-L)))))^(1/L)))))):

neweqn1 := combine(evala(expand(eqn1))):

seq(fsolve(neweqn1), ns=[0.9603,0.9647,0.9691]);

0.9300682773e-9, 0.3054144319e-8, 0.1172662805e-7

############################

eqn2 := r=16*(((A*L*(((N/A)+((A*L)^(L/(1-L))))^((L-1)/L)))+((a*exp((((N/A)+((A*L)^(L/(1-L)))))^(1/L))))))/(((A*L*(((N/A)+((A*L)^(L/(1-L))))^((L-1)/L))))^2):

neweqn2 := combine(evala(expand(eqn2))):

seq(fsolve(neweqn2), r=[0.2,0.1]);

0.9940260022e-7, 0.1056608562e-3

Download r_ac.mw

[edit] I think that reliance on the above fortuitous form is not the best approach for you. I think that it'd be better to use ranges nudged slightly off singular points, since that can usually be automated.

@Syed Asadullah Shah Your code makes F as a table. Do you understand than F(3), F(2), F(k+2) is not correct Maple syntax for indexing into that?

Do you understand what I meant by an instance of pade*(...) in the code?

Perhaps you might start by making syntax corrections.

@golnaz I will submit a bug report against this.

I notice that the following succeeds even without specifying the much reduced range for A. It's following a different path inside the internal fsolve:-fsolve96CplxUni routine.

restart;

N := 60: L := 10: a := 2*10^(-12):

eqn:=ns=1-((((N/A)+((A*L)^(L/(1-L))))^((1-L)/L))/(A*L))*(2+(a*exp((((N/A)+((A*L)^(L/(1-L)))))^(1/L)))/((A*L*(((N/A)+((A*L)^(L/(1-L))))^((L-1)/L)))+((a*exp((((N/A)+((A*L)^(L/(1-L)))))^(1/L)))))):

seq( fsolve(evala(eqn)), ns=[0.9603,0.9647,0.9691] );

0.9300682773e-9, 0.3054144319e-8, 0.1172662805e-7

Download A_ac2.mw

@Syed Asadullah Shah Please answer properly.

@Syed Asadullah Shah 

Please answer my question properly: What do you mean by F(k+2)? Did you mean F[k+2] instead?

Don't repost the same worksheet.

@DJJerome1976 There seems to be an issue with the 2D Input's parser, in particular with how it resolves the name Degree when used in that local declaration. The 2D parser is not resolving that to the binding of the GraphTheory package's export, despite the fact that with(GraphTheory) was previously executed. That problem doesn't occur with 1D input.

Here's an alternative (using Maple 2022.1, which I think may be the same version as you):

restart

with(GraphTheory)

n := 4; degrees := [1, 2, 2, 3]

L := NonIsomorphicGraphs(n, output = graphs, outputform = adjacency)

map(proc (u) local g, d; g := GraphTheory:-Graph(u); d := sort(GraphTheory:-Degree(g)); `if`(d = degrees, g, NULL) end proc, [L])

[GRAPHLN(undirected, unweighted, [1, 2, 3, 4], Array(1..4, {(1) = {4}, (2) = {3, 4}, (3) = {2, 4}, (4) = {1, 2, 3}}), `GRAPHLN/table/8`, 0)]

NULL

Download graph_ac.mw

Why haven't you bothered to attach the actual data (Mat2)?

@Thomas Richard I do not know of any launching option or init file setting that would change that limit.

I tried editing my init file and including a concocted line for FileMRU11. When I launched the GUI that entry did not appear in the drop-list, and it vanished upon full closing.

@nm The (mapped) operator,

   z->assign(z)

is a procedure in its own right. It declares its own z as its (only) procedural parameter. That z is not a parameter or local of a procedure within which that inner prodecure is defined.

Consider this example:

  f := proc(x)
    local p, r;
    p := proc(z) z^2; end proc;
    r := z -> sin(z);
    (z->sqrt(z))(p(r(x)));
  end proc;

The "z" that is a parameter of
   proc(z) z^2; end proc
is not a local or parameter of f.

The "z" that is a parameter of
   z -> sin(z)
is not a local or parameter of f.

The "z" that is a parameter of
   z->sqrt(z)
is not a local or parameter of f.

First 95 96 97 98 99 100 101 Last Page 97 of 592