acer

32343 Reputation

29 Badges

19 years, 326 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

To emulate the general effect of Matlab's parfor you could look at Threads:-Seq (if the statements are thread-safe) or Grid:-Seq.

Since the syntax for parfor is like a that of a do-loop you might have to use a procedure in the Seq call, if you're trying to get the effect of multiple statements.

One can compare also with:

restart;
solve({x^3+x*a+2 > 0}, x, parametric);

{            3
{ [[RootOf(_Z  + _Z a + 2, index = real[3]) < x],
              3
    [RootOf(_Z  + _Z a + 2, index = real[1]) < x,
                  3
     x < RootOf(_Z  + _Z a + 2, index = real[2])]] , a < -3

    [[1 < x], [-2 < x, x < 1]] , a = -3
               3
    [[RootOf(_Z  + _Z a + 2, index = real[1]) < x]] , -3 < a
However...
restart; solve({x^3+x*a+2 > 0, a>-3}, x);

                             1/3              1/3
                           %1        a      %1        a
                      {x < ----- - -----}, {----- - ----- < x}
                             3       1/3      3       1/3
                                   %1               %1

                                              3      1/2
                            %1 := -27 + 3 (3 a  + 81)

restart; solve({x^3+x*a+2 > 0, a<-3}, x);

                             1/3              1/3
                           %1        a      %1        a
                      {x < ----- - -----}, {----- - ----- < x}
                             3       1/3      3       1/3
                                   %1               %1

                                              3      1/2
                            %1 := -27 + 3 (3 a  + 81)

So you originally called `define_external` with typed declarations for each of the arguments, instead of that `MAPLE` keyword argument? And then you edited the resulting generated C file?

You could try the same thing but in that preliminary call to `define_external` wrap REF(...) around the type for the `a3` parameter. Then compare with what you got before, and edit. (The auto-generated C code would declare both an ALGEB and a FLOAT64 variable associated with `a3` I think.)

I've done exactly the thing you want myself in the past, but I won't be able to look at the old files I had until Monday.

In such a scenario you would end up making the following call from Maple like,

  mult( 2., 3., 'mult1' );

using single-right (unevaluation) quotes.

 

I created this worksheet in Maple 16.02. Hopefully I have properly understood your goals.

restart;

xst := -1.0: xfn := 1.0: yst := -1.0: yfn := 1.0:

myfn := proc (x::numeric, y::numeric)

  local output;
  output := 5.0*x^2+y^2

end proc:

# If we had a way to obtain the z-value for any arbitrary (x,y)
# data point then we could use the `contourplot` command.
# We can even pass that command a `grid` option, to compute as
# fine a grid of z-values as we wish.
#
# The assumption is that this is not available to us. So the plot
# below is akin to an ideal, to which we may compare later plots.

plots:-contourplot(  myfn, xst .. xfn, yst .. yfn
                   , contours = [0.1, 0.5, 1.0, 1.5, 2.0]
                   , filledregions
                   , coloring=["Blue","Orange"]
                   , view=[xst..xfn, yst..yfn]
                  );

# The `Output` Array below contains the supplied data.
#
# The presumption is that this amount of discrete data is supplied
# by some black-box mechanism, and that we do not have the luxury of
# querying it for additional data. (If we could, then we'd just use
# the `contourplot` command on a procedure that could query that
# other process for any arbitary (x,y) point-pair.
#
# The formulas being used here convert any `i` and `j` integer index of
# the Array and turn those into corresponding `x` and `y` values within
# the ranges xst..xfn and yst..yfn.
#
# This step is emulating the black-box process by which the data
# is "given" to us (just the once). So the translated `x` and `y` values
# are used to compute the finite grid of discrete z-values.

a,b,c,d := -7,8,-5,6: # Or -10..10 and -10..10 or whatever you have.
Output := Array(a..b, c..d,
                (i, j) -> 5.0*(xst+(xfn-xst)*(i-a)/(b-a))^2
                          + (yst+(yfn-yst)*(j-c)/(d-c))^2):

# We can use the `listcontplot` command to produce a contour plot from
# the `Output` Array. Furthermore, we can use the `transform` command to
# turn the `listcontplot` axes (based on the integer Array indices) axes
# that correspond to the desired `x` and `y` ranges.

plottools:-transform((x,y)->[xst+(xfn-xst)*(x-1)/(b-a),
                             yst+(yfn-yst)*(y-1)/(d-c)])(
  plots:-listcontplot(  convert(Output,listlist)
                      , contours=[0.1, 0.5, 1.0, 1.5, 2.0]
                      , filledregions
                      , coloring=["Blue","Orange"]
                      , view=[xst..xfn, yst..yfn]
                     )
                    );

# The above plot is not very smooth, because we had only a small
# number of dicrete data points available.
#
# Now let's try and get smoother contours, by interpolating the
# supplied discrete data.
#
# We can use the CurveFitting:-ArrayInterpolation command for this.

newa,newb,newc,newd := 4*a,4*b,4*c,4*d;

-28, 32, -20, 24

# These are the original x and y points represented by
# the entries of Output.

xInput := Array(a .. b,
               (i)->xst+(xfn-xst)*(i-a)/(b-a),
               datatype=float[8]):
yInput := Array(c .. d,
               (i)->yst+(yfn-yst)*(i-c)/(d-c),
               datatype=float[8]):

# These are the new x and y points, at which
# we want to compute interpolated values.

newxInput := Array(newa .. newb,
                  (i)->xst+(xfn-xst)*(i-newa)/(newb-newa),
                  datatype=float[8]):

newyInput := Array(newc .. newd,
                  (i)->yst+(yfn-yst)*(i-newc)/(newd-newc),
                  datatype=float[8]):

newOutput := CurveFitting:-ArrayInterpolation(
               [Vector(xInput),Vector(yInput)],
               Array(Output,datatype=float[8]),
               Array(newa..newb,newc..newd,1..2,
                     (i,j,k)->`if`(k=1,newxInput[i],newyInput[j]),
                     datatype=float[8]),
               method=spline):

ArrayTools:-Dimensions(newOutput);

[-28 .. 32, -20 .. 24]

# The contours using the interpolated data (refinement getting
# us more discrete data points that we were originally supplied)
# now appear smoother. Magic.

plottools:-transform((x,y)->[xst+(xfn-xst)*(x-1)/(newb-newa),
                             yst+(yfn-yst)*(y-1)/(newd-newc)])(
  plots:-listcontplot(  convert(newOutput,listlist)
                      , contours=[0.1, 0.5, 1.0, 1.5, 2.0]
                      , filledregions
                      , coloring=["Blue","Orange"]
                      , view=[xst..xfn, yst..yfn]
                     )
                    );

# If we want to get really fancy then we can even build any interpolating
# procedure, which accepts any arbitrary (x,y) point-pair as arguments.
# It will interpolate the corrsponding z-value, from the original coarse data.

F := (x,y) -> CurveFitting:-ArrayInterpolation(
               [Vector(xInput),Vector(yInput)],
               Array(Output,datatype=float[8]),
               Array(1..1, 1..1, 1..2, [[[x,y]]],
                     datatype=float[8]),
               method=spline)[1,1]:

# We now have a procedure, F, which interpolates the original coarse data
# at arbitary (x,y) points. So, even though we aknowledged that we could not
# query the original black-box process to obtain arbirary new data values,
# we have in effect produced something which emulates that by interpolation.
# Magic.

plots:-contourplot(  F, xst .. xfn, yst .. yfn
                   , contours = [0.1, 0.5, 1.0, 1.5, 2.0]
                   , filledregions
                   , coloring=["Blue","Orange"]
                   , view=[xst..xfn, yst..yfn]
                  );

 


Download m16_listcont.mw

You could try using the inert Sum command rather than the active (lowercase) sum command.

Otherwise calling f(x) will return the symbolic summation result of x*cos(x).

restart

f := proc (x) options operator, arrow; Sum((-1)^n*x^(2*n+1)/factorial(2*n), n = 0 .. infinity) end proc

proc (x) options operator, arrow; Sum((-1)^n*x^(2*n+1)/factorial(2*n), n = 0 .. infinity) end proc

D(f)

proc (x) options operator, arrow; Sum((-1)^n*x^(2*n+1)*(2*n+1)/(x*factorial(2*n)), n = 0 .. infinity) end proc

diff(f(x), x)

Sum((-1)^n*x^(2*n+1)*(2*n+1)/(x*factorial(2*n)), n = 0 .. infinity)

diff(f(x), x)

Sum((-1)^n*x^(2*n+1)*(2*n+1)/(x*factorial(2*n)), n = 0 .. infinity)

simplify(%)

Sum((-1)^n*x^(2*n)*(2*n+1)/factorial(2*n), n = 0 .. infinity)

value(f(x))

cos(x)*x

f := proc (x) options operator, arrow; Sum((-1)^n*x^(2*n+1)/factorial(2*n), n = 0 .. infinity) end proc

proc (x) options operator, arrow; Sum((-1)^n*x^(2*n+1)/factorial(2*n), n = 0 .. infinity) end proc

f(x)

Sum((-1)^n*x^(2*n+1)/factorial(2*n), n = 0 .. infinity)

value(f(x))

cos(x)*x

``


Download Sum_vs_sum.mw

The Expression palette only has the active form sum (which displays with a black typeset Sigma as a visual cue). But you can get the inert form Sum in 2D Input (which displays with a gray typeset Sigma) by using command-completion after typing just the letters of "Sum" in 2D Input mode. Then choose the template from the drop-menu that appears.

You wrote that you want "3 decimals".

Do you mean that you want 3 digits in total, or do you mean that you want 3 digits to the right of the decimal point?

I'm going to guess that you want 3 digits to the right of the decimal place, throughout. In that case you can issue this statement, after the call to the Import command.

BTE := map(u->parse(sprintf("%.3f",u)),
           Matrix(BTE, datatype = anything)):

Your goal is not unusual, but the ways in which you've attempted to do this so far are a little unusual.

I'll show you how you can get it to work using a worksheet to build the whole module, and using the read command to get the individual command into that module. But please read the end, where I state what I consider to be a better methodology.

Your .mpl file starts out as a plaintext file. It's your canonical source for the procedure. Assemble the module by using that plaintext source. Leave out trying to use savelib or save, and don't do this:
  save(Rtest, "Rtest.mpl");

Indeed, I can think of no good scenario in which using the save command is useful or most appropriate for this task.

I'll use the same plaintext file in one of your Comments. It contains just this:

Rtest:=proc()
  print("this is a test");
end proc;

Note that when you use the read command it assigns to the global name Rtest rather than the module export instance of that name.

Here is a worksheet in which that methodology can be salvaged.

restart;

currentdir(cat(kernelopts(homedir),"/ronan")):

read "Rtest.mpl";

# The global name Rtest has been assigned. Test it.
:-Rtest();

proc () print("this is a test") end proc

"this is a test"

Rtestm:=module()
  option package;
  export Rtest;

  # Assign the value (previously assigned to the
  # global name, to the module export.
  Rtest := eval(:-Rtest);

end module;

_m140008823023424

# Test it using the long form.
Rtestm:-Rtest();

"this is a test"

# Load the package (which rebinds the name).
with(Rtestm);

[Rtest]

# Test it.
Rtest();

"this is a test"

 


Download ronan_method1.mw

As you can see above, the process is now in two parts. The read call causes assignment to the global name, and the module definition makes an assignment to the export's name (by copying the value assigned to the global name).

Note: It's conceivable that your individual procedure had been previously stored to a .mla Maple Library Archive. I consider it far better to use the original source instead for building the module. But if you really, really want to use the instance of it from the .mla (instead of from the plaintext source file) then 1) you don't need to use the read command, and 2) you'll still need to use eval to assign the actual procedure to the module export/local.

Now here is a better way, IMO. It uses a plaintext source file for the module definition, as well as for the individual procedure(s) which form its exports or locals. It uses the $include directive rather than the read command. Here is the contents of that plaintext file:

Rtestm:=module()
  option package;
  export Rtest;

$include "Rtest.mpl"

end module;

And here is a worksheet that can read in that module definition.

restart;

currentdir(cat(kernelopts(homedir),"/ronan")):

read "Rtestm.mpl";

_m139750548981792

Rtestm:-Rtest();

"this is a test"

with(Rtestm);

[Rtest]

Rtest();

"this is a test"

 


Download ronan_method2.mw

I claim that this is a better way for a few reasons.

1) You didn't run into this problem with the read approach because of its simplicity, but if you have multiple module locals and exports which call each other then "fixing" the locals/exports with global name assignments can become highly problematic.

2) All your source code is now in plaintext files, which can be managed with revision control applications, and are also far more robust with regard to corruption.

3) you can use the external mint program (shipped with Maple) against the whole procedure at once. Eg, from your build worksheet, something like  ssystem("mint Rtestm.mpl"); 

So you should now be able to build your module from source. And in the same session (or worksheet if you wish) in which you've built/defined your module you can store the module in a .mla Maple Library Archive using the LibraryTools:-Create and LibraryTools:-Save commands. (IMO those are far less error prone for non-experts than is the savelib command.)

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

`&Delta;w` := colorize(':-`&Delta;w`', black)

sqrt(`&Delta;w`)

`#mi("\`&Delta;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 

First 193 194 195 196 197 198 199 Last Page 195 of 336