# Tagged Questions

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

168 views

### Expressions containing globally undefined symbols inside a function where they are defined

Consider the following code. f[a_,b_]:=x; Clear[a,b]; x=a+b; f[1,2] It returns a+b. However, from a certain viewpoint, one ...
1k views

### Divide all but the maximal element in a list by 10?

I have a list of numerical data, and I want to write a program that will keep the maximum as it is, but reduce the rest by certain factor (such as 10). For example: ...
179 views

### Coefficients of a polynomial in powers of 10

Can I express a polynomial function in Mathematica in power (ScientificForm) ? I was trying: ...
79 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? ...
456 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 ...
272 views

### Is it possible to find generating functions of infinite sequences with Mathematica?

I'm trying to find the generating function of a sequence as $(0,1,0,1,0,1,\dots)$ but reading Mathematica's help on FindGeneratingFunction[] seems to tell me that ...
172 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. ...
71 views

### Incomplete Integration in Area

Area[2 Sqrt[(1 - p^2)^2 - r^2], {p, 0, 1}, {r, 0, 1 - p^2}] is able to perform only the integral over r, leaving the integral ...
120 views

### How to fill a Marshal buffer with whitespace using NETLink

Further to Todd Gayley's answer on string handling in a DLL function, I have the following code: ...
80 views

### Aborting from a Dialog box

I'm trying to abort a While cycle, with a dialog box. I've tried the following: ...
324 views

### Default behaviour of Hash[expr] and hashing in different versions of Mathematica

In different versions of Mathematica, Wolfram silently changed the behaviour of Hash when the algorithm is not specified explicitly ...
165 views

### Function that returns the second argument of Reap

I'm trying to create a function that returns only the second argument of Reap. Here's my naive guess of how it would go : Reap2[x_]:= Flatten[Reap[x][[2]],1] ...
413 views

### More Ticks::ticks errors in AbsoluteOptions in v10

Bug introduced in 7.0 or earlier and persisting through 10.4 or later While the specific bug affecting Plot described in AbsoluteOptions prints error messages in ...
177 views

### choose any number e that is relatively prime to n

I try to write a command that means choose any number e that is relatively prime to n, like e^n [Congruent] 1 (mod n), but it didn't give me a value of e. e^n [Congruent] 1 (mod n)
46 views

### Regarding Cycles and Lists of Functions

So, I'm trying to determine the Normal Matrix of a Least Squares Aproximation; I have a basis constituted by 8 functions f1,f2...f8; I have 9 points which constitute Datax = {x1,x2...x9} Now, I ...
381 views

### What is shorthand way of Reap list that may be empty because of zero Sow

Sometimes because of conditionals, you cannot guarantee that Sow will be called at least once. Reap[Sow[1]][[2,1]] results in <...
69 views

### Binding trigonometric terms

I have many terms like A = Cos[Pi/18 + 2 x] + Cos[Pi/18 - 2 x] and I want to convert A to ...
102 views

### Defining a function using a preceding expression

How can I automatically define a function inside my Mathematica code using a result (expression) that preceded the point of definition. For example: ...
183 views

### Quantize a real-valued function?

I'm wondering if there's a built-in way in Mathematica to take a function whose output values are continuous, and quantize it to produce a step function. For example, I have the function ...
90 views

### How to package a function for export?

I often post code for functions on Stack-Exchange, and then later find that they are unexecutable - that people can't use them because I mistakenly omitted some private functions or values that are ...
328 views

### Where is the old option TraceInternal->True?

Already at least in version 2 (I think), the function Solve calls the function Roots. At that time, I had a rather dirty trick, that still works, to verify this: ...
110 views

### Define function over expression

Suppose I have the following expression system = x + y + z And I would like to define a function that contains this function, without explicitly typing the right ...
296 views

### Difference between Evaluation>>Quit Kernel and Quit[]

What is the difference between Evaluation >> QuitKernel and Quit[]? Both seem to quit the kernel (and clearing all ...
69 views

### Lists for built-in functions that can work without brackets

I just noticed that Exit and Quit can work without brackets i.e. a single Exit or ...
101 views

### FinancialData Input

What does the function FinancialData require as input for natural gas: http://finance.yahoo.com/q?s=NGG15.NYM Is it easier to export the natural gas data to excel,...
879 views

### Generating Random Real numbers with certain numbers not included

I'm writing a program that i need 1000 real number between -3 and 6. the code that I used for generating and saving them was l = RandomReal[{-3, 6}, 1000] But I ...
119 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 ...
69 views

### Improving RationalInterpolation Result

The following code produces a {4,4} rational interpolation approximation accurate to 10^-6 or better over the range ...
233 views

### Composition of Multivariable function

I am trying to compose functions of xleft, maybe like xleft[xleft[f]] or even higher order. And here is my function: ...
77 views

### Diffentiating a function f with respect to x [duplicate]

I have a tabe y={10,20,30,40...} and x={62,63,64,65...} y is a function f and this function needs to be interpolated. How do I defferentiate the function f with respect to x?
284 views

### How to make a function from body with variable number of arguments?

Suppose I have an UNKNOWN function, which generates formulas with given number of x[i]. ...
70 views

### Taking function output as shown, and processing it regardless of its history

I am making some symbolical calculations for my quantum chemistry class. I am supposed to build a wave function composed of multiple other functions, each of which is also composite of some lower ...
60 views

### What is the simplest way to obtain function obect of a given function?

Suppose I have a function p of some arguments: p[x_,y_]:= (* something *) Now I with to pass this function as an object to ...
9k views

### How to tell Mathematica that certain variables are real/imaginary, integer-valued, etc

I'm trying to expedite some quantum mechanical calculations by running them through Mathematica. Expectation values and stuff like that. When I say, for example, ...
167 views

### Why does LyapunovSolve solve non-standard form?

LyapunovSolve[A,Q] solves the equation $A P + P A^T = Q$ for $P$ whereas the standard form (wikipedia,lecture notes, p.25, linear control systems) of the Lyapunov ...
253 views

### How to define a nested function like this?

For example, I want to calculate the limit of $\frac{1}{1+\frac{2}{1+\frac{3}{1+\ldots}}}$. So I want to define: $f(1)=1$ $f(2)=\frac{1}{1+2}$ $f(3)=\frac{1}{1+\frac{2}{1+3}}$ Then I calculate ...
148 views

### Mathematica Lattice Reduce Command

I'm going through a very old copy of "Mathematica: A System for Doing Mathematics by Computer" for self practice. I'm on chapter 3, and ran into the LatticeReduce ...
367 views

### cycloid parametric [closed]

How do I enter 3 parametric equations for cycloids corresponding to circles with radii 1, 2, and 4. I have tried ...
254 views

### Crosscorrelation for nonperiodic signals

I want to detect patterns (of an absorption spectrum which is nonperiodic) with Mathematica automaticly. I have found CorrelationFuncion but as far as I understand, ...
168 views

### Missing control for depth of Inner

Working on a mechanics problem, I stumbled on something peculiar: Since Inner is a generalisation of Dot, it changes its ...
53 views

### How to add a part of a list to a function?

I want to be able to add a specific portion of a list to a part of a function but this fucntion intakes 6 variables where as the list is of example: ...
40 views

### Why does the same function defined by Set and SetDelayed look different? [duplicate]

I start with the following input: f[n_] = Sum[(1+x)^j, {j,1,n}]; g[n_] := Sum[(1+x)^j, {j,1,n}] When I try to evaluate the code above I get: ...
129 views

### Show how Eliminate arrives at reduction

Does anyone know how to get Mathematica to show how it arrives at the following result? ...
82 views

### Help creating a simple function

Can someone help me to create a function. The truth I'm new in Mathematica and I don't understand well the way functions work in I. I need a function that animate some rectangles according to a curve ...
83 views

### Integrate[] does not work when the function has an antiderivative function

This function (1 + (1 + 1/(2*Sqrt[x]))/(2*Sqrt[Sqrt[x] + x]))/(2*Sqrt[x + Sqrt[Sqrt[x] + x]]) has the antiderivative function, since ...
452 views

### Putting two functions in one manipulate plot

I have a problem that is somewhat related to this http://stackoverflow.com/questions/7727668/putting-two-plots-in-a-manipulate-whilst-keeping-the-plots-visible but I would like to plot two functions ...
295 views

### How do I override options with my own defaults?

I'm calling a function f from within a function g and would like to pass any valid options for ...
180 views

### using Module in NDSolve

I am trying to solve a set of two wave equations where solution of first equation defines initial conditions for the second one. And I would like to use Module to define those equations as a function ...