mathematica

In Mathematica, what does @@@ mean?

I've been working through problems on Project Euler, and some of the solutions that other people have posted use a triple-at-sign, i.e. '@@@'. In the help browser for v7, I find an entry for @@ (which says it's the infix version of 'Apply') but none for @@@. What does it mean? EDIT: Here's an example, which I think I can post without...

"Select any" in Mathematica

Does mathematica have something like "select any" that gets any element of a list that satisfies a criterion? ...

Yield in Mathematica

Can you do something like Python's yield statement in Mathematica, in order to create generators? See e.g. here for the concept. Update Here's an example of what I mean, to iterate over all Permutations, using only O(n) space: (Algorithm as in Sedgewick's Algorithms book): gen[f_, n_] := Module[{id = -1, val = Table[Null, {n}], visit}...

Why won't this work? Dynamic in a Select.

Ok, I do this: Select[Range[1, 20], # > Dynamic[q] &] And then I create the slider: Slider[Dynamic[q], {1, 20}] And it'll always return an empty set! Why! Update The goal of this is to have the set change as I move the slider. ...

Mathematica: Determine if all integers in a list are less than a number?

Is there a way in Mathematica to determine if all the integers in a list are less than a set number. For example if I want to know if all the numbers in a list are less than 10: theList = {1, 2, 3, 10}; magicFunction[theList, 10]; --> returns False Thanks for your help. ...

What does Wolfram Mathematica 7 offer for CS/CEN students?

Wolfram Mathematica 7 has an increasing popularity among computer science and computer engineering students, but what are the main benefits and features it offers? ...

How to prepend a column to a matrix?

Ok, imagine I have this Matrix: {{1,2},{2,3}}, and I'd rather have {{4,1,2},{5,2,3}}. That is, I prepended a column to the matrix. Is there an easy way to do it? My best propsel is this: PrependColumn[vector_List, matrix_List] := Outer[Prepend[#1, #2] &, matrix, vector, 1] But it obfuscaates the code and constantly requires loading ...

The semantics of Mathematica's Thread function, someone needs to finally put this to rest

Wolfram Research has had the same documentation for this function for the last 8 years at least: Thread[f[args]] "threads" f over any lists that appear in args. A lovely circular definition if I've ever seen one. Does anyone know what the actual semantics are and can provide a proper explanation that is non-circular? ...

How do you break out of parallel loops? ParallelBreak

Hi, in the following snippet, if you replace Do by ParallelDo, it will evaluate by a factor of 3 SLOWER, because now the loop will be broken in only ONE of the two kernels. ParallelEvaluate[NN = 10070]; SetSharedVariable[res] Module[{a, b, c}, Do[ c = NN - a - b; If[a a + b b == c c, res = a b c; Break[]] , {a, 1, NN}, {b, ...

Using the solution of a differential equation in two separate plot commands in Mathematica

I've encountered a problem while trying to use the answer from a NDSolve in two separate plot commands. To illustrate the problem, I'll use a simple differential equation and only one plot command. If I write something like this: {Plot[x[t], {t, 0, 10}], x[4]} /. NDSolve[{x'[s] == - x[s], x[0] == 1}, x, {s, 0, 10}] It solves the equa...

Are there Mathematica packages for presenting proofs/derivations?

When I write out a proof or derivation on paper I frequently make sign errors or drop terms as I move from one step to the next. I'd like to use Mathematica to save myself from these silly mistakes. I don't want Mathematica to solve the expression, I just want to use it carry out and display a series of algebraic manipulations. For a (tr...

Complex Calculations

What are the best tools (most efficient) available in .NET (C#) for calculating: integrals partial derivatives other non-trivial math Can people please comment on Mathematica and Matlab and their integration into C#? ...

Filter out sublist in Mathematica

I am a newbie user in mathematica. Here is my problem: For example, I have a nested list: lst = {{1, 0, 0}, {0, 1, 1}, {2, 0, 1}, {1}, {0,3}} I want to only output those sublist whose elements are 0 or 1. The above list's output should be: {{1, 0, 0}, {0, 1, 1}, {1}} I can get the list that satisfies my conditions with this: lst...

How do I maximize a function in Mathematica which takes in a variable length list as input?

I have a time-series like function which gives an output based on a list of real numbers(i.e. you can run the function on a list of 1,2,3,... real numbers). The issue I'm encountering is how to maximize the function for a given list length(subject to a set of constraints). I could fix the function to a fixed number of real numbers(i.e. f...

Is there HashTable structure in Wolfram Mathematic?

Hi All I want to use a Structure like HashTable. Is there similar structure in Wolfram Mathematic? Best Regards, ...

Express a number using words in Mathematica

Hi all I heard that we can use the English words to express the number. Like using One hundred to express 100. Does anyone know which function can do it? Best Regards, ...

How can I get the name of a calling function within a module in Mathematica?

If I write a function or module that calls another module, how can I get the name of the calling function/module? This would be helpful for debugging purposes. ...

Mathematica: How to use a single equation with multiple parameters to calculate any parameter

Hi, Currently I use a single equation with different combination of known/unknown parameters. As I don't have any fancy calculator it would be much easier to define the equation in Mathematica and passing known parameters to calculate unknown values. I would be very thankful if anyone of you could give an example solution (if possible ...

how to use units along function parameter values in Mathematica

I would like to pass the parameter values in meters or kilometers (both possible) and get the result in meters/second. I've tried to do this in the following example: u = 3.986*10^14 Meter^3/Second^2; v[r_, a_] := Sqrt[u (2/r - 1/a)]; Convert[r, Meter]; Convert[a, Meter]; If I try to use the defined function and conversion: a = 24...

Equivalent of "defined" in Mathematica.

I need a function that takes the name of a symbol as a string and returns whether that symbol is already defined. The function ValueQ is close but it returns False for function names. Also, it takes symbols rather than strings. Examples: defined["N"] --> True (predefined function N) defined["x"] --> False x = 7; defined["x"] --> True ...