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

learn more… | top users | synonyms

1
vote
3answers
145 views

Create a function which gets a function and a x as argument and returns the y [closed]

After a few hours and lots of tries, I am hoping that someone could give me a solution to my problem. I want to have a function, which gets a function and a value as arguments. The function should now ...
2
votes
2answers
104 views

Generating a permutation of elements in chunks

Is there a way for me to generate a list of permutations in "chunks" such that I needn't store everything on RAM all at once? Consider that (WARNING: DO NOT RUN! --- Will generate a list with 13! = ...
2
votes
1answer
51 views

Double application of NIntegrate produces unexpected error messages [duplicate]

In the course of trying to answer 69601, I encountered unexpected error messages. In highly simplified form, NIntegrate[NIntegrate[z y, {y, 0, 10}], {z, 0, 10}] ...
1
vote
2answers
97 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 ...
13
votes
11answers
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: ...
4
votes
1answer
119 views

Coefficients of a polynomial in powers of 10

Can I express a polynomial function in Mathematica in power (ScientificForm) ? I was trying: ...
1
vote
0answers
68 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? ...
6
votes
4answers
146 views

Minimizing a function with a constant $l > 0$

I'm VERY new to Mathematica and would like some help with minimizing a function. $$f(x) = \frac{1}{2} \sqrt{\frac{\left(l^4+x^4\right)^2}{l^4 x^2}}$$ I want to find which $x-value$ (probably ...
0
votes
2answers
122 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 ...
6
votes
3answers
179 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 ...
1
vote
2answers
129 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. ...
1
vote
2answers
56 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 ...
0
votes
0answers
54 views

Plot function failure, and understanding how mathematica selects recursion points for correction

I think it is best to start out by directing everyone to this link. The discussion concerns why the Plot function fails to accurately generate a simple sine wave for given parameters. The answer given ...
1
vote
1answer
94 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: ...
1
vote
1answer
56 views

Aborting from a Dialog box

I'm trying to abort a While cycle, with a dialog box. I've tried the following: ...
11
votes
0answers
133 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 ...
3
votes
1answer
150 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] ...
7
votes
0answers
123 views

More Ticks::ticks errors in AbsoluteOptions in v10

Bug introduced in 10.0.0 . Bug remains as of 10.1 While the specific bug affecting Plot described in AbsoluteOptions prints error messages in V10 has been fixed ...
0
votes
2answers
77 views

Choosing pairs from a list that satisfy a certain equality [closed]

If I have many numbers in here {{A,B},{C,D},{E,F}.....} And I want choose the B,D,F,....(the second number) to run a function y=f(x), where x=B,D,F.... Then I need to check if y=f(B) is equal to A or ...
0
votes
3answers
91 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)
0
votes
0answers
79 views

How to conveniently stop a programme without aborting the computation

I have a programme that will have to run for a few days. However, I would like the user to have the option of stopping the computation of the code, without aborting it, when he desires, without ...
0
votes
0answers
42 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 ...
6
votes
4answers
204 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 ...
0
votes
2answers
61 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 ...
1
vote
3answers
70 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: ...
1
vote
1answer
108 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 ...
2
votes
1answer
69 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 ...
15
votes
2answers
229 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: ...
0
votes
1answer
56 views

Defining a function with algebraic parameters

I am trying to define and use a function to represent the eigenstates of a Quantum Harmonic Oscillator, which have the general form: $$\psi_{n}(x) = \frac{1}{\sqrt{2^{n} n!}}\left(\frac{m \omega}{2 ...
2
votes
2answers
70 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 ...
0
votes
3answers
94 views

Defining a function which displays odd numbers? [closed]

Define a function that takes as input an integer n and returns as output the product of the first n odd numbers., i.e., 1 · 3 · 5 · · · 2n − 1. Evaluate your function at 1, 2, 3 and make sure you get ...
6
votes
2answers
145 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 ...
0
votes
2answers
707 views

How to find volume of an egg [closed]

I am a first time user of mathematica. I've been trying to figure out how to find the volume of a) f(x)=(ax^3 + bx^2 + cx + d)sqrt(1-x^2). I have been scouring the internet for a solution on how to ...
3
votes
0answers
59 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 ...
1
vote
1answer
83 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 ...
11
votes
4answers
578 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 ...
3
votes
1answer
88 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 ...
0
votes
0answers
50 views

Improving RationalInterpolation Result

The following code produces a {4,4} rational interpolation approximation accurate to 10^-6 or better over the range ...
1
vote
1answer
67 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: ...
0
votes
1answer
74 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?
2
votes
1answer
257 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]. ...
0
votes
1answer
44 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 ...
0
votes
1answer
52 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 ...
1
vote
2answers
722 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, ...
1
vote
1answer
122 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 ...
6
votes
3answers
206 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 ...
0
votes
1answer
60 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 ...
2
votes
2answers
159 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 ...
1
vote
0answers
118 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, ...