Tag for questions about using optional arguments in Mathematica functions.

learn more… | top users | synonyms

3
votes
1answer
59 views

Function of arguments given in non-fixed order [duplicate]

normally we define functions as f[x_, y_, z_] := ArcSin[x^2*y/z] however when one has many arguments (as I do) I find difficult to remember what is the meaning ...
3
votes
3answers
274 views

Plot graphs with direction and numbered in Mathematica

I would like to write a code in Mathematica such that it shows the direction with numbers on points. I wrote this code which does not do this. I want just to complete this code with two options I ...
4
votes
2answers
107 views

How do I make my function behave more like Plot? [duplicate]

I have written a function Fun as below: ...
6
votes
1answer
103 views

A question about two ways to use Default

Usually we define a function with default values by the syntax x_:default, but there is another technique to do this by registering a global default value with ...
0
votes
3answers
100 views

How to combine multiple functions into a single function, indexed bya new argument

I have a system of expressions (matrices) which correspond to increasing orders of precision in a theory. These expressions are quite complex (require about 40+ lines of code to produce) and are not ...
13
votes
4answers
418 views

How to make a function with its own options as well as passing options to other functions [duplicate]

I have a function with many of its own options, but I would also like to pass options to subfunctions using the FilterRules function. Here's a simple example: ...
0
votes
0answers
31 views

Use Map with OptionValue [duplicate]

Trying to map OptionValue to a list of option names doesn't work. ...
4
votes
1answer
87 views

Add options to upvalues

I have some objects that I want to present in TeXForm. Thus, it is easily to do as follows: YoungTableau/:TeXForm[YoungTableau[diagram_]] However, what if I ...
0
votes
2answers
532 views
1
vote
1answer
421 views

Which methods are available for NMinimize? [closed]

I can't find in the documentation the list of methods available to NMinimize[]. Is there a way to get this? The NMinimize page in Documentation Center mentions only ...
0
votes
1answer
107 views

How to make an index optional?

Can I define a relation between variables, such that the expression will also be evaluated (then assuming all indices are equal) when no index is given? $$ x_i + y_j = \delta_{ij} ...
3
votes
1answer
298 views

Evaluating function only when its optional argument is numeric

I want to have the argument 'a' for myf2 in form of optional argument, but at the same time I need to evaluate the function only if 'a' is Numeric, see also my previous question. ...
10
votes
4answers
229 views

Is it possible to separately call the default value of a variable which isn't at the end of the sequence?

After reading this post I recalled an old question I once met. We know that we can set default values for variables of a function: ...
21
votes
2answers
638 views

Is there any way to define pure functions with optional arguments?

For example consider the following function: Function[{u,v},u^2+v^4] Is there anyway to define default values for the variables ...
7
votes
1answer
147 views

Specifying optional arguments with variables

Perhaps this is poor programming on my part, but I would like to create a function that uses a variable as an optional parameter: var = 2; f[a_:var] := {a} The ...
2
votes
1answer
107 views

How can I define a function taking two distinguishable sets of options?

It commonly happens that one wants to define some function foo which in turn calls some other function (e.g., Plot) that can ...
2
votes
1answer
81 views

How to specify optional arguments that take functional values

I am trying to make a function with an optional argument that may change but mathematica caches the value when the function is defined. Here is an example where the optional time variable is set when ...
7
votes
2answers
134 views

Change some option of a function when calling it [duplicate]

Say I have defined some function like f[p_] := Plot[Sin[p*x], {x, 0, 2 Pi}] Now in most cases, I just need to specify the value of ...
11
votes
1answer
260 views

Is it possible to use Compile on a function with optional arguments?

My Mathematica is a little rusty, so apologies in advance. I think my problem is quite simple, but I can't seem to find the answer on my own! Simple example : ...
6
votes
2answers
217 views

Is it possible to use PatternTest and Optional value on one Pattern simultaneously? [duplicate]

Possible Duplicate: How to Combine Pattern Constraints and Default Values for Function Arguments First a simple example: define a function "add" with two arguments, and its second argument ...
2
votes
0answers
91 views

How can this function's options be used in different places? [duplicate]

I wrote this function to make a ListPlot where the points are colored by a third argument. ...
4
votes
2answers
170 views

How to use Optional as an omissible parameter in pattern-match?

Below is a function intended to test if an expression is a polynomial in which all the coefficients and exponents are integers: ...
19
votes
4answers
355 views

Can I make a default for an optional argument the value of another argument?

I'd like to define a function with several optional arguments, some of which default to the value supplied for other arguments. For example, I'd like to be able to write something like ...
15
votes
1answer
700 views

How to Combine Pattern Constraints and Default Values for Function Arguments

EDIT: As several respondents have noted in the answers and comments below, the original example had a default value that would never be used because of the way patterns and default values are ...
10
votes
2answers
439 views

How to test if optional argument has been given?

I understand that the last call (f[1]) returns True because arg does not exist and thus ...
38
votes
6answers
2k views

How can I create a function with optional arguments and options?

Is it possible to create a function with optional arguments that also takes options? Here is a simple example. I have a function f with option "g". It also has ...