On Mon, Aug 2, 2010 at 4:59 PM, cousteau <cousteaulecommand...@gmail.com> wrote: > 1. ENGINEERING MODE > Ok, I didn't think about the problems that using real numbers where > indexes are required would cause. Doesn't look easy to workaround, so > better forget about this one. > > 2. UNITS > Good to know that Sage already supports units, when were they > implemented?
I finished them off and got them into Sage not so long ago. David Ackerman (a UW undergraduate) did most of the actual work last summer (2009). > Apparently not in 4.1.2 at least. > It would still be useful to have an easy way to access units. If > adding a syntax like "9.8 'units' " involves messing too much with > Python's syntax, another solution is to make a function that returns > units from a string, something like "units('kg m/s2')". That's a great idea. > 3. BODE DIAGRAMS > Well, ok, maybe when I tried to plot a bode diagram I didn't research > much on the graphics array point, but there's still missing a way to > make the X axis have a logarithmic scale (without replacing x with > exp(x), which would work graphically but would write the wrong numbers > on the axis). Also, it would be nice to be able to make the Y axis > have divisions each 15, 45 or 90 degrees for the phase diagram, but it > will use 10, 20, 50 or 100 instead. I agree -- we definitely need log scale for sage's default plotting. > 4. MATRIX INPUT > If the "[...]m" syntax is messing too much with Python's syntax, don't > implement it then, but I keep thinking there should be an easier way > than the one right now to input matrices. It's just not comfortable > for people who does an intensive usage of matrices. > (Another alternate syntax would be using a semicolon inside a list: > "[1,2;3,4]", or "[1,2,3;]" for row matrices; it's more Matlab-like but > it still has the same problem... although there are already some cases > such as "list(1..10)" that don't look like valid Python) What about something like this: sage: m = lambda x: matrix([sage_eval(y,globals()) for y in x.split(';')]) sage: m('1,2; 3,4') [1 2] [3 4] sage: m('1,2,3,5/8; 3,4,7,1.5') [ 1.00000000000000 2.00000000000000 3.00000000000000 0.625000000000000] [ 3.00000000000000 4.00000000000000 7.00000000000000 1.50000000000000] sage: a = 10 sage: m('a,0;1,2') [10 0] [ 1 2] > 6. TRANSPOSE/CONJUGATE > It seems that implementing this would just involve modifying the > __pos__(self) method for complexes, matrices and complex matrices, and > I think that both conjugating and transposing are common enough > operations to deserve its own operator. -1 to making +A = A.transpose(). > > > On 2 ago, 22:47, William Stein <wst...@gmail.com> wrote: >> On Mon, Aug 2, 2010 at 1:38 PM, cousteau <cousteaulecommand...@gmail.com> >> wrote: >> > I'm studying engineering, and I'm used to some programs such as >> > Matlab, Maple, etc. When I knew about SAGE I found it very powerful, >> > simple and well structured, but I quickly found out that it wouldn't >> > be very useful in engineering, which is more oriented to numerical >> > analysis and simple math operations than to abstract algebra. Although >> > I could just use Octave for this, I'd like to be able to use SAGE for >> > some engineering-oriented tasks. Here are some proposed features: >> >> > 1. ENGINEERING MODE >> > Since SAGE is oriented to mathematics, all numbers are considered >> > Integer unless otherwise specified (an integer is converted using >> > Integer() to SAGE's inner type). This isn't practical for engineers, >> > who normally use real numbers. >> > Solution: There should be a variable that caused all numbers to be >> > converted to RealNumber by default instead of Integer, even if an >> > integer was entered. >> >> You can make this happen as follows: >> >> sage: RealNumber=float; Integer=float >> sage: 2 + 3 >> 5.0 >> sage: 4/7 >> 0.5714285714285714 >> >> Note that this will screw many things up big-time, e.g., list indexing >> is broken: >> >> sage: v = [1,2,3] >> sage: v[2] >> --------------------------------------------------------------------------- >> TypeError Traceback (most recent call last) >> >> /Users/was/build/sage-4.5.1/<ipython console> in <module>() >> >> TypeError: list indices must be integers, not float >> >> > 2. UNITS >> > It would be nice to make SAGE capable of handling units and do unit >> > conversion. >> > Solution: There are already some Python modules that allow the "1 m" >> > syntax for a value with units. For some more complex units, I'd use a >> > syntax like "9.8 'kg*m/s^2' " (a literal number followed by a string), >> > or "9.8 [kg*m/s^2]" (a literal number followed by the units between >> > brackets). >> >> Sage already has extensive support for units. >> >> sage: kg = units.mass.kilogram; m = units.length.meter; s = units.time.second >> sage: a = (9.8 * kg * m / s^2); a >> 9.8000000000000007*kilogram*meter/second^2.0 >> sage: a.convert(units.mass.gram * m / s^2) >> 9800.0*gram*meter/second^2.0 >> >> > 3. BODE DIAGRAMS >> > I didn't find it easy to plot a Bode diagram of a function. The plot() >> > function doesn't appear to have a "logarithmic" option, and it doesn't >> > look easy to put 2 parallel plots on the same image, one on the upper >> > half and another on the lower half. >> > Solution: have a bode() function that does all the work (along with >> > nyquist() and maybe root_locus()). Extending the options on the plot() >> > function would also be nice (at least, add logarithmic_x and >> > logarithmic_y options). >> >> Parallel plots? Do you mean like this: >> >> sage: graphics_array([plot(sin(x), 0, 3), plot(cos(x),0,3)],2,1) >> >> > 4. MATRIX INPUT >> > SAGE lacks an easy way to enter matrices. The easiest one is to do >> > something like "matrix([[1,2],[3,4]])", but that's uncomfortable, >> > specially for people who are used to Matlab's (or Octave's) "[1 2; 3 >> > 4]". >> > Solution: My proposed syntax is "[[1,2],[3,4]]m", this is, a literal >> > list followed by an "m", as an alias to "matrix([[1,2],[3,4]])". Same >> > for "v" (vectors), "c" (complex numbers), maybe "q" (quaternions), >> > "p" (polynomials)... >> >> I think this is pretty easy: >> >> sage: matrix(2, [1,2, 3,4]) >> [1 2] >> [3 4] >> >> I don't like your suggestion to introduce something that isn't valid >> Python to enter matrices. >> >> > 5. MATRIX INDEXES >> > I had written a long paragraph about how easy is to get slices of >> > matrices on Matlab/Octave and how good it would be to implement >> > something similar on SAGE with some examples, just to realize that it >> > was already implemented. :( >> > (some examples: mat[3], mat[1,2], mat[0:3], mat[[3,2,1,0]], mat[:, >> > 0]...) >> >> Moreover, if you use numpy arrays you get extremely powerful and >> efficient slicing into n-dimensional arrays. This is very useful, >> e.g., when dealing with 3d scientific data. >> >> >> >> > 6. TRANSPOSE/CONJUGATE >> > If I want to get the transposed of a matrix, I have to write >> > "mat.transpose()", while on Matlab it's as easy as "mat' ". Same for >> > conjugating complex numbers or transposing+conjugating complex >> > matrices. >> > Solution: The solutions are to have a .T (or .H, .C...) attribute, or >> > to have a custom operator that conjugates and transposes, such as >> > "*mat" or "+mat" (the latter might be easier to implement since >> > there's already an unary "+" operator in Python that doesn't do >> > anything useful). >> >> Why don't you do this: >> >> sage: T = lambda x: x.transpose() >> sage: A = matrix(3, [1,2, 3,4, 5,6]); A >> [1 2] >> [3 4] >> [5 6] >> sage: T(A) >> [1 3 5] >> [2 4 6] >> >> >> >> > -- >> > To post to this group, send an email to sage-devel@googlegroups.com >> > To unsubscribe from this group, send an email to >> > sage-devel+unsubscr...@googlegroups.com >> > For more options, visit this group >> > athttp://groups.google.com/group/sage-devel >> > URL:http://www.sagemath.org >> >> -- >> William Stein >> Professor of Mathematics >> University of Washingtonhttp://wstein.org > > -- > To post to this group, send an email to sage-devel@googlegroups.com > To unsubscribe from this group, send an email to > sage-devel+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-devel > URL: http://www.sagemath.org > -- William Stein Professor of Mathematics University of Washington http://wstein.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org