Questions about the use of built-in Mathematica functions, including pure functions.
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
...
7
votes
3answers
225 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
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.
...
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 ...
0
votes
1answer
386 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 !!!
...
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 ...
2
votes
1answer
206 views
Calculating volume [closed]
I'm new in mathematica and I'm stucked on how I can get the volume of a solid created by the inequation:
...
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 ...
20
votes
2answers
516 views
Strange ::usage behavior in v9
Note: This is fixed in 9.0.1.
Something has gone wrong with usage in Mathematica 9. Would someone tell me how to fix it?
I define a function ...
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
143 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
303 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
346 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. ...
0
votes
1answer
144 views
Evaluate multivariable function [closed]
I'm trying to use Mathematica to evaluate many values of $f(x,y) $, like $f(-\pi,\pi) $ for
$$f(x,y) = \left( \frac{-1}{4}\sin \left( \frac{x-y}{2} \right)\sin y \right)\left( \frac{-5}{4}\sin ...
0
votes
2answers
91 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
107 views
Why am I not getting Indeterminate for f[1] when f[x_] = (x - 1)/(x - 1)? [closed]
In Mathematica 9 If I write:
f[x_] = (x - 1)/(x - 1)
I get
1
And if then I write:
...
0
votes
1answer
118 views
Random sample with gap sizes
Lets say I have 101 instances of data with multiple attributes. In particular case, one attribute has 7 unique values. I want to get ...
30
votes
2answers
720 views
What is the difference between Reduce and Solve?
Solve and Reduce both can be used for solving equations.
Just by operating them, I know there is little difference between them.
But, the only thing I know is that there is little difference, and I ...
4
votes
1answer
205 views
Using DistributionFitTest on custom distributions in Mathematica 8
I originally posted this question on Stack Overflow, but I didn't get any answers, and I'm hoping to have better luck here.
I'm trying to compute the goodness-of-fit of a bi-modal Gaussian ...
7
votes
3answers
247 views
Radon function result's repeatability
I want to get a Hough transform of some edged image.
When I compare the same transformation on the same image I got different results.
...
9
votes
2answers
197 views
Define Log so that negative reals evaluate on lower edge of branch
I need to get Mathematica to evaluate the logarithm of a negative real number using the lower branch instead of the upper branch, so that while
...
1
vote
1answer
159 views
Filtering Lists in Mathematica [duplicate]
Possible Duplicate:
Select/Delete with Sublist elements?
I need help in filtering long lists of x,y coordinates.Lets use the following list as an ...
5
votes
3answers
161 views
How to rename a built-in function?
I want a built-in function renamed without loss of any properties, I want the shorter name to appear in all results and to be recognized as input. Is it possible?
-2
votes
1answer
164 views
How to pass arguments between functions
I have two Functions, f[] and g[]. f is passed some values ,say ...
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 ...
4
votes
6answers
172 views
Filter list with different list in it
I have a list like:
{{{4, 14}, 1}, {{4, 15}, 1}, {{4, 16}, 1}, {{4, 17}, 1},
{{4, 18}, 1}, {{4, 14}, 3}, {4,15}, {{4, 16}, 2},{4,18}}
Now I want to ...
8
votes
1answer
148 views
user defined functions, how to save them for future use?
I need certain user defined functions over and over. I was wondering how can I define and where and how to save them such that each time I start a notebook, these functions are available and need not ...
0
votes
1answer
277 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 ...
2
votes
0answers
77 views
Evaluating a function on permutations of its arguments
Say I have a function "temp" of $n+1$ variables, $y,z1,z2,z3,...,zn$. I want to test if my function has certain symmetries like swapping $y$ with square of any $z$, swapping any two of the zs, ...
0
votes
1answer
101 views
Solve 1-D function that has 2-D interpolating functions
I need some helps on NDSolve. Here are my equations:
...
3
votes
0answers
256 views
How can I solve this complicated custom function numerically?
I have a complicated function that calculates the total value of payments from an account into which deposits are made annually. I'd like to solve the function for a growth rate numerically, but ...
2
votes
2answers
139 views
Position function not always retuning an answer even with no apparent problems
I'm having some problems with Position.
Sometimes it will give an empty list instead of the actual position of the element I am looking for when that element is ...
2
votes
3answers
141 views
Use elements of Array inside function definition
I'm trying to define a function which modifies and sums over the elements of an array. Here is a very simplified version.
myF[kmax_] = Sum[v[[k]]/k, {k, 1, kmax}]
...
8
votes
1answer
109 views
Get the name of a symbol passed to a function
I'm trying to get the name of a symbol passed to a function with this:
f[x_] := {SymbolName[x], x}
SetAttributes[f, HoldFirst]
x = 5;
f[x]
But ...
2
votes
1answer
99 views
Difference between function definitions [duplicate]
Possible Duplicate:
Functions vs. patterns
I thought about describing the context in which I faced this problem, but I figured it is general enough and clear enough to pose it as it is.
...
