tomleslie

13876 Reputation

20 Badges

15 years, 181 days

MaplePrimes Activity


These are replies submitted by tomleslie

@mmcdara 

I didn't adjust any "tickmarks" - which would be done with the 'tickmarks' option in one of the plot commands.

I decided that that there was no combination of 'axis' and 'tickmarks' plot options which would give the layout you wanted. Notice that the final display command in my earlier post uses the option axes=none, because, I don't want any 'axes' to be plotted

Instead of using any kind of built-in 'axis' options, I created a couple of lines (pl1 and pl2) and some text (pl3 and pl4). The combination of all of these looks like a pair of 'axes', with some 'tickmarks'.

The advantage(?) of doing it this way is that I can specify exactly where the lines/text occur and how they appear, because they aren't 'axes', just a couple of lines and some text

@schapplm 

using  " manual derivation", merely using Maple for your "symbolic computation" from within Matlab.

Read the help page at ?Maple Toolbox Installation

The Maple symbolic toolbox which then becomes available from within Matlab is not "everything" which is available in "stand-alone" Maple. However, as well as basic algebra, you can do symbolic differentiation, symbolic integration, solve ODEs with dsolve(), symbolic Fourier and Laplace transforms, etc, etc. So you can do a lot from within the Matlab environment.

You can only do this if the the Matlab-Maple link was correctly, which is normally done during the Maple installation process. A simple way to check is to start Matlab, access its help, and check the contents of the left-hand pane, which should have Maple Toolbox listed under the Supplemental Software.

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

In the spirit of completeness, I should point out that using the with(Matlab) package in Maple, it is als possible to use the Matlab engine from within Maple, although I rarely/ever work this way around

@Muhammad Usman 

f:=exp(eta*k2)*x^2*y^3:
algsubs( exp(eta*k2)=Z^k2, f);

 

@nm 

The help for the Mathematica command FunctionDomain[], is

FunctionDomain[ f, x ,dom]
considers f to be a function with arguments and values in the domain dom

with the clarification later on the help page

If dom is Reals then all variables, parameters, constants, and function values are restricted to be real.

So for your example sqrt(x)*log(y) consider the argument values, x=-4, y=1, from which we can infer

  1. x is real
  2. y is real
  3. f=sqrt(-4)*log(1)=2*I*0=0 is real

Thus the answer given by the Mathematica command

is wrong, since it insists on x>=0.

Now (possibly) the help for Mathematica command, should state that the results of all intermediate calculations/simplifications are also required to be real???

In the spirit of a fair comparison, the closest one can probably get to this Mathematica command in Maple is to use the RealDomain() package, which would give the attached

restart;
with(RealDomain):
f:=sqrt(x)*ln(y);
solve(f, {x,y});
g:=x*ln(y);
solve(g, {x,y});

x^(1/2)*ln(y)

 

{x = x, y = 1}, {x = 0, y = y}

 

x*ln(y)

 

{x = x, y = 1}, {x = 0, y = y}

(1)

 

Download isReal.mw

I don't have a problem with the first solution returned by either of the above examples, since ln(1)=0, and sqrt(x) is defined for any value of 'x', so 0*sqrt(x)=0 always.

However I do have a problem with the second solution given in both examples, where 'y' is arbitrary. If 'y' is negative, then ln(y) is undefined and 0*undefined really ought to return undefined. Thus I think that the second solution in both cases should be {x=0, y>0}, so that ln(y) is never undefined.

So (rather depressingly) both Maple and Mathematica *seem* to return (different) incorrect answers, for the same trivial problem:-(

 

@farah adanan 

Attached is the solution to the problem posted in your latest worksheet. I tidied things up a little.

restart

ODEs := {(1+(4/3)*N[r])*(diff(theta(eta), eta, eta))+Pr*(f(eta)*(diff(theta(eta), eta))+Nb*(diff(phi(eta), eta))*(diff(theta(eta), eta))+Nt*(diff(theta(eta), eta))*(diff(theta(eta), eta))) = 0, diff(phi(eta), eta, eta)+Pr*Le*f(eta)*(diff(phi(eta), eta))+Nt*(diff(theta(eta), eta, eta))/Nb = 0, (1-n)*(diff(f(eta), eta, eta, eta))+f(eta)*(diff(f(eta), eta, eta))-(diff(f(eta), eta))^2-M*(diff(f(eta), eta))+n*W[e]*(diff(f(eta), eta, eta, eta))*(diff(f(eta), eta, eta)) = 0}; ICs := {Nb*(D(phi))(0)+Nt*(D(theta))(0) = 0, f(0) = 0, phi(8) = 0, theta(8) = 0, (D(f))(0) = 1+gamma*((`@`(D, D))(f))(0)+delta*((`@`(`@`(D, D), D))(f))(0), (D(f))(8) = 0, (D(theta))(0) = Bi*(theta(0)-1)}; params := [n = .1, W[e] = 1, M = .2, gamma = 1, delta = -1, N[r] = .8, Pr = .7, Nb = .5, Nt = .5, Bi = 2, Le = 5]

{(1+(4/3)*N[r])*(diff(diff(theta(eta), eta), eta))+Pr*(f(eta)*(diff(theta(eta), eta))+Nb*(diff(phi(eta), eta))*(diff(theta(eta), eta))+Nt*(diff(theta(eta), eta))^2) = 0, diff(diff(phi(eta), eta), eta)+Pr*Le*f(eta)*(diff(phi(eta), eta))+Nt*(diff(diff(theta(eta), eta), eta))/Nb = 0, (1-n)*(diff(diff(diff(f(eta), eta), eta), eta))+f(eta)*(diff(diff(f(eta), eta), eta))-(diff(f(eta), eta))^2-M*(diff(f(eta), eta))+n*W[e]*(diff(diff(diff(f(eta), eta), eta), eta))*(diff(diff(f(eta), eta), eta)) = 0}

 

{Nb*(D(phi))(0)+Nt*(D(theta))(0) = 0, f(0) = 0, phi(8) = 0, theta(8) = 0, (D(f))(0) = 1+gamma*((D@@2)(f))(0)+delta*((D@@3)(f))(0), (D(f))(8) = 0, (D(theta))(0) = Bi*(theta(0)-1)}

(1)

sol := dsolve(eval(`union`(ODEs, ICs), params), numeric); plots:-odeplot(sol, [[eta, f(eta)], [eta, theta(eta)]], eta = 0 .. 8)

proc (x_bvp) local res, data, solnproc, _ndsol, outpoint, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; _EnvDSNumericSaveDigits := Digits; Digits := 15; if _EnvInFsolve = true then outpoint := evalf[_EnvDSNumericSaveDigits](x_bvp) else outpoint := evalf(x_bvp) end if; data := Array(1..4, {(1) = proc (outpoint) local X, Y, YP, yout, errproc, L, V, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; X := Vector(17, {(1) = .0, (2) = .4925059274447906, (3) = .9864478294835473, (4) = 1.4827366169910285, (5) = 1.9813020385169982, (6) = 2.4815118499490483, (7) = 2.9827397496785797, (8) = 3.4845392947178437, (9) = 3.9866433783336213, (10) = 4.488920269710354, (11) = 4.991309796581576, (12) = 5.493773514828711, (13) = 5.996276226566114, (14) = 6.498793347594503, (15) = 7.001340601727559, (16) = 7.503735082536752, (17) = 8.0}, datatype = float[8], order = C_order); Y := Matrix(17, 7, {(1, 1) = .0, (1, 2) = .5230063561602272, (1, 3) = -.4769936438397729, (1, 4) = -.13796237414967114, (1, 5) = .1805652727565984, (1, 6) = .9097173636217009, (1, 7) = -.1805652727565984, (2, 1) = .20761530036187237, (2, 2) = .33434228422120843, (2, 3) = -.3027114371630355, (2, 4) = -0.5512433704692855e-1, (2, 5) = .1461132714674293, (2, 6) = .8213346053931457, (2, 7) = -.17740360719652437, (3, 1) = .34082070039705986, (3, 2) = .2140246691423277, (3, 3) = -.19285994552853616, (3, 4) = 0.17879385586096193e-2, (3, 5) = 0.844406705560101e-1, (3, 6) = .7353870262197288, (3, 7) = -.17014337951350703, (4, 1) = .42648440709363866, (4, 2) = .13694705868264315, (4, 3) = -.12304209120233393, (4, 4) = 0.308608697049114e-1, (4, 5) = 0.36404522731167406e-1, (4, 6) = .6531927994441571, (4, 7) = -.1608725848770333, (5, 1) = .48152522997006614, (5, 2) = 0.87536139899834e-1, (5, 3) = -0.7852345141866558e-1, (5, 4) = 0.4150472119569088e-1, (5, 5) = 0.9406861632688978e-2, (5, 6) = .5755128585468426, (5, 7) = -.15064901593544763, (6, 1) = .5168079165008237, (6, 2) = 0.5589528000534416e-1, (6, 3) = -0.50119522100873004e-1, (6, 4) = 0.4264437542086628e-1, (6, 5) = -0.308524028263688e-2, (6, 6) = .5027945710539881, (6, 7) = -.1400893545956027, (7, 1) = .5393737585600935, (7, 2) = 0.35655615900416895e-1, (7, 3) = -0.3199843791956728e-1, (7, 4) = 0.39652597844489074e-1, (7, 5) = -0.8022281871943374e-2, (7, 6) = .43521717319207986, (7, 7) = -.1295976024773356, (8, 1) = .5537774765735471, (8, 2) = 0.2271616311390297e-1, (8, 3) = -0.2043854475838024e-1, (8, 4) = 0.3515238728449494e-1, (8, 5) = -0.9562695429290346e-2, (8, 6) = .3727527245474802, (8, 7) = -.11943652278937752, (9, 1) = .5629521054311722, (9, 2) = 0.14443603800916117e-1, (9, 3) = -0.13064196800994217e-1, (9, 4) = 0.302799595778473e-1, (9, 5) = -0.9707051811390782e-2, (9, 6) = .31523428812056425, (9, 7) = -.10976402710806184, (10, 1) = .5687791667496256, (10, 2) = 0.9151470903076666e-2, (10, 3) = -0.8359883182468275e-2, (10, 4) = 0.25489667925360098e-1, (10, 5) = -0.9316860877180264e-2, (10, 6) = .2624128944092391, (10, 7) = -.10066353612038628, (11, 1) = .5724623592757002, (11, 2) = 0.5761625251924899e-2, (11, 3) = -0.5359312458509848e-2, (11, 4) = 0.2094955879167705e-1, (11, 5) = -0.8741677517135345e-2, (11, 6) = .2139999811144098, (11, 7) = -0.9216940005038136e-1, (12, 1) = .5747705015677156, (12, 2) = 0.35853334527218227e-2, (12, 3) = -0.34463777225590482e-2, (12, 4) = 0.1671311151520795e-1, (12, 5) = -0.811907699190564e-2, (12, 6) = .1696942767616943, (12, 7) = -0.8428552880330699e-1, (13, 1) = .5761941524536748, (13, 2) = 0.21825968381674094e-2, (13, 3) = -0.222809862381396e-2, (13, 4) = 0.12789014251581667e-1, (13, 5) = -0.7502418546034026e-2, (13, 6) = .12919617173953826, (13, 7) = -0.7699764125429386e-1, (14, 1) = .5770459589653595, (14, 2) = 0.1272200260168142e-2, (14, 3) = -0.14537182753043478e-2, (14, 4) = 0.9168560470302532e-2, (14, 5) = -0.6912101227525887e-2, (14, 6) = 0.9221449608941013e-1, (14, 7) = -0.7028085859014069e-1, (15, 1) = .5775247732261395, (15, 2) = 0.6742937321433107e-3, (15, 3) = -0.9632059904576869e-3, (15, 4) = 0.5836240462073442e-2, (15, 5) = -0.6355526339784237e-2, (15, 6) = 0.5846901856031407e-1, (15, 7) = -0.6410423276105486e-1, (16, 1) = .5777564956413378, (16, 2) = 0.27393042555859696e-3, (16, 3) = -0.6545917342854846e-3, (16, 4) = 0.27755089916536298e-2, (16, 5) = -0.5835083347156419e-2, (16, 6) = 0.27707635799608995e-1, (16, 7) = -0.5843650428370853e-1, (17, 1) = .5778205780449803, (17, 2) = .0, (17, 3) = -0.4644640273272487e-3, (17, 4) = .0, (17, 5) = -0.53562999550771494e-2, (17, 6) = .0, (17, 7) = -0.53302381848732455e-1}, datatype = float[8], order = C_order); YP := Matrix(17, 7, {(1, 1) = .5230063561602272, (1, 2) = -.4769936438397729, (1, 3) = .44366612438665537, (1, 4) = .1805652727565984, (1, 5) = .0, (1, 6) = -.1805652727565984, (1, 7) = .0, (2, 1) = .33434228422120843, (2, 2) = -.3027114371630355, (2, 3) = .2776736037527766, (2, 4) = .1461132714674293, (2, 5) = -.11770889007388582, (2, 6) = -.17740360719652437, (2, 7) = 0.11535162474904371e-1, (3, 1) = .2140246691423277, (3, 2) = -.19285994552853616, (3, 3) = .175246622159894, (3, 4) = 0.844406705560101e-1, (3, 5) = -.11789868744852035, (3, 6) = -.17014337951350703, (3, 7) = 0.17171737765381723e-1, (4, 1) = .13694705868264315, (4, 2) = -.12304209120233393, (4, 3) = .11109598912776887, (4, 4) = 0.36404522731167406e-1, (4, 5) = -0.7418854016888395e-1, (4, 6) = -.1608725848770333, (4, 7) = 0.19847675645033067e-1, (5, 1) = 0.87536139899834e-1, (5, 2) = -0.7852345141866558e-1, (5, 3) = 0.7059462234529035e-1, (5, 4) = 0.9406861632688978e-2, (5, 5) = -0.36820654421883474e-1, (5, 6) = -.15064901593544763, (5, 7) = 0.20966910183463437e-1, (6, 1) = 0.5589528000534416e-1, (6, 2) = -0.50119522100873004e-1, (6, 3) = 0.44922950893252114e-1, (6, 4) = -0.308524028263688e-2, (6, 5) = -0.1554488112565766e-1, (6, 6) = -.1400893545956027, (6, 7) = 0.21125549233966583e-1, (7, 1) = 0.35655615900416895e-1, (7, 2) = -0.3199843791956728e-1, (7, 3) = 0.28614584505153893e-1, (7, 4) = -0.8022281871943374e-2, (7, 5) = -0.5511322320954588e-2, (7, 6) = -.1295976024773356, (7, 7) = 0.20655851460199687e-1, (8, 1) = 0.2271616311390297e-1, (8, 2) = -0.2043854475838024e-1, (8, 3) = 0.18238822143111736e-1, (8, 4) = -0.9562695429290346e-2, (8, 5) = -0.12587779138762724e-2, (8, 6) = -.11943652278937752, (8, 7) = 0.19793396618134576e-1, (9, 1) = 0.14443603800916117e-1, (9, 2) = -0.13064196800994217e-1, (9, 3) = 0.11630054753598528e-1, (9, 4) = -0.9707051811390782e-2, (9, 5) = 0.41746335337783727e-3, (9, 6) = -.10976402710806184, (9, 7) = 0.18708655038253866e-1, (10, 1) = 0.9151470903076666e-2, (10, 2) = -0.8359883182468275e-2, (10, 3) = 0.7416857107615308e-2, (10, 4) = -0.9316860877180264e-2, (10, 5) = 0.10293256460391816e-2, (10, 6) = -.10066353612038628, (10, 7) = 0.17518001636517535e-1, (11, 1) = 0.5761625251924899e-2, (11, 2) = -0.5359312458509848e-2, (11, 3) = 0.47289560281316995e-2, (11, 4) = -0.8741677517135345e-2, (11, 5) = 0.12186271799617572e-2, (11, 6) = -0.9216940005038136e-1, (11, 7) = 0.162963574942415e-1, (12, 1) = 0.35853334527218227e-2, (12, 2) = -0.34463777225590482e-2, (12, 3) = 0.3013151115985244e-2, (12, 4) = -0.811907699190564e-2, (12, 5) = 0.12433845090519674e-2, (12, 6) = -0.8428552880330699e-1, (12, 7) = 0.15089736333113795e-1, (13, 1) = 0.21825968381674094e-2, (13, 2) = -0.222809862381396e-2, (13, 3) = 0.19172529751051975e-2, (13, 4) = -0.7502418546034026e-2, (13, 5) = 0.12047933241445558e-2, (13, 6) = -0.7699764125429386e-1, (13, 7) = 0.13925180610052263e-1, (14, 1) = 0.1272200260168142e-2, (14, 2) = -0.14537182753043478e-2, (14, 3) = 0.12167752073440573e-2, (14, 4) = -0.6912101227525887e-2, (14, 5) = 0.11424143897638267e-2, (14, 6) = -0.7028085859014069e-1, (14, 7) = 0.12817685894797773e-1, (15, 1) = 0.6742937321433107e-3, (15, 2) = -0.9632059904576869e-3, (15, 3) = 0.7685141815792771e-3, (15, 4) = -0.6355526339784237e-2, (15, 5) = 0.10719593274732785e-2, (15, 6) = -0.6410423276105486e-1, (15, 7) = 0.11774699350934987e-1, (16, 1) = 0.27393042555859696e-3, (16, 2) = -0.6545917342854846e-3, (16, 3) = 0.4812080543864675e-3, (16, 4) = -0.5835083347156419e-2, (16, 5) = 0.9999248311741635e-3, (16, 6) = -0.5843650428370853e-1, (16, 7) = 0.10799475741324609e-1, (17, 1) = .0, (17, 2) = -0.4644640273272487e-3, (17, 3) = 0.29821191513560054e-3, (17, 4) = -0.53562999550771494e-2, (17, 5) = 0.9299525232142666e-3, (17, 6) = -0.53302381848732455e-1, (17, 7) = 0.9902478653573165e-2}, datatype = float[8], order = C_order); errproc := proc (x_bvp) local outpoint, X, Y, yout, L, V, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; Digits := 15; outpoint := evalf(x_bvp); X := Vector(17, {(1) = .0, (2) = .4925059274447906, (3) = .9864478294835473, (4) = 1.4827366169910285, (5) = 1.9813020385169982, (6) = 2.4815118499490483, (7) = 2.9827397496785797, (8) = 3.4845392947178437, (9) = 3.9866433783336213, (10) = 4.488920269710354, (11) = 4.991309796581576, (12) = 5.493773514828711, (13) = 5.996276226566114, (14) = 6.498793347594503, (15) = 7.001340601727559, (16) = 7.503735082536752, (17) = 8.0}, datatype = float[8], order = C_order); Y := Matrix(17, 7, {(1, 1) = .0, (1, 2) = -0.5862517873626374e-12, (1, 3) = -0.5857245537544939e-12, (1, 4) = -0.3446086864038791e-8, (1, 5) = 0.9028180464072134e-10, (1, 6) = -0.4514079999570232e-10, (1, 7) = -0.9028180464072134e-10, (2, 1) = 0.2725558273541703e-9, (2, 2) = -0.25935300300244323e-9, (2, 3) = 0.24096137598667663e-9, (2, 4) = -0.20739847849506686e-9, (2, 5) = 0.43450725786509314e-9, (2, 6) = -0.7465259841560272e-10, (2, 7) = -0.9626744568281825e-11, (3, 1) = 0.21543934846365037e-9, (3, 2) = -0.1996593817427614e-9, (3, 3) = 0.1794559082272104e-9, (3, 4) = 0.42819486319291743e-10, (3, 5) = 0.21263423543073033e-9, (3, 6) = -0.4334698986573822e-10, (3, 7) = -0.43005329311396525e-11, (4, 1) = 0.12274105011592464e-9, (4, 2) = -0.11274605279189733e-9, (4, 3) = 0.9885174663284775e-10, (4, 4) = -0.10414485859542835e-8, (4, 5) = 0.17785172194616727e-8, (4, 6) = -0.23413349783131685e-10, (4, 7) = -0.2835096231266572e-10, (5, 1) = 0.5489638623609616e-10, (5, 2) = -0.5153855366742272e-10, (5, 3) = 0.4415392165886803e-10, (5, 4) = -0.20735740961705445e-9, (5, 5) = 0.4054987521072646e-9, (5, 6) = -0.4113770388579659e-10, (5, 7) = 0.33738094032348794e-11, (6, 1) = 0.15344476258688495e-10, (6, 2) = -0.16742614873086095e-10, (6, 3) = 0.137551590353477e-10, (6, 4) = 0.35204650694725614e-9, (6, 5) = -0.6530137477752568e-9, (6, 6) = -0.4661971416678089e-10, (6, 7) = 0.20664329272266118e-10, (7, 1) = -0.41276758098481495e-11, (7, 2) = 0.3173313162199449e-13, (7, 3) = -0.62584885419393e-12, (7, 4) = 0.18405292366966559e-9, (7, 5) = -0.36256389451203687e-9, (7, 6) = -0.391983154085738e-10, (7, 7) = 0.15934696543569464e-10, (8, 1) = -0.11716784114178734e-10, (8, 2) = 0.6387570626621784e-11, (8, 3) = -0.5915827010996332e-11, (8, 4) = -0.24237795960455205e-10, (8, 5) = 0.4086235915977838e-10, (8, 6) = -0.3143411115607115e-10, (8, 7) = 0.10106078539170667e-10, (9, 1) = -0.13183955263121608e-10, (9, 2) = 0.7477297490769996e-11, (9, 3) = -0.6670117086523094e-11, (9, 4) = -0.7110770080709512e-10, (9, 5) = 0.13689376572720004e-9, (9, 6) = -0.2604465368540329e-10, (9, 7) = 0.8213627654174223e-11, (10, 1) = -0.12004760575338523e-10, (10, 2) = 0.6343722233557935e-11, (10, 3) = -0.55407938050920645e-11, (10, 4) = -0.44337653832023905e-10, (10, 5) = 0.8534198281034035e-10, (10, 6) = -0.218146750480583e-10, (10, 7) = 0.7930265668054529e-11, (11, 1) = -0.10036325113226002e-10, (11, 2) = 0.4591798661338396e-11, (11, 3) = -0.3914494008451461e-11, (11, 4) = -0.15878524909314793e-10, (11, 5) = 0.29030319423245467e-10, (11, 6) = -0.1792912274415256e-10, (11, 7) = 0.7664381118666103e-11, (12, 1) = -0.8141691642328481e-11, (12, 2) = 0.2958118285962089e-11, (12, 3) = -0.2421192336574445e-11, (12, 4) = -0.223304136339681e-11, (12, 5) = 0.21173570014693325e-11, (12, 6) = -0.14244326854506773e-10, (12, 7) = 0.71458314893632095e-11, (13, 1) = -0.6638671824772672e-11, (13, 2) = 0.17036641159358978e-11, (13, 3) = -0.12786587102170382e-11, (13, 4) = 0.14823818775752453e-11, (13, 5) = -0.4826240159312385e-11, (13, 6) = -0.10813584676762523e-10, (13, 7) = 0.6510737869870992e-11, (14, 1) = -0.5569363344878998e-11, (14, 2) = 0.8565962942152084e-12, (14, 3) = -0.5039284458191517e-12, (14, 4) = 0.1418220677424475e-11, (14, 5) = -0.41597166637601015e-11, (14, 6) = -0.7678677352263885e-11, (14, 7) = 0.5880850458264125e-11, (15, 1) = -0.4866568917005325e-11, (15, 2) = 0.3496746530840654e-12, (15, 3) = -0.3273903832728354e-13, (15, 4) = 0.6637411346194867e-12, (15, 5) = -0.21378991266742934e-11, (15, 6) = -0.4841069473747855e-11, (15, 7) = 0.5303987352729337e-11, (16, 1) = -0.4428395508736312e-11, (16, 2) = 0.9138332822974048e-13, (16, 3) = 0.2188180767861246e-12, (16, 4) = 0.16551043616582943e-12, (16, 5) = -0.6803601365335944e-12, (16, 6) = -0.22813966451008524e-11, (16, 7) = 0.4787537234726947e-11, (17, 1) = -0.4166281284305807e-11, (17, 2) = .0, (17, 3) = 0.3246668662594375e-12, (17, 4) = .0, (17, 5) = 0.5655490513123579e-13, (17, 6) = .0, (17, 7) = 0.4330904423772082e-11}, datatype = float[8], order = C_order); if not type(outpoint, 'numeric') then if outpoint = "start" or outpoint = "left" then return X[1] elif outpoint = "right" then return X[17] elif outpoint = "order" then return 8 elif outpoint = "error" then return HFloat(3.446086864038791e-9) elif outpoint = "errorproc" then error "this is already the error procedure" elif outpoint = "rawdata" then return [7, 17, [f(eta), diff(f(eta), eta), diff(diff(f(eta), eta), eta), phi(eta), diff(phi(eta), eta), theta(eta), diff(theta(eta), eta)], X, Y] else return ('procname')(x_bvp) end if end if; if outpoint < X[1] or X[17] < outpoint then error "solution is only defined in the range %1..%2", X[1], X[17] end if; V := array([1 = 4, 2 = 0]); if Digits <= trunc(evalhf(Digits)) then L := Vector(4, 'datatype' = 'float'[8]); yout := Vector(7, 'datatype' = 'float'[8]); evalhf(`dsolve/numeric/lagrange`(17, 7, X, Y, outpoint, var(yout), var(L), var(V))) else L := Vector(4, 'datatype' = 'sfloat'); yout := Vector(7, 'datatype' = 'sfloat'); `dsolve/numeric/lagrange`(17, 7, X, Y, outpoint, yout, L, V) end if; [eta = outpoint, seq('[f(eta), diff(f(eta), eta), diff(diff(f(eta), eta), eta), phi(eta), diff(phi(eta), eta), theta(eta), diff(theta(eta), eta)]'[i] = yout[i], i = 1 .. 7)] end proc; if not type(outpoint, 'numeric') then if outpoint = "start" or outpoint = "left" then return X[1] elif outpoint = "method" then return "bvp" elif outpoint = "right" then return X[17] elif outpoint = "order" then return 8 elif outpoint = "error" then return HFloat(3.446086864038791e-9) elif outpoint = "errorproc" then return eval(errproc) elif outpoint = "rawdata" then return [7, 17, "depnames", X, Y, YP] else error "non-numeric value" end if end if; if outpoint < X[1] or X[17] < outpoint then error "solution is only defined in the range %1..%2", X[1], X[17] end if; if Digits <= trunc(evalhf(Digits)) and (_EnvInFsolve <> true or _EnvDSNumericSaveDigits <= trunc(evalhf(Digits))) then V := array( 1 .. 6, [( 1 ) = (7), ( 2 ) = (0), ( 3 ) = (false), ( 4 ) = (false), ( 5 ) = (false), ( 6 ) = (false)  ] ); L := Matrix(7, 2, {(1, 1) = .0, (1, 2) = .0, (2, 1) = .0, (2, 2) = .0, (3, 1) = .0, (3, 2) = .0, (4, 1) = .0, (4, 2) = .0, (5, 1) = .0, (5, 2) = .0, (6, 1) = .0, (6, 2) = .0, (7, 1) = .0, (7, 2) = .0}, datatype = float[8], order = C_order); yout := Vector(7, {(1) = .0, (2) = .0, (3) = .0, (4) = .0, (5) = .0, (6) = .0, (7) = .0}, datatype = float[8]); evalhf(`dsolve/numeric/hermite`(17, 7, X, Y, YP, outpoint, var(yout), var(L), var(V))) else if _EnvInFsolve = true then Digits := _EnvDSNumericSaveDigits end if; V := array( 1 .. 6, [( 1 ) = (7), ( 2 ) = (0), ( 3 ) = (false), ( 4 ) = (false), ( 5 ) = (false), ( 6 ) = (false)  ] ); L := Matrix(7, 2, {(1, 1) = 0., (1, 2) = 0., (2, 1) = 0., (2, 2) = 0., (3, 1) = 0., (3, 2) = 0., (4, 1) = 0., (4, 2) = 0., (5, 1) = 0., (5, 2) = 0., (6, 1) = 0., (6, 2) = 0., (7, 1) = 0., (7, 2) = 0.}, order = C_order); yout := Vector(7, {(1) = 0., (2) = 0., (3) = 0., (4) = 0., (5) = 0., (6) = 0., (7) = 0.}); `dsolve/numeric/hermite`(17, 7, X, Y, YP, outpoint, yout, L, V) end if; [outpoint, seq(yout[i], i = 1 .. 7)] end proc, (2) = Array(0..0, {}), (3) = [eta, f(eta), diff(f(eta), eta), diff(diff(f(eta), eta), eta), phi(eta), diff(phi(eta), eta), theta(eta), diff(theta(eta), eta)], (4) = 0}); solnproc := data[1]; if not type(outpoint, 'numeric') then if outpoint = "solnprocedure" then return eval(solnproc) elif member(outpoint, ["start", "left", "right", "errorproc", "rawdata", "order", "error"]) then return solnproc(x_bvp) elif outpoint = "sysvars" then return data[3] elif procname <> unknown then return ('procname')(x_bvp) else _ndsol := pointto(data[2][0]); return ('_ndsol')(x_bvp) end if end if; try res := solnproc(outpoint); [eta = res[1], seq('[f(eta), diff(f(eta), eta), diff(diff(f(eta), eta), eta), phi(eta), diff(phi(eta), eta), theta(eta), diff(theta(eta), eta)]'[i] = res[i+1], i = 1 .. 7)] catch: error  end try end proc

 

 

NULL

Download odeProb.mw

@Preben Alsholm 

OS issue?? I'm running 64-bit Win7, what are you running?

With this OS, the CUDA help page executes with no errors in

Maple 18
Maple 2015.2
Maple 2016.2
Maple 2017.3

as well as Maple 2018.1, which was the only Maple version I used for my earlier comments

If, I run the following commands, I get some information about my CUDA capabilities

CUDA:-ComputeLevel(id=0); # not sure what this means, except "bigger is better"
                               3.

CUDA:-HasDoubleSupport(id=0); # GPU supports double precision
                              true

CUDA:-Properties(); # A lot of info I don't really understand!
[TABLE(["Memory Pitch" = 2147483647, "Major" = 3,

  "Max Grid Size" = [2147483647, 65535, 65535],

  "Resisters Per Block" = 65536,

  "Max Threads Dimensions" = [1024, 1024, 64], "Minor" = 0,

  "Clock Rate" = 1058500, "Max Threads Per Block" = 1024,

  "ID" = 0, "Total Constant Memory" = 65536,

  "Total Global Memory" = 2147483648, "MultiProcessor Count" = 8,

  "Texture Alignment" = 512, "Warp Size" = 32,

  "Shared Memory Per Block" = 49152, "Name" = "GeForce GTX 680",

  "Kernel Exec Timeout Enabled" = true, "Device Overlap" = 1])]

 

Force the 'seed', before each call to Sample() - in which case the same sample set will be produced. However the moment you change the 'distribution parameter' which the Optimisation process will do, then a new set of samples will be generated. See the attached

 with(Statistics):
#
# Force the seed before each call to
# Sample() - the same samples will be
# generated
#
  p[1]:=1.0;
  randomize(5):
  Sample(Exponential(1/p[1]), 10);
  randomize(5):
  Sample(Exponential(1/p[1]), 10);
  randomize(5):
  Sample(Exponential(1/p[1]), 10);
#
# But change the distribution parameter
# and a different set of samples will be
# generated
#
 p[1]:=1.1;
 randomize(5):
 Sample(Exponential(1/p[1]), 10);
 randomize(5):
 Sample(Exponential(1/p[1]), 10);
 randomize(5):
 Sample(Exponential(1/p[1]), 10);

p[1] := 1.0

 

5

 

Vector[row](10, {(1) = .6712845969334367, (2) = .9015330932207778, (3) = .4948799729481841, (4) = 0.7367465693581245e-1, (5) = .6837132578083422, (6) = .44749553082775895, (7) = .43471194836243726, (8) = 1.6434182579678538, (9) = 1.1314516791005587, (10) = 1.5140533707945583})

 

5

 

Vector[row](10, {(1) = .6712845969334367, (2) = .9015330932207778, (3) = .4948799729481841, (4) = 0.7367465693581245e-1, (5) = .6837132578083422, (6) = .44749553082775895, (7) = .43471194836243726, (8) = 1.6434182579678538, (9) = 1.1314516791005587, (10) = 1.5140533707945583})

 

5

 

Vector[row](10, {(1) = .6712845969334367, (2) = .9015330932207778, (3) = .4948799729481841, (4) = 0.7367465693581245e-1, (5) = .6837132578083422, (6) = .44749553082775895, (7) = .43471194836243726, (8) = 1.6434182579678538, (9) = 1.1314516791005587, (10) = 1.5140533707945583})

 

p[1] := 1.1

 

5

 

Vector[row](10, {(1) = .610258724491045, (2) = .819575539299812, (3) = .4498908845028481, (4) = 0.6697696085140836e-1, (5) = .6215575071047086, (6) = .4068141189383945, (7) = .39519268033344035, (8) = 1.4940165981675346, (9) = 1.0285924355562484, (10) = 1.3764121552815445})

 

5

 

Vector[row](10, {(1) = .610258724491045, (2) = .819575539299812, (3) = .4498908845028481, (4) = 0.6697696085140836e-1, (5) = .6215575071047086, (6) = .4068141189383945, (7) = .39519268033344035, (8) = 1.4940165981675346, (9) = 1.0285924355562484, (10) = 1.3764121552815445})

 

5

 

Vector[row](%id = 18446744074373423582)

(1)

 

Download rand2.mw

Conclusion: head, brickWall; stop using the former to hit the latter

@Bosco Emmanuel 

Simple practice beats "perception". Contemplate the following - and consider what you "expected"

 with(Statistics):
 randomize(5);
 p[1]:=1.0;
 Sample(Exponential(1/p[1]), 10);
 Sample(Exponential(1/p[1]), 10);
 p[1]:=1.1;
 Sample(Exponential(1/p[1]), 10);
 Sample(Exponential(1/p[1]), 10);

5

 

p[1] := 1.0

 

Vector[row](10, {(1) = .6712845969334367, (2) = .9015330932207778, (3) = .4948799729481841, (4) = 0.7367465693581245e-1, (5) = .6837132578083422, (6) = .44749553082775895, (7) = .43471194836243726, (8) = 1.6434182579678538, (9) = 1.1314516791005587, (10) = 1.5140533707945583})

 

Vector[row](10, {(1) = .11377133271465704, (2) = .5660236151033777, (3) = .47493179541304126, (4) = .6932721719228526, (5) = .3946356972427462, (6) = 2.3491289397526622, (7) = .6964217967722122, (8) = .4917720317879856, (9) = 1.8028760167975455, (10) = .20393896501821102})

 

p[1] := 1.1

 

Vector[row](10, {(1) = .2954962542886287, (2) = .6103438683841103, (3) = .10631610833581644, (4) = .2209382393646557, (5) = 1.425184603877873, (6) = .44204039668908374, (7) = 2.8059355763313554, (8) = .9448235100947775, (9) = .9178371684860548, (10) = .9480227525893345})

 

Vector[row](%id = 18446744074761004086)

(1)

 

Download rand.mw

which will find a solution, when no solution exists

Removing lots of useless cr*p from your worksheet, and restricting the number of calculations in the outer loop to 100 (rather than 1000, cos I can't be bothered to wait that long). I get what is shown in the attached. Rather obviously, the fsolve() command occasionally fails.

I have netiher the time nor the interest to evaluate each of these failures individually, but I wil discuss the first failure, for educational purposes. (I assume all of the othere are something more or less similar - you check them if you have the energy)

The first failure is R[16}, which is the solution of the expression

fsolve(3*exp(.2490248922/R)-exp(.8056958715/R) = 2, R, 0 .. infinity)

Now if you can't see why this equation has no solution, then I suppose you could try plotting the expression. However a braindead examination of the expression shows that as R tends to infinity, the expression tends to

3*exp(.2490248922/infinity)-exp(.8056958715/infinity), which tends to

3*exp(0)-exp(0) which tends to

3-1=2

So the only "solution" is R=infinity. However fsolve() is a mere numerical process, and 'infinity' is not a solution whihc can be obtained by any numerical means:-(

A fast 'eyeball' check shows that an identical argument can be applied to the failures at R[21], R[37], R[48], R[50], and R[58]. See hte attached

fsolveProb.mw

 

 

@Bosco Emmanuel 
as I have already observed, during a single iteration of the optimisation process, the Optimize package will make multiple calls to the function lc(), with different values of the parameters. Anytime that the values of the parameters p[1], p[2], [3] change then you will be defining a "new" distribution for the random numbers - and hence a new set of values.

"Freezing the seed" *ought* to return the same set of samples from a parameterized distribution, provided the parameter(s) used to define the distribution stay(s) the same. Since the parameters p[1], p[2], p[3] vary (in general) with each call to lc() within a single iteration, the distributions will be redefined, and new sample sets generated.

  1. I can't see any way to avoid this behaviour when the parameters defining the r.v. distributions are also the parameters for which you are optimizing.
  2. Hence I don't see any way that such an optimzation process can be "guaranteed" to work
  3. Hence my questions about the nature of the underlying problem
  4. Hence my suggestion about investigating alternatives, such as correlation

In order to fsolve(sys), it is necessary that 'sys' evaluates to something meaningful. However in your code 'sys' is defined in terms of some table entries 'eq[i,j]' whihc are nowhere defined in your worksheet.

I assume that you actually mean what is shown in the attached

(there are more efficient ways to implement this!)

restart; Digits := 5; with(plots); with(LinearAlgebra)

NULL

a := 0; b := 1; N := 9; h := (b-a)/(N+1); k := 1/1000; phi := .5; K := 10^(-6); mu := 1.67; alpha := K/(phi*mu); lambda := alpha*k/h^2

0.11976e-6

(1)

NULL

for i from 0 while i <= N do u[i, 0] := h*i+1 end do

NULL

for j from 0 while j < N+1 do u[0, j] := .1; u[N+1, j] := .5 end do

NULL

printlevel := 2; for i while i <= N do for j from 0 while j <= N do lambda*u[i-1, j]+(2-2*lambda)*u[i, j]+lambda*u[i+1, j] = -lambda*u[i-1, j+1]+(2+2*lambda)*u[i, j+1]-lambda*u[i+1, j+1] end do end do; for i while i <= N do for j from 0 while j <= N do eq[i, j] := lambda*u[i-1, j]+(2-2*lambda)*u[i, j]+lambda*u[i+1, j] = -lambda*u[i-1, j+1]+(2+2*lambda)*u[i, j+1]-lambda*u[i+1, j+1] end do end do

sys := ([seq])(seq(eq[i, j], j = 0 .. 9), i = 1 .. 9); indets(sys)

fsolve(sys)

{u[0, 10] = u[0, 10], u[1, 1] = 1.1000, u[1, 2] = 1.1000, u[1, 3] = 1.1000, u[1, 4] = 1.1000, u[1, 5] = 1.1000, u[1, 6] = 1.1000, u[1, 7] = 1.1000, u[1, 8] = 1.1000, u[1, 9] = 1.1000, u[1, 10] = 1.1000+0.59880e-7*u[0, 10]+0.98982e-65*u[10, 10], u[2, 1] = 1.2000, u[2, 2] = 1.2000, u[2, 3] = 1.2000, u[2, 4] = 1.2000, u[2, 5] = 1.2000, u[2, 6] = 1.2000, u[2, 7] = 1.2000, u[2, 8] = 1.2000, u[2, 9] = 1.2000, u[2, 10] = 1.2000+0.35856e-14*u[0, 10]+0.16530e-57*u[10, 10], u[3, 1] = 1.3000, u[3, 2] = 1.3000, u[3, 3] = 1.3000, u[3, 4] = 1.3000, u[3, 5] = 1.3000, u[3, 6] = 1.3000, u[3, 7] = 1.3000, u[3, 8] = 1.3000, u[3, 9] = 1.3000, u[3, 10] = 1.3000+0.21470e-21*u[0, 10]+0.27605e-50*u[10, 10], u[4, 1] = 1.4000, u[4, 2] = 1.4000, u[4, 3] = 1.4000, u[4, 4] = 1.4000, u[4, 5] = 1.4000, u[4, 6] = 1.4000, u[4, 7] = 1.4000, u[4, 8] = 1.4000, u[4, 9] = 1.4000, u[4, 10] = 1.4000+0.12856e-28*u[0, 10]+0.46100e-43*u[10, 10], u[5, 1] = 1.5000, u[5, 2] = 1.5000, u[5, 3] = 1.5000, u[5, 4] = 1.5000, u[5, 5] = 1.5000, u[5, 6] = 1.5000, u[5, 7] = 1.5000, u[5, 8] = 1.5000, u[5, 9] = 1.5000, u[5, 10] = 1.5000+0.76980e-36*u[0, 10]+0.76988e-36*u[10, 10], u[6, 1] = 1.6000, u[6, 2] = 1.6000, u[6, 3] = 1.6000, u[6, 4] = 1.6000, u[6, 5] = 1.6000, u[6, 6] = 1.6000, u[6, 7] = 1.6000, u[6, 8] = 1.6000, u[6, 9] = 1.6000, u[6, 10] = 1.6000+0.46096e-43*u[0, 10]+0.12857e-28*u[10, 10], u[7, 1] = 1.7000, u[7, 2] = 1.7000, u[7, 3] = 1.7000, u[7, 4] = 1.7000, u[7, 5] = 1.7000, u[7, 6] = 1.7000, u[7, 7] = 1.7000, u[7, 8] = 1.7000, u[7, 9] = 1.7000, u[7, 10] = 1.7000+0.27602e-50*u[0, 10]+0.21471e-21*u[10, 10], u[8, 1] = 1.8000, u[8, 2] = 1.8000, u[8, 3] = 1.8000, u[8, 4] = 1.8000, u[8, 5] = 1.8000, u[8, 6] = 1.8000, u[8, 7] = 1.8000, u[8, 8] = 1.8000, u[8, 9] = 1.8000, u[8, 10] = 1.8000+0.16528e-57*u[0, 10]+0.35856e-14*u[10, 10], u[9, 1] = 1.9000, u[9, 2] = 1.9000, u[9, 3] = 1.9000, u[9, 4] = 1.9000, u[9, 5] = 1.9000, u[9, 6] = 1.9000, u[9, 7] = 1.9000, u[9, 8] = 1.9000, u[9, 9] = 1.9000, u[9, 10] = 1.9000+0.98970e-65*u[0, 10]+0.59880e-7*u[10, 10], u[10, 10] = u[10, 10]}

(2)

NULL

Download CN.mw

@ianmccr 

  1. Can you define (local) procedures withiin a module, which are available to other (exported) procedures within the module? YES
  2. Can you define a sub-module within a module whose exports are available to other (exported) procedures within the parent module, but not to the 'outside world' YES
  3. Can you use a procedure defined outside a module, in procedures defined within the module. Well, you can, but you shouldn't

The first two above are the "most common" situations which you might want to use.

Don't use the third - the programming purity police will visit and smash up your keyboard: it violates the whole concept of 'encapsulation' etc, which is (probably) the main point of using modules in the first place.

The attached "toy" example shows how all of the above situations can be written

restart;
fred:= proc( a )
             return a+2
       end proc:
z5 := module()
             local z6, plusOne:
             export plustimes, timesplus, addOnes, addTwos:

           ###########################################
           # Define a local sub-module, whose exports
           # will only be available in this (parent)
           # module
           ###########################################
             z6:= module()
                         export plus, times;
                         plus:= proc(a, b)
                                     return a+b;
                                end proc;

                         times:= proc(a, b)
                                       return a*b;
                                 end proc;
                  end module;

          ##############################################
          # Define a local procedure, which will only be
          # available to other procedures in this module
          ##############################################
             plusOne:= proc( p )
                             return z6:-plus(p,1)
                       end proc;

          ##############################################
          # Define a couple of exported procedures which
          # themselves call procedures from the local
          # sub-module z6 defined above
          ##############################################
             plustimes:= proc( p, q )
                               return z6:-plus
                                          ( z6:-times(p, q),
                                            z6:-plus(p, q)
                                          );
                         end proc;
             timesplus:= proc( p, q )
                               return z6:-times
                                          ( z6:-plus(p, q),
                                            z6:-times(p, q)
                                          );
                         end proc;

          #############################################
          # Define an exported procedure which calls a
          # local procedure
          #############################################
             addOnes:= proc( p, q)
                             return plusOne(p), plusOne(q)
                       end proc;

          #############################################
          # Define an exported procedure which calls a
          # procedure defined outside this module. You
          # really, REALLY shouldn't do this
          #############################################
             addTwos:= proc(p, q)
                             return :-fred(p), :-fred(q);
                       end proc;

       end module:
z5:-timesplus(2,3);
z5:-plustimes(2,3);
z5:-addOnes(2,3);
z5:-addTwos(2,3);

30

 

11

 

3, 4

 

4, 5

(1)

 


 

Download toyModule.mw

@Carl Love 

I know that you know this stuff, so this is for the benefit of the OP.

The phrase, evaluating a procedure and executing it, is clouding your thinking There are only two stages whihc yu should consider: 'defining' a procedure, and 'executing' it.

'Defining' a procedure just means incorporating the code for the procedure which may, or may not,  ever be executed (with appropriate arguments) at some point in an application.

A procedure definition is anything which exists in the form proc(possiblySomeArguments).....end proc, and which may (or may not) be assigned to a name. So

fred:=proc(SomeArguments).....end proc;

defines a procedure, but actually doesn't achieve very much. Action only happens when the procedure is called, with

fred(theArguments)

in which case the code in the procedure will be executed with the supplied arguments and (hopefully) return a meaningful answer.

A procedure doesn't need to be assigned to a 'name', but would usually be assigned to something which makes calling it convenient. So defining it and assigning it to an entry in a table with

          entry[someName]:= proc(SomeArguments).....end proc;

is fine. Then it can be called (ie executed) with

entry[someName](theArguments)

You don't even have to assign a procedure to anything if you don't want do. The code

anAnswer:=proc(SomeArguments).....end proc(theArguments)

defines a procedure, executes it with 'theArguments' and assigns the return value to 'anAnswer'. However since the procedure has not been assigned to anything, then any subsequent use of the same procedure will require the same calling sequence - so it is generally a better idea to assign the proc(SomeArguments).....end proc to something or other: if nothing else it saves typing!

@Bosco Emmanuel 

Firstly why should it call "lc" 117 times for one iteration? I thought "lc" will be called by the Minimize only when the values of the parameters are changed. Do you mean to say that "lc" will be called multiple times for the same set of values of the parameters? I do not quite understand why it should do this.

When an optimisation evaluates the target function for a given set of parameters, this gives no indication of how the parameters should be "adjusted" to improve things. Consider a "toy" example with two parameters, f(p1, p2), then one can imagine the optimisation routine performing the simple process for one iteration

f(p1, p2) # reference value
f(p1+delta, p2) # shift p1 by +delta, is value greater than or less than reference?
f(p1-delta, p2) # shift p1 by -delta, is value greater than or less than reference?
f(p1, delta-p2) # shift p2 by +delta, is value greater than or less than reference?
f(p1, delta+p2) # shift p2 by -delta, is value greater than or less than reference?

ie five function evaluations. You might think this provides sufficient information to determine which "directions" to shift which parameters, but it leaves a number of questions unanswered: such as

  1. How do you pick a value for the increment delta? Maybe you should try two or three?
  2. Why would you necessarily pick the same value(s) of the increment delta for different parameters?
  3. Are you certain that if f(p1-delta1, p2) is an improvement and f(p1, p2+delta2) is also an improvement, that f(p1-delta1, p2+delta2) would be better than either?
  4. If you have more than two parameters, then the situation described in (3) above, starts to give a lot of combinatiions which you might want to check

So how many function evaluations do you think might be necessary per iteration??? My previous comment was based on the observation (for your problem) that the impact of changing the set of random variables for each function evaluation may mask the effect of changing the underlying parameters, so the optimisation process described above may give inconsistent results!!!

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

Be very careful about describing one Optimization routine as being "better" or "more robust" than any other. There is no Otimization process on the planet which can absolutely guarantee to find a global optimum for anything other than convex functions. Some (may) be better than others for certain types of problems, but none of them is perfect!

If you took a poll on this site, then I am sure that you will find that the DirectSearch() package is (generally speaking) more robust than the in-built Optimization() package

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

The description of your fundamental problem does not *seem* to justify the use of random variables during the optimisation process.

  1. You have a 'synthetic' function depending on 6 parameters - ie S(p1,p2,p3,p4,p5,p6)
  2. It *seems* as if you want to compute the (possibly weighted, almost certainly wrapped, aka circular) correlation function between this synthetic function and actual patient data
  3. Then use Optimization() to change the parameters p1,p2,p3,p4,p5,p6 in order to maximize the correlation function
  4. No need for random variable generation anywhere????
  5. I may be wrong!
First 88 89 90 91 92 93 94 Last Page 90 of 207