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


 

restart;

d := s*x*(E*K*q-K*r+K*sigma[1]+r*x)*
     (1-x*(E*K*q-K*r+K*sigma[1]+r*x)
     /(K*sigma[2]*L))/(K*sigma[2])+sigma[1]*x
     -x*(E*K*q-K*r+K*sigma[1]+r*x)/K;

s*x*(E*K*q-K*r+K*sigma[1]+r*x)*(1-x*(E*K*q-K*r+K*sigma[1]+r*x)/(K*sigma[2]*L))/(K*sigma[2])+sigma[1]*x-x*(E*K*q-K*r+K*sigma[1]+r*x)/K

L := ldegree(d,x);

1

x^L * collect(d/x^L,x,u->simplify(u,size));

x*(-s*r^2*x^3/(K^2*sigma[2]^2)-2*s*(E*q-r+sigma[1])*r*x^2/(K*sigma[2]^2)+(-s*(E*q-r+sigma[1])^2*K+r*sigma[2]*(s-sigma[2]))*x/(K*sigma[2]^2)+((-E*q+r)*sigma[2]+s*(E*q-r+sigma[1]))/sigma[2])

 


 

Download poly.mw

In general what you ask is not always possible, since the characteristic polynomial of your Matrix might not have its roots expressible in "closed form". That's a mathematical consquence more than a limitation of any computer algebra system.

Let's suppose, for fun, that your Matrix entries are very sparse in x, and the charcteristic polynomial of your Matrix is a degree 50 polynomial in x, and that by some chance its structure is such that the roots can be expressed exactly, each taking say 200 pages of output. What would you expect to do with that kind of expression? You're almost certainly not going to get any insight by trying to look at it. Subsequent algebraic manipulation of it would likely be expensive and awkward at best.

Now let's suppose instead that you created a procedure which, when supplied a numeric value for x, would return a sorted list or Vector of all the eigenvalues. You could plot them (or their real and imaginary parts), as x varied. You could extract the max or min or them, as x varied. You might even compute lower order rational polynomial approximations of such functions of x (perhaps over a range). Indeed you could do a wide set of interesting computations with such a black-box function of x.

My question to you is: what manner of (qualitative or quantitative) insights from subsequent computations did you hope to attain with a closed form representation of the eigenvalues of the Matrix that you thing you could definitely not attain from some numeric black-box procedure?

(ps. I've noticed that you leave many of the Answers to your Questions on this site no reply. One consequence is that we cannot tell whether you've understood, or not.)

See the attachment:

Pause_examples.mw 

(The three ways shown are using readstat, DEBUG, and Embedded Components.)

That's just numeric roundoff error. Your Matrices have entries on the order of 10^19, and that final Norm value is small roundoff noise.

If you want Aa with shape=symmetric indexing function then you could make it so yourself:

  Aa := Matrix(Aa,shape=symmetric,datatype=float[8]):

It's not a big deal but I notice that Mt is datatype=complex[8]. You might make it float[8] to get rid of the 0.0*I fluff.

Another choice is just to increase the working precision (Digits), but of course there's a slowdown when you move from hardware to software floats.

Another choice is to rescale your data (and saving the scaling coefficient for later adjustment as needed, naturally). Eg,

Kk := Kk/max(map(abs, Kk));

 

For symbolic Matrix inversion Maple will use two kinds of simplifying call.

One is Testzero, which is used to guard against inadvertently selecting a "hidden zero" as a pivot. Choosing as a pivot -- and dividing by -- an expression which could actually simplify to zero would make the answer an evaluation time bomb. By default Testzero uses Normalizer.

The other is Normalizer which is used when reducing a row, in order to keep expression swell down. Linearsolve first checks whether this has been changed from being identical to the `normal` procedure. If so it uses it as is. If not then it tries a little to figure out what might be appropriate (e.g. radnormal, evala, simplify (...,trig), or 'simplify' as larger bore gun).

[edit: ...cont'd] Sometimes LinearSolve will pass off to `solve` or `SolveTools`, but it mostly does similar things with Normalizer.

If you effectively "turn off" Normalizer by setting it to, say x->x then sometimes symbolic/exact LinearSolve can become considerably faster. Potentially dangerously faster as then it may divide by a pivot whose expression would be exact zero if simplified, leading to an invalid result and a division by zero error later.

If you change Normalizer then by default consequence you change Testzero. But in general one still needs zero-testing of candidate pivots, so better to change both separately in the case that Normalizer is being disabled.

Only you will know what you might want for normalizing across the row while pivoting, depending on your example. It can help in final result size, and in practice it can help with speed because adequate zero-testing for pivot selection can slow down if all the candidates have grown enormously complicated.

Another aspect of choice is in how to choose between candidate pivots. It's not possible in general to know which might lead to the simplest result (without trying everything, which is combinatorically impractical). In the exact case you could select according to expression `length` (naive), leaf-count, types of subexpressions, etc.

So you might try experimenting with adjusting Normalizer and Testzero, and/or using similar in your own code.

Why not use the ImportMatrix command?

I copied and rearranged elements of your sample line, to get a two-line file. The following handled both as expected, using Maple 2016.

ImportMatrix("foo.txt", source=csv);

Also, using your call to readline, how about following that with,

[parse(StringTools:-Escape(current_line,regexp))];

Since you attempted it using piecewise, here's an alternate way to handle this example. (It's just for fun, since Carl's suggestion to use plots:-inequal is more straightforward.)
 

restart;

f := x -> -x^2+3*x+2:
l := x -> 4*x:
m := x -> 2*x-4:

P1 := min(f(x), l(x)):
P2 := max(m(x), 0):
plots:-shadebetween(piecewise(P1 > P2, P1, undefined),
                    piecewise(P1 > P2, P2, undefined),
                    x = -1 .. 4, view = -5 .. 10);

Download shadebetween.mw

[edit] For those with older versions without the modern plots:-shadebetween or plots:-inequal functionality, an old technique (shown by Alec Mihailovs and Robert Israel if I recall) can also be used:

restart;
f := x -> -x^2+3*x+2:
l := x -> 4*x:
m := x -> 2*x-4:
P1 := min(f(x), l(x)):
P2 := max(m(x), 0):
fcn1 := piecewise(P1 > P2, P1, undefined):
fcn2 := piecewise(P1 > P2, P2, undefined):
plots:-display(
  plot([f,l,m,0],-1 .. 4),
  plottools:-transform(
    unapply([x,y+fcn2],x,y))(plot(fcn1-fcn2,x=-1 .. 4,
                                  filled=true,color="gray")),
  view=[-1..4,-5..10]);

In my Maple 2016 both of the following produce 0 exactly.

radnormal(convert(c,radical));
simplify(convert(c,radical));

It's actually easier if you you just write that data out to a Matrix, using just the 3rd column of your original. (The first two columns indicate regular spacing, which is so easy to handle that there's no need to store it.)

Are you hoping for a log-scale or one or both axes? That would make it a bit more challenging. Also, labelled contour lines need some extra effort.

Anyway, here's something. Is it on the right track? (I used Maple 2016 for this. If you have only Maple 18 then the surfdata example that used valuesplit in the colorscheme won't work. But the rest does, including this contour plot below.)

program_2.mw

That made this (and also some surfdata plots, whose blurry rendering due to the coarseness of the data sample is harder to deal with):

Is the op command what you're after?

Eg,

eqn1:= (1/2)*p+1+(-4*p^2-p-1)/(3*p^3+7*p^2+2*p+2):
op(eqn1);
op(1,eqn1);
op([1],eqn1);
op([1,1..2],eqn1);
op([3,1,1..],eqn1);

See also the nops command.

Is this similar to what you want? (I used Maple 2016.1, but it also seems ok in Maple 2015.2)

The idea is to build up the assignment statement (using colon-equals) as a string, and then to parse that (without evaluation).

mathcontainer.mw

A 3-D plot with a smooth edge can be obtained relatively simply here with:

plot3d(x^2+y^2-2*y+1,
       x=-sqrt(-y^2+4)..sqrt(-y^2+4), y=-2..2);

You could also get a smooth edge using a polar form (without having to go to a so-called parametric calling sequence of the plot3d command). Eg,

plots[changecoords](plot3d(changecoords(x^2+y^2-2*y+1,[x,y],
                                        polar,[r,t]),
                           r=0..2,t=0..2*Pi),
                    polar );

You can figure out that range for `r` by examining:

changecoords(x^2+y^2<=4,[x,y],polar,[r,t]);
simplify(%);

As Kitonum mentioned, you can use the plots:-display command to show several plots together. Eg,


 

restart;

with(plots):
with(plottools):

expr := x^2+y^2-2*y+1:

Psurf := plot3d(expr,
                x=-sqrt(-y^2+4)..sqrt(-y^2+4),y=-2..2,
                color="LightBlue"):

#expr_polar := changecoords(expr,[x,y],polar,[r,t]);
#Psurf := plots:-changecoords(plot3d(expr_polar,
#                                    r=0..2,t=0..2*Pi),
#                             polar):

Pdisk := transform((x,y)->[x,y,0])(disk([0,0],2)):

Pcyl := plot3d(2,t=0..2*Pi,z=0..9,color=green,
               transparency=0.85,style=surface,
               coords=cylindrical):

Ppt := pointplot3d([0,1,0],color=red,
                   symbolsize=25,symbol=solidsphere):

display(Psurf,Pcyl,Pdisk,Ppt,
        orientation=[50,50,0]);

Download constrainedsurf.mw

If you are willing to restrict yourself to the case of a plot inside a PlotComponent then you can use that component's functionality to detect and act upon hover-over.

Here's a simple example.  simplehover.mw

The information is not a popup per se, but is capable of dynamically revealing/hiding itself. More complicated examples are possible, of course. (I also tried having it dynamically set the component's tooltip, but unfortunately the GUI's revealing of the tooltip was too erratic to be useful in that capacity.)

The code is accessible by right-clicking on the component and, via the menu, looking at its Action code related to hover events.

The Component has properties such that the default manipulator is click&drag, and the plot's manipulator is set to click&drag. I forget whether both of those always survive re-opening a sheet in all recent versions.

By keeping the book a constant height while "rolling" those bodies in your posted video are indicating that they have constant width.

That's not the "Gomboc" shape, as far as I am aware, and I don't understand why you would use that term here.

See this old mapleprimes posting about such 3D shapes.

http://www.mapleprimes.com/questions/203617-3D-Shapes-Of-Constant-Width

What I see at the start of your video , rolling under the book, looks to me almost like the revolution of a Reuleaux triangle. I say "almost" because those in the video show a smooth top while the revolution of a Reuleaux triangle has a cusp at its top. There is also an animated MathApp for that in recent Maple versions (and on the maplecloud).

That old mapleprimes posting I cite discusses three shapes in particular: the revolution of a Reuleaux tetrahedron, the Reuleaux tetrahedron, and the Meissner tetrahedron. The shapes in your video appear to me to be bodies of revolution, and to have constant width, which is why I suspect that they may be a variant of the first of these three.

You could try and construct a customized caption instead of a legend, using the technique in my answer here.

Or you could just fake it by using another dummy plot with the legend you want. Eg,

plots:-display( plot( sin(x), x=-Pi..Pi, color="Red",
                      style=pointline, legend="",
                      numpoints=20, adaptive=false ),
                plot( [[0,0]], style=point, legend="sin(x)" ) );
First 198 199 200 201 202 203 204 Last Page 200 of 336