How about this,
That way you only rebind those trig functions and not all other operators which are redefined by the package.
Also, since this uses Units[Standard], other common symbols like R will be kept available.
If you don't wish to have to type in Unit(deg) then you might use the SI units palette. Or you could use command-completion to get the Unit() constructor. You could also have your input formatted at 2dmath, with the double-braces [] appearing around the unit symbols.
Team Lead, Mathematical Software, Maplesoft, Inc
Have you tried ssystem (starts with a double s) for getting the resulting test from a system call back to maple? Dave Linder Team Lead, Mathematical Software, Maplesoft, Inc.
You can remove units as follows, > F := sin(x)*Unit(m); F := sin(x) [m] > F_no_unit := convert(F, unit_free, 'F_unit'); F_no_unit := sin(x) > F_unit; [m] The usage above, with a 3rd parameter as a name like 'F_unit', allows you to retain the units that get removed. You could then plot F_no_unit and place F_unit in the plot's label or legend. Eg, > plot(F_no_unit,x=-6..6,labels=["",convert(op(F_unit),string)]); Dave Linder Team Lead, Mathematical Software, Maplesoft, Inc.
There may be two ways to get what you want. If you just want to re-form a single expression with units of N/mm instead of kg/s^2, then you can use the context-menu. Eg, > Unit(kg/s^2); and follow the menu Units -> Replace Unit and type in N/mm in the pop-up box. In worksheet mode the above produces the following, with its output, > convert( combine( Unit(kg/s^2), 'units'), 'units', N/mm); If you wish the dimension of, > convert(kg/s^2,dimensions); surface_energy_density to be displayed in general as N/mm then you can add a new system which you create as a modification of the SI system. > Units:-AddSystem(mySI,Units:-GetSystem(SI),N/mm); > Units:-UseSystem(mySI); At this point the following should appear with units N/mm, > 4*Unit(kg/s^2); > 4*Unit(mg/s^2); Dave Linder Team Lead, Mathematical Software, Maplesoft, Inc.
There is a known issue with Optimization on objectives
for which a numeric gradient is not immediately available.
We are investigating this issue. The problem arises when
the external solver tries to numerically compute either
the gradient of the objective (or the jacobian of the
This comes up in your example, where the objective is
supplied in "procedural" form. It may be possible to work
around the issue by supplying a gradient function to
the NLPSolve command. I include an example below. If you
had supplied the objective as an expression which Maple
itself could produce partial derivatives for, then the
issue should not appear. It's understood though that you
are working towards using a more involved "black box"
objective in some Matlab sources.
The issue does not seem to appear when using the GlobalSolve
routine from the GlobalOptimization toolbox, where the
solver does not rely on numerical derivatives.
There are some methods available to NLPSolve in Maple 10
which also do not rely on numeric deriatives and hence which
also do not run into the problem I described, for example
when one supplies the method=nonlinearsimplex option. But
that method is only for problems supplied without bounds,
which does not fit your example. (Perhaps you tried this,
without bounds, when getting the result outside of 0..1,0..1?)
> mat2map5 := proc (a, b) local Res, res;
> Matlab:-setvar("a", a);
> Matlab:-setvar("b", b);
> Matlab:-evalM("result = mat2map6(a,b)");
> Res := (Matlab:-getvar)("result");
> res := convert(Res, float);
> return res
> end proc:
# Test it.
> mat2map5(5, 3);
# Sometimes we see a "no iterations performed" warning.
# That is related to known issues with the internal
# numeric calculation of derivatives.
# NB. I have never seen it return results outside the
# specified range.
> Optimization:-NLPSolve(mat2map5, 0..1, 0..1);
Warning, no iterations performed
[0.500000000000000000, [ ]]
# We can construct a numeric gradient function ourselves,
# to help out the solver. We could do this in a variety
# or ways (see comments in the proc).
> mat2map5grad := proc( V, G )
> global mat2map5;
> local x,y;
> G := fdiff('mat2map5'(x,y),x,[x=V,y=V]);
> G := fdiff('mat2map5'(x,y),y,[x=V,y=V]);
> # Or we could express it explicitly, given mat2map6.
> # Or, we could call to Matlab to get the partials
> # via another Matlab .m function...
> return NULL;
> end proc:
> Optimization:-NLPSolve(mat2map5, 0..1, 0..1,
[0., [ ]]
Let us know if this sort of modification helps.
Team Lead, Mathematical Software, Maplesoft, Inc.