0
votes
0answers
52 views

deleteduplicates Delete elements of a list [duplicate]

I have a math problem about Mathematica, I am looking help from you. I hope that you could help me. The Math Problem: list= { {0,0,1},{1,0,0},{0,1,0} ,{1,2,3}}; ...
6
votes
1answer
254 views

What is wrong about Abs[x]-a? Is it a bug?

Why is the Out[74] not {1 - a, {x -> -1}}? ...
0
votes
0answers
87 views

A problem with functions and Infinite expression 1/0 encountering

Following code (function) makes integrals and then replace f[x] with Cos functions and calculate the definite parametric ...
0
votes
1answer
104 views

A problem with set values

The following code is just an example to clearly explain my problem. Assume that : ...
2
votes
0answers
53 views

Can BreadthFirstScan be modified?

I would like to obtain a "slick" implementation of A*-search algorithm on Graph objects, using the built-in BreadthFirstScan (if that is possible at all). I noticed that BreadthFirstScan is static in ...
1
vote
3answers
171 views

How to update a list in a function in each iteration

There is a list with numbers 1 to 8 ( p1 ) and another list (j) which contains 4 numbers which shows different 4 positions of ...
-1
votes
1answer
88 views

Transformation of a simple logic statement

I'm designing a logic circuit and I was wondering if the following two things are equivalent: (x <= y) and (x < (y + 1)) I can't think of any set of numbers that would make these two things ...
0
votes
1answer
46 views

How to put some values from a list into a function in a Do loop

I want to program a code in MATHEMATICA in order to calculate some values in different iteration. For example, assume this list: list={1,2,3,4,5} Now assume that ...
1
vote
2answers
75 views

Avoid making repeated Random Integer in different iterations

Assume following code : Do[ i1 = RandomInteger[{1, 5}]; i2 = RandomInteger[{1, 5}]; While[i1 == i2, i2 = RandomInteger[{1, 5}]] , {k, 1, 4}];` This ...
0
votes
1answer
73 views

How to write series of Do[ ]'s with a single Table[ ]?

Edited to provide more information (sorry I don't know how to format matrices here) I would like to replace: m = 4; ...
2
votes
1answer
103 views

Piecewise function with user-input interval

I would like define a function g[data,bins,x] which is a piecewise constant function taking value data[[i]] in the range ...
8
votes
3answers
179 views
0
votes
1answer
215 views

How to combine two usages of # into one and speed up the code?

I have a function num with two variables, matf and matg. How can I combine the last two lines of code below into one? The code is aimed to find out the maxiaml count bel when we give each $i3 = ...
4
votes
4answers
317 views

How to find the maximum of a function on a set of discrete points?

How to find the maximum of a function on a set of discrete points? For example, what is the best way to find the maximum of ...
17
votes
1answer
179 views

How to get Cases to wrap results in an arbitrary head?

A number of functions provide for results to be wrapped in an arbitrary head. This is very important in cases where the results should not be evaluated. Take ...
10
votes
5answers
477 views

How to find first list element that differs from average of N previous elements by more than a given amount?

Given a list of real numbers, I need to write a function that returns the value of the first element in the list that differs from the mean of the previous $N$ elements by greater than $P$ standard ...
2
votes
1answer
234 views

Call Functions From File Without Modifying Context (Sandbox)

Let's say I have file named test.m containing test[arg1_] := ( Print[arg1];) What is the best technique for calling test like ...
17
votes
4answers
518 views

Accessing list elements by name

First, a bit of a long introduction to my problem: I only have a few weeks of Mathematica experience. I am creating a mathematica application that calculates some material properties of steel based ...
11
votes
4answers
1k views

How to modify function argument?

Usually in programming languages, function arguments are normal local variables, which can be modified. Is this not true in Mathematica? ...
11
votes
4answers
784 views

Pure Functions with Lists as arguments

Assuming I have two function: example 1: add[{x_, y_, z_}] := x + y - z add[{1, 3, 5}] If use pure function,I know I can write it as : ...
0
votes
2answers
120 views

How to obtain a smaller-sized output from Solve

I am solving a system of 15 simultaneous linear equations using Solve. On running the code, I get a message saying "A very large output was generated" with options ...
0
votes
1answer
1k views

Loops and subroutines [duplicate]

Possible Duplicate: Alternatives to procedural loops and iterating over lists in Mathematica I am new to Mathematica and not familiar with functional programming. In particular, I have no ...
1
vote
1answer
210 views

Problem with function as an argument

I want to write a function like the following: s[u_, v_, x_, val_] := u[val]/NIntegrate[u'[x] v[x] + u'[x] v'[x], {x, 0, 1}] So I can evaluate something like ...
2
votes
1answer
318 views

Cournot Equilibrium

I'm trying to determine reaction functions of a Cournot equilibrium for $n$ firms using the same optimal condition, using the fixed point method. This is the method I'm using: ...
2
votes
5answers
378 views

How to leave function unevaluated programmatically?

Is it possible to write a function in such manner, that it can be either evaluated or left unevaluated? This is a general question. Sample below is just a sample. No need to find solution for this ...
4
votes
3answers
357 views

Generate a Combination of letters by a number

I'm trying to write a function f. example: ...
4
votes
2answers
242 views

How can I use Max[] in a function that is passed a list not find the max of the list

For most functions in Mathematica, passing them a list will call the function on each element of the list. For example: ...
4
votes
1answer
243 views

How to organize and run functions?

I am very new to Mathematica. I thought I would try it out for my first assignment in my computer science class. Until now I have only used C-base languages including C#, Java, Objective-C, and ...
8
votes
2answers
1k views

Pass function or formula as function parameter

I can write either Integrate[x^2, {x,0,3}] or f[x_] = x^2 Integrate[f[x],{x,0,3}] and get the same computation. Suppose I ...
8
votes
1answer
721 views

(Non-Convex) Polygon Union and Intersection Functions [duplicate]

Possible Duplicate: Intersecting graphics Back in 2009 I posted a question in comp.soft-sys.math.mathematica looking for a function which generates the union of two (not necessarily convex) ...
2
votes
3answers
161 views

Using Nest inside NestList

I need results like this: {Cos[Cos[x]], Sin[Cos[Cos[x]]],Cos[Cos[Sin[Cos[Cos[x]]]]], Sin[Cos[Cos[Sin[Cos[Cos[x]]]]]], ... } I've tried to use ...
13
votes
3answers
275 views

How to keep some of the results of the NestList

I'm using some iterative arithmetics to calculate wave propagation with the help of NestList. I have to use a small step size for iteration to guarantee the accuracy, which lead to too much data (e.g, ...
9
votes
1answer
447 views

GeoDirection and GeoDistance Memory Leaks: How to Recover the Memory?

The functions GeoDirection and GeoDistance have memory leaks. To see this, run the example functions below and watch as the Physical Memory Available in the Windows Task Manager, Performance tab, ...
7
votes
2answers
264 views

What's the purpose of the Unique function?

As the title says: What's the purpose of Unique? I understand that it generates some unique symbol, but when and for what is it to be used? Are there applications ...
51
votes
2answers
2k views

Flatten command: matrix as second argument

One thing I could never wrap my head around is how Flatten works when provided with a matrix as the second argument, and the Mathematica help isn't particularly ...