8 years, 300 days

These are answers submitted by acer


13 hours ago acer 10006
0 0

It is described in the second bullet point of the Description section of the help-page dsolve,numeric,bvp .



July 23 2014 acer 10006
0 1

Your T is an operator with only two parameters, which returns a list with only 2 entries. But the 3D plot has three components. So what do you expect the transformation to do?

Try a transformation that accepts three parameters and returns a list of three components. You'll have to figure out what you want it to actually do, of course. ("back-transform" doesn't mean anything special, to me...)

For example, this produces a transformed 3D plot. Whether it is the transformation you intend is for you to decide, naturally.

T3 := plottools[transform]((s, u, z) -> [piecewise(s <= a_1, 1000000*K*s,
                                                   1000000*a_0+1000000*g*(s-a_1)), u, z]):

plots:-display( T3(pic) );



July 23 2014 acer 10006
1 1

If you replace `solve` by `eliminate` and assign the result to `sols` then sols[1] will contain expressions for T and n in terms of del and p.

Unfortunately the results appear to be the roots of a polynomial which don't factor explicitly for unknown del and p (and not even for some explicit values of same). Note that the problem might be math, not Maple, as there are no general explicit formula for roots of polynomials higher than 5.

If you leave e,f,ep, and q all unassigned then it is actually easier for Maple to do and the result are an implicit RootOf of a 7th degree polynomial for both T and n. Similarly if you assign those float values to e,f,ep, and q but wrap the set of equations to be solved in a call to convert(...,rational). If you try to do it using the float values then the result seems to contain implicit RootOfs involving a 15th degree polynomial.

It may interest you that the 7th degree polynomial will have at least one real root pair T and n, for each purely real pair of inputs del and p. But I don't see how to get an explicit formula for that.

Perhaps this is an appropriate moment to ask what you intended on doing with an explicit pair of formulas for T and n, if you had them. Suppose that you had the explicit closed formulas in terms of dep and p, and they were each ten thousand pages long. What would you do with them that you could not do with a black-box procedure that -- given any numeric values as input for parameters del and p -- computed all real roots in terms of T and n?



July 22 2014 acer 10006
0 6

NLPSolve is having difficulty figuring out what are the variables over which to optimize.

Try is as,

NLPSolve(1/(n^3*(F0*F1-F1)), tau1 = 115 .. 201, tau2 = 237 .. 273, variables=[tau1,tau2]);

           [                       -8                            ]
           [-3.15130715961255079 10  , [tau1 = 158., tau2 = 255.]]

But that doesn't seem right, as a result, considering what the 3D plot looks like over that range.

Better seems,

NLPSolve(subs(int=Int,1/(n^3*(F0*F1-F1))), tau1 = 115 .. 201, tau2 = 237 .. 273, variables=[tau1,tau2]);

                 [                                   -8   
                 [-3.18004616322786483130789361569 10  , [

                   tau1 = 201.000000000000000000000000000, 

                   tau2 = 273.000000000000000000000000000]]


Tasks, Student:-Precalculus

July 21 2014 acer 10006
0 0

Have a look through the Tasks, such as those in the subsection for Algebra. See the Table of Contents (left side panel) of the Help system (in your installed Maple, or online here and here) and look for the section called Tasks. (If you need help on using and inserting content from those Tasks then also see here.)

Perhaps also have a look at the visualization commands in the Student:-Precalculus package.

If you're a student and new to Maple, you might also wish to look here.

There are also some Math Apps that cover a bit of what you mentioned. Perhaps see here, and here.



July 21 2014 acer 10006
1 0

So, are you just wondering about the formats for floats that printf supports?

If all your output intended for export is going to be produced in such a way that you might use fprintf rather than printf and writeto.

The printf command accepts HFloats just as it accepts "software floats", as input for its supported float formats. No need to convert it first, if I am understanding your question.

For example,


printf("x=%.3f\n", x);

printf("x=%.3e\n", x);

printf("x=%.3g\n", x);

printf("x=%Y\n", x);


hue? or custom shading?

July 20 2014 acer 10006
2 1

If you wish for hue or more easily customizable piecewise-linearly-interpolated shading schemes then you might want to consider the 2-dimensional output from plots:-surfdata that are possible with Maple 18. That is the result R in the code below.

It also gives a more smoothly interpolated default color rendering (for a hue scheme, at least).

Apart from comments in the code below, I could also mention that plots:-densityplot might be also be used to get a hue shading scheme (possibly by constructing a procedure which floored x and y arguments and returned the appropriate Matrix entry values).

And, unlike plots:-listdensityplot, the plots:-densityplot command allows more control over the end-values via its restricttoranges option. But this is also easily handled by including or omitting an offset as in the code below for calling plots:-surfdata.

And you can also quite easily make plots:-surfdata use your own customized piecewise linearly interpolated color scheme in Maple 18. So alternatively you could easily have it shade from orange through white to green, etc. (You can get plots:-densityplot to produce the same effect, but it's more effort to set up.)

NB. The 3D surfdata plot looks much better in the Maple GUI than it does inlined below. But even in the GUI the hue scheme is not a good match at one extreme. And the 2D surfdata plot also looks cleaner and smoother in the Maple 18 Std GUI than it does inlined below.


with(plots): with(plottools):


M:=Matrix(N,N,(i,j)->evalhf(sin(i*2*Pi/N)*(j-N/2)), datatype=float[8]):

# By default, listdensityplot has tickmarks aligned with the middle
# or Matrix column- or row-values

A:=listdensityplot(M, colorstyle=HUE, thickness=0, style=surface):

# 2D coordinate transformation of above plot A

f:=transform( (x,y)->[2*x+1,y-3] ):
T:=display(f(A), axes=frame, gridlines=false):

#display(Array([A, T]));

# 3-dimensionsional, with forced orientation.
# Note the 3D zhue shading goes from magenta to red, thus not a true match!
# Offsets of 0.5 are used, to get same mid-point alignment.
# Note the color interpolation during rendering, smoother than above.


CL:=plots:-surfdata(-M, a..b, c..d, shading=zhue, style=patchnogrid,
                    orientation=[-90,0,0], lightmodel=none):

# 2-dimensionsional (Maple 18), producing a densityplot structure,
# but with finer control over the color shading.
# Note that this scheme hits red at both extremes, 0 and 1, matching
# listdensityplot HUE shading.
# Same offsets of 0.5 as above are used.
# Note the smoother color interpolation during rendering.



R:=plots:-surfdata(-M, a..b, c..d, dimension=2, axes=frame, style=patchnogrid,

#display(Array([T, R, CL]));





July 11 2014 acer 10006
2 2

Below I replace sum by Sum, scale up h by a factor of 10^1560, and increase the working precision. A result near 15.7 then comes out pretty quickly.


f := (a, b, k) -> (Sum(exp(-x)*x^m/(m!), m = a .. b))^k:

h := f(0,0,82)*f(1,3,49)*f(4,6,47)*f(7,10,47)*f(11,15,57)*f(16,20,40)

     if not type(X,numeric) then
       return 'procname'(args);
     end if;
end proc:

#plot(H(x,2000), x=14..18);


               [                   5                        ]
               [6.96925226027268 10 , [x = 15.6881165583629]]



July 08 2014 acer 10006
2 1

The problem is your use of `sum`.

The `plot` command is receiving the result of subs(M=11,f(t)) which is expensive to compute (it is not evalhf'able). Issue the command,


to see what you were actually passing to `plot`.

So you have been hit by premature evaluation, where f(t) is evaluated as normal as part of an expression passed as the first argument to `plot`.

The problem for this example is not that Maple attempts symbolic summation for each new numeric value of `t` to be plotted (which Axel may have surmised). That situation is also quite common, and the symptoms and fix are often the same. But, technically, in this example the problem is that the initial symbolic summation succeeds and produces an expression which subsequently evaluates expensively at numeric values of `t`.

There are several alternatives, including,

# Use the inert `Sum`

# Pass M as an extra argument to `f`.
# Here single (uneval) right-quotes around the call to `f`
# delay evaluation.

# A variant of the above (fast as long as numeric M is "small enough" for
# `sum` to dispatch to `add` rather than try symbolic summation.
# Here again quotes delay the evaluation of `f`.

# A variant of the first above, with `f` accepting 2 args and not using `subs`.
# Since the inert form `Sum` is used evaluation needn't be delayed.
# This is the one that Axel showed.



July 07 2014 acer 10006
1 1

Do you want B_interp(N,M) to returned unevaluated if N and M are not both numeric?

B_interp := proc(W,T)
   if not ( type(W,numeric) and type(T,numeric) ) then
      return 'procname'(args);
                                       Array(1 .. 1, 1 .. 1, 1 .. 2, [[[W, T]]]),
   end if;
end proc:

In such a way, you should be able to construction an expression containing B_interp(N,M) where N and M are still symbols. But you could later evaluate that expression with numeric values for M and N. Eg,

  expr := ... + B_interp(N,M) + ...
  eval( expr, [N=5.4, M=3.2,...] );

Or you could `unapply` your expression with respect to M,N,etc.



July 07 2014 acer 10006
0 3

What do you expect to get, by asling for the Jacobian of a scalar valued expression such as your obj??

Are you perhaps thinking instead of the Gradient? So your end goal is the Hessian? The Jacobian of the gradient?

Why not use the Hessian command directly, if that's what you're after?

So, after defining obj and loading Student:-VectorCalculus, either,




including any extra arguments wanted.

What kind of result are you hoping for, for this particular example though?



July 05 2014 acer 10006
0 6

If you are trying to find the general form of the eigenvectors (as columns of your `NewMatrix3`) of the Matrix of data in your `NewInput3` then your methodology looks suspect.

I do not see how your general equation,

{seq(seq((NewMatrix3 . NewInput3(1..-1,i))[j]=(v[i]* NewInput3(1..-1,i))[j], j=1..3), i=1..3)}

properly represents the definition

A . X[i] = lambda[i] . X[i]

where NewInput3 = A is the data, NewMatrix3[..,i] = X[i] is the ith eigenvector, and v[i] = lambda[i] is the ith eigenvalue. Using those equivalences then shouldn't you instead have,

NewInput3 . NewMatrix3[..,i] = v[i] . NewMatrix3[..,i]


As for how LinearAlgebra:-Eigenvectors does it for a Matrix A of exact rational data, the rough answer is that it first finds the eigenvalues. And then for each eigenvalue v[i] it evaluates the characteristic Matrix A-lambda*Id at lambda=v[i] and then computes the nullspace (kernel) of that.

For floating-point data the eigen-solving is passed to a LAPACK function. If you have float data then you might want to consider letting Maple use the fact that NewInput3 = InputMatrix3^%T . InputMatrix3 is symmetric. In the case of float data that will allow Maple to produce purely real results with no very small imaginary (numerical roundoff) artefacts. Ie,

NewInput3 := Matrix( InputMatrix3^%T . InputMatrix3, shape=symmetric );

Or you could consider squaring the singular values of InputMatrix3, and taking care for the ordering. Consider,


InputMatrix3 := Matrix([[31.25,30.8,30.5],[30.8,30.5,0],[30.5,0,0]]):

map(t->t^2, SingularValues(InputMatrix3));

                             [                ]
                             [                ]

Eigenvalues(Matrix(InputMatrix3^%T . InputMatrix3, shape=symmetric));

                             [                ]
                             [                ]

Eigenvalues(InputMatrix3^%T . InputMatrix3);

                          [4789.06261226748 + 0. I]
                          [                       ]
                          [591.210617040192 + 0. I]
                          [                       ]
                          [284.319270692331 + 0. I]


G := Matrix(InputMatrix3^%T . InputMatrix3, shape=symmetric):


                                  [                ]
                         evals := [591.210617040193]
                                  [                ]

seq( NullSpace(CharacteristicMatrix(G,evals[i])), i=1..3 );

     /[ 0.326650403460829]\    /[-0.588317874678543]\    /[0.739717238039373]\ 
     |[                  ]|    |[                  ]|    |[                 ]| 
    < [-0.737693385300777] >, < [ 0.330570994334320] >, < [0.588669081053437] >
     |[                  ]|    |[                  ]|    |[                 ]| 
     \[ 0.590853605559242]/    \[ 0.737973506325627]/    \[0.326017055932820]/ 


   [284.319270692331]  [-0.326650403460830  -0.588317874678544  0.739717238039373]
   [                ]  [                                                         ]
   [591.210617040193], [ 0.737693385300778   0.330570994334321  0.588669081053437]
   [                ]  [                                                         ]
   [4789.06261226748]  [-0.590853605559242   0.737973506325627  0.326017055932820]

For exact data Maple will compute the nullspace by solving the linear system with the zero-Vector as the right hand side. For floats it will use... (wait for it..), the full SVD.

Why do you want to do it all by hand?


root directory

July 02 2014 acer 10006
0 1

Did you intend a separator in front of "Users", so that it was fully qualified as a file location?

Ie, "/Users/..."

If you don't, then it'll try to use a location relative to whatever the Maple command `currentdir()` returns. So, with your original syntax it might possibly have succeeded and produced a file with some odd long name.


Embedded Components

June 27 2014 acer 10006
2 6

The distinction is mostly between interative applications written with Maplets and those written with Embedded Components.

The Math Apps are examples of the latter, as are the Mobius Apps. The last few releases of Maple have included a growing number of such Math Apps, as featured items (see here and here).

Embedded components reside in a .mw Worksheet or Document. These kinds of apps can also be run interactively in the free Maple Player, as well as in the Maple Standard GUI. And these kinds of worksheet apps done with embedded components have been placed on both the regular and the Mobius Cloud. The Explore command produces a kind of inlined worksheet interative application done with embedded components, and this recent Appclication Center item contains notes on how it was built using Explore.

Andt Maple TA now supports facilities for an instructor/app-author to set certain states of embedded components within a worksheet as being gradeable. See here, perhaps.



June 27 2014 acer 10006
0 15

It's not clear to me whether you are trying to solve the question you asked, or some related multiobjective optimization method.

I'll try to address what you wrote in the original question, but replacing `Max` with `max`.

(Was that your only issue? That you used `Max` which means nothing to Maple...)

It looks as if `penalty` has a minimum of 0, which it attains over a triangular region. Did you have some additional weighting with which to adjust the objective, in order say to force a unique minimum?

Or were you trying to solve some other question (ie. not that `penalty`, and with g1,g2,g3 as constraints, etc)?

The result of using the objective as originally posed, after replacing Max by max, doesn't look like a sensible result if you actually wished to minimize f1 and f2 together somehow, in some multiobjective sense. Both your suggested result and the one Markiyan obtained from DirectSearch look better on that query not explicitly asked (though perhaps implied by the paper citation), with both results unsurprisingly on the upper edge of the triangle. Does the paper claim that penalty should lead to a pareto minimum?



f1 := -2*x1 - x2:

f2 := -x1 - 4*x2:

g1 := 2*x1 + 3*x2 - 6:

g2 := -x1:

g3 := -x2:

penalty := lambda1*max(f1-M,0) + lambda2*max(f2-M,0)
           + (M^2)*(max(g1,0) + max(g2,0) + max(g3,0)):

k := 1:

s := 1:

obj := eval(penalty,[lambda2=0.5,lambda1=0.5,M=1]);

ans := Minimize(obj,x1=-10..9,x2=-10..9);

       obj := 0.5 max(0, -2 x1 - x2 - 1) + 0.5 max(0, -x1 - 4 x2 - 1)

          + max(0, 2 x1 + 3 x2 - 6) + max(0, -x1) + max(0, -x2)

        ans := [0., [x1 = 0.266505412954423, x2 = 0.573107578136192]]


              [x1 = 0.266505412954423, x2 = 0.573107578136192]

eval(f1,ans[2]), eval(f2,ans[2]);

                    -1.10611840404504, -2.55893572549919

## There are several ways to find see region where `penalty`=0 (its minimum).


#                    gridrefine=3,view=[-1..4,-1..3]);

sol := solve(convert(obj,rational));

                   /                                   2       \
           sol := { 0 <= x1, 0 <= x2, x1 <= 3, x2 <= - - x1 + 2 }
                   \                                   3       /

# Your suggested value also lies on the edge of that region.
eval( x2<=-2/3*x1+2, [x1 = 1.551123, x2 = 0.965918] );

                           0.965918 <= 0.965918000

  plots:-pointplot([[1.551123, 0.965918]],symbol=solidcircle,





1 2 3 4 5 6 7 Last Page 1 of 97