Questions tagged [function-construction]

For questions on writing functions (pure or using Set/SetDelayed) for any purpose, including the features that may be incorporated in those functions, such as options, patterns and conditions.

Filter by
Sorted by
Tagged with
0
votes
1answer
22 views

Interpolation of a set of points that include a non-numeric real constants

I have a set of data like: matrix=Table[{x,y,x+y*c1},{x,0,1,0.1},{y,0,1,0.1}] where 'c1' is a real constant. I'm trying to create an interpolation function called '...
-1
votes
0answers
30 views

Calculating an unsimplified expression containing derivative of an expression which is substituted instead of a function

I have the following expression: Derivative[0, 1][Integrate[E^(-(n*\[Tau]) - I*k*y*Cosh[\[Tau]])*B[\[Tau]], \[Tau]]][x, y] which is created by substitution of a ...
-1
votes
0answers
40 views

Detecting whether a function is initially defined with the form R[x,y] or R[x_,y_], etc

I have a very long code that may have errors in definition of functions and I want to trace these errors. Is there any attribute or function to detect whether a function is initially defined in the ...
0
votes
1answer
52 views

Changing part of the name of the function

Is it possible in Mathematica to replace the part of the name of the function to give the same arguments to another function? In fact, I have a lot of functions with the following name pattern: ...
1
vote
1answer
27 views

How can I extract a list of terms with functions in terms of a specific variable

I have an expression in the following form: a f[x] + b Exp[g[x, y]] + r[z] f[y] + f[y] Sin[h[x, y, z]^2] + r[z] Log[t[z, y]] I want to extract an expression ...
2
votes
2answers
186 views

Defining a function recursively

I want to construct polynomials (or just function) $f_n$ from $f_{n-1}$ using mathematica. For some kind of reason, I didn't manage to do this. So basically something like a recurrence table, but for ...
4
votes
3answers
152 views

Permutation avoidance function

It is common for me to see if a permutation of 1,2,...,n, avoids some fixed permutation pattern. For example, the permutation [1,4,2,3,5] contains the pattern 1,3,2, as the elements [1,4,3] appear in ...
2
votes
1answer
76 views

What's wrong with SetDelayed? The body of the function works alone, while setdelayed to it as $f[x\_]:=func$ gives the wrong answer

So I was writing a function to get the poincare map of a given dynamic system, for example, the duffing oscillator. I obtained the time series in advance, then take the poincare map based on this time ...
1
vote
0answers
48 views

How to make a function in terms of constants to inherit the attribute of being constant

I have defined two variables a and b: SetAttributes[a, Constant]; SetAtributes[b, Constant]; I have defined a function c as ...
1
vote
2answers
38 views

How to assume some variables to "not" be a function of other variables at the time of defining a function [closed]

I have a function with the following definition: F[x]=Exp[q*w*x]; I want to take total derivatives of F. How can I define that q and w are not dependent on x at the ...
1
vote
1answer
39 views

How to separately pass elements of a 3D list as part of the arguments of a function

Hi I have a function which its arguments have the form F[a,b,c,d,e] but the 2nd to 4th arguments are in a list of the form R={{{b,c,d},{e,f,g}},{{h,i,j},{k,l,m}}} how can I pass these elements as ...
2
votes
2answers
51 views

Partially Orderless Arguments in Functions

I am a Mathematica beginner and I'm trying to implement a function of type f[i1_,i2_,i3_,i4_] such that it is orderless in the first two arguments and in the last ...
0
votes
0answers
43 views

How to define a function without giving explicit formula

I want to have a function and I need to do some complex calculations to obtain an equation and then I want to assign the values to the function and then solve this equation to obtain the unknown ...
1
vote
0answers
129 views

How to Create an Efficient Word Square Algorithm?

I am working on the Wolfram Challenge Babbage Squares. I have looked at the following resources in order to come up with an idea for how to find all the possible word squares: Word Squares and Beyond ...
1
vote
0answers
47 views

Loops Not Working- Kernel Crashes and Values Incorrectly Updated

I haven't used Mathematica in a while so any help is very greatly appreciated. I am trying to run a program with nested for loops that runs two function evaluations in the inner most part of the loops....
0
votes
2answers
27 views

How to turn FindFit result into function within a Module context

I'm trying to construct a 'normal' function (with formal parameter) from the FindFit result within a Module context. While this works on a global level: In := ...
1
vote
1answer
46 views

How to create a simple transformation function on lists using short form of ReplaceAll?

I can easily do this with Map so the real goal of this exercise is to get a better grip on using transformation rules. Please help with this. The outputs should be ...
0
votes
0answers
42 views

Silly trouble expressing recursive formulas?

I am trying to code the following formulas: I did it in the following way: ...
1
vote
1answer
59 views

Is there a comprehensive list of most common or most important native Message-s (w/tags) for errors and Failed?

Yes I understand how to use Messages[symbol] but that doesn't help much. I have no idea which important ones I may have missed in my search or even how many exist. ...
0
votes
0answers
58 views

Recursively rewrite function

Let's imagine I already have a function like myfac[0] :=1 myfac[n_ /; n>=0] := n myfac[n-1] this home grown factorial. Now I want to equip it with tracing (and ...
0
votes
1answer
48 views

Could anyone help me to plot the following function? [closed]

Unfortunately Mathematica is not able to run the following program area[d_]:=Pi*d^2/4 Q=80/1000 v[d_]:=Q/area[d] [Nu]=10^-6 Reynolds[d_]:=v[d]*d/[Nu] [Epsilon]=0.04/1000 CW[[Lambda],d]:=1/Sqrt[[Lambda]...
0
votes
0answers
20 views

(Laplace Coefficents) Integral function definition

TLDR: need help defining two functions involving integrals in the form of "Laplace Coefficents". My intention is to define functions that involve Laplace Coefficents. In particular, if $$b_{...
0
votes
0answers
29 views

Suppressing tensor indices and function labels of a function

I am trying to do some GR calculations, and want to write a code which shows the expressions symbolically using compact indices, rather than write all the quantities in detail. More precisely, ...
2
votes
1answer
48 views

Why is Style ignored in my custom Echo error function?

To highlight the type of error that occurred the function echoError (via err) should display type of error in color: ...
3
votes
1answer
139 views

Using Mathematica to derive analytic form of single variable function

I am interested in finding an analytical form of the following function $f(n)$ defined as: $$f(n):=\sum_{\{\bar{K}\}}\prod_{l<j}^{n}e^{ik_lk_j},$$ where $\{\bar{K}\}$ is the full set of binary ...
2
votes
1answer
66 views

Defining function with arguments in a specific pattern similar to Graphics[]

I'm trying to define a function that is of this form: ...
7
votes
1answer
189 views

How to set deeper patterns in arguments within function definitions. For example if an argument must be a list of 1 or more strings

Suppose I want to define a function whose argument must be a List of only Strings and List must have at least one member. I know how to require that the Head must be a List but how does one qualify ...
0
votes
2answers
65 views

Integrate of simple equation but is not solving!

I have this simple integral but I don't know why Mathematica can't solve it?! FullSimplify[Integrate[x/(-x^2 + a x + b)^(1/2), {x, Sqrt[b], Sqrt[R^2 + b]},Assumptions -> {a > 0, b > 0}]]
1
vote
1answer
106 views

Condition (/;) not working correctly on a function with optional arguments and options

I have read this post: How to avoid collision between optional arguments and options, and use Mr.Wizard's method to solve this problem. But when I add conditions to optional arguments, it seems that ...
0
votes
1answer
40 views

Creating and defining a family of functions with indexed variables?

I am trying to do the following: Create a list as Table[Subscript[\[Beta], i] _, {i, 1, dim}] And then use this list to define a function: ...
4
votes
1answer
72 views

Plotting a sequence of functions with cases

How can I plot functions like this $$f_{2^n+j}(x)=\begin{cases}0, x\in [\frac{j}{2^n},\frac{j+1}{2^n}]\\1, x\in x<\frac{j}{2^n} \text{ or } x>\frac{j+1}{2^n}\end{cases}$$? I tried something like ...
0
votes
0answers
41 views

Define multivariate even general function

I want to define a multivariate even function. This question shows how to do it for a single variable function Defining general odd function but I don't see how to generalize the syntax to multiple ...
0
votes
1answer
64 views

How to clear all things inside a loop?

It happens to me a lot when I write a loop, I have to Clear all functions, variables, definitions and etc to be sure my calculations is done correctly. namely as a ...
0
votes
0answers
40 views

How can I set a find max value function with parameter in NDSolve

For example, Here is a NDSolve function with a parameter of w ...
0
votes
1answer
35 views

FoldList type evaluation for multivariable function

In the example code which follows I define a two variable conditional function h[_i, _v], one variable denotes the integer index i, and the other is an N-dimensional vector v (I denote dimension 'N' ...
5
votes
1answer
297 views

Why the first one works fine but not the second one?

Why the first one works fine but not the second one? How can I make it work? Abs[#] Exp[I Arg[#]] &@(1 + I) ...
0
votes
0answers
30 views

Force list of colours to have same grayscale value, maintaining hue

A sketch of what I'd like to achieve is given by ...
1
vote
1answer
66 views

Dynamic influenced by a countdown Clock ignores actions in second argument

I stripped a Dynamic down to its bare essentials. Dynamic doesn't execute any of the functions asked for in second argument. ...
2
votes
2answers
88 views

Function as a sum of functions

I just get started with Mathematica and I have a basic question about defining a function (I am sorry if this was asked before). I have 2 functions defined as: ...
0
votes
0answers
117 views

How to use Equal for close arbitrary precision numbers to be considered the same?

I am trying to add a comparator function in a larger piece of code which can equate two arbitrary precision numbers and yields True if they are approximately close. ...
9
votes
2answers
196 views

Looking for a Compilable Form of DeleteDuplicates

Union is Compilable but DeleteDuplicates Isn't?! First, DeleteDuplicates is not compilable ...
6
votes
1answer
258 views

IntegerQ[x] gives false. Just leave it as it is

Since x is an alphabet not an integer, Clear[x];IntegerQ[x] gives False But sometimes I ...
7
votes
1answer
101 views

Compile Can Handle Passing an Empty List Only When Returned by Some Functions?

There seems to be a bug whereby Compile can deal with empty lists only when passed in some cases. Consider the case below. ...
1
vote
1answer
45 views

How to make a vector of elements the pattern of a function?

if I have an expression that contains a lot of symbolic elements and I would want to make it a function of the vector containing all the elements I've found a solution based on rule delayed: ...
1
vote
0answers
88 views

How to make a function ignore an argument [closed]

Motivation I am trying to call a function f, that has either 1 or 2 (or multiple) parameters, from a function g that uses ...
1
vote
1answer
53 views

generate quadratic functions to evaluate membership of points

How can I make a printable list with different quadratic functions and with points that belong or not to them so that a young person can check whether or not the point belongs to the parabola? my code ...
10
votes
1answer
263 views

"instruction 9223372036854775807" Bug and Bug with Using DeleteCases[] inside Compile[]

I get an error referring to "instruction 9223372036854775807" as follows. I run the code ...
1
vote
1answer
63 views

Extract function argument sequence

Is it somehow possible to access and reference the sequence of arguments of a non-pure function? For example if I want to take the derivative with respect to the n'th argument, a pseudocode example ...
0
votes
1answer
56 views

Extracting function from contour plot [closed]

I have made a contour plot via Minitab and got an image like this one: With $z$ being the enthalpy $[BTU/lb]$ $x$ being the temperature $[°F]$ $y$ being the ...
5
votes
2answers
835 views

I believe Beep uses the system sound which is obnoxious and rude. How does one create a friendlier less intrusive sound?

Beep is a terrible sound for alerting when a background task has successfully completed. It was primarily designed for errors or when a task fails. That's why it's ...

1
2 3 4 5
43