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
0 answers
35 views

Change the function-defined solution domain to fit NDSolve original Interpellation domain

Given a system of coupled non-linear equations, I used NDSolve to solve it in the domain of: $$ -10^{50} \le r \le 10^{50} $$ ...
Daniel Vainshtein's user avatar
1 vote
2 answers
95 views

How to construct a custom-made matrix conditional on a set of rules?

The following code does what I intend to achieve; however, it is too cluttered for a simple matrix operation. I like to reduce the code to a one-line code as a ...
Tugrul Temel's user avatar
  • 5,470
0 votes
1 answer
36 views

Creating function with array input with desired coefficient and evaluate it

I had asked the same question before here Creating a list of functions with desired coefficients but did not get the desired answer, may be I was not clear in my question. I have defined this function ...
Learner's user avatar
  • 219
2 votes
1 answer
88 views

Creating a list of functions with desired coefficients

I have defined this function to results some list of functions, however its not returning what I want ...
Learner's user avatar
  • 219
3 votes
2 answers
161 views

First argument -h is not a valid variable

I am trying to simpligy my life by defining a function that gets the series expansion of $f(x+h)$ and $f(x-h)$ (at $x=0$) by the following code, ...
kichapps's user avatar
1 vote
1 answer
73 views

Map list of strings to appropriately nested functions

I have a list of strings consisting of sequences of "+" or "-"'s. For example, let's take the list ...
AG1123's user avatar
  • 561
2 votes
2 answers
123 views

Can I write a function that describes a hysteron?

Is there a way to write a "function", or as the answer below refers it better as a memory, that has the following output: k=0 if the last time x was outside the range (a,b), it was x<a. ...
juv95's user avatar
  • 197
0 votes
0 answers
31 views

Defining a function for FunctionCompile[]

Lets say that I have the definition EQN4 that is determined from some calculation. If I run it in a cell, I get the following output: ...
Bajablaster's user avatar
2 votes
3 answers
69 views

Define function to test arguments and set value to 0 (application 0 Log [0] = 0)

I have an expression that has the form f1[a, b, c] Log[ f2[a, b, c] ] Now if f1[a,b,c] and ...
Sid's user avatar
  • 977
0 votes
0 answers
36 views

How to calculate this hierarchy in Mathematica?

A hierarchy can be defined as follows: $F_0(n) = 1 $ when n = 1, 0 for all other values $F_{\alpha+1}(n) = \sum_{i=1}^nF_\alpha(i)$ $F_{\alpha}(n) = F_{\alpha[n]}(n)$ when $\alpha$ is a limit ordinal ...
Allam A.'s user avatar
  • 333
2 votes
2 answers
79 views

How can I Save function defintion without its DownValues?

I use functions that memorize their values like this one: ...
Igor Kotelnikov's user avatar
2 votes
2 answers
119 views

Write Integral in Ostrogradsky's Method Form

Lets say we want to integrate $$\tag{1}F(x) = \frac{3 x^5-x^4+2 x^3-12 x^2-2 x+1}{\left(x^3-1\right)^2}$$ One approach might be to write it in partial fraction form and then integrate each fraction ...
Moo's user avatar
  • 3,044
0 votes
1 answer
71 views

How to make a polynomial output be used as function for input?

I basically made a code interpolating a set of data that gives me the polynomial for the interpolation. Here's the sample interpolation I did. ...
Mule's user avatar
  • 43
0 votes
0 answers
41 views

Defining function through a formula

I would like to define a cocycle on a group that maps into the unit circle. That is, I want to be able to define a function $f:G\times G\to\mathbb{T}$ such that $f(e_G,a)=f(a,e_G)=1$ for all $a\in G$ ...
aqwer's user avatar
  • 1
1 vote
0 answers
37 views

Is it possible to use the Finite Fields package to define the elements of GF(4) in terms of the irreducible polynomial $P$?

I am new to the Finite Fields package and am finding the package tutorial confusing. I am wondering, if I am working over GF[4], is there a way of finding the elements of GF[4] in terms of the ...
QC123_367's user avatar
  • 481
2 votes
1 answer
86 views

How to code retarded time in Lienard-Wiechert potential equations?

I have been making strides on my project with the help of others here but have run into another snag: I am having difficulty in expressing the Lienard-Wiechert potentials with retarded time. For ...
JDRobin's user avatar
  • 55
5 votes
4 answers
110 views

Interpolation of missing matrix values

Problem statement I want to replace missing matrix values, denoted by an integer 0, with the Mean of their surrounding values. ...
eldo's user avatar
  • 47.5k
1 vote
1 answer
85 views

Nearest inside Minimize

How to use Nearest inside Minimize? The following returns errors but if # - {a, b} is ...
azerbajdzan's user avatar
  • 9,568
4 votes
3 answers
297 views

Plotting multiple parametric 3D curves without using the Show command

How can I plot multiple parametric 3D curves on a single graph without the need to combine them using Show? Additionally, is there a way to clearly distinguish ...
emnha's user avatar
  • 2,411
2 votes
1 answer
122 views

Evaluation control in function definition: Total interferes with Evaluate

Here is a simple example to illustrate my problem: ...
Sooner's user avatar
  • 387
2 votes
1 answer
98 views

How to express a retarded time function?

I have been messing around with Lienard-Wiechert potentials and am having some trouble properly expressing my retarded time function. As of this moment the function looks like so ...
JDRobin's user avatar
  • 55
3 votes
1 answer
123 views

Creating a plot for a summation function

I have this potential function which I believe is representative of a grounded cube in a 3D plane. I'm not entirely sure if this is it, but here is the general solution of the function: v(x,y,z) = G(...
Carson Joseph's user avatar
0 votes
1 answer
114 views

How can I effectively input more than two list arguments into a function?

I am trying to input more than two list arguments into a function. For example, I have written the following code: ...
Rakesh's user avatar
  • 169
1 vote
1 answer
59 views

Appying Function To All Elements Of A Long List vs Over List's First Element Gives Different Results

So, I have two lists, and a function. If I apply my function to both lists in a "listable" manner, I have one result, but if I apply it to lists' elements one-by-one, in a "map" ...
Anton's user avatar
  • 345
1 vote
1 answer
112 views

Succinctly plotting a function defined in terms of many intermediate functions

I'm trying to plot a function that is in turn defined in terms of a lot of other functions, which each have a lot of variables. Here's a stylized example of the kind of thing I'm trying to do: ...
knzhou's user avatar
  • 165
0 votes
0 answers
97 views

Why won't this magnetic field plot?

I have been having some longstanding trouble in getting a 2D vector plot of a magnetic field to show up. For context, I am working with Lienard-Wiechert potentials and as such trying to plot the curl ...
JDRobin's user avatar
  • 55
5 votes
4 answers
320 views

Show positions of duplicated matrix elements

1. Problem statement I want to replace duplicated elements within a matrix with a placeholder value. 2. Example data ...
eldo's user avatar
  • 47.5k
5 votes
6 answers
340 views

Swap lists and sequences

I'm looking for a function which does the following: ListSequenceSwap[{6, {1, 2, 3}, 4, 5, {2, 2}, {4}}] {{6}, 1, 2, 3, {4, 5}, 2, 2, 4} ...
eldo's user avatar
  • 47.5k
0 votes
0 answers
81 views

Is there a way to optimize it for larger n?

This is Domen's code from my previous thread here. I think it covers all the cases that I mentioned there and works well for small values of n. However, for large ...
emnha's user avatar
  • 2,411
4 votes
8 answers
482 views

Delete list elements above a certain threshold

1. Problem statement Going from right to left, I want do delete all elements after they have occured n times. The solution I found seems to work reliably, but is ...
eldo's user avatar
  • 47.5k
4 votes
2 answers
567 views

How to calculate equivalent resistance for a network of same-value resistors?

Let's assume I have n identical resistors. I can connect them either in series or in parallel (let's disregard bridge connections for now). Now, I want to list all ...
emnha's user avatar
  • 2,411
0 votes
0 answers
36 views

Commutator for Solving Coefficients in a Hamiltonian

I am relatively new to Mathematica but I understand the basics. I want to solve for coefficients by commutator constraints and I have problems implementing the commutator. The setup is the following: ...
iron's user avatar
  • 1
1 vote
1 answer
60 views

How to remove terms with negligible constant from expression? [closed]

I'm working on a Notebook that requires the integration of multiple expressions (sometimes numeric, sometimes analytic). These expressions are normally of the form: ...
Pedro Hablespanyos's user avatar
0 votes
1 answer
74 views

Using Part[[i]] to defined a function

I would like to define a function like this f[x_, v_] := Part[m, 4, 1] where m = {{x^2}, {x^3}, {x^6}, {v x^4}}. but I can't ...
Dinesh Shankar's user avatar
4 votes
1 answer
225 views

Okhsl colour space

I am trying to recreate the Okhsl colour space from here. Below are the hue-saturation plots desired: I can create something similar (code adapted from here) with ...
martin's user avatar
  • 8,152
2 votes
1 answer
72 views

Function to Save/DumpSave without specifying full path

I am trying to create a function that saves a set of symbols into "test.mx" and is easy to use. ...
Albercoc's user avatar
  • 966
0 votes
2 answers
112 views

Can't we find the range of values for this formula?

This algebraic expression is as follows: s=a/(a + b + c) + b/(b + c + d) + c/(a + c + d) + d/( a + b + d) where the parameters a, b, c, and d are all greater ...
csn899's user avatar
  • 2,879
0 votes
2 answers
60 views

Understanding SetDelayed, ":=" [closed]

Consider the example below, p = {1, 2, 3}; x = {x1,x2,x3}; fun[x_] := {{1, 0, 0}, {0, 1, 1}} . (p + x); fun2[x_] = {{1, 0, 0}, {0, 1, 1}} . (p + x); I expected <...
Adriana LE's user avatar
0 votes
0 answers
51 views

Comparing graphs in mathematica: shape vs. name

I'm trying to identify and remove duplicate graphs when contracting vertices. To illustrate this, I'll start with two simple graphs where I'm trying to create a function that can recognize them as ...
hana's user avatar
  • 2,688
1 vote
0 answers
43 views

Graphics3D with projected/flat eye view? [closed]

Following image can be perceived as a cube (a regular hexagon with 3 internal line segments) : But in mathematica, it is not possible to make such shape with rotation. Examples of some close state of ...
imida k's user avatar
  • 4,047
4 votes
2 answers
191 views

Graphic3D, white face, black edge in any view?

Graphics3D[ Cuboid /@ Complement[Tuples[{1, 2, 3}, 3], {{1, 2, 3}, {3, 1, 3}}], ViewPoint -> {45.42, -83.46, 31.83}, Boxed -> False] Above code generates ...
imida k's user avatar
  • 4,047
2 votes
3 answers
81 views

What is the best way to redefine a function that has type ambiguity 0/0 at an isolated point?

Consider the following Green Function of wire turn producing magnetic field: ...
Igor Kotelnikov's user avatar
14 votes
1 answer
1k views

Visualizing gravity warping the fabric of spacetime

What is a stable way of creating a set of points that are attracted to a single moving point? I have tried the following: ...
martin's user avatar
  • 8,152
2 votes
1 answer
202 views

Solving Schrödinger equation for Dirac comb potential (kicked rotor)

I need to solve the Schrödinger equation for a Dirac delta potential. I could not find the correct way to write the time-dependent potential and how to solve the time-dependent equation for it. The ...
user84456's user avatar
  • 1,524
0 votes
1 answer
77 views

Is there any other good way to convert an algebraic expression into a specified form?

The original algebraic formula is: ((-a^2 + b^2) k)/Sqrt[(1 + k^2) (b^2 + a^2 k^2)] To convert to: ...
csn899's user avatar
  • 2,879
0 votes
0 answers
57 views

Using compile with indexed variables

I have the following piece of code which I made faster by using compile. I make the following definitions ...
QFTheorist's user avatar
1 vote
1 answer
57 views

Why the first is evaluated while the second is not (Sum behaves differently from Integrate)?

...
Anixx's user avatar
  • 3,543
-1 votes
1 answer
53 views

Difficulty in Proving Symbolic Equality in Mathematica [closed]

I'm currently working with the Mathematica software to verify the symbolic equality between two mathematical expressions. However, I've encountered a challenge where Mathematica's symbolic ...
algebroo's user avatar
0 votes
1 answer
65 views

A problem of Mathematica function with different parameters in the same model

I'm simulating a graph of a function, and have made a preliminary attempt with mathematica, my test code is as follows:: ...
little star's user avatar
4 votes
1 answer
103 views

Function[0], Function[,0], and Function[{},0]: Is there any inherent distinction in the "academic" sense?

Note that Function[,0] is by default interpreted as Function[Null,0]. The following three calls all give ...
user688486's user avatar

1
2 3 4 5
49