acer

33310 Reputation

29 Badges

20 years, 264 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

restart;

k1:=sqrt(1-lambda1^2):
result:=int(sqrt(1-k1^2*sin(x)*sin(x)),x=0..Pi/2);

EllipticE((-lambda1^2+1)^(1/2))

expr:=4*lambda2*result^2/(Pi*(lambda2+1)^2)-lambda1;

4*lambda2*EllipticE((-lambda1^2+1)^(1/2))^2/(Pi*(lambda2+1)^2)-lambda1

sols:=[solve(expr,lambda2)];

[(2*EllipticE((-lambda1^2+1)^(1/2))^2-lambda1*Pi+2*(EllipticE((-lambda1^2+1)^(1/2))^4-EllipticE((-lambda1^2+1)^(1/2))^2*Pi*lambda1)^(1/2))/(lambda1*Pi), -(-2*EllipticE((-lambda1^2+1)^(1/2))^2+lambda1*Pi+2*(EllipticE((-lambda1^2+1)^(1/2))^4-EllipticE((-lambda1^2+1)^(1/2))^2*Pi*lambda1)^(1/2))/(lambda1*Pi)]

plot(sols,lambda1=0..1,view=[0..1,0..2],color=[red,blue]);

# Since you seem to want only the range lambda2 = 0..1 then let us take sols[2]

ans := sols[2];

-(-2*EllipticE((-lambda1^2+1)^(1/2))^2+lambda1*Pi+2*(EllipticE((-lambda1^2+1)^(1/2))^4-EllipticE((-lambda1^2+1)^(1/2))^2*Pi*lambda1)^(1/2))/(lambda1*Pi)

# Is the above not adequate? By which I mean, do you need to export
# from Maple an expression containing only elementary functions,
# so that you can evaluate it in some other program? If so then
# you could create an expression that numerically approximates
# `ans`.
#
# If, on the other hand, you are only going to be working in Maple,
# then you can evaluate that `ans` at any value you want (and then?
# you wouldn't need any approximant or interpolant.

eval(ans, lambda1=0.33);

.4265904939

eval(ans, lambda1=1/4);
evalf[30](%);

-4*(-2*EllipticE((1/16)*15^(1/2)*16^(1/2))^2+(1/4)*Pi+2*(EllipticE((1/16)*15^(1/2)*16^(1/2))^4-(1/4)*EllipticE((1/16)*15^(1/2)*16^(1/2))^2*Pi)^(1/2))/Pi

.279607283408364385834201767217

# And of course you can create a procedure to evaluate it,
# if you prefer.

func := unapply(ans, lambda1):

func(0.33);
evalf[15]( func(1/4) );

.4265904939

.279607283408366

# Let's suppose that you really do need an approximating
# expression which does not contain the special-function
# `EllipticE`.

# You could try and create a B-spline approximant (or maybe even
# a piecewise-spline) from a set of data points at which you
# eveluate `ans`. But you can obtain a reasonably accurate
# approximant without having to discrtetize the data like that.

# One choice is to compute a rational polynomial approximation.

approx := evalf[15](eval(numapprox:-chebpade(ans, lambda1=1.0e-9..0.435, [6,6]), T = orthopoly[T]));

(.363867761260166-.209922180741883*lambda1-.597477979861973*(4.59770115999472*lambda1-1.00000000459770)^2+0.796809220003615e-1*(4.59770115999472*lambda1-1.00000000459770)^3+.323737070510297*(4.59770115999472*lambda1-1.00000000459770)^4-0.323162936462787e-1*(4.59770115999472*lambda1-1.00000000459770)^5-0.427622120950442e-1*(4.59770115999472*lambda1-1.00000000459770)^6)/(3.38601816848211-9.24878986039695*lambda1-.520442783507366*(4.59770115999472*lambda1-1.00000000459770)^2+1.63010229481725*(4.59770115999472*lambda1-1.00000000459770)^3-.323738919142684*(4.59770115999472*lambda1-1.00000000459770)^4-.167956123339779*(4.59770115999472*lambda1-1.00000000459770)^5+0.230947750746192e-1*(4.59770115999472*lambda1-1.00000000459770)^6)

plots:-display(
  plot(approx, lambda1=0..0.435,
       style=point, symbol=cross, color=blue,
       numpoints=60, adaptive=false),
  plot(ans, lambda1=0..0.435),
view=[0..1,0..1]
);

# Let's see how well `approx` approximates `ans`.

Digits:=50:
plot(ans - approx, lambda1=0..0.435);
Digits:=10:

 


Download approximating.mw

By default that time(...) command will measure a sum of the changes of cpu time in all relevant threads. In that case you will not be able to recognize any improvement (even if it occurs), and might even misinterpret the results as denoting a slowdown.

If your machine is otherwise unloaded then you'd make easier sense from the results of the time[real](...) command, which measures wall-clock time.

Or you can wrap with the CodeTools:-Usage(...) command, and get both of those kinds of timing measurements displayed.

 

Did you try something like,

plots:-display(
  plots:-surfdata( Op1, xrng1, yrng1 ),
  plots:-surfdata( Op2, xrng2, yrng2 )
);

restart;

colorize := proc(x::name,c)
  local col;
  uses ColorTools;
  col:=RGB24ToHex(RGBToRGB24([Color(c)[]]));
  nprintf("#mi(\"%a\",mathcolor=%a);",x,col);
end proc:

colorize(Q,"Orange");

`#mi("Q",mathcolor="#FFA500");`

# Specify the color in your choice of format.
x := colorize(':-x',red):
y := colorize(':-y',"#40BB50"):
z := colorize(':-z',"Olive"):
Lambda := colorize(':-Lambda', [255,0,255]):

expr1 := sin(x*Lambda) + y^2;

sin(`#mi("x",mathcolor="#FF0000");`*`#mi("Lambda",mathcolor="#FF00FF");`)+`#mi("y",mathcolor="#40BB50");`^2

diff(expr1, x) + diff(expr1, y);

`#mi("Lambda",mathcolor="#FF00FF");`*cos(`#mi("x",mathcolor="#FF0000");`*`#mi("Lambda",mathcolor="#FF00FF");`)+2*`#mi("y",mathcolor="#40BB50");`

eval(expr1, x=z);

sin(`#mi("z",mathcolor="#808000");`*`#mi("Lambda",mathcolor="#FF00FF");`)+`#mi("y",mathcolor="#40BB50");`^2

p[u] := colorize(':-p', black)[colorize(':-u', black)];
diff(p[u]^3, p[u]);

`#mi("p",mathcolor="#000000");`[`#mi("u",mathcolor="#000000");`]

3*`#mi("p",mathcolor="#000000");`[`#mi("u",mathcolor="#000000");`]^2

x__t := colorize(':-x__t',"Green"):

expr2 := tan(x__t);

tan(`#mi("x__t",mathcolor="#008000");`)

diff(expr2, x__t);

1+tan(`#mi("x__t",mathcolor="#008000");`)^2

`Δw` := colorize(':-`Δw`', black)

sqrt(`Δw`)

`#mi("\`Δw\`",mathcolor="#000000");`^(1/2)

 

 

Download colorized_output.mw

Since you assigned a and b with numeric values near the beginning, don't forget to unassign them before you call NonlinearFit with an expression in which a and b are intended as unassigned parameter names.

Your candidate expression (formula as first argument passed to NonlinearFit) has a call to Dens(u/1+a*u). You get better control over what happens throughout, IMO, if you make Dens return unevaluated if its own argument is not numeric. That way you can completely seperate the working precision stuff going on within Dens from that at the higher level, without having to switch to the so-call operator form calling sequence.

Also, it doesn't seem like a good idea to force a lower working precision within the Dens procedure (with your evalf[8] call). That may confuse code within NonlinearFit that is attempting to approximate gradients at a greater working precision, and it may accidentally decide the the gradients are zero because the function isn't changing for some small change in u. (When that kind of thing happens you'd see a warning, like "no improved point could be found", or "...because first order conditions met", etc).

I ran the following attachment in 64bit Maple 14.01 for Linux.

Download nonlinearfit.mw

Note that the NonlinearFit command does local optimization, so while the computed a and b might provide a local minimum there may be a better global optima. This is one reason while the DirectSearch package (from the Application Center) is popular.

Is it possible that your data might be suitable for logarithmic fitting?

restart;

eq:=a*x^2+b*y^2+c*x*y:

terms:=[op(eq)];

                         2     2
            terms := [a x , b y , c x y]

conds1:=a>0, b<0, c>0:

conds2:=x::real, y::real, x<>0, y<>0:

select( u->is(u>0), terms ) assuming conds1, conds2;

                         2
                     [a x ]

select( u->is(u<0), terms ) assuming conds1, conds2;

                         2
                     [b y ]

remove( u->is(u<0) or is(u>0), terms ) assuming conds1, conds2;

                     [c x y]

I suggest using simple bounds (ie, ranges) for the variable, rather than adding those in as constraints. The solvers actually accept and handle those slightly differently. Using simple bounds with LSSolve I was able to avoid having to use feasibilitytolerance to guard against negativity.

Also, using tighter bounds (for all variables) allowed a better solution to be found.

Also, by using NLPSolve rather than LSSolve things went a little easier, it seemed. Note that if your simple bounds are of the symmetric form var=-a .. a then it may take 0.0 as initial point, and for your example that might result in initial gradients being zero (at which point, alas, the solver stops saying it cannot improve the initial point). I generally use a range that is not symmetric about zero gradients, if it's easy to see.

This might also be a good time to mention that the commands from the Optimization package do local optimization. If your nonlinear optimization problem has multiple local optima then it is not guaranteed that the computed solution is the global optima. See the DirectSearch package (version 2, not 1) from the Application Center, for multivariable global optimization.

I used Maple 2016.0 for this, as that seems to be your current version. I recommend upgrading to the point-release 2016.2 (which won't cost you).

restart;

interface(warnlevel=0):

list_1 := [-0.777253031437943e-1+6.57999999999998*D2+(276.680000000000-Phi12_17)*D17, .978053142243381-633.614000000000*D2+(-6.58400000000000-Phi23_17)*D17, -0.178064883733416e-1+253.738100000000*D2+(-5.34190000000000-Phi34_17)*D17, -0.353869747788979e-2+39.4444000000000*D2+(-1.06160000000000-Phi45_17)*D17, -0.884707703096015e-3+9.86159000000000*D2+(-.265410000000000-Phi56_17)*D17, -0.226985309680582e-1+190.480500000000*D2+(-6.80950000000000-Phi67_17)*D17, -0.862540843423853e-3+2.15544000000000*D2+(-.258760000000000-Phi78_17)*D17, -0.141061228211511e-2+2.10972000000000*D2+(-.423180000000000-Phi89_17)*D17, -0.163814759658455e-2+2.45006000000000*D2+(-.491440000000000-Phi910_17)*D17, -0.525504575536290e-2+6.99450000000000*D2+(-1.57650000000000-Phi1011_17)*D17, -0.305389325672901e-1+28.4964000000000*D2+(-9.16160000000000-Phi1112_17)*D17, -0.987175261941468e-1+25.7100000000000*D2+(-29.6150000000000-Phi1213_17)*D17, -0.493604297782517e-2+1.28550000000000*D2+(-1.48080000000000-Phi1314_17)*D17, -0.522437882168112e-1+6.41700000000000*D2+(-15.6730000000000-Phi1415_17)*D17, -.141614566362726+13.9970000000000*D2+(-42.4840000000000-Phi1516_17)*D17, 0.777253031360147e-1-42.4900000000000*D15+(155.450000000000-Phi12_17)*D28, 0.219470855957043e-1-13.9960000000000*D15+(43.8940000000000-Phi23_17)*D28, 0.178065694473007e-1-12.8320000000000*D15+(35.6130000000000-Phi34_17)*D28, 0.353886380190268e-2-2.92230000000000*D15+(7.07770000000000-Phi45_17)*D28, 0.884703450426918e-3-.730700000000000*D15+(1.76940000000000-Phi56_17)*D28, 0.226985885266366e-1-20.8670000000000*D15+(45.3970000000000-Phi67_17)*D28, 0.862553364039491e-3-.965300000000000*D15+(1.72510000000000-Phi78_17)*D28, 0.141060550149453e-2-1.62670000000000*D15+(2.82120000000000-Phi89_17)*D28, 0.163815638896446e-2-1.88900000000000*D15+(3.27630000000000-Phi910_17)*D28, 0.525502049507568e-2-6.09000000000000*D15+(10.5100000000000-Phi1011_17)*D28, 0.305386191034954e-1-35.8000000000000*D15+(61.0770000000000-Phi1112_17)*D28, 0.987153849993141e-1-117.980000000000*D15+(197.430000000000-Phi1213_17)*D28, 0.493586925035572e-2-5.89830000000000*D15+(9.87170000000000-Phi1314_17)*D28, 0.522452037612234e-1-62.6800000000000*D15+(104.490000000000-Phi1415_17)*D28, -.858384447685986+609.990000000000*D15+(283.230000000000-Phi1516_17)*D28, 0.133722502645145e-2-5.34000000000003*D3+(264.760000000000-Phi12_19)*D19, 0.492898645263975e-1-253.740000000000*D3+(373.290000000000-Phi23_19)*D19, -.792605146598487+1386.78000000000*D3+(1127.70000000000-Phi34_19)*D19, .132715839620078-165.954000000000*D3+(-206.460000000000-Phi45_19)*D19, 0.331294375945810e-1-41.4870000000000*D3+(-51.6140000000000-Phi56_19)*D19, .512857041219517-749.640000000000*D3+(-946.930000000000-Phi67_19)*D19, 0.345803892354315e-2-6.58880000000000*D3+(-9.00300000000000-Phi78_19)*D19, 0.253797811562394e-2-5.18510000000000*D3+(-7.71800000000000-Phi89_19)*D19, 0.294701900455624e-2-6.02140000000000*D3+(-8.96290000000000-Phi910_19)*D19, 0.754969755588153e-2-15.8980000000000*D3+(-24.4690000000000-Phi1011_19)*D19, 0.181312716670633e-1-44.7810000000000*D3+(-82.4390000000000-Phi1112_19)*D19, 0.133647518064223e-1-35.1810000000000*D3+(-90.5060000000000-Phi1213_19)*D19, 0.667987641718040e-3-1.75900000000000*D3+(-4.52530000000000-Phi1314_19)*D19, 0.217080361770671e-2-6.75400000000000*D3+(-28.8440000000000-Phi1415_19)*D19, 0.365299883394169e-2-12.8320000000000*D3+(-69.3130000000000-Phi1516_19)*D19, -0.130020251659236e-2+6.81000000000000*D6+(263.430000000000-Phi12_19)*D20, -0.493576878414119e-1+190.470000000000*D6+(323.980000000000-Phi23_19)*D20, -.207482316974689+749.650000000000*D6+(920.260000000000-Phi34_19)*D20, -.132570648903326+410.334000000000*D6+(461.-Phi45_19)*D20, -0.329843798422150e-1+102.583000000000*D6+(115.250000000000-Phi56_19)*D20, .487420161727992-1880.19000000000*D6+(-1459.80000000000-Phi67_19)*D20, -0.345553822678983e-2+26.0430000000000*D6+(-12.4610000000000-Phi78_19)*D20, -0.254139584204717e-2+18.7200000000000*D6+(-10.2570000000000-Phi89_19)*D20, -0.295045955688278e-2+21.7400000000000*D6+(-11.9110000000000-Phi910_19)*D20, -0.755117615405593e-2+55.1470000000000*D6+(-32.0200000000000-Phi1011_19)*D20, -0.181178219908242e-1+124.980000000000*D6+(-100.570000000000-Phi1112_19)*D20, -0.133520796896221e-1+89.6200000000000*D6+(-103.870000000000-Phi1213_19)*D20, -0.668104062372097e-3+4.48110000000000*D6+(-5.19340000000000-Phi1314_19)*D20, -0.217033804692734e-2+13.3910000000000*D6+(-31.0150000000000-Phi1415_19)*D20, -0.365556938318863e-2+20.8670000000000*D6+(-72.9670000000000-Phi1516_19)*D20, 0.135489886901528e-2-.259999999999991*D7+(256.360000000000-Phi12_21)*D22, 0.680675384195741e-2-2.16000000000000*D7+(131.350000000000-Phi23_21)*D22, 0.167104193845212e-1-6.59000000000000*D7+(164.020000000000-Phi34_21)*D22, 0.655190381659506e-2-2.76600000000000*D7+(47.9000000000000-Phi45_21)*D22, 0.163878244157080e-2-.692000000000000*D7+(11.9750000000000-Phi56_21)*D22, 0.603897781618217e-1-26.0400000000000*D7+(394.350000000000-Phi67_21)*D22, -.981708865268294+89.7700000000000*D7+(51.2660000000000-Phi78_21)*D22, .286945758784479-5.67000000000000*D7+(-34.6470000000000-Phi89_21)*D22, .333288992029305-6.58400000000000*D7+(-40.2350000000000-Phi910_21)*D22, .115166403866294-14.3630000000000*D7+(-101.530000000000-Phi1011_21)*D22, 0.796486977999666e-1-12.5100000000000*D7+(-238.060000000000-Phi1112_21)*D22, 0.513893785319347e-1-8.19999999999999*D7+(-201.690000000000-Phi1213_21)*D22, 0.257108190144080e-2-.409500000000000*D7+(-10.0840000000000-Phi1314_21)*D22, 0.486795807939043e-2-.850999999999999*D7+(-45.2570000000000-Phi1415_21)*D22, 0.524862014258993e-2-.965000000000003*D7+(-94.7990000000000-Phi1516_21)*D22, -0.136101769174909e-2+1.57999999999998*D10+(255.450000000000-Phi12_21)*D23, -0.680508845874531e-2+6.99000000000001*D10+(126.790000000000-Phi23_21)*D23, -0.167210744986313e-1+15.9000000000000*D10+(152.820000000000-Phi34_21)*D23, -0.654955044315159e-2+6.04100000000000*D10+(43.5110000000000-Phi45_21)*D23, -0.163599881722489e-2+1.51050000000000*D10+(10.8780000000000-Phi56_21)*D23, -0.603847441196420e-1+55.1500000000000*D10+(353.890000000000-Phi67_21)*D23, -0.182876336377057e-1+14.3600000000000*D10+(39.0120000000000-Phi78_21)*D23, -.286946970814718+35.7040000000000*D10+(83.0820000000000-Phi89_21)*D23, -.333290206967530+41.4630000000000*D10+(96.4820000000000-Phi910_21)*D23, .884841237755273-359.510000000000*D10+(-178.690000000000-Phi1011_21)*D23, -0.796889746454705e-1+94.6100000000000*D10+(-291.440000000000-Phi1112_21)*D23, -0.513575859600819e-1+60.8700000000000*D10+(-236.110000000000-Phi1213_21)*D23, -0.256926809156710e-2+3.04300000000000*D10+(-11.8060000000000-Phi1314_21)*D23, -0.486633264478440e-2+5.69300000000000*D10+(-48.5180000000000-Phi1415_21)*D23, -0.524686208104891e-2+6.08500000000001*D10+(-98.3150000000000-Phi1516_21)*D23, 0.740538677273994e-2-9.16000000000000*D11+(244.710000000000-Phi12_23)*D25, 0.642783571664902e-2-28.4970000000000*D11+(91.3030000000000-Phi23_23)*D25, 0.879545937424008e-2-44.7820000000000*D11+(92.1380000000000-Phi34_23)*D25, 0.267263958813606e-2-14.5080000000000*D11+(22.9620000000000-Phi45_23)*D25, 0.668159897034014e-3-3.62700000000000*D11+(5.74050000000000-Phi56_23)*D25, 0.224071702943972e-1-124.980000000000*D11+(173.760000000000-Phi67_23)*D25, 0.204975705587393e-2-12.5020000000000*D11+(12.1500000000000-Phi78_23)*D25, 0.398190796934755e-2-24.6980000000000*D11+(22.6800000000000-Phi89_23)*D25, 0.462414151228524e-2-28.6810000000000*D11+(26.3380000000000-Phi910_23)*D25, 0.152190448689061e-1-94.6100000000000*D11+(86.2100000000000-Phi1011_23)*D25, -.905930086863230+912.110000000000*D11+(526.060000000000-Phi1112_23)*D25, .687841196392981-376.270000000000*D11+(-673.250000000000-Phi1213_23)*D25, 0.343937963386998e-1-18.8130000000000*D11+(-33.6620000000000-Phi1314_23)*D25, 0.305873475333330e-1-34.1060000000000*D11+(-88.3170000000000-Phi1415_23)*D25, 0.294965405620479e-1-35.8000000000000*D11+(-140.200000000000-Phi1516_23)*D25, -0.740003311264899e-2+15.6700000000000*D14+(213.610000000000-Phi12_23)*D26, -0.643002877220721e-2+6.41700000000000*D14+(64.3070000000000-Phi23_23)*D26, -0.879503935483085e-2+6.75400000000000*D14+(55.1990000000000-Phi34_23)*D26, -0.267001194740175e-2+1.73800000000000*D14+(11.7380000000000-Phi45_23)*D26, -0.668002989087778e-3+.434300000000000*D14+(2.93440000000000-Phi56_23)*D26, -0.224051002552570e-1+13.3910000000000*D14+(79.6550000000000-Phi67_23)*D26, -0.205000917309872e-2+.851000000000000*D14+(3.54140000000000-Phi78_23)*D26, -0.398201781818492e-2+1.50890000000000*D14+(5.95680000000000-Phi89_23)*D26, -0.462402069093096e-2+1.75230000000000*D14+(6.91760000000000-Phi910_23)*D26, -0.152200681046646e-1+5.69300000000000*D14+(22.2930000000000-Phi1011_23)*D26, -0.941004210676048e-1+34.1030000000000*D14+(130.980000000000-Phi1112_23)*D26, -.687853077910222+122.340000000000*D14+(437.750000000000-Phi1213_23)*D26, -0.344056792915157e-1+6.11800000000000*D14+(21.8880000000000-Phi1314_23)*D26, .969399863074721-383.950000000000*D14+(-216.780000000000-Phi1415_23)*D26, -0.295001320031278e-1+62.6800000000000*D14+(-264.080000000000-Phi1516_23)*D26]:

with(Optimization):

rep1 := LSSolve(list_1):

Dlist:=[D10,D11,D14,D15,D17,D19,D2,D20,D22,D23,D25,D26,D28,D3,D6,D7];
Olist:=[op(indets(list_1,name) minus {op(Dlist)})];

[D10, D11, D14, D15, D17, D19, D2, D20, D22, D23, D25, D26, D28, D3, D6, D7]

[Phi1011_17, Phi1011_19, Phi1011_21, Phi1011_23, Phi1112_17, Phi1112_19, Phi1112_21, Phi1112_23, Phi1213_17, Phi1213_19, Phi1213_21, Phi1213_23, Phi12_17, Phi12_19, Phi12_21, Phi12_23, Phi1314_17, Phi1314_19, Phi1314_21, Phi1314_23, Phi1415_17, Phi1415_19, Phi1415_21, Phi1415_23, Phi1516_17, Phi1516_19, Phi1516_21, Phi1516_23, Phi23_17, Phi23_19, Phi23_21, Phi23_23, Phi34_17, Phi34_19, Phi34_21, Phi34_23, Phi45_17, Phi45_19, Phi45_21, Phi45_23, Phi56_17, Phi56_19, Phi56_21, Phi56_23, Phi67_17, Phi67_19, Phi67_21, Phi67_23, Phi78_17, Phi78_19, Phi78_21, Phi78_23, Phi89_17, Phi89_19, Phi89_21, Phi89_23, Phi910_17, Phi910_19, Phi910_21, Phi910_23]

rep1[1];
eval(Dlist,rep1[2]): min(%), max(%);
eval(Olist,rep1[2]): min(%), max(%);

0.182130325886275e-7

HFloat(1.4284944659735357e-4), HFloat(0.01111211271354064)

HFloat(-244.28897794294045), HFloat(376.3514935402879)

#infolevel[Optimization]:=3:
bnds:=seq(var=0.0001 .. 0.02, var=Dlist);
otherbnds:=seq(var=-250 .. 400, var=Olist);
rep2 := NLPSolve(1/2*add(ee^2,ee=list_1), bnds, otherbnds, method=modifiednewton, evaluationlimit=10000):
infolevel[Optimization]:=0:

D10 = 0.1e-3 .. 0.2e-1, D11 = 0.1e-3 .. 0.2e-1, D14 = 0.1e-3 .. 0.2e-1, D15 = 0.1e-3 .. 0.2e-1, D17 = 0.1e-3 .. 0.2e-1, D19 = 0.1e-3 .. 0.2e-1, D2 = 0.1e-3 .. 0.2e-1, D20 = 0.1e-3 .. 0.2e-1, D22 = 0.1e-3 .. 0.2e-1, D23 = 0.1e-3 .. 0.2e-1, D25 = 0.1e-3 .. 0.2e-1, D26 = 0.1e-3 .. 0.2e-1, D28 = 0.1e-3 .. 0.2e-1, D3 = 0.1e-3 .. 0.2e-1, D6 = 0.1e-3 .. 0.2e-1, D7 = 0.1e-3 .. 0.2e-1

Phi1011_17 = -250 .. 400, Phi1011_19 = -250 .. 400, Phi1011_21 = -250 .. 400, Phi1011_23 = -250 .. 400, Phi1112_17 = -250 .. 400, Phi1112_19 = -250 .. 400, Phi1112_21 = -250 .. 400, Phi1112_23 = -250 .. 400, Phi1213_17 = -250 .. 400, Phi1213_19 = -250 .. 400, Phi1213_21 = -250 .. 400, Phi1213_23 = -250 .. 400, Phi12_17 = -250 .. 400, Phi12_19 = -250 .. 400, Phi12_21 = -250 .. 400, Phi12_23 = -250 .. 400, Phi1314_17 = -250 .. 400, Phi1314_19 = -250 .. 400, Phi1314_21 = -250 .. 400, Phi1314_23 = -250 .. 400, Phi1415_17 = -250 .. 400, Phi1415_19 = -250 .. 400, Phi1415_21 = -250 .. 400, Phi1415_23 = -250 .. 400, Phi1516_17 = -250 .. 400, Phi1516_19 = -250 .. 400, Phi1516_21 = -250 .. 400, Phi1516_23 = -250 .. 400, Phi23_17 = -250 .. 400, Phi23_19 = -250 .. 400, Phi23_21 = -250 .. 400, Phi23_23 = -250 .. 400, Phi34_17 = -250 .. 400, Phi34_19 = -250 .. 400, Phi34_21 = -250 .. 400, Phi34_23 = -250 .. 400, Phi45_17 = -250 .. 400, Phi45_19 = -250 .. 400, Phi45_21 = -250 .. 400, Phi45_23 = -250 .. 400, Phi56_17 = -250 .. 400, Phi56_19 = -250 .. 400, Phi56_21 = -250 .. 400, Phi56_23 = -250 .. 400, Phi67_17 = -250 .. 400, Phi67_19 = -250 .. 400, Phi67_21 = -250 .. 400, Phi67_23 = -250 .. 400, Phi78_17 = -250 .. 400, Phi78_19 = -250 .. 400, Phi78_21 = -250 .. 400, Phi78_23 = -250 .. 400, Phi89_17 = -250 .. 400, Phi89_19 = -250 .. 400, Phi89_21 = -250 .. 400, Phi89_23 = -250 .. 400, Phi910_17 = -250 .. 400, Phi910_19 = -250 .. 400, Phi910_21 = -250 .. 400, Phi910_23 = -250 .. 400

rep2[1];
eval(Dlist,rep2[2]): min(%), max(%);
eval(Olist,rep2[2]): min(%), max(%);

0.182130325886291149e-7

HFloat(1.428494465392359e-4), HFloat(0.011112112715347953)

HFloat(-244.2889781143481), HFloat(376.3514935433254)

rep2_1 := Optimization:-LSSolve(list_2):

Dlist2:=[D18,D27,D29,D36];
Olist2:=[op(indets(list_2,name) minus {op(Dlist2)})];

[D18, D27, D29, D36]

[Phi1011_18, Phi1011_24, Phi1112_18, Phi1112_24, Phi1213_18, Phi1213_24, Phi12_18, Phi12_24, Phi1314_18, Phi1314_24, Phi1415_18, Phi1415_24, Phi1516_18, Phi1516_24, Phi23_18, Phi23_24, Phi34_18, Phi34_24, Phi45_18, Phi45_24, Phi56_18, Phi56_24, Phi67_18, Phi67_24, Phi78_18, Phi78_24, Phi89_18, Phi89_24, Phi910_18, Phi910_24]

rep2_1[1];
eval(Dlist2,rep2_1[2]): min(%), max(%);
eval(Olist2,rep2_1[2]): min(%), max(%);

0.173158517170151e-3

HFloat(-0.02877258006663398), HFloat(0.012053079546584859)

HFloat(-83.08949138713488), HFloat(263.20617377185454)

#infolevel[Optimization]:=3:
bnds:=seq(var=0.0001 .. 0.02, var=Dlist2);
otherbnds:=seq(var=-250 .. 400, var=Olist2);
rep2_2 := NLPSolve(add(1/2*ee^2,ee=list_2), bnds, otherbnds, method=modifiednewton, evaluationlimit=10000):
infolevel[Optimization]:=0:

D18 = 0.1e-3 .. 0.2e-1, D27 = 0.1e-3 .. 0.2e-1, D29 = 0.1e-3 .. 0.2e-1, D36 = 0.1e-3 .. 0.2e-1

Phi1011_18 = -250 .. 400, Phi1011_24 = -250 .. 400, Phi1112_18 = -250 .. 400, Phi1112_24 = -250 .. 400, Phi1213_18 = -250 .. 400, Phi1213_24 = -250 .. 400, Phi12_18 = -250 .. 400, Phi12_24 = -250 .. 400, Phi1314_18 = -250 .. 400, Phi1314_24 = -250 .. 400, Phi1415_18 = -250 .. 400, Phi1415_24 = -250 .. 400, Phi1516_18 = -250 .. 400, Phi1516_24 = -250 .. 400, Phi23_18 = -250 .. 400, Phi23_24 = -250 .. 400, Phi34_18 = -250 .. 400, Phi34_24 = -250 .. 400, Phi45_18 = -250 .. 400, Phi45_24 = -250 .. 400, Phi56_18 = -250 .. 400, Phi56_24 = -250 .. 400, Phi67_18 = -250 .. 400, Phi67_24 = -250 .. 400, Phi78_18 = -250 .. 400, Phi78_24 = -250 .. 400, Phi89_18 = -250 .. 400, Phi89_24 = -250 .. 400, Phi910_18 = -250 .. 400, Phi910_24 = -250 .. 400

rep2_2[1];
eval(Dlist2,rep2_2[2]): min(%), max(%);
eval(Olist2,rep2_2[2]): min(%), max(%);

0.108728397220773730e-8

HFloat(3.333776105270352e-4), HFloat(0.008322924299277928)

HFloat(-90.7352239950815), HFloat(262.0877484499128)

 

Download worksheet_help_1_modif.mw

 

Why not use the FileTools package for opening the file? That package has commands specifically for testing whether a file exists, or is currently open, etc.

See the help page for topic FileTools,IsOpen 

Using Digits:=15 my 64bit Maple 2017.1 for Linux obtained a solution with a pretty good residual, in not so bad time.


 

restart;

kernelopts(version);

`Maple 2017.1, X86 64 LINUX, Jun 19 2017, Build ID 1238644`

Digits:=15:

# m:=2.5: N:=15: h:=0.29669:
m:=3: N:=17: h:=0.41600:

p := proc(x)
          c[-N-1]*x^2+1
     end proc:
dp := diff(p(x), x);
ddp := diff(p(x), x, x);
DELTA2 := piecewise(k <> j, -2*(-1)^(j-k)/(j-k)^2, k = j, -(1/3)*Pi^2)/h^2;
DELTA1 := piecewise(k <> j, (-1)^(j-k)/(j-k), k = j, 0)/h;
DELTA0 := piecewise(k <> j, 0, k = j, 1);
PHI := proc(x)
            ln(sinh(x));
       end proc;
dPHI := diff(PHI(x), x);
ddPHI := diff(PHI(x), x, x);
for i from -N-1 to N do
    x[i] := ln(exp(i*h)+(exp(2*i*h)+1)^(1/2));
 end do:

POL := seq(simplify(eval(sum(c[k]*((eval(2*dPHI*DELTA1), x = x[j])+eval(x[j]*ddPHI*DELTA1, x = x[j])+x[j]*(eval(dPHI^2, x = x[j]))*DELTA2), k = -N .. N)+eval(ddp, x = x[j])+2*(sum(c[k]*(eval(x[j]*dPHI*DELTA1, x = x[j])+DELTA0), k = -N .. N)+eval(dp, x = x[j]))/x[j]+(c[j]*x[j]+p(x[j]))^m, x = x[j])), j = -N-1 .. N):
 

dp := 2*x*c[-18]

ddp := 2*c[-18]

DELTA2 := 5.77847633136095*piecewise(k <> j, -2*(-1)^(j-k)/(j-k)^2, k = j, -(1/3)*Pi^2)

DELTA1 := 2.40384615384615*piecewise(k <> j, (-1)^(j-k)/(j-k), k = j, 0)

piecewise(k <> j, 0, k = j, 1)

proc (x) ln(sinh(x)) end proc

cosh(x)/sinh(x)

1-cosh(x)^2/sinh(x)^2

K := CodeTools:-Usage( fsolve({seq(POL[v] = 0, v = 1 .. 2*N+2)}) );

memory used=3.26GiB, alloc change=7.00MiB, cpu time=22.36s, real time=20.56s, gc time=4.10s

{c[-18] = -0.158067746087552e-1, c[-17] = -0.387542884266278e-4, c[-16] = -0.130630169518967e-3, c[-15] = -0.239834317398380e-3, c[-14] = -0.415811440194114e-3, c[-13] = -0.646693636830992e-3, c[-12] = -0.101389527576115e-2, c[-11] = -0.153641273761729e-2, c[-10] = -0.235331965565866e-2, c[-9] = -0.355711573437526e-2, c[-8] = -0.541208015126014e-2, c[-7] = -0.818412067244522e-2, c[-6] = -0.124116070087548e-1, c[-5] = -0.187405318724168e-1, c[-4] = -0.282444166168333e-1, c[-3] = -0.421629853858902e-1, c[-2] = -0.619121771983790e-1, c[-1] = -0.878051524903856e-1, c[0] = -.117654444653016, c[1] = -.145782460278171, c[2] = -.166307162557309, c[3] = -.176491199766487, c[4] = -.177378358017197, c[5] = -.171361063895020, c[6] = -.160969710441339, c[7] = -.147975310537005, c[8] = -.133706933631217, c[9] = -.118868260983916, c[10] = -.104020256360719, c[11] = -0.893402689793291e-1, c[12] = -0.750814767898076e-1, c[13] = -0.611879309401569e-1, c[14] = -0.478386383346360e-1, c[15] = -0.348219351557400e-1, c[16] = -0.224317459414568e-1, c[17] = -0.100575149091325e-1}

Digits,oldDigits := 50, Digits: # increase while computing residuals
eval(map(abs@(rhs-lhs),{seq(POL[v] = 0, v = 1 .. 2*N+2)}),K);
max(%);
Digits:=oldDigits: # restore

{0.1848364467526429241183563989099735e-15, 0.202587081085419172747222400227041933204473295e-15, 0.10097241581802646603811727298402707e-14, 0.14553137467375713934400384650335701e-14, 0.22560173770270976761107758930223125e-14, 0.27160112886445930168063402665723885e-14, 0.39319837003387081002098376695012516e-14, 0.51325880161426781211477890118403909e-14, 0.53776848377504449929291594039049726e-14, 0.585095713936770588566043075378528608079752e-14, 0.688270019244350727096392771883525748e-14, 0.78563785170572199376709531083519070e-14, 0.904099525662313748582996811317018268e-14, 0.92859555415356170929146484133354861e-14, 0.94853914917733280044366040147412311e-14, 0.97752062759665148221253544524779454e-14, 0.107763339630216080424904434349711800e-13, 0.11405979550333858018322263416696762e-13, 0.132198657572373080463771901878901716e-13, 0.145643280852386524219168072988804449e-13, 0.149782918036741699690104183753487886e-13, 0.152120601633383535853708830652785124275e-13, 0.163630089886033587689846874750524749e-13, 0.188390085778795556521433153435070662e-13, 0.225289266140715475831341813098011734e-13, 0.22643740696535725265433769519996728e-13, 0.24504005846030340232899949273655086e-13, 0.249295353634064239781347372712429555e-13, 0.2605477850150012807659458375862248648e-13, 0.268800255486011004914803275475734128e-13, 0.329272851091861856917522923708165545e-13, 0.3337556394391884128014195478415057e-13, 0.4857403341990820827906483739374796e-13, 0.578726405983914849751293908345002674e-13, 0.606234244112589733855448574102251748e-13, 0.7569341881763600803047512052987563131e-13}

0.7569341881763600803047512052987563131e-13

with(DirectSearch):

KDS:=CodeTools:-Usage( SolveEquations([seq(POL[v] = 0, v = 1 .. 2*N+2)], evaluationlimit = 10000000) );
 

memory used=13.61GiB, alloc change=0 bytes, cpu time=9.78m, real time=2.53m, gc time=52.76s

KDS := [2.90084071296831*10^(-8), Vector(4, {(1) = ` 1 .. 36 `*Vector[column], (2) = `Data Type: `*anything, (3) = `Storage: `*rectangular, (4) = `Order: `*Fortran_order}), [c[-18] = -0.158088096698655e-1, c[-17] = -0.387372604634768e-4, c[-16] = -0.130628354565356e-3, c[-15] = -0.239814730814512e-3, c[-14] = -0.415808213284412e-3, c[-13] = -0.646665453648750e-3, c[-12] = -0.101388696973837e-2, c[-11] = -0.153635877299765e-2, c[-10] = -0.235322045150403e-2, c[-9] = -0.355695760087773e-2, c[-8] = -0.541194604080468e-2, c[-7] = -0.818397616579811e-2, c[-6] = -0.124115320868477e-1, c[-5] = -0.187404175924928e-1, c[-4] = -0.282444401564308e-1, c[-3] = -0.421630930157411e-1, c[-2] = -0.619121766646340e-1, c[-1] = -0.878045849452816e-1, c[0] = -.117652147369853, c[1] = -.145779235574756, c[2] = -.166303042914011, c[3] = -.176488924141685, c[4] = -.177377976537771, c[5] = -.171360759204415, c[6] = -.160967434973583, c[7] = -.147971797900332, c[8] = -.133702754001262, c[9] = -.118863260180314, c[10] = -.104015284296128, c[11] = -0.893367200861269e-1, c[12] = -0.750793728225821e-1, c[13] = -0.611862816909835e-1, c[14] = -0.478375133919584e-1, c[15] = -0.348219354414091e-1, c[16] = -0.224325517898647e-1, c[17] = -0.100584010716369e-1], 381334]

Digits,oldDigits := 50, Digits: # increase while computing residuals
eval(map(abs@(rhs-lhs),{seq(POL[v] = 0, v = 1 .. 2*N+2)}),KDS[3]);
max(%);
Digits:=oldDigits: # restore

{0.1316051275014097210203166431394540633767326e-6, 0.16567493632487175641503270951110534929791808e-5, 0.171097061896518610704916484686124009437803975e-5, 0.198878038317539469674371030654542948189175e-5, 0.32964708225449765391612205407049708511591347820180e-5, 0.36325879158394784567603910731688966263904716e-5, 0.3851725808084988897920578176631049809733860e-5, 0.49646464490371853392283541801202920785065812e-5, 0.60890892790904263948088460983886903976605094e-5, 0.70363623448832614626242257806259121617999511e-5, 0.76145203964341754818177628290243078038844310242149e-5, 0.775220502813178515830217832601841447079846880e-5, 0.8378161538157416400386574710947981123823915e-5, 0.89421177524876502276344954543452592001914342e-5, 0.98170124856628187641607136453197188863566653e-5, 0.1169758246855752838450333464927366109118322984e-4, 0.139246505864902482964045769873769916140840802e-4, 0.140778123350927219393406017802690733781604448e-4, 0.166109274878519454023120195435751265679363930e-4, 0.169876715052390473458298370703925749175976160e-4, 0.178668817360814463379014807453011108554767105e-4, 0.181820800297383253512272665858361286004395892e-4, 0.188899101375935002010945680746218503476038793e-4, 0.188975806447715851676183514546955494103967398e-4, 0.2733275740365502174280626102023360593676048e-4, 0.276044871350656030202679618781482069944118799e-4, 0.280773598773883973037295194373159810278793796e-4, 0.28993793439522313932850202406749385764519814155465e-4, 0.327506996541199330313883762041458294139131200e-4, 0.330175317111639870334269695379056703090550518e-4, 0.3464188663803647672938358802772720534951015360e-4, 0.492112160463829717048186171468347841390459201e-4, 0.526231401385384954271656833023762174041184407e-4, 0.573621915174304647320863872247580496407557314e-4, 0.648075220779544423555542611235192153856057008e-4, 0.82731962706244942095321358821961365091919244e-4}

0.82731962706244942095321358821961365091919244e-4

 


 

Download bigSys_dig15.mw

 

 

Try adding the option,

tickmarks=[piticks,default]

to your call to implicitplot.

You might also wish to force the full horizontal view from 0 to Pi/2, say by also adding the option.

view=[0..Pi/2,default]

 

Execute the statement,

randomize():

at the start of your worksheet.

Q:=Matrix(Q, datatype=float[8]);

or,

Q:=Matrix(5,5,(i,j)->simplify(Q[i,j],zero));

or several other variants.

Similarly,

H:=Vector(H,datatype=float[8]);

or,

H:=Vector(5,(j)->simplify(H[j],zero));

or variants. As you've seen in other message threads, small nonzero imaginary components can be handled with `fnormal`, before calling `simplify`. Or you can be more forcing and use the `Re` command. 

nb.Without running your code in Maple, your Matrix K looks purely real, symmetric, and your Matrix M looks purely real, symmetric, positive-definite. If so then the eigen-solution should have all-zero imaginary components.

Are you using an older version of Maple? If I recall then in recent Maple version the zero imaginary components of complex[8] rtables are suppressed on printing.

The fnormal command let's you replace small floating-point values with 0.0 or 0.0+0.0*I, etc. This command allows you to control the fineness, optionally. See its Help page.

As Kitonum has shown, the command simplify(expr, zero) removes the 0.0 occurences (real or imaginary) from the expression `expr`.

 

Are you looking for plots:-implicitplot3d, where its first argument might be f(x,y,z)=K for K numeric?

Let's try an example with more corrner cases in it.

Below I use uneval quotes (single right-quotes) because neither typefunc nor last_name_eval is a protected name.

restart;

eq := diff(x(t), t) = t + x(t) - 1 + sin(x(t))
      + cos(t) + G(t, x(t), v(t)):

indets(eq,{name,'typefunc(name,Non(last_name_eval))'});

                               {t, v(t), x(t)}

indets(eq,'typefunc(name,Non(last_name_eval))');

                                {v(t), x(t)}

indets(eq, {name, function(name)});

                           {t, cos(t), v(t), x(t)}

indets(eq,function(name));

                            {cos(t), v(t), x(t)}

How about handling F(t), where F is a user-defined procedure which returns unevaluated if its argument is not numeric? (Think of using the known option of dsolve/numeric, and other similar situations.) For unassigned argument t, calling F(t) returns the unevaluated function call F(t) itself.

Since F is a known procedure, which is already defined to compute an output number from an input number, then neither F nor F(t) is a "dependent variable" of the DE.

# In general F may be a black-box procedure, whose workings
# are not explicitly known.
F:=proc(u)
  if not type(u,numeric) then
    return 'procname'(u);
  else
    tan(u)+u^2;
  end if;
end proc:

F(t); # returns unevaluated for unassigned t

                                    F(t)

F(0.1); # returns a number. we won't "solve for F".

                                0.1103346721

eq2 := diff(x(t), t) = t + x(t) - 1 +  sin(x(t))
       + cos(t) + G(t, x(t), v(t)) + F(t):

indets(eq2,{name,'typefunc(name,Non(last_name_eval))'});

                               {t, v(t), x(t)}

indets(eq2,'typefunc(name,Non(last_name_eval))');

                                {v(t), x(t)}

indets(eq2, {name, function(name)});

                        {t, F(t), cos(t), v(t), x(t)}

indets(eq2,function(name));

                         {F(t), cos(t), v(t), x(t)}
First 204 205 206 207 208 209 210 Last Page 206 of 346