537 views

Using predefined expressions as free variables in a pure function [duplicate]

I want to have a function value of an expression where some variables are solutions to some set of equations, with some values of parameters. I had an idea to use pure functions for that. However, ...
100 views

Globally Defining a Variable that Depends on Arguments of Functions [duplicate]

I have many delayed-defined functions of many variables, and all the functions share a term containing some of these variables. Thus, I would like to just call the term ...
480 views

Calling a function on a variable with parameters [duplicate]

I have an equation that contains parameters. I want to use it in a function like NDSolve, but I can't seem to figure out how to do so. Here's an example: I define ...
198 views

Assign a function within a function [duplicate]

What I'm doing wrong? 1st function works as expected but the 2nd one doesn't. What I want is to enter an algebraic expression and two numeric constants and get the same result as with the first ...
126 views

Implementation of a recursive function [duplicate]

I have been trying to implement a recursive function, but still struggle. Here's what I have written: ...
80 views

Defining function [duplicate]

ver1 = 2 x verf[x_] := ver1 verf[3] Result : 2 x Expected Result : 6 In the above code ...
39 views

Basic Question on function of $n$ when it shift to $n-1$ [duplicate]

This question is basic, but I do not know what is wrong. Clear[a0,a] a0=n; a[n_]:=a0 But when I evaluate a[n-1] the output ...
24 views

Substitution in delayed evaluation function [duplicate]

I am trying to do the the following: precomputing an expression and then making a function out of it. It has to be delayed evalution, because some of the parameters are only known when the function is ...
2k views

Enforcing correct variable bindings and avoiding renamings for conflicting variables in nested scoping constructs

Using global variables the following turns an "expression" into a Function: expr = 2 x; Function[x, Evaluate[expr]] Of course ...
3k views

How to pass variables by reference and by value [duplicate]

I haven't seen this question specifically addressed before in this site, although some hints and traces have been given, for instance, here: Pass by reference for an option argument Does pass-by-...
416 views

What is the the proper way to define a function from an expression?

Say after some long computation we get an expression expr=x^2 We do not know what the value of expr beforehand. Now we want ...
1k views

Delayed evaluation of assignment

I have a set of PDE's that depend on parameters. They depend on many parameters, but for simplicity we can here assume that they depend only on one, say a. I want ...
395 views

Using Block with a list of variables

I have a list of variables var={v1,v2}; which I want to protect/localize during a particular operation. I have decided that I want to use ...