Questions about the use of built-in Mathematica functions, including pure functions.
1
vote
0answers
73 views
How can I obtain the function described by given set of central moments?
I want to investigate how my function P behaves with different probability functions rho as input variables.
This means
...
1
vote
1answer
111 views
Speeding up code by avoiding repeated evaluation of a function
I want to speed up my code and I have two ideas, but I don't know how I can implement them.
Here is a little part of my code, which I want to improve:
...
1
vote
1answer
102 views
Function definition and delayed assignment
I need to define the following function
MyWavelet[n_]["PrimalLowpass", prec_ : MachinePrecision] :=
Table[(-1)^(j - 1) h[[2*n - j]], {j, 0, 2*n - 1}]
which ...
9
votes
2answers
118 views
Function with custom Options and modified Options for built-in Symbols
I couldn't find a more descriptive title, but I guess an example will explain my problem.
I set up some customized Grid function including some additional ...
7
votes
6answers
259 views
Manipulate and Turning Expressions into Functions
I've been trying to use Manipulate to do interactive plotting, but I've been running into a few problems with saved expressions. I have an expression saved as "func" and I want to work with it and ...
4
votes
3answers
95 views
Creating a nonperiodic function in mathematica
I want to create a non-periodic square wave with values of 1 and -1(not necessarily alternating).
For e.g. I want to convert an arbitrary array like {1,-1,-1,1,-1,1,-1} into a function.
I tried ...
3
votes
1answer
112 views
Downvalues vs. Scoping for Functions
Regarding my recent question on using a default value for a function argument when a pattern was not met yielded some interesting answers, but the general consensus was "Yes this can be done, but ...
1
vote
3answers
168 views
Solve with v9 (issues with Subscript, Overscript, Superscript etc)
The way Solve works has changed in v9 ... in essence, to get the answers that one obtained under v8, one now often has to specify a lot more information about all ...
23
votes
2answers
681 views
Block attributes of Equal
I answered “Equating matrices (or higher order tensors) element-wise” with:
...
2
votes
1answer
155 views
Print out all functions in Mathematica
Sometimes I only remember parts of a function name and I want find that function name quickly, and if I search in the document center, it will give too much informations related to that and difficult ...
8
votes
1answer
227 views
Optimizing the performance of an algorithm
First - a bit of an introduction. If you're only interested in the code, you can skip this section.
The following question is drawn from Dennis E. Shasha's Puzzling Adventures, and is listed under ...
1
vote
0answers
22 views
Define a second name for a function [duplicate]
I'm working with an own package of functions. During development I noticed, that my naming scheme is not that clever; for example some of my functions are starting with capital letters. But I have ...
2
votes
1answer
106 views
How to export/import function values [duplicate]
I have a function with two variables:
f[x_,y_]:=f[x,y] = ...
I calculated some values (they are fractions like 435345345/3424242424) and would like to store the ...
6
votes
4answers
170 views
Function argument to default under certain condition
Inspired by this and this question (and how I handle this in practice), what is the best way to default a function value when a certain condition is met?
For example, if a function is defined as:
...
5
votes
2answers
163 views
How to declare a function of variable?
In my program, there are many functions relying on spatial coordinates: x, y, and z, which are also functions of time t, i.e., composite function. I need to differentiate some functions for example f:
...
7
votes
2answers
106 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 ...
7
votes
2answers
152 views
How do I write a function that can be used in a rule to modify both sides of an equation? [duplicate]
I sometimes need fine grain control over equations in Mathematica in order to help me understand how to solve a problem manually. A greatly simplified example of a session might be something like ...
2
votes
1answer
87 views
Plot[] breaks behavior of custom data handling function - Recursion
I am working on a utility to analyze a set of data. I want to process the data with a sliding window, in such a way that there is an output associated with each sample of data.
To start, I have a ...
1
vote
1answer
96 views
How can I calculate a limit with a free variable?
For example, when I evaluate
Limit[(1 + x^n + (x^2/2)^n)^(1/n), n -> Infinity]
Mathematica does not output any result. When I evaluate
...
2
votes
0answers
60 views
From notebook,how can I change variable value with in .m file dynamically?
I wrote a function named Testing.
...
1
vote
1answer
141 views
How do I define functions in TraditionalForm?
I'd like to be able to define functions (at least simple ones that Mathematica can otherwise understand) using TraditionalForm; but this seems to require the use of ...
1
vote
2answers
166 views
While-Loop Linear Projection
I'm would like to do a linear progression for a recursive relation of a consumption function. Combining my program skills and my sparse knowledge of mathematica, I was thinking about doing it in a ...
0
votes
0answers
91 views
Strange result from integrate
I am working on the following problem. However, the first task takes too long, although the answer 0 is correct. In the second task, to reduce the calculation time, ...
7
votes
3answers
226 views
FullSimplify does not work on this expression with no unknowns
I can't reproduce this simple example from Habrat, 2010 ("Mathematica : a Problem-Centered Approach"). It is supposed to demonstrate the functionality of ...
3
votes
0answers
120 views
Help on how to write a function to be used with NMinimize
I need some help to write a proper function to be used as a parameter on NMinimize. Here is the code of the function to be minimized (Please correct, optimize and rewrite the code if you want to - I ...
0
votes
0answers
86 views
MiniMaxApproximation [closed]
I'm new to Mathematica and I'm trying to obtain a minimax rational function approximation to a certain expression. In particular, I'm using
...
3
votes
1answer
67 views
Values set using SetOptions are staying in the kernel, beyond the necessary time [closed]
I wrote a function name as functionTest and also mentioned default Options.
...
0
votes
1answer
388 views
Given x[u,v], y[u,v], and f[x,y] how do I find D[f,x] in terms of u,v?
I have two functions x = x(u,v) and y = y(u,v). The chain rule says that for a function f(x,y), df/dx = df/du du/dx + df/dv dv/dx, and similarly df/dy = df/du du/dy + df/dv dv/dy.
How do I get ...
10
votes
2answers
199 views
Functions that remember their values
Can someone explain what is going on with the following ...
func[y_] := func[y] = (Print["Hello world !!!"];)
func[1]
Hello world !!!
...
8
votes
2answers
158 views
Tally repeated evaluation of function
How can I tally the result of repeated evaluation of a function?
n=100000;
f[]:=RandomInteger[{1, 4}]
Tally@Table[f[], {n}]
When ...
3
votes
0answers
59 views
What is the difference between Block and Module? [duplicate]
Possible Duplicate:
What are the use cases for different scoping constructs?
I don't understand the difference between the Matheamtica functions Block ...
0
votes
1answer
95 views
Stubborn Output: Returning the value from the wrong subroutine [closed]
Problem:
I wanted to program these 2 subroutines shown below and each was to return a function expression:
AnIntegrand[n0_] :=
Module[{n = N[n0]},
Return[6 t^2 Cos[2*n*t*Pi]];];
...
3
votes
1answer
66 views
Efficiently finding the maximum value of a column in a matrix
Imagine I have a matrix of the following form:
TestArray = $((a_1,b_1,...),(a_2,b_2,...),(a_3,b_3,...),...)$, where a specific example might be:
TestArray = ...
2
votes
1answer
97 views
writing a function using multiple variables
I am fairly new to Mathematica and am trying to write a function for the equation:
xx = [x/(Sqrt[h^2 + d^2 + y^2]))*(Sqrt[h^2 + (d + yy)^2])
where h, d are known ...
6
votes
2answers
196 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 ...
0
votes
0answers
52 views
Enable syntax-coloring on user-defined function [duplicate]
Possible Duplicate:
Syntax highlighting for your own functions
I have defined a function myIntegrate that carries out a routine similar to Mathematica's ...
1
vote
0answers
74 views
9
votes
0answers
117 views
What is PointForm?
I stumbled across a function called PointForm but the only documentation I can find is the pop-up line offered by autocomplete, which contains the same information ...
8
votes
1answer
144 views
Overloading second argument of CountryData
For convenience I'm trying to add an extra property to CountryData
...
5
votes
1answer
119 views
FunctionTreeForm
I'd like to implement a function FunctionTreeForm which takes an arbitrary complex function and renders all the captionable subfunctions in a TreeForm.
Explanation
If we take e.g. a function:
...
2
votes
1answer
90 views
Representation of product with exclusions
Is there a nice way to define output formatting for my expression, a product from n = k to j with ...
3
votes
2answers
305 views
How to study asymptotic behavior, built-in functions
My question is as follows. Suppose we have a function $f(r)$ and we want to study its asymptotic behavior at infinity ($r\rightarrow \infty$). For example, the function may reduce to $-\frac{a}{r}$ or ...
1
vote
0answers
116 views
How to use If with long instructions?
I would like to execute the following code, in which if the condition is true it should execute two instructions instead of one. When I run the code the instructions are executed, but no result is ...
2
votes
1answer
123 views
Mathematica crashes after evaluating a call to a user-defined function [closed]
I have recently installed Mathematica 9 on my macbook pro, os version 10.6.8. As you can see in the minimal example notebook you can download here:
...
1
vote
1answer
168 views
Plotting Fresnel function
I am trying to plot the partial sums and the cesaro means of the function $\sqrt{|x|}$ and for $a_{n}$, I obtained the following code which contains FresnelS.
...
7
votes
4answers
289 views
Is there a concise form of Which or similar conditional?
Suppose that I want to write a function fun that takes an Integer num as input, and returns ...
10
votes
3answers
340 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?
...
1
vote
1answer
110 views
need help with finding right syntax for an IF statement
I am working with two multi-variable functions A and B. They depend on some counting factors ...
6
votes
4answers
347 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
1answer
106 views
Some Problem with WhenEvent!
Anyone knows what's the problem with the following code and how can I fix it? I am not sure that I wrote the WhenEvent section correctly.
By the way, I want to solve the equations and then plot y vs. ...



