Tagged Questions

Questions about the use of built-in Mathematica functions, including pure functions.

58 views

Function does not initialise variable as changes are made in the manipulate function

My function "DefineRss[]" takes in three arguments and outputs a plane value. It sits in the first argument of the function plot3D and that in turn sits in the manipulate function The function also ...
220 views

Shorthand for operations?

Mathematica has a large number of built-in symbols, and I am unsure when there is a shorthand for the operation I am trying to perform. Question 1: Is there a shorthand for the function ...
25 views

Determining default value from previous arguments [duplicate]

How does one specify a default value for an argument which is dependent on the previous arguments of a function? For instance, consider the function ...
413 views

What is primary, function computation or function application?

What is the order of computations here? g[x_]:=x^2; f[x_]:=Sqrt[g[x]]; Map[f, Range[100]] Does this code first get $f(x)=x$ and then gives its values or for ...
141 views

Minimize under constraint on an interval

I want find the minima of a (multivariable) function under a constraint which has to be fulfilled on a whole interval, let's say  \nabla f (\underline x) = 0 \ \\ \ c(\underline x,s)\geq0\ \forall s\...
109 views

PrimitiveRoot function

The function PrimitiveRoot[n] claims to return the smallest primitive root of n. I believe this is not true. For example ...
944 views

Is there a name for #1@#2&?

Why does the pure function # @ #2 & have no name? I'm asking because sometimes I find inelegant to write expressions like ...
169 views

Evaluate list of functions at a certain point

I have a list of functions (actually they are derivatives) of the type: {D[g[x,y],x],D[g[x,y],y]} I would like to evaluate all of these functions at a point, say,...
80 views

My code of plotting a two-variable function is too slow [closed]

I have a code in which my complicated function to be plotted is F(x,p). I would like to graph it for 5 values of p equal to 10^7, 10^8, 10^9, 10^10 and 10^11 for x values between 0.01 and 0.99. All ...
149 views

How can I change variable passed to a function? [duplicate]

Sometimes I'd like to make a function, which would take an argument "by reference" instead of usual "by value". This is semantically similar to what e.g. AppendTo ...
121 views

RegionPlot fails when given function with internally redefined variables

I've just upgraded to v10, and have noticed that some of my trusty old notebooks which used RegionPlot now fail to run. I've boiled down the problem I'm having to ...
2k views

Determine whether some expression contains a given symbol

Given a symbol t and an expression expr, how can I determine whether or not the symbol t ...
116 views

Finding x when sin(x) = -.758 [closed]

I'm not understanding how to find all the angles for when sin(x) is equated to a negative decimal can someone explain to me how to find it..? So far I came up with 49.288 degrees, and 229.288 degree. ...
77 views

...
278 views

Polynomial expansion of operator

I am new to Mathematica, I am trying to generate the polynomial function of a operator. So for example, the operator $L$ is $\frac{\partial f}{\partial x}+\frac{\partial f}{\partial y}$, and I want ...
143 views

Display level of recursion of a recursive function during execution

Given a recursive function, is there some simple way to display or store the value of recursion or "how many levels deep" the function is at a given time? For instance, if we wrote the recursive ...
93 views

Numerical Integration/Function

I have a problem with a function defined numerically through an integral of the form: ...
123 views

How-to convert real number into List of its digits?

How could I convert a real number into a List of its digits in Mathematica? Example: 8.168643234 Desired output: {8,1,6,8,6,4,3,2,3,4} Many thanks in ...
150 views

Recursive definition of nested sums

I have a set of functions which take lists as arguments. They recursively nest sums, and I have defined them as follows ...
330 views

I use ...
376 views

Is there a built-in function to do binary search?

Is there a built-in function to do binary search? Say, given a list (sorted) and a number, find the position which keeps the listed sorted when the number is inserted. I know that ...
161 views

Loop function question [duplicate]

I'm new to Mathematica. Below is the code I have trouble with. ...
160 views

Getting terms and only evaluate specific parts

I want to expand the expression but I do not want it to evaluate. Sum[(HoldForm[1/(2 # - 1) - 1/(2 # + 1)] &)[i], {i, 1, 6}] However if you evaluate this you ...
216 views

Breaking a While loop

A simple example to illustrate what I'm talking about: m=0; While[m<=50, m=m+1; p=m] The result is: m=51 p=51 In ...
176 views

Extracting an equation from an interpolated function

Im trying to use LibraryLink to do some calculations in C but part of the expression i want to calculate is an Interpolating Function. C cant use that obviously so I'm trying to shift it to a data ...
60 views

How to put Black as the background colour, and text as white in Mathematica? [duplicate]

My question is equal to this one,even though by different reasons. I would like to know how can I change the white background to black, and the black text to white. I'm asking again, since a year has ...
98 views

FinancialDerivative function call without parameter fails in Mathematica 10

fixed in 10.0.2 When I type FinancialDerivative[] in Mathematica 10. There is error listed as follows. Anybody know how to solve it? Thanks.
96 views

Parametric Function

i'm struggling to implement the following parametric function: I need to create a g function with two arguments (w and v). If w and v are not empty lists, then it will return a list containing two ...
58 views

Input Reduce[Mod[a + x, l] == 0, x]' and output x == -a + kl`?

Reduce[a + x == k l && k > 0, x] (* k > 0 && x == -a + k l *) I think a + x == k l and ...
137 views

How to use Manipulate to cycle through a list of lists over a function

So I can do something like this which I like: Manipulate[i, {i, {1,2,3,4}}] It lets me pick which specific values I want to allow to be chosen for my function. ...
95 views

How to add my own functions to the library? [duplicate]

I would like to have my own functions (some sort of helper or utility functions) available all the times I run Mathematica. How to do that?
84 views

Solving coefficients of a function having boundary conditions

I have a function F=c+dz, which has particular boundary values, say F(z=1)=2 and F(z=-1)=1, ...
130 views

FullForm applied to functions

I would have expected FullForm[Cases[{a^2, a^3}, a_^1]] to produce Cases[List[Power[a, 2], Power[a ,3]], Pattern[a, Blank[]]]...
149 views

182 views

Coefficients of a polynomial in powers of 10

Can I express a polynomial function in Mathematica in power (ScientificForm) ? I was trying: ...
80 views

What are the differences between these functions when used for NMaximize?

In short, the question is how to construct the function you want to optimize? ...
479 views

Replace variables and redefine a function

I would like to redefine a function f(x)=1+2x^2 to a new function g(y)=1+2y by using the replacement ...
174 views

Josephus problem

See the Josephus Problem. My code takes in two numbers; one is the number of participants, and the other is supposed to be the number of players skipped between executions. ...