6
votes
5answers
352 views

Find function inverse

I'm trying to find the inverse of a function: (30*x^2 (1 - x)^2) (* where 0<x<1 *) I tried all the following options: 1. ...
4
votes
0answers
151 views

Strange behaviour of MMA in derivatives of some standard functions

There are some peculiar things to be discovered in derivatives of some standard functions in MMA: Strange behaviour Example 1: Abs We have ...
3
votes
0answers
55 views

Listable on first level

I have some function which take List as input. f[l_List]:=someActions[l] I need apply this function to a list of lists. Now I ...
3
votes
5answers
250 views

How to add periodicity to condition?

Is it possible to set the following function f[a], where a can be any real number? $$ f(\alpha) = \begin{cases} 1 ...
2
votes
1answer
175 views

Finding average error of the data

Considering I have some data, and I want to fit the data to a linear fit and find the average error from the linear fit, how can I do that using Mathematica? I have ...
1
vote
1answer
57 views

Remove curly brackets _completely_ to map a function to the elements of a list [duplicate]

Most list manipulations can be done with Flatten, Partition and Take. I didn't managed to ...
0
votes
1answer
29 views

Why would this function work only when I make a copy of the variable? [duplicate]

Why would this function work with a copy of the function variable: ...
2
votes
1answer
92 views

Define PolyLog so that positive reals evaluate on upper edge of branch cut

Generalizing the previous question: Define Log so that negative reals evaluate on lower edge of branch For real positive values $x>1$, Mathematica's polylogarithm function ...
0
votes
2answers
87 views

Defining a function as a sum of several Gaussians

I have a function that is a summation of several Gaussians. Working with a 1D Gaussian here, there are 3 variables for each Gaussian: A, ...
2
votes
3answers
260 views

Tracking iterations of a function

I'm learning MMA with Wagner's book. On page 41, he uses this to display the iterative steps of a FindRoot. However, I can't seem to replicate this (code at end), perhaps due to the difference in MMA ...
3
votes
2answers
79 views

Function pattern to support listed and non-listed arguments

I often want to write functions that take as an argument either a) a rule or b) a list of rules. As an example, when using Replace with just one rule, it does not ...
0
votes
1answer
64 views

function of derivative of a function

I know a similar question is answered somewhere, but it doesn't work for my case for some reason. I have the following problem in Mathematica. I want to compute f[h[x]]= x^2 + D[h[x],x]. Here, h[x] ...
0
votes
1answer
42 views

Defining arbitrary order derivatives function [duplicate]

I have a function $\phi(t)$ and I want to define a function $\phi D(t,r):=\phi^{(r)}(t)$, in other words evaluate the $r$'th derivative of $\phi$ at $t$. The naive code that I have is: ...
4
votes
4answers
208 views

Speed up replace all

I have large list of rules, I would like to use list/.rule, but assume that rule is a set of rules rule 1, rule2 rule...I want ...
1
vote
0answers
23 views

Minimizing roots of a transcendental equations [duplicate]

I'm trying to use the solution of FindRoot with parameters for further calculations. Annoyingly enough it always gives me trouble with replacing the parameters. As an example I'm attaching a simple ...
0
votes
0answers
116 views

A problem with functions and Infinite expression 1/0 encountering

Following code (function) makes integrals and then replace f[x] with Cos functions and calculate the definite parametric ...
0
votes
1answer
107 views

A problem with set values

The following code is just an example to clearly explain my problem. Assume that : ...
0
votes
1answer
50 views

How to put some values from a list into a function in a Do loop

I want to program a code in MATHEMATICA in order to calculate some values in different iteration. For example, assume this list: list={1,2,3,4,5} Now assume that ...
0
votes
1answer
84 views

Normalize equation in NDSolve?

I have numerically solved and plotted the solution to the Mathieu equation using NDSolve successfully, as below: ...
5
votes
4answers
1k views

“do … while” loop equivalent in Mathematica [closed]

Have I missed something or is there no built-in which mimics the behaviour of do ... while loop? I am looking for a construct that evaluates procedure once and ...
0
votes
1answer
87 views

Working with functions

I am required to write a function that takes a function as a parameter. ...
3
votes
2answers
267 views

Differential operator squared

I defined a one-dimensional momentum operator $\hat{p}=-i\hbar\frac{\partial}{\partial{x}}$ in Mathematica p = -I * h * D[#, x]& and I want to get the ...
0
votes
3answers
99 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 ...
5
votes
2answers
391 views

Multiply each element of an array by another array?

I would like to multiply an array by each element of another array, and am having a lot of trouble finding a built-in or automated method of doing. Here is an example of what I'd like to achieve: ...
5
votes
2answers
331 views

Define a function with a function for an input

I want to create the functions $even[f]$ and $odd[f]$ which will apply the formula $even[f(x)] = \frac{f(x)+f(-x)}{2}$ and $odd[f(x)]=\frac{f(x)-f(-x)}{2}$ for an arbitrary $f$. I tried using ...
0
votes
0answers
41 views

Using Table[ ] vs using Do[Append [ ] ] [duplicate]

Is it generally better/faster to use the Table function over using Do[Append []]? For example, I have this piece of code: ...
0
votes
1answer
165 views

Please explain this code (contains Append, Do, Coefficient)

I am a graduate student using a past student's Mathematica program. Will someone please explain to me exactly what this piece of code is doing? Specifically the ...
-1
votes
1answer
74 views

How to specify a specific range for a loop?

I'm having trouble with setting up a particular range in a loop for my programming. Now I have a defined range of data (not continuous numbers) that needs to be applied in a loop. Since the aim for my ...
1
vote
3answers
176 views

professionalize/optimize my code that calls a function

I have the following construction, which defines a function that I subsequently call in a loop multiple times. I use this very often, but I have never looked into if there is a more professional way ...
2
votes
2answers
82 views

`PrimeNu` counting function

Building on this question, what is the most efficient counting function for distinct prime factors? It would obviously be more efficient if Prime and ...
8
votes
2answers
237 views

Automatically compute r[1] = r1; r[2] = r2; …

I have three variables like this, r1 = 4; r2 = 3; r3 = 1; and I want to insert them into a function use them in a function definition like so: ...
1
vote
1answer
96 views

Linearity of a function in Mathematica

I have a function which has something like myFunc[q,a state[c,d]] a could be anything, and I want to tell Mathematica that ...
3
votes
3answers
217 views

Prime factor counting function

Is there any way I can speed up this prime factor counting function? (I am looking for all numbers in a range with 3 prime factors (counted with multiplicity).) ...
1
vote
3answers
175 views

Pure function inside another pure function

I have the following working expression: In[15]:= Length[Select[IntegerPartitions[10],First[#1]==5&]] Out[15]= 7 But, instead of using the constant 5 I want ...
4
votes
3answers
803 views

Make a differentiable smooth sawtooth waveform

So, I am trying to understand the effect of sawtooth waveform on a mechanical system model. For example, a system of a plate and a box on it. And then we try to oscillate the plate. In order to do ...
8
votes
3answers
197 views
5
votes
1answer
65 views

How to bail out from a non-applicable transformation function?

I provide a custom function in TransformationFunctions options of FullSimplify that can do a transformation only for some values ...
0
votes
0answers
74 views

creating some smooth density functions

I would like to create some density functions based on some distance measure $D$. As a base density function lets say I have a Gaussian density $f$ with mean $-1$ and variance $1$. I would like to ...
0
votes
2answers
80 views

I want to define a function that has integer power [closed]

I am defining this function: f[x_] = kr*g[x] + (c^l*x^l)/(KIR + c^l*x^l) But I want to make l bigger than 0, so if I evaluate ...
2
votes
2answers
553 views

Q-Function representation in Mathematica

I observed that there is no Q-function representation in Mathematica. The definition of Q-Function is: \begin{align} Q(x) &= \frac{1}{\sqrt{2\pi}} \int_x^\infty e^{-\frac{u^2}{2}}du \\ ...
14
votes
1answer
331 views

How to represent a continuous monotonic phase of Airy functions?

Note: In this question I am concerned only with real-valued variables and functions. DLMF, §9.8 Airy Functions, Modulus and Phase, formula $9.8.4$ defines the phase of Airy functions: ...
5
votes
2answers
655 views

How to find the non-differentiable point(s) of a given continuous function?

For example, the non-differentiable point of the function $f(x)=|x|$ is at $x=0$. How to find the non-differentiable points of a continuous function that is defined numerically?
2
votes
1answer
105 views

How to define a function of z[bar], etc

Using Displaying index as subscript on output: e.g. C[i] -> C_i with Notation[...] or Interpretation[..]? I have often ended up wanting to define functions of annotated variables to better match my ...
1
vote
2answers
412 views
3
votes
1answer
235 views

NestList with a list inside?

I'm new to Mathematica, and was looking for more efficient ways to implement the Do loop below. a, ...
1
vote
1answer
103 views

User-defined Distance Functions with extra parameters [duplicate]

The Nearest function accepts a customized distance function. For example, a simple case that works well is ...
7
votes
3answers
181 views

How can I break through Function's HoldAll attribute to force evaluation of a body element?

The question concerns creating a function. Let consider the following code With[{f = Function[t, Cos[t]]}, {First[#], f'[#]} & ] which returns ...
4
votes
4answers
221 views

How to avoid writing $K$ loops?

I want to evaluate a mathematical function of $K$ variables each of variables varying between 1:N. One way to do this is writing $K$ loops and varying variables accordingly, as shown below: ...
2
votes
2answers
223 views

Writing a function that returns a (usable) function

I am trying to create a function that returns Arnold's Cat Map of size n iterated k times. I can get something out of the Function command, but I can't figure out ...
1
vote
0answers
162 views

Positive integrand giving negative answer

I'm integrating a positive function f(t) times sin(t) from 0 to pi/5 and get -38. Actually f is slightly negative for a short time (smallest value ~ -0.0005), but far from enough to explain this. ...