# All Questions

31 questions
Filter by
Sorted by
Tagged with
1answer
36 views

### Construction of symmetric function / matching function argument patterns

[Edited for clarification after comment] Suppose that the function f is defined as the linear combination of several translated/reflected functions starting from the primitive f0[x,y,z] ...
1answer
32 views

### Constructing sequence of function with elements depending on the previous one / recursion

Starting from a function $\theta0[x\_ , y\_ , z\_ ]$, the terms $\varphi[x\_ , y\_ , z\_ ]$ constitutes a sequence of functions that is constructed as follows: Order 1 (one function and its ...
1answer
54 views

### Replace constant in summation function using replace or If or /

Hi i how do i replace constant for k in this summation. For following: Even 2*n Even replace k by a Even 2*n+1 Odd replace k by b Here is the code ...
2answers
51 views

### Replacement rule for terms that are separated by operators?

My main problem is how one can create a "transcending between operators rule" in the same term according to the minimal example bellow. Suppose I need to perform a replacement of the form ...
2answers
105 views

### Convert defined variables to rule list

I'd like to make a function that takes a list of variables and returns a corresponding rule list with the current values of the variables. E.g. ...
3answers
75 views

### How to make functional rules not depend on an argument?

Consider the following: rule = f[x] -> Sin[x] if I now do, say: f[y] /. rule this does not work, because the rule wants ...
3answers
148 views

### Substitution rule for sums of similar objects?

Consider objects like ...
0answers
29 views

### Define a function using pattern matching and repeated replacement to sum the elements of a list.(exercise in Paul Wellin's Book)

I am reading Paul Wellin "Essentials of Programming in Mathematica". I have a question about his answer to 4.1 Exercise 5. 4.1 Exercise 5: Define a function using pattern matching and repeated ...
5answers
257 views

### First evaluate in place all subexpressions matching pattern before substituting result

ReplaceAll[expr, {patt1:>rhs1, patt2:>rhs2, …}] works by looking for and making all possible replacements of subexpressions in ...
1answer
85 views

### Using Table to make a set of replacement rules for functions

I have a 3x3 matrix of functions. It looks like ...
1answer
144 views

### Make mathematica create equations and put them into NSolve

I want to be able to define n shapes and find the intersection between them and a line. I'm treating the shapes as "one" shape, i.e. I do not want any internal ...
0answers
42 views

### Can't plug solution to system of equations into function [closed]

I'm defining a new function by plugging the solution to a system of equations into an existing function. I cannot calculate the value of the new function for given variable values. I'm providing a ...
1answer
76 views

### Substitution rules do not trigger

I am trying to write substitution rules to obtain an ordered 4-form from four 1-forms constructed by applying a total differentiation to four functions: ...
1answer
72 views

### Forcing variable substitution on delayed evaluation

Problem, the following snippet doesn't substitute vars ...
1answer
162 views

### How to put a Hold on a variable so it can be set

I've got a weird problem here.... So I have a function that takes blocks of codes and them uses Map on them and passes them around and then selects and returns the one that is needed. A simplified ...
3answers
316 views

### Compare elements iteratively

Assume I have the following data: data = {{30, 8}, {37, 3}, {36, 8}, {40, 17}, {1, 4}} and I need to apply the function EuclideanDistance between element 1 and 2,...
2answers
84 views

### How to capitalize a variable in equation? [closed]

I have a function of following kind: $f[\delta,\lambda]=A+B[\delta]+C[\lambda]+E[\delta,\lambda]$. Now, I want to make a function "g" from "f" such that\$g[f[\delta,\lambda]]=A+B[\delta]+C[\lambda]+E[\...
2answers
196 views

### Evaluating ReplaceAll inside SetDelayed, first

Consider the following (simplified for the purpose of example) definitions: f[x_] := y /. y -> x g[x_] := x Where for example, the definition of ...
1answer
761 views

### Safe way to put a pattern on the right hand side of a rule

I'm interested in creating a function or rule that generates its own set of rules. For instance, it would take as an input the expression h[m, n] and the indices <...
0answers
58 views

### A kind of function optimization problem [duplicate]

I have the following problem. Out of a calculation I got the four functions shown at the end of the post. These functions depends on many variables, qk, pk etc (all of them are actually scalar ...
2answers
118 views

### Replace function with multiple functions while respecting the inputs

I want to replace a function with either one or two functions and also combine their arguments. Say I have an original expression expr = u[i + 1] r[i] r[i-1] ...
1answer
242 views

### Substitute a function's definition for its name

I'm having trouble with a function which is supposed to work on another function. Simplified version: ...
1answer
104 views

### Function returned an unexpected list

I was trying out a question in Wellin's Programming with Mathematica that says the following. Question: Given a set of points in the plane (or 3-space), find the maximum distance between any pair of ...
1answer
118 views

### How can I write a function which takes another function of a variable and the variable itself as arguments and gives a list of critical points?

This is an exercise from Power Programming with Mathematica by Wagner. I need a function which takes a function and a variable as arguments, like this: critpts[f_,x_]:= and then on the rhs I've got ...
2answers
2k views

### Best practice of passing a large number of parameters to functions

I have a number of functions that all take a large number of parameters. I am wondering what is the best practice of passing these parameters to those functions. I could, of course, simply specify ...
2answers
207 views

### How to assign special colors to the output of DensityPlot?

I have created the following function for plotting ...
1answer
70 views

### How to substitue local variables into expression with free variables?

I'm wondering how to do the following: expr = L + R; foo[L_, R_] := expr; foo[1, 2] (* L + R *) and have it substitute the function variables into ...
1answer
276 views

### Equating and solving equations that have been generated using table[]

I am in the process of trying to use Mathematica to find the coefficients of transmission and reflection for the wavefunction of a beam of particles tunnelling across any number of identical potential ...
2answers
115 views

### Creating functions from output of other calculations

Apologies in advance if the title is vague, I'm not really sure what to call this. I have a function (call it 'foo') that generates a largeish polynomial, and it is natural to make the variables be ...
2answers
375 views

### How to use Solve rules as a function body?

Solve gives me an expression which I want to use as the body of a function. Rather than run Solve every time inside my function ...
2answers
684 views

### Returning Replacement Rules in a function and using it later on

I would like a function which returns replacement rules as some internal mathematica functions are doing and use the results in other functions. I could not find any information on that and I'm ...