Tagged Questions
24
votes
2answers
406 views
Variable naming changes everything
I am having a rather unusual problem I do not understand with Mathematica where renaming one of the variables of my function causes the function to stop "working". Here is the example of the code ...
1
vote
1answer
77 views
Mathematica plots a discontinuity in piecewise function that does not exist [duplicate]
I have the following function defined:
...
9
votes
2answers
152 views
How can I get the right hand side of a delayed expression?
Imagine there is a given function f, defined with SetDelayed, say
f[x_] := Sin[x]^2 + Cos[x]^2.
Is it possible to get rhs of ...
0
votes
1answer
192 views
How can I define a Step-Wise function in Mathematica (Not using Heaviside Step Function)? [closed]
I need to define a function, which has very different behaviour in different regions. There are about 13 different regions. A sample of my function is the foloowing table:
I want to define it as a ...
1
vote
1answer
153 views
Why does the first derivative of a piecewise continuous function turns out with discontinuities?
I have this piecewise continuous function which is also continuously differentiable over time :
...
15
votes
4answers
238 views
Enforcing correct variable bindings and avoiding renamings for conflicting variables in nested scoping constructs
Using global variables the following turns an "expression" into a Function:
expr = 2 x;
Function[x, Evaluate[expr]]
Of course ...
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
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 ...
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
111 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 ...
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:
...
2
votes
0answers
60 views
From notebook,how can I change variable value with in .m file dynamically?
I wrote a function named Testing.
...
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.
...
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 !!!
...
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 ...
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 ...
9
votes
2answers
196 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
...
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 ...
2
votes
0answers
76 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, ...
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.
...
1
vote
1answer
73 views
Why function is evaluated backward?
I have a simple function:
f[x0_,y0_]:= Module[{x=x0,y=y0},For[i=0,i<2,i++;Print[x],Print[x+y]];]
So when I call it:
...
1
vote
2answers
104 views
How to mix Unevaluated property of function arguments with expression assignments?
This is a follow-up to my (solved) question How to distribute a generic function of two arguments (without evaluating the arguments)
Say, I have a binary function
...
4
votes
3answers
110 views
How to distribute a generic function of two arguments (without evaluating the arguments)
I guess there is an easy way to do this, but I can't seem to figure it out. What I would like to do is to distribute a generic (i.e. without specifying what this function really does) binary function. ...
3
votes
3answers
165 views
How to pull scalars out of a function that should act on lists?
Suppose I have
A = a vecA
B = b vecB
where a and b are supposed to be arbitrary scalars ...
9
votes
2answers
264 views
NestList on a function with more arguments
I'd like to know if it is possible to use NestList on a regular function with more arguments, such as:
...
1
vote
2answers
182 views
Piecewise function with a function as argument
I want to define a piecewise function, which has two arguments, one of which is a function of the other's piecewise argument. I am giving an example
...
1
vote
2answers
102 views
How can define a set of nested parameters
I would like to know how I to define a function with a nested set of parameters (or whatever you would like to call it). For example, how would I get the following function ...
1
vote
3answers
158 views
Variables Inside Functions Not Evaluating
x = 5*y
function1[y_] := x
function1[5]
Am I wrong in thinking that function1[5] should equal 25? Instead this comes out.
...
3
votes
1answer
150 views
Evaluation of self-defined functions
I defined a function that I call disc which I want to minimize later. The function is defined as
...
11
votes
4answers
287 views
Assessing argument type in set delayed function definitions
I'm wondering how to properly assess the type of arguments passed to functions defined with :=. I want my functions to be the most efficient, unambiguous and clear ...
2
votes
3answers
180 views
How to Compute Aggregate Best and Worst Cases for a Large Number of Estimates?
I need to aggregate multiple estimations, but I haven't been able to find a built-in function in Mathematica that aggregates multiple probablity estimations (I am specially interested in estimations ...
2
votes
3answers
151 views
Ways to change an explicit function into a pure function
I'm trying to use FixedPoint to solve a transcendental equations, but the first argument of the FixedPoint should be a pure ...
9
votes
2answers
376 views
5
votes
1answer
345 views
Nesting multiple functions of multiple variables
I was wondering how one would go about nesting multiple functions of, say, two variables. The problem comes from trying to implement the Chirikov standard map without using "for" cycles. I found a ...
13
votes
3answers
387 views
Is it possible to get the order of inputs when “overloading” an orderless function?
When working with symbolic matrix operations or other objects which don't have commutative multiplication, it would be nice to not have to constantly switch out times for ...
4
votes
1answer
202 views
How do I use the result of Solve in a function definition?
I'm trying to adapt the following piece to the part where PowerF is a function of amax.
...
7
votes
3answers
287 views
Inverting a function in a certain region
InverseFunction works well for globally invertible functions, like
f = 2*# + 2 &;
InverseFunction[f]
...