acer

32622 Reputation

29 Badges

20 years, 44 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Your original approach can be made to work if your use the restricttoranges option of the plots:-densityplot command, and ensure that the grid size it uses matches the dimensions of your T table exactly, and ensure that it accesses T values indexed in the same way that they're assigned (in your code, by integer values, but you could alternatively store them as floats).

But it's awkward, mostly on account of using T like both an array and a function call at the same time.

restart:
with(plots):

nx:=20: tmax:=50: T1:=1: T2:=10: L:=1: k:=1: rho:=1:
cp:=1: chi:=k/rho/cp: h:=L/(nx-1): t:=1e-3:

for k from 0 to nx do T(k,0):=T1 od:

for w from 1 to tmax do
  T(0,w):=T1: T(nx,w):=T2:
  for q from 1 to nx-1 do
    T(q,w):=T(q,w-1)+chi*t/h^2*(T(q+1,w-1)+T(q-1,w-1)-2*T(q,w-1));
  od: od:

ft:=proc(x,y) T(trunc(x),trunc(y)); end proc:

densityplot(ft, 0..nx, 0..tmax, grid=[21,51], restricttoranges,
            #colorstyle=HUE,
            style=surface);

Here's an idea for scaling intensity by convergence rate. Lighter means it took longer, but the black regions (exhibited when there is no converegence within maxiter iterations) still means failure to converge. You can play around with it. newtbasin2.mw

@Kitonum The multiple Questions by this member look like coursework, to me. If that is so then I would expect the instructor intends the computations to be done in binary, rather than being computed base-10 with fore and aft conversions. Just a thought.

@Doug Meade I removed the multiple angle-bracket sideways-chevrons (red prompts) from the Execution Groups that defined the procedures. If you recall, the bug in Maple 2015.0 was that the GUI was wrongly interpreting some lines (which preceded a line with a chevron) within the same Exec Group as terminated statements.

The one I uploaded runs ok in Maple 2015.0, while the original did not. Both are fine in Maple 18.x, Maple 2015.2, Maple 2016.x, etc.

By "removed the multiple chevrons" I mean that I cut and pasted every line in the multi-line Exec Groups, by hand, using Shift-Enter to get to new input lines (without additional chevrons/prompts).

There was nothing that needed fixing in the code itself, as your syntax was all correct.

@brian bovril You will get the error message "reserved word `uses` unexpected` if you attempt to run Doug's worksheet in Maple 2015.0 because of this version-specific bug.

That bug is fixed in the point-releases. If you are already using Maple 2015.0 then you should consider upgrading (for free) to Maple 2015.2 which you can obtain here.

Here is Doug's sheet, edited to work in Maple 2015.0. Langford_2015.0.mw (Doug, please let me know if you'd like to copy and repost, or if you'd like me to remove this link to your material.)

@Kitonum It might be interesting to see whether the Bits package makes at least some aspects of these kinds of computation easier (to author, or understand), or not.

@AdamBarker I suspect that there is a scaling of the iteration count that can visually convey that information, yes. It was the code comment "## Optional, scale the saturation by the time to converge" where I did something for that which works visually only for a smaller maximal iteration limit.

It likely can be done with a suitable call to `ln`, say. I'll play with it and let you know if it looks nicer. I'm not sure within which channels (H,S, or V) it's be more useful. I should try and make the color-selector faster too, where it assigns a color based on which root it's converging towards.

How do you expect that to work when you define ex1 and ex2 as operators but pass use them like expressions (in x,t,z) when calling implicitplot3d?

What's that extra `e` doing inside ex2?

acer

You aren't going to be able to distinguish amongst roots with the same absolute value, using that Newton command. So if you're trying to color by the value of the roots then that command won't always get you there.

But it should be possible using the IterativeMaps:-Escape command, by using the real and imaginart pats of converged value for two separate layers in the result.

What platform and OS are you using? 32bit, 64bit, OSX, Windows, Linux? Any other OS details? Does the Compiler work for you, otherwise?

I can't see the images of code you posted in your question. Perhaps upload a worksheet (green arrow) along with OS details.

acer

@Clarins The example you're citing relates to 3D data and interpolation, and the input points (at which one wants to compute interpolated values) are expected to be supplied in an Array with the corresponding dimension(s).

That input Array just looks a little funny when there is just one single new point at which to interpolate. But the structure could alternatively hold multiple such points.

If you intend 1/(x*(1-x))*(1+2*x) then type it in that way, rather than as 1/(x(1-x))(1+2*x) . What you had involved function calls, not multiplication.

acer

@Markiyan Hirnyk 

restart;

showstat((Optimization::GlobalUnivariate)::FindLConstant,2):


(Optimization::GlobalUnivariate):-FindLConstant := proc(func, a, b, useevalhf)
local i, L, L1, L2, n, temp1, temp2, V, Fv, fpoly, fpolyvec, reven, rodd, qeven, qodd;
       ...
   2   V := Vector(n,i -> a+(i-1)*(b-a)/n,('datatype') = ('float'));
       ...
end proc

proc()
  local oldkop,T;
  try
    oldkop:=kernelopts(':-opaquemodules'=false);
    T:=:-ToInert(eval(:-Optimization:-GlobalUnivariate:-FindLConstant));
    if op([5,2,2,2,2,5,1,2,3,1],T)=':-_Inert_LEXICAL_LOCAL'(3) then
      unprotect(:-Optimization:-GlobalUnivariate:-FindLConstant);
      :-Optimization:-GlobalUnivariate:-FindLConstant:=
        :-FromInert(:-subsop([5,2,2,2,2,5,1,2,3,1]
                             =':-_Inert_SUM'(':-_Inert_LEXICAL_LOCAL'(3),
                                             ':-_Inert_INTNEG'(1)),T));
      protect(:-Optimization:-GlobalUnivariate:-FindLConstant);
    end if;
  catch:
  finally
    protect(:-Optimization:-GlobalUnivariate:-FindLConstant);
    kernelopts(':-opaquemodules'=oldkop);
  end try;
  NULL;
end proc();

showstat((Optimization::GlobalUnivariate)::FindLConstant,2):


(Optimization::GlobalUnivariate):-FindLConstant := proc(func, a, b, useevalhf)
local i, L, L1, L2, n, temp1, temp2, V, Fv, fpoly, fpolyvec, reven, rodd, qeven, qodd;
       ...
   2   V := Vector(n,i -> a+(i-1)*(b-a)/(n-1),('datatype') = ('float'));
       ...
end proc

g:=(c,d)->Optimization:-NLPSolve(x^4+x^3+c*x^2+d*x-c-1, x=-1..1, maximize,
                                 method=branchandbound)[1]:

CodeTools:-Usage( plot3d(g, -5..5, -5..5, style=surface, color="DarkOliveGreen",
                         orientation=[-25,35,-5],
                         lightmodel=Light1, glossiness=0.9, style=surface) );

memory used=1.39GiB, alloc change=36.00MiB, cpu time=8.06s, real time=8.07s, gc time=604.00ms

 

bandbpatch.mw

 

@lg674 Kitonum's code works for me in Maple 18.02. I attach it in a Worksheet.

curve.mw

I also added the option numpoints=500 to the calls to spacecurve, to get a smoother curve (for the full range of t) in that Maple version.

@Axel Vogt Hi Axel, I've made a few posts about cusomiztion of context-menus in the past, ie, here, here, here, and a few others. But none of those generated much commentary or response, even by those more expert at Maple programming.

Maybe I should write the code to augment the stock context-menus with calls to the DirectSearch package's commands (possibly in the submenu used for Optimization?)

@Chris It must be tough to use a Maple Document or Worksheet, including stock context-menus for instructing primary school students. How do you help them not become confused by the mathematical jargon that is years beyond their current knowledge?

There are some interactive popup applications (Maplet based "applets") available from the main menubar, via Tools->Options->Tutors (or Assistants). The one's from the Precalculus package might provide a gentle experience for the very young or mathematically inexperienced.

I should probably mention that the third argument of the Entries:-Add command in the code snippet I gave above is the type which the right-clicked expression must match in order for the context-menu item to appear. Now, (x-1)/(x-2) will trigger it, since that is of type ratpoly which is the type I used in that code example. But y=(x-1)/(x-2) is not of that type, and so won't trigger it. You could either relax that type to be something like, literally, anything instead of ratpoly so that it is matched by more variants of expression. Or you could construct a more involved type that more expressions would satisfy.

You can also augment the context-menu with even more items, such as more of the available tutors. Or if you find (or author) even more popup applets then you could augment the context-menu with those too.

In my code snippet above the first line makes a full copy of the "stock" Library-side context-menus. And you can add your own customized items into existing submenus (like I did above), or make your own submenus for them. You could even start from scratch with an essentially empty set rather than use the Copy command as I did above, and add only your own items. Or you could experiment with the ContextMenu[CurrentContext][Entries][Disable] command if your students are overwhelmed by the jargon in the slew of stock items. The system is pretty flexible, but setting up a customization does require programming.

This is an area for which I haven't seen a lot of interest in customization by users, over the years. It's possible that this is because there are only programmatic means available for customization. I wonder whether a Maplet or Embedded-Components based graphical interface to customization would make a big difference.

First 310 311 312 313 314 315 316 Last Page 312 of 596