Mac Dude

1551 Reputation

17 Badges

12 years, 125 days

MaplePrimes Activity


These are answers submitted by Mac Dude

Matrix and <<>> operate on different levels. Matrix() is a full-blown constructor that allows pretty much all options know to (wo)man to be used when creating an instance of a Matrix. Also it allows filling using formulae and algorithms; or not filling. <<>> is a shortcut that applies a set of default options and needs more-or-less explicit values to fill the Matrix.

If <<>> does the trick; use it. Much easier than Matrix(). If <<>> is not able to do what you want, chances are the Matrix() constructor will.

Try to create a 1000 by 2 element Matrix, unfilled, data type float, with <<>>. You'll see what I mean.

Mac Dude

You can copy the graphic using the contextual menu (ctrl click on Mac OS X) and then rotate it & save in a .png file. You then read the rotated graphic in from the Property window (Change... button for the image).

Do this twice, once for selected and once for unselected.

M.D.

You are using a lot of indexed variables without declaring the arrays. Maple tends to set these up as Tables, which is not the most efficient way. I suggest you declare the Arrays and Vectors you want to use upfront, and if they store only numbers declare them with the datatype=float option which is more efficient than the default datatype=anything. As a side benefit, if Maple tries to run some analytic evaluation in a loop (often a recipe for exponential growth in demand on memory) you get an arror and see immediately where it is going off track.

Mac Dude

 

The code you show will actually immediately distribute the factors over the elements of the list for both x and y. If you really need to keep the factors separately, here is one kludge how to do it by replacing the numeric factors with variables and using frontend to collect the list. Note that, if you replace the variables with numbers, Maple will immediately distribute across the list again.

x:=i2*[x_1,x_2,x_3];# i2 shall be your factor 2
                    x := i2 [x_1, x_2, x_3]
y:=i3*[x_1,x_2,x_3];# i3 shall be your factor 3
                    y := i3 [x_1, x_2, x_3]
factor(x+y);
            i2 [x_1, x_2, x_3] + i3 [x_1, x_2, x_3]
frontend(collect,[(4),[x_1,x_2,x_3]]);#so far so good
                   [x_1, x_2, x_3] (i2 + i3)
subs(i2=2,i3=3,(5));# but this is not what you want.
                     [5 x_1, 5 x_2, 5 x_3]


Note that the (4) and (5) references are line numbers, with the first line being (2) (i have a restart with some output that takes number (1)).

Another way to do this would be to replace the list with a placeholder variable and only substitute the list(s) back in when you are ready to do so. In this context be aware of the difference between := (immediate assignment) and = (an equation). Often using equations can help as the replacement of variables happens manually (using subs or applyrule or...) when you want it.

Now, I do wonder what it is that makes it so important for you to keep the factor outside of the list. I find that in many such cases it is better to let Maple do its thing and not spend endless time trying to force Maple to do what it does not want to. This is not always the correct strategy, but often enough it is.

Mac Dude.

You put your data into a Matrix e.g. like this:

Matrix(<seq(<x|x^2>,x=1..10)>);

and you use ExportMatrix to write this thing out.

ExportMatrix("Filename.txt",Matrix,delimited, delimiter=" ");

Read up on ExportMatrix in help as there are options to consider.

Mac Dude

 

The \, is to control character spacing, specifically it adds a thin space. You may argue with what Maple is doing, but that is what it is for.

If you object to the space between \frac and {}{}, then relax. At least for me, this works just fine.

Mac Dude

 

I have been getting better resolution by displaying a plot reasonably large on the screen, selecting it and choosing Export... from the Plot menu. But I doubt it is anywhere near 1000 dpi.

plotsetup(); allows you to change the plotdevice and redirect the plot output to a file. You'll need to rtfm, too much to say for this board. But if the docs are right you should be able to produce much higher resolutions in this way. Look for "device" in Help.

M.D.

parms:=[beta=((5000/10^12)*(omega^2))^(1/4),k_r=3.33*10^10,k_h=1.62*10^9,c_r=3.14*10^9,m=350000,L=147,EI=10^12]:

simplify(LinearAlgebra:-Determinant(subs(parms,M)));

Since your matrix M has some imaginary entries the resulting expression is complex. The solution for omega is not obvious (unless the determinant is 0 in which case omega=0).

restart;
with(CodeTools):
ode:=2*a*x^3*y(x)^3+2*x*y(x)+diff(y(x), x);
result:=Usage(assign(soln=dsolve(ode=0,y(x))),output='cputime');


                     "Maple Init loaded..."
                      3     3              / d      \
          ode := 2 a x  y(x)  + 2 x y(x) + |--- y(x)|
                                           \ dx     /
memory used=3.43MiB, alloc change=2.62MiB, cpu time=404.00ms, real time=905.00ms
                        result := 0.404
soln;
                                  2                     
       y(x) = - --------------------------------------,
                                                 (1/2)  
                /            2        /   2\    \       
                \-2 a - 4 a x  + 4 exp\2 x / _C1/       

                                  2                   
         y(x) = --------------------------------------
                                                 (1/2)
                /            2        /   2\    \     
                \-2 a - 4 a x  + 4 exp\2 x / _C1/     

 

Mac Dude

 PS: time[real]() gives the real, wall-clock time. time() gives the cpu time

I pulled the code out of the scrollbox and copied it into  a regular worksheet, then saved it into a .mla file theway I do this with my own stuff. Here is the way I am saving it:

LibraryTools:-Save(Steenrod2,cat(libname[1],"/Steenrod2.mla"));

(where I previously prepended the directory of my own library files to the Maple directory; therefore the libname[1] construct).

Now, in a new worksheet I can say

with(Steenrod2);

STEENROD package: by Ken Monks, Version 10.3
MBasis routine by Vince Giambalvo


[&*, &^, &rlex, &x, &xx, ActOn, Adem, AdmisAnBasis, Alpha,

  AnBasis, BinaryChart, Bottom, ChangeBasisMatrix, Coproduct,

  DEGREE, DualMult, Equal, Excess, ExtendToBasis, Filtration,

  FindPivotColumns, Flip, Gamma, IntSolve, Inverse, IsInAn, K,

  MBasis, May, MilnorMult, NULLSpace, Nil, Parts, ReduceToBasis,

  SqDickson, TensorDualMult, TensorMilnorMult, Top, V, ZERO,

  alpha, chi, delta, id, init, multinom, nu, omega, s1, s2, tri,

  v, w]

The list is the list of exports from package Steenrod2.

I have Coproduct:

Describe(Coproduct);

Coproduct( a::{Dual, Milnor} )

I don't know what Steenrod is so I cannot meaningfully test it, but at least Coproduct exists.

I believe your error is in saving the library file. It needs to be a .mla file, not a .m file. I am also not sure about savelib; that may be a deprecated command.

Mac Dude

 

 

If the data file has pure numeric data, I would use ImportMatrix, something like

M:=ImportMatrix("filename", source=delimited, datatype=float, delimiter=" ");

If the file has mixed data, you can use the datatype=anything option, in which case you may need to use parse to get at the numeric content. This  is considerably slower.

Mac Dude

 

 

In your example above, you omitted the multiplication sign between 2 and y. Putting that in, Maple gets

x*y^2/(x+1)+x*(1/(x-2*y)^2)=0;

(3)

solve((3),x);

RootOf, incidentally, indicates the root (zero) of the expression in its argument. Sometimes you can specify the option radical in solve to get an explicit expression, if in fact Maple can provide it.

Now, if x and y stand for something more complicated and you want to solve, not for a name but for a subexpression, you can use freeze() and thaw() to coerce Maple to treat the subexpression as a simple name.

Mac Dude

 

Well, maybe it is because you are having terms with x^3983*(many other factors involving x to some sizeable powers).

To make any progress here you first need to increase Digits to give Maple a chance to evalf the equation. I used 200 (no clue whether this is the right number, but it prevents Maple from just returning zero).

Then you need to give fsolve a starting value, e.g. your 15.7 hint. ?fsolve/details to see how it is done.

I also changed the sum to add since you are doing floats anyway and do not want sum to try doing this symbolically.

So, after you line h:=... I have

evalf(subs(x=15,h));# check what we actually get here

4.72586785... 10^-1558 # WTF!

diff(h,x):
fsolve(%=0,x=15.7);

15.688116558... (200 digits)

So, it seems to work. I don't know whether 200 Digits is ok, too many, or too few. This is yours to figure out.

But, in all due respect, does this expression make any sense?

Mac Dude

 

solve(a+b*ln(x)-c(x),x,allsolutions);

W is the LambertW function (see its help). _Z2~ stands for any integer. _Z2 denotes the branch to take, the ~ indicates the assumption placed on _Z2 ("about(_Z2)" will tell you what assumptions exist).

For some reason my version of Maple does not let me subs explicit values for _Z2... must be something else going on.

Mac Dude.

 

 

Here is what I get:

de:=a-y(x)=diff(y(x),x)*bc;

dsolve(de);

Initial value to find _C1:

simplify(subs(x=0,(3)));

So the sign of _C1 gets found from the initial value for y(x).

No?

Mac Dude

 

First 13 14 15 16 17 18 19 Page 15 of 20