Maple 2016 Questions and Posts

These are Posts and Questions associated with the product, Maple 2016

The first example is very slow compared to the second.  The difference is in the definition of f().

restart;
y := int(1/(-0.4016e-1*m^(2/3)-0.211e-3*m^(5/3)), m);
f:= unapply(abs(y), m):
n := 500: ## sample size
M := <seq(2*idx/n,idx=1..n)>; ## m
Y := f~(M)+~Statistics:-Sample(Normal(0,3), n)^+; ## signal + noise

restart;
y := int(1/(-0.4016e-1*m^(2/3)-0.211e-3*m^(5/3)), m);
f:= (x) -> abs(subs(m=x,y));
n := 500: ## sample size
M := <seq(2*idx/n,idx=1..n)>; ## m
Y := f~(M)+~Statistics:-Sample(Normal(0,3), n)^+; ## signal + noise


The code below projects a torus illuminated by a point light source located at the origin onto an ellipsoid as the torus's centre moves along the x axis from [-0.8,0,0] to [0.8,0,0].

Ellipsoid := (1/32)*x^2+(1/18)*y^2+(1/12)*z^2 = 1:
EllipsoidTitle := Typesetting:-Typeset((1/32)*x^2+(1/18)*y^2+(1/12)*z^2 = 1):
DispEllipsoid := implicitplot3d(Ellipsoid, x = -10 .. 10, y = -10 .. 10, z = 1.25 .. 5, style = surface, color = yellow, grid = [30, 30, 30]):
TorusVorig := Vector([(1+.25*cos(v))*cos(u), (1+.25*cos(v))*sin(u), .6+.25*sin(v)]):

i := 0;

for x from -.8 by .1 to .81 do

i := i+1;

TorusV := `<,>`(x, 0, 0)+TorusVorig:

DispTorusV := plot3d(TorusV, u = 0 .. 2*Pi, v = 0 .. 2*Pi, shading = xyz):

NormTorusV := Normalize(TorusV, Euclidean):

Vadj := solve((1/32)*w^2*NormTorusV[1]^2+(1/18)*w^2*NormTorusV[2]^2+(1/12)*w^2*NormTorusV[3]^2 = 1, w):

if evalf(eval(Vadj[1]*NormTorusV[3], [u = Pi, v = Pi])) > 0 then

DispTorusVproj := plot3d(Vadj[1]*NormTorusV, u = 0 .. 2*Pi, v = 0 .. 2*Pi):

else

DispTorusVproj := plot3d(Vadj[2]*NormTorusV, u = 0 .. 2*Pi, v = 0 .. 2*Pi):

end if:

Disp[i] := display(DispTorusV, DispEllipsoid, DispTorusVproj, view = [-10 .. 10, -10 .. 10, 0 .. 5], scaling = constrained, Plot3Daxes, title = typeset("Project %1 onto %2 from a light at the origin", TorusV, EllipsoidTitle), titlefont = [Courier, bold, 14]):

end do:

display(seq(Disp[j], j = 1 .. i), insequence = true);

How can I plot the unmoving torus centred on the z axis projected onto the ellipsoid illuminated by a point light source moving on the x axis from [-0.8,0,0] to [0.8,0,0]?

Is there an elegant way to plot a surface with three given parameters, such as
x=(5+w\cos v)\cos u, y=(5+w\cos v)\sin u, z=w\sin v

with u,v between 0 and 2Pi and w between 0 and 3?

I would like the C-Text style in 14pt Times Roman while the C-2D-Math style is 12pt.

My use case is that I am typing in a single execution block.

I use Format >> Styles and select the style for C-Text and set it to 14pt Times. I click OK to close the dialog. Next I repeat this for the C-2D-Math style but this time set the font size to 12pt and, for testing, the colour to blue. The effect is to give me 14pt Times for both styles, though the C-text is black and the 2-D-Math is blue.

Can the effect I want be achieved, or is this a bug/feature?

This is Maple 2016.1 on Windows 10 64bit

 Thanks for any help

With a somewhat complicated equation for a line, draw fails.

with(geometry):

point(P1,[47+(38+22/60)/60, -(122+(43+4/60)/60)]);
point(P2,coordinates(P1) +~ [cos(30*Pi/180),sin(30*Pi/180)]);
line(L1,[P1,P2]);
Equation(L1);
draw(L1); ## no line

point(P1,[0,0]);
point(P2,[7,9]);
line(L1,[P1,P2]);
draw(L1);  ## works

Tom Dean

I have been working on a general solution to motion analysis and seem to be going backwards.  I have an numerical solution in Octave I use for comparison.  I have reduced the problem to a small example that exhibits the problem.

I posted a question similar to this, but, without a set of known values.

I am doing something wrong, but, what?

Tom Dean

## bearing.mpl, solve the target motion problem with bearings only.
##
## Consider a sensor platform moving through points (x,y) at times
## t[1..4] with the target bearings, Brg[1..4] taken at times t[1..4]
## with the target proceeding along a constant course and speed.
##
## time t, bearing line slope m, sensor position (x,y) are known
## values.
##
## Since this is a generated problem the target position at time t is
## provided to compare with the results.
##
#########################################################################
##
restart;
##
genKnownValues := proc()
    description "set the known values",
    "t - relative time",
    "x - sensor x location at time t[i]",
    "y - sensor y location at time t[i]",
    "m - slope of the bearing lines at time t[i]",
    "tgtPosit - target position at time t[i]";
    global t, m, x, y, tgtPosit;
    local dt, Cse, Spd, Brg, A, B, C, R, X;
    local tgtX, tgtY, tgtRange, tgtCse, tgtSpd;
## relative and delta time
    t := [0, 1+1/2, 3, 3+1/2];
    dt := [0, seq(t[idx]-t[idx-1],idx=2..4)];
## sensor motion
    Cse := [90, 90, 90, 50] *~ Pi/180; ## true heading
    Spd := [15, 15, 15, 22];  ## knots
## bearings to the target at time t
    Brg := [10, 358, 340, 330] *~ (Pi/180);
## slope of the bearing lines
    m:=map(tan,Brg);
## calculate the sensor position vs time
    x := ListTools[PartialSums](dt *~ Spd *~ map(cos, Cse));
    y := ListTools[PartialSums](dt *~ Spd *~ map(sin, Cse));
## target values  start the target at a known (x,y) position at a
## constant course and speed
    tgtRange := 95+25/32; ## miles at t1, match octave value...
    tgtCse := 170 * Pi/180; ## course
    tgtSpd := 10; ## knots
    tgtX := tgtRange*cos(Brg[1]);
    tgtX := tgtX +~ ListTools[PartialSums](dt *~ tgtSpd *~ cos(tgtCse));
    tgtY := tgtRange*sin(Brg[1]);
    tgtY := tgtY +~ ListTools[PartialSums](dt *~ tgtSpd *~ sin(tgtCse));
## return target position vs time as a matrix
    tgtPosit:=Matrix(4,2,[seq([tgtX[idx],tgtY[idx]],idx=1..4)]);
end proc:
##
#########################################################################
## t[], m[], x[], and y[] are known values
##
## equation of the bearing lines
eq1 := tgtY[1] - y[1]    = m[1]*(tgtX[1]-x[1]):
eq2 := tgtY[2] - y[2]    = m[2]*(tgtX[2]-x[2]):
eq3 := tgtY[3] - y[3]    = m[3]*(tgtX[3]-x[3]):
eq4 := tgtY[4] - y[4]    = m[4]*(tgtX[4]-x[4]):
## target X motion along the target line
eq5 := tgtX[2] - tgtX[1] = tgtVx*(t[2]-t[1]):
eq6 := tgtX[3] - tgtX[2] = tgtVx*(t[3]-t[2]):
eq7 := tgtX[4] - tgtX[3] = tgtVx*(t[4]-t[3]):
## target Y motion along the target line
eq8 := tgtY[2] - tgtY[1] = tgtVy*(t[2]-t[1]):
eq9 := tgtY[3] - tgtY[2] = tgtVy*(t[3]-t[2]):
eq10:= tgtY[4] - tgtY[3] = tgtVy*(t[4]-t[3]):
##
#########################################################################
##
## solve the equations
eqs  := {eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10}:

Sol:= solve(eqs, {tgtVx, tgtVy, seq([tgtX[k], tgtY[k]][], k= 1..4)}):
##

genKnownValues():
## these values are very close to Octave
evalf(t);evalf(m);evalf(x);evalf(y);evalf(tgtPosit);
## The value of tgtX[] and tgtY[] should equal the respective tgtPosit values
seq(evalf(eval([tgtX[idx],tgtY[idx]], Sol)),idx=1..4);

 

I accidentally came across a nice Mma animation. Unfortunately, I am able to present only few frames of it in MaplePrimes. See two inconsecutive frames below

 

I find this animation very deep. I don't remember something similar. It looks like an iterative
map shown in its dynamics. Not being an expert in Mathematica, I don't understand the machinery of the generating code.
n = 1000;
r := RandomInteger[{1, n}];
f := (#/(.01 + Sqrt[#.#])) & /@ (x[[#]] - x) &;
s := With[{r1 = r}, p[[r1]] = r; q[[r1]] = r];
x = RandomReal[{-1, 1}, {n, 2}];
{p, q} = RandomInteger[{1, n}, {2, n}];
Graphics[{PointSize[0.007], Dynamic[If[r < 100, s];
Point[x = 0.995 x + 0.02 f[p] - 0.01 f[q]]]}, PlotRange -> 2]
Here is its fragment translated into Maple:
>with(MmaTranslator):
>FromMma(" (#/(.01 + Sqrt[#.#])) & /@ (x[[#]] - x) &;");
map(unapply(_Z1/(0.1e-1+sqrt(_Z1 . _Z1)), _Z1), unapply(x(_Z1)-x, _Z1))
To my regret,
>FromMma(" n = 1000;
r := RandomInteger[{1, n}];
f := (#/(.01 + Sqrt[#.#])) & /@ (x[[#]] - x) &;
s := With[{r1 = r}, p[[r1]] = r; q[[r1]] = r];
x = RandomReal[{-1, 1}, {n, 2}];
{p, q} = RandomInteger[{1, n}, {2, n}];
Graphics[{PointSize[0.007], Dynamic[If[r < 100, s];
Point[x = 0.995 x + 0.02 f[p] - 0.01 f[q]]]}, PlotRange -> 2]");
Error, (in MmaTranslator:-FromMma) incorrect syntax (at position 11) in last character of "...0)
r"

Hi all,

Using the Physics package, I have defined a density operator, shown in the image below:

Definition of Density Operator

(I did assume(s ≠i), assume(v≠h).

I then operate on it with the Bracket as shown in the next image:

Bracket on Density Operator

 

I think this should evaluate to (|Y,s,h><Y,s,h|)/2; or at least that's the result I want. However, Maple evaluates this to zero.

Is there a where to convince Maple to evaluate this to what I want/expect?

Thanks in advance,

Kevin

I would prefer that all the polynomials generated in my workbook by MAPLE were in expanded form.  For instance, it the elements of a matrix are polynomials, I want to see the expanded form for all of them.  What do I type into a workbook to make this happen.  (I am a new user of MAPLE.) 

12pt type is difficult for me to read.  I would like to fix a workbook so that everything yet to appear will be in 18pt type, without my having to enlarge things one at a time.   (I am a new MAPLE user.)  

A few people have asked me how I created the sections in the Maple application in this video: https://youtu.be/voohdmfTRn0?t=572

Here's the worksheet (Maple 2016 only). As you can see, the “sections” look different what you would normally expect (I often like to experiment with small changes in presentation!)

These aren't, however, sections in the traditional Maple sense; they're a demonstration of Maple 2016's new tools for programmatically changing the properties of a table (including the visibility of its rows and columns). @dskoog gets the credit for showing me the technique.

Each "section" consists of a table with two rows.

  • The table has a name, specified in its properties.
  • The first row (colored blue) contains (1) a toggle button and (2) the title of each section (with the text in white)
  • The second row (colored white) is visible or invisible based upon the state of the toggle button, and contains the content of my section.

Each toggle button has

  • a name, specified in its properties
  • + and - images associated with its on and off states (with the image background color matching the color of the first table row)
  • Click action code that enables or disables the visibility of the second row

The Click action code for the toggle button in the "Pure Fluid Properties" section is, for example,

tableName:="PureFluidProperties_tb":
buttonName:="PureFluidProperties_tbt":
if DocumentTools:-GetProperty(buttonName, 'value') = "false" then   
     DocumentTools:-SetProperty([tableName, 'visible[2..]', true]);
else
     DocumentTools:-SetProperty([tableName, 'visible[2..]', false]);
end if;

As I said at the start, I often try to make worksheets look different to the out-of-the-box defaults. Programmatic table properties have simply given me one more option to play about with.

 

For many years I succesfully used the command:

Lambda := ImportMatrix(LambdaFile, delimiter = "", datatype = string);

 

but for some txt files I now got the following error in Maple 2016:
Error, (in ImportMatrix) cannot interpret file

The same code still runs without problems at all in previous versions of Maple.

The strange thing is that other txt files can be still be imported in Maple 2016 without problems.

I will upload two files:

ULSlx3.txt returns an error message

ULStd3.txt no problems

ULSlx3.txt

ULStd3.txt

complete code:

restart;
with(LinearAlgebra); with(Statistics);
interface(rtablesize = infinity);
with(Typesetting):
interface(typesetting=extended):

LambdaFile := "C:/path/ULSlx3.txt";
Lambda := Matrix(5, 1);

in the whatsnew there is no information on changes with respect to the ImportMatrix command, although there is some (unrelated) information on Importing Data:

Importing Data
By default, the Import command now returns a DataFrame when importing from Excel, CSV, DIF, and TSV file formats, and returns a DataSeries when importing from ODS, SXC, and TSV file formats. Use the output option to specify a different format. For example, Import(origin, output=Matrix).

 

I have no clue what is wrong with my code and why some text files can be imported as before whereas other files returns an error message.

greetings Harry

In using Maple there are many ways to complete a command on a function. Using shortcuts in the worksheet/document you can enter the command on the line rather than using the drop down menus or clickable math menu.  I would like to see what the shortcut command are for the packages in Maple.  There are so many, I am using the LinearAlgebra package and have seen Dr. Lopez use " ||A||2 to determine the Euclidean Norm of A.  But where does this use get described in the help or examples of other shortcut usage for Maple. I've seen the shortcut commands for Documents in General, but the use of shortcut commands for other packages  don't seem to discuss the usage of such shortcuts.

Is there a document that documents these shortcuts.

 

Hello there,

 

Suppose I have a parametric experssion like   P(ε)=1+ε+ε23 where ε is very small. How can I get P(ε)≈1+ε or P(ε)≈1+ε+ε2

 

Thanks

Hello.

int(floor(x^2), x = 0 .. 2) = 6 , but it should be 1.85374.

 

 

Bug_in_integrate(floor_and_ceil).mw

Mariusz Iwaniuk

First 54 55 56 57 58 59 60 Page 56 of 60