mathematica

radians translating radians to degrees

I notice that translating radians to degrees and vice versa is like translating a percentage to a whole number and vice versa. for example , to get 60 percent of 345 you do the following 60 * 345/100 to get 60 degrees in radians you do 60 * 3.14/180 There is a pattern there BUT. we use 100 to compare percentages to a numbe. so why ...

Introspection of messages generated in Mathematica

Is there any way to get at the actual messages generated during the evaluation of an expression in Mathematica? Say I'm numerically solving an ODE and it blows up, like so In[1] := sol = NDSolve[{x'[t] == -15 x[t], x[0] == 1}, x, {t, 0, 1}, Method -> "ExplicitEuler"]; In this case, I'll get the NDSolve::mxst er...

Solving vector equations in Mathematica

I'm trying to figure out how to use Mathematica to solve systems of equations where some of the variables and coefficients are vectors. A simple example would be something like where I know A, V, and the magnitude of P, and I have to solve for t and the direction of P. (Basically, given two rays A and B, where I know everything about...

How to import data from a file as an array in Mathematica?

I am trying to import a data set to Mathematica. The problem is that I cannot have the imported data as regular numbers in Mathematica. They are imported as "list". So, I cannot use them in the equations I need: Import["out.dat", "Data"] {{5.7, 4.3}, {-1.2, 7.8}} Array[cc, {2, 2}] For[i = 1, i <= 2, i++, For[j = 1, j <= 2, j++, cc[...

Calling java project from Mathematica

Hi, Could you please give me a hint how can I invoke a java project (written in eclipse) from Mathematica? I want to give values generated by my Mathematica program as input to a java project, and use the (outputs) results obtained from solving the problem by java, as input to my Mathematica code. I know there is a J/Link package for cal...

Web UI for inputting a function from the reals to the reals, such as a probability distribution.

I would like a web interface for a user to describe a one-dimensional real-valued function. I'm imagining the user being presented with a blank pair of axes and they can click anywhere to create points that are thick and draggable. Double-clicking a point, let's say, makes it disappear. The actual function should be shown in real time...

Does Mathematica have a function equivalent to Matlab's "unique" function

Is there a Mathematica function that provides results equivalent to the unique() function in MATLAB? I realize I could use the Union[] function to obtain the unique elements of a list, but I would like something equivalent to the three-result version of the function that provides index arrays that map between the input array and the arra...

Which one of C# and Java is more easy and fast when interfacing with Statistics/Simulation Softwares?

First, I know almost nothing about the interfacing of this type and this is the first time, I'm trying it out. I am looking to use one of the Statistics/Simulation software either Maple or Mathematica or R for calculations and use C#/Java to handle other areas like persistence and data collection and so on. Can you tell me which one of ...

Mathematica + GraphPlot + GraphicsGrid with EdgeLabels

I had some very strange problems with GraphicsGrid. The individual PraphPlot:s looks nice and ok, but the code GraphicsGrid[{{GraphPlot[{{a -> b, "ab"}, {a -> c, "7"}}]}, {GraphPlot[{{a -> b, "5"}, {a -> c, "2"}}]}}] just produces 2 big clots of garbage. If I remove the edge labels, everything works as expected. I am using Mathema...

Does Mathematica 7 support lazy evalution?

Suppose I have a list of Matrices saved in the variable G and apply the following operations: top[g_] = Minors[g] Diagonal[top /@ G] Minorsreturns a matrix where each element is the determinant with the (i,j) row/col deleted, and Diagonal returns a list of the diagonal elements of a matrix. My question is on the evaluation of these ...

Mathematica: Idiomatic way to replace values in a list that match a condition?

I want to truncate absolute values below an epsilon to 0, e.g., Truncate[{-3, -2, -1, 0, 1, 2, 3}, 1.5] -> {-3, -2, 0, 0, 0, 2, 3} I guess I could write a function using Scan[] and If[], but is there a more idiomatic "one-liner" way of doing it in Mathematica? ...

Bug in Mathematica: regular expression applied to very long string

In the following code, if the string s is appended to be something like 10 or 20 thousand characters, the Mathematica kernel seg faults. s = "This is the first line. MAGIC_STRING Everything after this line should get removed. 12345678901234567890123456789012345678901234567890123456789012345678901234567890 1234567890123456789012345678901...

FindRoot -symbolic results to numeric

I am using the FindRoot statement. My problem is that the results are only in symbolic form. How can I get mathematica to store results as a vector or list for easy use later. g[r_]:=(A^r - 1)/(A^r - B^r); func[r_]:= Piecewise[{{g[r],r<-.01 },{ g[r],r>.01} }]; roots = Table[0,{10}]; q= Table[pp,{pp,.01,0.1,0.01}]; Do[ roots[[i]]=Find...

Ways to work around Mathematica Notation bug?

Mathematica offers the Notation package to define custom notation, and it seems to work great until I save a notebook with custom notation as a package and try to use Needs["..."] to import the new notation. As documented on the Mathematica mailing list, this causes bizarre syntax errors when evaluating any call to Notation[]. The sugges...

mathematica printing with multiple indices

What do I need to do to make Pa[p] an ASN[P] to come out as numeric values. Abreviated code is given below. roots, PA2[p] and ANS2[p] are created using an i index. MMA CODE: ******** Clear[x, y, p]; x := BinomialDistribution[n1, p]; y := BinomialDistribution[n2, p]; Pa[p_] := CDF[x, c1] + Sum[PDF[x, j]*CDF[y, c2 - j], {j, c1 + 1, c2...

mathematica -creating lists and vectors of specific length

In Mathematica, How can I create a list of length n and fill with zeroes? How can I create a vector of length n and fill with zeroes? ...

2D integrals in scipy

I am trying to integrate a multivariable function in scipy over a 2d area. What would be the equivalent of the following Mathematica code? In[1]:= F[x_, y_] := Cos[x] + Cos[y] In[2]:= Integrate[F[x, y], {x, -\[Pi], \[Pi]}, {y, -\[Pi], \[Pi]}] Out[2]= 0 Looking at the scipy documentation I could only find support for one dimensional...

Way to deal with large data files in Wolfram Mathematica

Hi. I wonder if there exists way to work with large files in Mathematica ? Currently I have a file about 500Mb with table data. Import["data.txt","Table"]; What is alternate way? ...

how to import a file into mathematica and reference a column by header name

Hi, I have a tsv file with many columns like so; genename X1 X100 X103 X105 X115 X117 X120 X122 X123 Gene20728 0.415049 0.517868 0.820183 0.578081 0.30997 0.395181 I would like to import it into mathematica, and then extract and sort a column. ie I want to extract column ["X117"] and sort it, and...

How to reshape matrices in Mathematica

When manipulating matrices it is often convenient to change their shape. For instance, to turn an N x M sized matrix into a vector of length N X M. In MATLAB a reshape function exists: RESHAPE(X,M,N) returns the M-by-N matrix whose elements are taken columnwise from X. An error results if X does not have M*N elements. In the case ...