Linked Questions

13
votes
2answers
1k views

Dynamic Programming with delayed evaluation

By using dynamical programming, we can save intermediate steps for recursive relations, as in f[n_]:= f[n] = f[n-1] + f[n-2] However, this only stores ...
13
votes
2answers
1k views

Displaying a series obtained by evaluating a Taylor series

Description of problem I would like to use Mathematica to display the series obtained by substituting a value for $x$ in a Taylor series expansion. The terms of the series will be rational numbers, ...
11
votes
2answers
392 views

Setting options of expressions similar to using SetOptions on objects

Introduction I often have the problem that in an expression, I want to change an option. If we are sure the option is not present, we could simply use ...
9
votes
2answers
390 views

Evaluation in lambda function

If I have a function, that returns a function, for example: f[a_] := a^2 * # & then f[3] == 3^2 # & Is there a way ...
8
votes
2answers
180 views

Syntactic Sugar for TestReports

Seems to me that VerificationTests are a bit verbose: ...
8
votes
2answers
1k views

How to replace a variable that was assigned a value before

Question How to make the replacement $f[x] \to f[y]$ for an abitrary function $f$ if $x$ was assigned a value before? Example 1 How can I make the replacement $x +1 \to y + 1$ if I have assigned ...
7
votes
2answers
165 views

Method that can be used to collect the variables of a function

Suppose we have a function f[x, y, z] and we want to get all its variables Sequence[x,y,z], what method can we use then? The ...
6
votes
2answers
3k views

Define function using variable list

I have a list of variables variables={a,b} and a list with values values={1,2}. I'd like to define a function using the ...
5
votes
2answers
335 views

Overlapping pure functions

Let say I need and option for Plot: RegionFunction -> (-6 < #2 < 6 &) But I also want those ...
5
votes
2answers
274 views

How to silence all messages associated with a built-in symbol?

The post title's pretty much says it all... The reminder of this post just describes the little headway I made with this problem, FWIW. One would hope that ...
4
votes
2answers
190 views

How can I use sequence in plotting domain?

I would like to plot a function but have a domain defined elsewhere as follows: xrange = Sequence[0, 2π]; Plot[Sin[x], {x, xrange}] However, this doesn't work ...
4
votes
2answers
153 views

Generating compiled functions from inactive expressions

I am working on a project in which I need to dynamically generate CompiledFunctions from Inactive expressions. For example, I ...
4
votes
2answers
121 views

Choosing an initializer list in With

I'm trying to have several initializer lists in a With function and choose which one I want to use. So far I have this: ...
4
votes
2answers
249 views

why set values in this way doesn't work?

question is as follows define a list ttt={1,2}; and if I set values in this way {ttt[[1]],ttt[[2]]}={3,4} then the value ...
4
votes
2answers
2k views

Local variables

I'm trying to use Modules together with functions. tmp2 = x^2 + 1; f[y_] := Module[{x = 1}, Evaluate[y tmp2]] This works when ...
3
votes
2answers
150 views

HoldFirst and Hold expression as argument

I store a reference to the association in a held expression in a variable: a=<||>; b=Hold[a]; And in the code, I want to do manipulations with the original ...
3
votes
2answers
204 views

Order of Evaluate for Map

I would like to get a list of variable names as strings. For example, x = 1; y = 2; Map[SymbolName, Unevaluated /@ Unevaluated@{x, y}] {"x", "y"} This works ...
19
votes
1answer
888 views

List manipulation to build a functional expression

Since Mathematica deals with Head[a, b] as an expression in this way The first Part of Head[a, b] is ...
7
votes
1answer
127 views

How to define a version of Table[] which localizes iteration variable by Module[]?

For reusable code it's good practice to use Module[] to localize iteration variables used by Table[], as explained by this post. ...
6
votes
1answer
128 views

Convert between string and expression representation of boxes

Boxes may be represented as expressions or as strings. How can I convert between the two forms? In particular, how can I convert from the string representation to the expression representation? ...
6
votes
1answer
539 views

Generate regularly spaced points from the surface of simplexes

I need to generate regularly spaced samples (points) from the surface of unit simplexes with 2 or greater vertices or end points. I can generate random samples pretty straightforwardly: ...
3
votes
1answer
325 views

Generate assignment code to symbols from string

I want the function to take in string, then assign a value to its corresponding symbol. An implementation using ToExpression is ...
3
votes
1answer
296 views

different situations with Compilation of ConstantArray

First, we load some tools related to Compile for analysis. ...
3
votes
1answer
1k views

How to evaluate some parts of an expression inside Hold? [duplicate]

I want to return a Hold expression but with some parts pre-evaluated. The easiest way to explain this is probably through code example. Here is what I have ...
2
votes
1answer
95 views

Writing a procedure that invokes Manipulate[]

I would like to write a procedure with the signature: Foo[vars, params] which produces a Manipulate object. The procedure ...
1
vote
1answer
113 views

How to get LogPlot to accept a Sequence for its Min/Max Limits [duplicate]

If you use Plot like this, Plot[Sin[x], {x, 1, 5}] it produces the correct Sin graph ...
1
vote
1answer
161 views

Overriding the behavior of Dot

I would like to override the behavior of Dot, so that Dot[u,v] will return a scalar instead of a 1x1 matrix in the case that the ...
1
vote
1answer
162 views

Using With in combination with Graphics [duplicate]

Assume that we are given a symbol p={x,y} which should represent a 2D point. If x and y have ...
0
votes
1answer
185 views

Using sublists returned from a function as elements of a list argument to an other function

This is a contrived example, but it gets the point across. I am looking to use the following as inputs: ...
1
vote
0answers
35 views

How to replace expressions in a `HoldComplete` and then evaluate them? [duplicate]

Example: ...

15 30 50 per page