acer

32490 Reputation

29 Badges

20 years, 8 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@oldstudent Your basic problem seems to be either that you feel the x-axis has to be drawn along y=0 and you are not paying attention to the tickmarks drawn by Maple, or that you feel that y=0 ought to be occur at the bottom of the graph. Or some other muddle related to an inflexible notion of how this curve should be "graphed properly".

The plot shown by,

  plot(x^2+2, x= -2..2);

has y=2 along the bottom edge of what is displayed, and that is where the x-axis is drawn for that particular view of the x-y plane. Please note the values of the tickmarks drawn along the y-axis.

If you do not like the default view (which is mostly designed to match the extent of the curve, by default) then you can easily force whatever other finite view you'd prefer. Eg,

  plot(x^2+2, x=-2..2, view=0..6);

  plot(x^2+2, x=-2..2, view=[-1..2, -1..6]);

@mehdi jafari Your Maple code will very often be more flexible and useful if you put it in a procedure or module.

Doing everything only at the top level is clumsy and can even run slower.

Switching over to working mostly with procedures is like moving from primary school to high school.

@Mathieu1234 

restart:

expr:=(a1/2+a2/2)*ln(a1/2+a2/2+sqrt((a1/2+a2/2)^2+(b1/2-b2/2)^2+d^2))
      +(a1/2-a2/2)*ln(a1/2-a2/2+sqrt((a1/2-a2/2)^2+(b1/2-b2/2)^2+d^2)):

ans1 := simplify(expr, {a1-a2=deltaa, a1+a2=sigmaa}):

U:=Student:-Precalculus:-CompleteSquare:

ans2 := subsindets(ans1,`^`,u->`^`(U(op(1,u),[a1,b1]),op(2,u)));

           /           /                             (1/2)         \\       
         1 |           |/         2      2         2\              ||       
 ans2 := - \-ln(2) + ln\\(b1 - b2)  + 4 d  + deltaa /      + deltaa// deltaa
         2                                                                  

        /           /                             (1/2)         \\       
      1 |           |/         2      2         2\              ||       
    + - \-ln(2) + ln\\(b1 - b2)  + 4 d  + sigmaa /      + sigmaa// sigmaa
      2                                                                  


simplify( ans1-ans2 );

                                      0

Terser, if maybe slower in general, might be,

ans3 := subsindets(ans1,`+`,u->U(u));

           /           /                             (1/2)         \\       
         1 |           |/         2      2         2\              ||       
 ans3 := - \-ln(2) + ln\\(b2 - b1)  + 4 d  + deltaa /      + deltaa// deltaa
         2                                                                  

        /           /                             (1/2)         \\       
      1 |           |/         2      2         2\              ||       
    + - \-ln(2) + ln\\(b2 - b1)  + 4 d  + sigmaa /      + sigmaa// sigmaa
      2                                                                  


simplify( ans1-ans3 );

                                      0

And you could still try and force how it approaches squares, eg,

subsindets(ans1,`+`,u->U(u,[b1,a1]));

And another few ways to do that might be,

evalindets(ans1, `+` , U);

evalindets(ans1, `+` , U, [b1,a1]);

What's your machine's exact cpu chipset, do you mind saying? It may just be that your machine supports AVX instructions and that MKL is not gracefully reverting to just SSEx in the case that some mkl_*avx*.so is missing in the Maple redistributables.

Have you tried in 18.00, if you still have that available?

It's not clear what you mean about loading your own MKL. Which version? How, in a way that Maple would pick it up at run time?

And what LinearAlgebra operations are losing accuracy? SVD? Arithmetic? Other? Could you upload a representative worksheet (green arrow)?

acer

@Markiyan Hirnyk What's the significance of that expression you evaluated at beta=0, with regard to the original expression posted?

How about beta=0 ?

More seriously, perhaps, what kind of answer are you hoping for? An exact characterization of all roots? Or a floating-point approximation to all roots within a finite range? Or...?

acer

I'm not really sure what it is that you are asking.

Is it something like this, perhaps?

acer

@mattcanderson1 This is a silly response since it includes basic math (not what was asked) but provides no real answer to the questioner's difficulty with Maple usage.

@Carl Love The procedure `isconvex` is a machine for finding bugs and weaknesses in `is`.

@Markiyan Hirnyk If you tried to paste the 1D Maple Notation code from my reply above (without the leading prompt symbols) as 2D Maple input then the GUI will issue an error. It is 1D code, and plaintext 1D notation Maple code cannot generally be pasted as straight plaintext into a 2D Math input area.

In Maple 18.01 the 1D Maple Notation code pasted easily and successfully into an execution group.

But the code posted above is not prepared for more than one unknown, and blindly picks off the first. But you have another post with an example with one unknown variable and 2 constrained parameters. So here is an edited version which accepts an extra argument (name).

Please note that this is 1D Maple Notation code, I remove the leading command prompts.

restart:
isconvex := proc(expr,x::name,A::realcons:=-infinity,B::realcons:=infinity)
 local a,b,t,use_expr,res;
   #x := indets(expr,name) minus {constants};
   if nops(x) = 1 then
     x := op(x);
   else error;
   end if;
   # For more than one variable, one could test
   # positive-definiteness of the Hessian.
   res := is( diff(expr,x,x) >=0 )
            assuming x>=A, x<=B;
   if res<>FAIL then
     return res;
   else
     userinfo(1,'isconvex',`falling back to the definition`);
     # Is it better to expand, or simplify, or put
     # Normalizer calls around the two-arg evals or
     # their difference, oder...?
     use_expr:=expand(expr);
     is( eval(use_expr,x=(1-t)*a+t*b) <=
         (1-t)*eval(use_expr,x=a)+t*eval(use_expr,x=b) )
       assuming a<=b, t>=0, t<=1, b<=B, a>=A;
   #else
   ##Is global optimization another fallback?
   end if;
 end proc:

f := log[x](1+(x^a-1)*(x^b-1)/(x-1)):

isconvex(f, x, 0, 1) assuming a>0, a<1, b>0, b<1;

                              FAIL

isconvex(f, x, 1, infinity) assuming a>0, a<1, b>0, b<1;

                              FAIL

isconvex(eval(f,[a=1/2,b=3/4]), x, 0, 1);

# Maple ran out of memory on me, for the last one above, and never got past
# the initial 2nd deriv test. I also got a FAIL for it, with just the
# "definition" fallback. One could try with simplify or expand at judicious points.
# Analysis is hard in a CAS, and `is` could be improved.

I'll let you know if I get any results under simplify or expand of intermediate expressions (using either method of the code above).

One approach might be to first hit your original procedure `unapp` with codegen[prep2trans] in order to generate a Maple procedure with conditional code rather than piecewise constructs.

This worked for most but not all of the terms. I was not yet able to succeed like this, as it seems to go wrong generating conditional code while handling the rhs terms which involve sums of terms involving piecewise.

It might be easier to have Maple generate the entire float[8] Matrix of results (for all timesteps), which I believe I might have suggested in a comment buried in your ealier post.

If instead you decide to stick with your original approach from the earlier post then at the very least I would suggest that you first evaluate the list (or Vector) [BAT_A, BAT_V,...] at elimsol[1] prior to using unapply. That way each call to your unapp procedure will generate a list (or Vector) of numeric values directly. That at least should perform better than the original way which produced a list of equations [BAT_A=..,BAT_V-.,...] at each timestep (and for each of which the a seperate evaluation or lhs map was needed to pick off the numeric values). Hope that makes sense.

acer

Did you intend the first instance of rho on your (red code) input line to be followed by a multiplication symbol?

acer

@taro If you got 1/2 as that last result then your procedure generated by shift(sin) is behaving like sin(x+1). So maybe the problem you see is just with printing.

By the way, in a console, using the commandline (TTY) interface, I see,

%maple9 -s
    |\^/|     Maple 9 (APPLE PPC OSX)
._|\|   |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2003
 \  MAPLE  /  All rights reserved. Maple is a trademark of
 <____ ____>  Waterloo Maple Inc.
      |       Type ? for help.

shift:=(f::procedure)->(x->(f(x+1))):

shift(sin);

                                x -> sin(x + 1)

%(Pi/6-1);

                                      1/2

kernelopts(version);

             Maple 9.01, APPLE PPC OSX, Jul 9 2003 Build ID 137227
shift:=(f::procedure)->(x->(f(x+1))):

shift(sin);

                                x -> sin(x + 1)

kernelopts(version);

            Maple 9.03, IBM INTEL LINUX, Oct 1 2003 Build ID 141050

And, using Maple V R5 on a sparc,

shift:=(f::procedure)->(x->(f(x+1))):

shift(sin);                          

                                x -> sin(x + 1)

%(Pi/6-1);                           

                                      1/2

@teh_allchemist The command to query for curent memory allocation by the OS to the running kernel is kernelopts(bytesalloc) and not kernelopts(bytesused).

The former reports on allocated memory. The latter reports on how much was "processed" by the memory management system, and generally shows a much larger value that is not at all an indication of the current memory allocated. It sounds like you want the former, for your measurement.

Also, passing out a huge collection of lists to Matlab, and then invoking operations in Matlab to extract the numeric array values, line by line and entry by entry or even column by column, doesn't sound like an approach for any kind of decent performance.

Instead, why not convert the huge list of equations to a Matrix or Vector of just the numeric values, in Maple itself, and pass that to Matlab instead. You could even store it to a file. You could store a Vector of the column header names separately from the numeric data. You could store the purely float data in a Matrix or Vector in Maple with datatype=float[8] as itsme suggested. You could export that to text file, or even to a Matlab format binary format file. I would be surprised if this couldn't all be done very efficiently.

I suggest processing the symbolic equations in Maple, first, and then exporting the resulting compact numeric Matrix and a small Vector of just the column header names. That's what itsme's code does, I believe.

Even if you are sitting with control currently in Matlab and have produce the large symbolic list structure in a running (associated) Maple session, then it'd likely still be much better to make a single `maple` call-out, to convert the rhs's of the symbol equations to a Maple datatype=float[8]  Matrix in one fell swoop. Even if you had to make another `maple` call-out from Matlab to Maple, in order to get Maple to export that to a compact Matlab binary format file. 

Perhaps I don't properly understand which program you are running in to execute commands. It sounds to me as if you are running in Matlab, and calling out to Maple to run simulations and generate results (which you then want to import into your running Matlab). Is that near right?

First 357 358 359 360 361 362 363 Last Page 359 of 594