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

1
vote
0answers
34 views

How can I convert a list to an expression? [duplicate]

For example, I have the following list: {x1,op1,x2,op2,x3,op3,...} And I would like to convert the list to the following expression: x1 op1 x2 op2 x3 op3 ...
1
vote
0answers
134 views

Why doesn't ParallelMap improve the performance of FoldList?

This question arose during my analysis of the following problem: filling gaps. (The code used here is Simon Woods's work.) FoldList seems to not cooperate with ...
1
vote
0answers
214 views

Forecasting future Stock Prices II

I intend to do the following: I want to forecast future stock price under the following assumptions: The stock price is governed by the stochastic differential equation: dS = μSdt + σSdWt whereas ...
1
vote
0answers
214 views

Data structure for a list of actions

The idea: I need to generate a sequence of events then run a "propagator" over the list of events where the "propagator" will update the state of the following event. I can then write functions that ...
1
vote
1answer
187 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 ...
1
vote
0answers
167 views

Return Functions from parallel execution of module

I wrote a module which numerically solves an ODE using NDSolve. The result from this is e.g. either ...
0
votes
3answers
320 views

How can I fill in a matrix at every iteration of a Do loop?

I have a matrix whose dimensions are 26x26x3. For my assignment I have written a program which is using a Do loop (maxx=maxy=10,maxz=2): ...
0
votes
3answers
103 views

Why is my funtion is wrong? [duplicate]

My aim is to know whether the data has same element. ...
0
votes
2answers
118 views

How to avoid restart during development? [duplicate]

Possible Duplicate: How do I clear all user defined symbols? During package development things get messed up quite often. (especially when playing with notations) Is there a simple way to ...
0
votes
3answers
163 views

Determinant of a random matrix consisting of integers

I am trying to implement a function that finds the determinant of a random matrix consisting of integers. This is the code I have written so far, but I am stuck. Suggestions ? I want to find a ...
0
votes
1answer
45 views

Problem with Label in a Do loop, “nolabel” [closed]

Can someone tell me why this code doesn't work and how to fix it ? Thanks. ...
0
votes
1answer
111 views

Where do those nulls come from? [closed]

I have seen discussions of unwanted nulls in the output in the context of building lists with conditions on the elements, but that is not involved here. I would like to know where the nulls come from ...
0
votes
2answers
597 views

Basic Dynamic Interface Programming that returns variables to nb functions

I have a dynamic module that contains some basic PopupMenu's and Buttons but also need to use the variables returned from these buttons and PopupMenu's in my nb functions outside of this ...
0
votes
1answer
206 views

Graphics copy paste

Background. I have a function ( stored in a package ) that creates 2D graphic images, its prototype looks like this: ...
0
votes
1answer
106 views

Conditioning on group of functions

I have two sets of functions which I want to implement them in a single function with an option indicating which set of functions should be used. Suppose that I have two lists like:(updated example) ...
0
votes
1answer
366 views

What is wrong with this Cobweb plot [closed]

Something is wrong with my cobweb plot code but I couldn't figure out where do the mistakes come from. So basically we have the iterative map $x_n == x_{n-1}^{2} - 3 \mu$. I would like to draw a ...
0
votes
2answers
67 views

How can i execute several Commands in one text file and use it in notebook?

I want to execute several commands in one text file and use it in notebook by Get[] command. for example: ...
0
votes
2answers
191 views

characteristic polynomial based on differential equation

I have this differential equation: $$\ddot{x}-\frac{1}{6} \dot{x} - \frac{1}{6}x = e^t$$ When I DSolve it looks like this: ...
0
votes
1answer
430 views

Find Roots in Do loop

Task: Finding roots in loop t = List[1, 2, 3, 4, 5] fx[x_] := a*x^2 - 5 List[Do[Print[FindRoot[fx[k] == 1, {a, 1}]], {k, 0, 5}]] Output: Currently the output is ...
0
votes
1answer
242 views

How can I improve my code with efficient mathematica built-in functions?

I have written a module for my assignment like below. V[n + 1] = rk[x[n], y[n] ,z[n], V[n]]; vs = V[n].V[n+1]; V[n + 1] = I want to modify it with efficient ...
0
votes
1answer
277 views

How can I make many runs of a simulation and plot all the results with one expression evaluation?

I have many cells, starting with this first cell: ...
0
votes
1answer
133 views

FE`symbols that remain in notebook internals even after removing them and SaveDefinitions->True issue

How does one clear the notebook from symbols that remain in it after an edit session?
0
votes
1answer
212 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
707 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
44 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
82 views

Finding lags of time series with `Do`

I have generated two time series, S[t] and P[t] as follows: ...
0
votes
1answer
70 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
82 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
211 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
124 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
219 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
75 views

A problem with set values

The following code is just an example to clearly explain my problem. Assume that : ...
0
votes
1answer
79 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
76 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
159 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
66 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
175 views

A problem on generating convex hull

For example, I typed the following: ...
0
votes
3answers
136 views

How to create a distributive function in Mathematica

More specifically, I would like to define an algebra such that: f[x1 op1 x2 op2 x3,...]=f[x1] op1 f[x2] op2 f[x3]... I know of the Distribute function but the problem I get into is that the function ...
0
votes
1answer
89 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
111 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
220 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
370 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
76 views

Mathematica examples with many calculations? [on hold]

This what I'm trying to do with mathematica: I have to do a lot calculation, and use results from previous calculations to conduct followings. But I only know to use Mathematcia in this way: The ...
0
votes
0answers
85 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
37 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
22 views

Does RuleDelayed work inside MessageName?

using : Mathematica 9.0.1.0 Hello ! Does RuleDelayed work inside MessageName ? This code: ...
0
votes
1answer
65 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
0answers
67 views

Integrate double definite integral [duplicate]

I am trying to evaluate an integral numerically and plot its result. My mathematica code is: ...
0
votes
0answers
17 views

NDSolve_ODESolve_Plotsolution [duplicate]

I am trying to use mathematica to solve this problem. Thank you! Given the ODE $$ -\frac{a^2 V_0}{2} f''(x)-V_0\cos\big(\frac{2\pi x}{a}\big) f(x)=E f(x) $$ (a,V_0) are positive real constants. Find ...
0
votes
1answer
279 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 ...