mathematica

controlling order of variables in an expression

In Mathematica, how do you change the order of importance of variables? for example: if i enter b+c+a+d, i get a+b+c+d but i want b and d to preceed other variables. so that i get b+d+a+c note, i'd like to use it where + is non-commutative ...

simplifying and rearranging non-commutative variables in mathematica

this is a little complicated. i spent 2 weeks on this, so i'd love ur input or suggestion how to figure it out or where to post. in short, i have an expression that contains multiplications between p1,p2,q1 and q2, and i'd like to use [qi,pi]=ii*hb, where i={1,2} to get the expression to a symmetric form (pi^a*qi^b+qi^b*pi^a)/2. so for...

Mathematica to Python

How can this Mathematica code be ported to Python? I do not know the Mathematica syntax and am having a hard time understanding how this is described in a more traditional language. Source (pg 5): http://subjoin.net/misc/m496pres1.nb.pdf ...

Visualizing a geometric problem with mathematica

I am trying to figure out a way to move two points, X and Y, independently of one another along the edges of an equilateral triangle with vertices A, B, and C. There are also some collision rules that need to be taken into account: (1) If X is at a vertex, say vertex A, then Y cannot be on A or on the edges adjacent to it. i.e., Y ca...

Is this a bug in NSolve in mathematica?

One would expect and hope that if you ask Mathematica to find the roots of a polynomial, it should give the same (approximate) answers whether you do this symbolically, then find numerical approximations to these exact answers, or whether you do it numerically. Here's an example which (in Mathematica 7, running on OS X) where this fails ...

Reset ItemNumbered

I know there must be a simple answer to this but I've looked and looked. Suppose I form an ItemNumbered list at some point in the notebook. Then at some other point I want a new ItemNumbered list starting with number 1, but without resetting the original list. At present when I try to form the second list it always starts with n + 1, whe...

How do you programmatically dsplay a partitioned matrix in Mathematica?

I know that using the Insert menu, you can create a matrix with vertical and horizontal lines, but not a more generic partition, such as dividing a 4x4 matrix into 4 2x2 partitions. Nor, can MatrixForm do any sort of partitioning. So, how would I go about programmatically displaying such a partitioned matrix? I would like to retain th...

Solving 2d movement differential equations

I'm trying to solve a really simple problem of finding object position under force {k1+k2 * y, k3*t}. Here's what I'm entering into Mathematica 7: DSolve[{ x''[t]*m == k1 + k2*y[t], y''[t]*m == k3*t, y'[0] == 0, y[0] == 0, x'[0] == 0, x[0] == 0 }, {x[t], y[t]}, t] and I get this error: DSolve::deqn: Equation or list of eq...

Mathematica Help: FullSimplify does not use conjugate identities

FullSimplify fails to recognize that: a*Conjugate[b] + b*Conjugate[a] = 2 Re[a*b] I have some very complex equations that could be simplified greatly if Mathematica could recognize this simple identity (and that a*Conjugate[b] - b*Conjugate[a] = 2 Im[a*b]). See, Mathematica will not finish solving my equations when written i...

Write Euler's method in Mathematica

Hello, I would like to write a function that has a loop in it which preforms the operations necessary for Euler's method. Below it my poor attempt. In[15]:= Euler[icx_,icy_,h_,b_,diffeq_] := curx; cury; n=0; curx = icx; cury = icy; While [curx != b, Print["" + n + " | " + curx + cury]; n++; dq = StringReplace[diffeq, "y...

Optimizing interpolation in Mathematica.

As part of my work, I often have to visualize complex 3 dimensional densities. One program suite that I work with outputs the radial component of the densities as a set of 781 points on a logarithmic grid, ri = (Rmax/Rstep)^((i-1)/(pts-1), times a spherical harmonic. For low symmetry systems, the number of spherical harmonics can be fa...

Mathematica solving differential equations

I would like to numerically find the solution to u_t - u_xx - u_yy = f on the square y ∈ [0,1], x ∈ [0,1] where f=1 if in the unit circle and f=0 otherwise. The boundary conditions are u=0 on all four edges. I have been trying to use ND-solve for ages but I keep getting error messages. I'm new to Mathematica so I don't know how to ...

Prescribing strange boundary conditions

Does anyone know how to prescribe boundary conditions of like u[t,0,y]==u[t,1,1-y] in Mathematica using NDSolve... It always complains that the arguments of the dependent variable should literally match the independent variable. Thanks in advance. ...

What is the default hash code that Mathematica uses?

The online documentation says Hash[expr] gives an integer hash code for the expression expr. Hash[expr,"type"] gives an integer hash code of the specified type for expr. It also gives "possible hash code types": "Adler32" Adler 32-bit cyclic redundancy check "CRC32" 32-bit cyclic redundancy check "MD2" 128-bit MD2 code "MD5" ...

FullSimply Inequalities and then rearranging them in Mathematica 7

Hi I am using Mathematica 7 in the notebook interface and I want to rearrange an inequality so that I get a certain variable on one side. For eg. FullSimplify[x^3+L+r>3x^3+2r] Gives L > r + 2 x^3 However, I want : r < L-2x^3 Is there anyway we can instruct FullSimplify to order variables in a particular way? I am using Mathema...