Questions on writing non-trivial programs in Mathematica. Do not use this tag for questions on plotting/graphics or for questions on doing mathematics with Mathematica, where the focus is more on the math than the program.

learn more… | top users | synonyms

0
votes
2answers
84 views

How to localize the symbols x,y, A, B in the following program? [closed]

I see a example in Paul Wellin's Programming with Mathematica An Introduction, 4th edition: ...
0
votes
1answer
73 views

ParallelTable not firing

...
0
votes
1answer
228 views

Rayleigh Criterion

I want to use the Rayleigh criterion to find the resolution of an optical system. I have two functions f1 = Sinc[x]^2 and ...
0
votes
1answer
805 views

Getting imaginary data from known real data using Kramers-Kronig relations [duplicate]

Possible Duplicate: Kramers-Kronig in Mathematica I am trying to get epsilon2 (imaginary part) from known epsilon1 ...
0
votes
1answer
121 views

Using Findroot within a loop

I am trying to get solution to an equation in a loop. The isolate equation works ...
0
votes
1answer
104 views

A problem with set values

The following code is just an example to clearly explain my problem. Assume that : ...
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 ...
0
votes
2answers
94 views

Finding lags of time series with `Do`

I have generated two time series, S[t] and P[t] as follows: ...
0
votes
1answer
71 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; ...
0
votes
1answer
98 views

Holding Input Windows

I am creating a Mathematica document which contains a list of proofs in various fields of Mathematics so that I can easily review whenever I would like. First, I create a large set I call 'proofs' ...
0
votes
1answer
214 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 = ...
0
votes
1answer
138 views

Pattern match with Table for matrix dimension check

In Mathematica, often an expression involving matrices will encounter dimension mismatch errors, like we are multiplying a 3x2 matrix to a 3x4 matrix. Below we define a new symbol Dim, which can be ...
0
votes
1answer
222 views

Why does memory run out when adding same-sized matrices in a loop?

I have written a module that it generates a 101x101x51 zero matrix at first. At every iteration, it generates a list by funct1 and based on this list, if list is empty it gives the previous result. ...
0
votes
1answer
196 views

Obtaining the envelope of an oscillating function and perform fitting

There is an elegant way to obtain the envelope of an oscillation function explained here http://mathematica.stackexchange.com/a/27854/15966 My question is how to modify the code below so I can fit ...
0
votes
1answer
111 views

Using a LocatorPane

I have a network of a power grid where the edge are the power lines and the vertices are loads or generators. I was wondering how I can import an image into Mathematica to derive some sort of ...
0
votes
1answer
84 views

How to produce functions [closed]

I want to produce n functions. For example, assume that by giving n=3, 3 definite integrals will be created, like the following: ...
0
votes
1answer
122 views

Mathematica Implementation of Householder’s Method

I typed the Householder code in this paper, which starts on page 7. The code is: ...
0
votes
1answer
214 views

Heat Transfer equation by numerical methods

I want to solve the following heat conduction equation using numerical methods: D[u[x, t], t] -alpha*D[u[x, t], {x, 2}] == 0 u[x, 0] == 1/(1 + x^2)^0.25, u[-10, t] == u[10, t] == 0, ...
0
votes
1answer
184 views

Evaluate function of two variables using nested Do loops

Is there a more efficient way of evaluating a function of two variables on a rectangular grid the the following nested Do loops? ...
0
votes
1answer
190 views

A problem on generating convex hull

For example, I typed the following: ...
0
votes
1answer
90 views

Collecting roots of different equations and create a list

I solve two equations and have two solutions one by each equation. I want to create list of these roots. Could anyone please help me? Appreciate it. m02R150 = FindRoot[P1 == 0, {E1, 0.07, 0.1}] ...
0
votes
2answers
117 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
231 views

Problem with Eventlocator Method for NDSolve

I want to solve the ode and plot the solution v[x] for different values of parameter a where ...
0
votes
1answer
380 views

How to solve a problem in relative motion?

I have a project due tomorrow that I have been struggling with for a month. I am utterly stumped, any help would be appreciated. The problem is: There is a ferris wheel, 30m in radius, set 80m ...
0
votes
0answers
66 views

Timing Differences

In More efficient implementation for comparing coefficient lists in a Do-loop link, george2079 posts in his first answer a piece of code that takes 352 seconds to compute. When I run this same piece ...
0
votes
1answer
84 views

For-loop only executes first line in body

I have a simple For[] loop: ...
0
votes
0answers
37 views

Automatic Cuda/CPU code; Fast programme run [duplicate]

I have developed my thesis codes by means of Mathematica software in a .nb file format. Despite using the available Parallel code capabilities and doing all the numerical integrations by means of ...
0
votes
0answers
75 views

mdifying a code for nested matrices

I have a matrix such as: ...
0
votes
0answers
34 views

Can the value of a variable be made to persist between front end sessions? [duplicate]

For example, say I create a notebook with a cell a = 5 + 2 and then I close Mathematica, reopen the notebook, enter a new cell ...
0
votes
0answers
38 views

What is a good alternative to this numerical example taken from FindFit?

I am using MMA V9.0 What do you suggest for this numerical example? I am not getting good results trying to use my own procedure to find a "best" fit using the 1-norm. The 1-norm example for ...
0
votes
0answers
67 views

How to save the results in an identical Excel file (.xls) in each iteration of a Do loop

Assume the following code (Below code is just an example to clearly illustrate my problem): ...
0
votes
0answers
91 views

Mean Squared Deviation for Population Data

I've been using the Lotka-Volterra equation to estimate population sizes and need to find the MAD (mean absolute deviation), MSD (mean squared deviation) and mape (mean absolute percentage error) for ...
0
votes
0answers
88 views

Issue with Set function

Tables often come with column headers. Indexing the columns with the header is a natural thing to do. Although a proper dictionary is the usual solution in such a case, I find it often practical and ...
0
votes
0answers
83 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
0answers
25 views

Does RuleDelayed work inside MessageName?

using : Mathematica 9.0.1.0 Hello ! Does RuleDelayed work inside MessageName ? This code: ...
0
votes
1answer
120 views

Defining a new matrix product of matrix function

Suppose I have two matrices A, B, whose entries are functions of x. Suppose they are 2*2. In the product, each entry is of the form $\sum_k A_ik B_kj$. There are two summands corresponding to k=1,k=2. ...
0
votes
1answer
408 views

How can I draw this particular phase diagram in Mathematica? [duplicate]

Sketch the phase diagram for systems with the following velocity functions where a and b are constants with ...
0
votes
0answers
113 views

Improving Function with Loop Structure

I'd like to write a function that would perform a loop, I guess Do or While should be helpful here. I've simplified the problem, ...
0
votes
0answers
137 views

How minimize a function involving abs $(|\ldots|)$?

I am trying to decide the best way to solve this: Minimise $Y = | K + ax^2 + bxy + cy^2 |$, with decision variables $x$ and $y$ and $a > 0$. I also have a number of convex and affine ...
0
votes
0answers
79 views

Programming a Meijer G related result

I am not that new in Mathematica, but I do not remember I have ever used it for programming (like we may do in Java). I have an important result given here by this integral: $$ \int_0^{+\infty} ...
0
votes
0answers
145 views
0
votes
0answers
82 views

Implementing a back button (in CDF)

I have a rather large notebook, which contains a lot of hyperlinks to different parts of the notebook. Is it possible to make a back button (maybe as a docked cell button?) so that when a reader ...
0
votes
0answers
118 views

Pearl's Message Passing Algorithm

Has anyone tried to implement the Message Passing algorithm using Mathematica's Graph/Combinatorica features?
0
votes
0answers
90 views

Inconsistent results in fits from NArgMin

EDIT: Just realized I had misspelled "inconsistent." I'm using version 7.0. I'm trying to fit a (noisy) data set to a large-order polynomial. (Just for context: there isn't a model for the ...
0
votes
0answers
39 views

Generating partitions of a set with a specified size of the parts [duplicate]

I tried the following (inspired by the answer here) myList = {a, b, c}; Needs["Combinatorica`"]; SetPartitions[myList] and I got this answer, ...
0
votes
0answers
20 views

Conflict among Permutations and Graph utilities once Combinatorica is loaded [duplicate]

I have tried to figure out and solve the problem of compatibility of Permutations and Graph utilities of Mathematica once the Combinatorica Package is loaded, but I failed :(. Could anyone explain me ...
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
votes
2answers
249 views

How can I find a function that fits some points? [closed]

I have some points and want to find a function from them. For example, $(-2,4),(0,0),(1,1),(5,25)$. I don't have a function that generates the points.
-1
votes
1answer
43 views

How to loop in reverse order?(e.g. for i from 10 to 1) [closed]

I have a list F = {382.856, 638.53, 915.482, 1192.44, 1469.39, 1746.34, 2023.29, 2181.91} And I want to use it to calculate V: I think it should be something ...