PatrickT

Dr. Patrick T

2108 Reputation

18 Badges

16 years, 305 days

MaplePrimes Activity


These are replies submitted by PatrickT

As pointed out by Axel and Georgios, the letter e does not refer to the exponential (but alias can make it to, as I showed, if you really want to).

Note that e does exist in Maple, to construct "software floating-point numbers" as follows:

1e1;
                                 10.

So be careful if you want your e to refer to the exponential -- you'd better get used to exp(1) and avoid the letter e altogether.

As pointed out by Axel and Georgios, the letter e does not refer to the exponential (but alias can make it to, as I showed, if you really want to).

Note that e does exist in Maple, to construct "software floating-point numbers" as follows:

1e1;
                                 10.

So be careful if you want your e to refer to the exponential -- you'd better get used to exp(1) and avoid the letter e altogether.

alias(e=exp(1));
                                  e

ln(e);
                                  1

alias(e=exp(1));
                                  e

ln(e);
                                  1

sorry but I don't know these things. Can you adapt the code I gave you at all? it may be easier to see what you want to do if you attempt to write it in code, even if the Maple syntax is faulty, someone will sure be able to take it from there.

Perhaps you just need plot3d, the documentation is very good on this. Note that Maple has a built-in harmonic function, in case you need it, also in the documentation. Note that the cosine function is cos in lowercase letters.

sorry but I don't know these things. Can you adapt the code I gave you at all? it may be easier to see what you want to do if you attempt to write it in code, even if the Maple syntax is faulty, someone will sure be able to take it from there.

Perhaps you just need plot3d, the documentation is very good on this. Note that Maple has a built-in harmonic function, in case you need it, also in the documentation. Note that the cosine function is cos in lowercase letters.

Thanks pagan, I did just that (below).

I didn't know about try...catch, very useful, thanks for the pointer,

Patrick.

 

getarrows := proc(x0, y0, xd, yd, T, x1, y1)
  local DEsol, tm,j,w;
  w:= interface(warnlevel):
  interface(warnlevel=0):
  DEsol:= dsolve({xd,yd,x(0)=x0,y(0)=y0}, numeric,
    events=[[y(t)-y1,halt],[x(t)-x1,halt],[x(t),halt]],
    output=procedurelist);
  tm:= floor(subs(DEsol(T),t));
  interface(warnlevel=w):
  seq(subs(DEsol(j), [x(t), y(t)]), j = 0 .. tm); 
  end proc:

absolutely fascinating, thanks guys for enlightening me.

Extracted from: http://www.thefreedictionary.com/MAP

map  (mp)

n.
1.
a. A representation, usually on a plane surface, of a region of the earth or heavens.
b. Something that suggests such a representation, as in clarity of representation.
2. Mathematics The correspondence of elements in one set to elements in the same set or another set.
3. Slang The human face.
4. Genetics A genetic map.

Thanks jakubi, this is very useful -- I've just got to use op before using map and I'm set!

From the Help pages:

The map commands apply fcn to the operands or elements of expr.

I must confess that I hadn't looked up "operand" at the time of my first read. It would indeed be very useful (for me, perhaps for other newbies?) if the Help page for map showed how to use op to get the operands, the way you taught me.

op and map are a good combo.

not so simple, my points are not ordered at this stage, so I must first produce them as a list of "same-time" points... must go back to the procedure and change the way the list is produced ... but it will have to wait a few days :-(

That's probably more than enough points. I just need to connect them now...

[[.499999998587336e-1, .130930537400000e-1], [.101446601249299925, .330816134345225180e-1], [.191325925024244392, .779718967480298314e-1], [.330961309760921196, .163968244283412307], [.530471813677961812, .291439804870238572], [.850401818544466170, .403866349329540353], [1.62380556341087767, .341012347433000906], [.499999998587336e-1, .128258485600000e-1], [.102152468328775364, .323979916886800307e-1], [.195045229279712934, .762171500460927520e-1], [.345880037659655748, .158977451819020510], [.586215632172467194, .273939511364954813], [1.05863639563009282, .338147039732239362], [2.36940918244569020, .186641295357803910], [.499999998587336e-1, .125586433800000e-1], [.102858232694636856, .317147263101554902e-1], [.198760898801755598, .744696425640464372e-1], [.360742490110908531, .154074907877767675], [.641272652984081093, .257449065633849172], [1.25881712068172958, .283927893667180131], [.499999998587336e-1, .122914382100000e-1], [.103563894354350330, .310318171409247022e-1], [.202472949673347308, .727293436522582216e-1], [.375549085392499316, .149259081481213584], [.695666515565993128, .241906615871317981], [1.45181089506622030, .239018340695969500], [.499999998587336e-1, .120242330300000e-1], [.104269453395302497, .303492639462301512e-1], [.206181388542350020, .709962262737185990e-1], [.390300536462559300, .144528403637870422], [.749418860731822734, .227254613535316618], [1.63835600476125909, .201685289921014921], [.499999998587336e-1, .117570278500000e-1], [.104974909826225134, .296670665679688480e-1], [.209886226171258598, .692702609403622049e-1], [.404997263246624828, .139881423035256996], [.802550573846086634, .213439417047752905], [1.81908598616537831, .170547273713197889], [.499999998587336e-1, .114898226700000e-1], [.105680263682662742, .289852248225021710e-1], [.213587470792889006, .675514190743369548e-1], [.419639805472101612, .135316679877657386], [.855081771549861536, .200410848383218487], [1.99454968658536380, .144497079323883032], [.499999998587336e-1, .112226174900000e-1], [.106385515000323560, .283037385262854269e-1], [.217285130863828002, .658396722471921576e-1], [.434228641985748120, .130832751237734690], [.907031320942753406, .188121966997184920], [2.16522269636272568, .122642100990736011], [.499999998587336e-1, .109554123100000e-1], [.107090663814759624, .276226074959481788e-1], [.220979216353058089, .641349923103087388e-1], [.448764281238262118, .126428235702498476], [.958417482289478760, .176528928967537440], [2.33152079524982669, .104259271202889830], [.499999998587336e-1, .106882071400000e-1], [.107795710134558492, .269418315738621344e-1], [.224669747205165720, .624373491773723144e-1], [.463247223868672842, .122101759607494850], [1.00925774118802725, .165590758168678410], [2.49380858295801966, .887600996806442306e-1], [.499999998587336e-1, .104210019600000e-1], [.108500654046329774, .262614105263603258e-1], [.228356721263698882, .607467179669908890e-1], [.477677953070971050, .117851976436573648], [1.05956881176420436, .155269085873101814], [2.65240702323916544, .756634658804771210e-1], [.499999998587336e-1, .101537967800000e-1], [.109205495555673104, .255813441967420730e-1], [.232040147246064393, .590630717747240089e-1], [.492056946236115844, .113677568527704859], [1.10936665917936383, .145527969229518216], [2.80760021883666422, .645744189106853134e-1], [.499999998587336e-1, .988659160100000e-2], [.109910234689169744, .249016324060569692e-1], [.235720034167827470, .573863835056119126e-1], [.506384673659100448, .109577240944517080], [1.15866647080020968, .136333667824451998], [2.95964051720770004, .551675913502871415e-1], [.499999998587336e-1, .961938642200000e-2], [.110614869415599837, .242222771477522414e-1], [.239396385499847514, .557166300434471310e-1], [.520661539741391954, .105549723774836484], [1.20748283336580631, .127654635531026072], [.499999998587336e-1, .935218124400000e-2], [.111319400347490605, .235432788128691860e-1], [.243069217275946714, .540537798215622450e-1], [.534888015152290564, .101593764363340888], [1.25582988475685654, .119461324632128536], [.499999998587336e-1, .908497606600000e-2], [.112023831095841506, .228646330861957682e-1], [.246738518397621510, .523978083341057818e-1], [.549064638504355606, .977081246189223374e-1], [1.30372124520234411, .111725956297322196], [.499999998587336e-1, .881777088700000e-2], [.112728161404743968, .221863402598996423e-1], [.250404299200595593, .507486870681756464e-1], [.563191849127740563, .938916071713974538e-1], [1.35116968383581782, .104422400518108013], [.499999998587336e-1, .855056570900000e-2], [.113432390972420999, .215084005227940030e-1], [.254066576845225600, .491063855988636416e-1], [.577270061305966032, .901430301704320147e-1], [1.39818758889913530, .975262036642334518e-1], [.499999998587336e-1, .828336053000000e-2], [.114136519495654038, .208308139624800404e-1], [.257725364026081926, .474708758869952994e-1], [.591299672837248380, .864612280468377848e-1], [1.44478690201798021, .910144123566840879e-1], [.499999998587336e-1, .801615535200000e-2], [.114840546663912274, .201535806054605436e-1], [.261380667881235762, .458421322065274418e-1], [.605281126444240592, .828450649737408896e-1], [1.49097908098614162, .848654412127634318e-1], [.499999998587336e-1, .774895017400000e-2], [.115544472186334346, .194767004157351612e-1], [.265032491491457634, .442201301811136691e-1], [.619214866153876774, .792934269247665274e-1], [1.53677509639671994, .790589812603363917e-1], [.499999998587336e-1, .748174499500000e-2], [.116248295788351830, .188001733150486260e-1], [.268680843226082876, .426048435337965312e-1], [.633101321059726052, .758052185209393548e-1], [1.58218546274488392, .735759196950664108e-1], [.499999998587336e-1, .721453981700000e-2], [.116952017485549980, .181239991140596489e-1], [.272325730376977937, .409962456559277364e-1], [.646940902758355696, .723793622223258965e-1], [1.62722033037831793, .683982931611465811e-1], [.499999998587336e-1, .694733463800000e-2], [.117655638430754494, .174481772571398048e-1], [.275967153369639172, .393943120098736860e-1], [.660734028453743405, .690148040638491472e-1], [1.67188948326542630, .635092029880381382e-1], [.499999998587336e-1, .668012946000000e-2], [.118359158146191314, .167727076943261916e-1], [.279605117680785886, .377990168281632928e-1], [.674481088855996003, .657105022055162192e-1], [1.71620234130260751, .588927417650840780e-1], [.499999998587336e-1, .641292428200000e-2], [.119062576153022458, .160975903635034480e-1], [.283239631160839000, .362103339248057987e-1], [.688182470259106948, .624654334264361580e-1], [1.76016797226881750, .545339285971443294e-1], [.499999998587336e-1, .614571910300000e-2], [.119765892173647302, .154228251426201998e-1], [.286870702501155262, .346282371229135744e-1], [.701838566126274488, .592785964139675368e-1], [1.80379510539131971, .504186504599242261e-1], [.499999998587336e-1, .587851392500000e-2], [.120469106053771674, .147484118832339942e-1], [.290498340442399083, .330527004431473703e-1], [.715449770164134912, .561490093150929376e-1], [1.84709215188067954, .465336059738116620e-1], [.499999998587336e-1, .561130874600000e-2], [.121172217735213916, .140743504081692547e-1], [.294122553518205931, .314836981154610272e-1], [.729016473087046312, .530757081992815002e-1], [1.89006721302666824, .428662532606616798e-1], [.499999998587336e-1, .534410356800000e-2], [.121875227204760378, .134006405407691050e-1], [.297743349808588076, .299212046244542556e-1], [.742539060422710229, .500577462843099161e-1], [1.93272808981668986, .394047690706830420e-1], [.499999998587336e-1, .507689839000000e-2], [.122578134492540542, .127272820925508554e-1], [.301360737008133151, .283651946436306903e-1], [.756017912096186406, .470941933184971309e-1], [1.97508231393052404, .361380024775774453e-1], [.499999998587336e-1, .480969321100000e-2], [.123280939650696406, .120542748738441275e-1], [.304974722413387134, .268156430218992118e-1], [.769453402062613810, .441841352623377690e-1], [2.01713715651422199, .330554334439623065e-1], [.499999998587336e-1, .454248803300000e-2], [.123983642736453084, .113816187030423930e-1], [.308585312934561096, .252725247706432899e-1], [.782845898236227966, .413266740630433422e-1], [2.05889963730933622, .301471343237459284e-1], [.499999998587336e-1, .427528285400000e-2], [.124686243824454770, .107093133898536042e-1], [.312192515249936742, .237358149972147700e-1], [.796195763062882422, .385209273680729228e-1], [2.10037653557899695, .274037338607844780e-1], [.499999998587336e-1, .400807767600000e-2], [.125388742981662138, .100373587558229768e-1], [.315796335800507810, .222054889256391788e-1], [.809503357696966796, .357660297152447016e-1], [2.14157439882201528, .248163837908643194e-1], [.499999998587336e-1, .374087249800000e-2], [.126091140283073806, .936575461680991262e-2], [.319396783809067164, .206815215283037250e-1], [.822769039802358826, .330611311976427777e-1], [2.18249955427380504, .223767278012796042e-1], [.499999998587336e-1, .347366731900000e-2], [.126793435802096898, .869450079046822470e-2], [.322993866173482136, .191638880840298426e-1], [.835993154078734424, .304053944252542612e-1], [2.22315811347281178, .200768708091131135e-1], [.499999998587336e-1, .320646214100000e-2], [.127495629601577898, .802359710361346020e-2], [.326587588203946732, .176525641300100296e-1], [.849176043428853666, .277979977185356560e-1], [2.26355598631090204, .179093532424000196e-1], [.499999998587336e-1, .293925696200000e-2], [.128197721751563158, .735304337443601700e-2], [.330177955919744026, .161475252045817572e-1], [.862318048755732036, .252381344610808772e-1], [2.30369888821458035, .158671248790522336e-1], [.499999998587336e-1, .267205178400000e-2], [.128899712307947500, .668283943236856488e-2], [.333764975734634872, .146487469264171850e-1], [.875419507986586854, .227250126391476230e-1], [2.34359233865727922, .139435208196039950e-1], [.499999998587336e-1, .240484660600000e-2], [.129601601330751768, .601298510030039840e-2], [.337348654401867454, .131562049766918935e-1], [.888480756027178576, .202578543302815648e-1], [2.38324169154382926, .121322390399994078e-1], [.499999998587336e-1, .213764142700000e-2], [.130303388876263776, .534348020190830806e-2], [.340928998866680266, .116698751294272360e-1], [.901502124358774193, .178358953562358854e-1], [2.42265212949120468, .104273184233898316e-1], [.499999998587336e-1, .187043624900000e-2], [.131005074989278519, .467432456898122032e-2], [.344506016149503048, .1

that's the thing Joe, I haven't learned how to use map yet.

> what do you expect map(f, x/y) to return? 

I expect f(x)/f(y), but wait:

map(f, x/y);
                             f(x) f(1/y)

> How about map(f, 3*x/4)?

After a cursory glance at the help page, I would perhaps have expected f(3)*f(x)/f(4) or f(3)*f(x/4), but after what you said I would be more likely to expect f(3*x)/f(4) though I can't exclude the thought that it might be f(3/4)*f(x) ... let's see:

map(f, 3*x/4);
                             f(3/4) f(x)

To be honest, it would be an exageration to say that I saw the last one coming, not with so many potential witnesses...

Don't get me wrong, all this is saying nothing about the userfriendliness or usefulness of map, rather it says a great deal about my inability to read the help pages properly...

 

quite an insight into the difference between about and getassumptions! jakubi, you do not leave a stone unturned!

Recently (a few hours ago), I learned from Robert Israel how to make a fancy phase diagram (fancy is my adjective here).

Here's a description of the project: Write a procedure that throws a salvo of arrows in a neighborhood of a given point of the phase diagram. The main procedure was written by Robert following my lame attempts. In its first incarnation, the procedure takes a list of points x0 and y0, solves the solution of a system of two ODEs with initial values [x0, y0] and then plots arrows at dates t=0,1,2,3, etc.

I would like to extend the procedure in several directions, 1) construct initial values in a neighborhood of a given point [x0,y0] in a more systematic way, and 2) connect these points for each value of t, i.e. connect the current positions of all the trajectories at sampled moments of time. That is, I want to construct iso-chrone lines. Funny, I haven't found references to isochrones... but I haven't searched yet, let's see what google will throw up.

I lamely generalized the procedure to take the two ODEs of the system as well as the maximal time interval over which to sample. That's a low-hanging fruit indeed.

 

getarrows:= proc(x0, y0, xdot, ydot, T)
  local DEsol, tm,j;
  interface(warnlevel=0):
  DEsol:= dsolve({xdot,ydot,x(0)=x0,y(0)=y0}, numeric,
    events=[[y(t)-2,halt],[x(t)-2,halt],[x(t),halt]],
    output=procedurelist);
  tm:= floor(subs(DEsol(T),t));
  seq(subs(DEsol(j), [x(t), y(t)]), j = 1 .. tm) 
  end proc:

My contribution is to have added the xdot, ydot, and T arguments. Yeah.

The ODEs are:

xdot := diff(x(t),t) = x(t)-y(t);
ydot := diff(y(t),t) = y(t)*(1-x(t));

As an economist I'm mostly interested in saddle-point "stable" system (what everyone else would call "unstable"). So I want to throw a salvo of arrows from a neighborhood of the stable manifold, so that they will diverge off the manifold but not too fast.

The first incarnation of the procedure requires you to feed in the x0 and y0. Here I'm going to calculate the x0 by solving the system backwards, starting from very close to the saddle point.

T := 10:
DEsol:= dsolve({xdot,ydot,x(0)=0.9999,y(0)=0.9999},
  numeric,output=procedurelist):
x0 := rhs(DEsol(-20)[2]);
y0 := rhs(DEsol(-20)[3]);

                     x0 := 0.0338099509514997732


                     y0 := 0.00808750706571607220

y0 := [
  seq(y0-0.001*i,i=1..5),
  seq(y0+0.001*i,i=0..5),
  seq(y0-0.0001*i,i=1..5),
  seq(y0+0.0001*i,i=0..5),
  seq(y0-0.00001*i,i=1..5),
  seq(y0+0.00001*i,i=0..5),
  seq(y0-0.0000001*i,i=1..5),
  seq(y0+0.0000001*i,i=0..5)
]: 

init:= map2(getarrows, x0, y0, xdot, ydot, T):

DEtools[DEplot](
 {xdot,ydot}, 
 {x(t),y(t)}, 
 t=-20..0, 
 [[x(0)=0.9999,y(0)=0.9999],[x(0)=1.0001,y(0)=1.0001]], 
 scene=[x(t),y(t)], 
 x=0..2, y=0..2, 
 arrows=smalltwo, 
 dirfield=init, 
 size=magnitude, 
 color=magnitude,
 linecolor=black,
 thickness=2,
 numpoints=1000
);

 

That's kind of good enough for now, for my purpose. My time IS limited.

So the next thing is to connect the ends of the arrows. Shouldn't be too hard... for the average Maple user that is!

I can't get enough of the Maple calculator, I don't otherwise use a hand-held calculator. Most of my students use the calculator on their mobile phones (I even allow it during some exams) -- some phones even have scientific functions in their calculators. To the extent that most phones will soon have all the functions of the best scientific calculators, in this sense the hand-held scientific calculator is on its way to extinction, I think.

First 69 70 71 72 73 74 75 Last Page 71 of 93