New answers tagged function-construction
3
votes
Building A Function Using Constants From a List
f[t_] := Mean[indata[[All, 2]]] +
Plus @@ MapThread[#[[2]] Sin[#[[1]] t + #[[3]]] &, {freqvals}]
Plot[f[t], {t, 0, 1}]
- 25.2k
3
votes
Building A Function Using Constants From a List
Following suggestions in other answers is a good idea, i.e., avoid the use of loops in Mathematica. There are are almost always better ways to do things. That said, to minimally change your code so ...
- 22.3k
6
votes
Accepted
Building A Function Using Constants From a List
Welcome to MSE!
To be effective with Wolfram Language, you have to change your thinking from "procedural" to "functional". E.g., try to avoid using explicit ...
- 4,778
4
votes
Better way to do such iteration
Using Map and Flatten can avoid the 2^(n - 1).
We seperate the times ...
- 49.3k
10
votes
7
votes
How to plot a point with two colors?
We can define PlotMarkers by any Graphics object and using ListPlot to add such markers of ...
- 49.3k
6
votes
How to plot a point with two colors?
It's not so easy to do this automatically, and you have to account for the aspect ratio of your plot, without which you end up with a squashed marker. Here's my attempt for manual points and colour ...
- 21.8k
2
votes
How to gather functions which intersect at the same point?
This goes only through all $(n^2-n)/2$ Subsets[func, {2}] as suggested by @Syed. For $n=100$ that is only $4950$ cases.
It calculates the intersection points of ...
- 33k
4
votes
How to gather functions which intersect at the same point?
This goes through all $2^n -n -1$ subsets of length 2 or more. An overkill that allows very simple code, but it's not practical for large $n$. See other answer(s).
...
- 33k
6
votes
Accepted
Using the Apply construction
As an expression, before being evaluated, this...
Function @@ {t, g}
is actually this...
Apply[Function, List[t, g]]
Now, we ...
- 13.9k
7
votes
Accepted
Better way to do such iteration
Based on your update with the fractal demo, I think I may have a solution. The basic idea is that a triangle is split into two smaller triangles based on a parameter that determines how long the new ...
- 13.9k
1
vote
Better way to do such iteration
This isn't complete, but I'm at a point where I need feedback. As best as I can tell, your func is doing a rescale operation, and that rescaling happens to rescale <...
- 13.9k
2
votes
Function defined through conditional pattern and derivative
I think this comes closest to what you're looking for:
...
- 19.6k
0
votes
Function defined through conditional pattern and derivative
You got something wrong. You confuse ":" and "/;". What you wrote is a default value.
...
- 35.4k
5
votes
Accepted
How to delete edges from a graph with some condition?
MMA is smart enough to sort the vertices. Therefore the "Reverse" is not needed.
...
- 35.4k
2
votes
Sort a list using a scoring list with Switch
In each sublist, leave the first letter unchanged but "invert" the remaining letters $(a \leftrightarrow z, b \leftrightarrow y, ...)$. Then use a traditional sort... on the first element, ...
- 37.6k
4
votes
3
votes
Sort a list using a scoring list with Switch
Let's specify the order of the first elements in an easy way, just list the possible first elements in the order you want:
...
- 13.9k
2
votes
Define a function on a MeshRegion
I used the hints in the comments to write the following code (excerpt from my notebook):
With a little more calculation this allowed me to generate:
Explanation: ...
- 151
5
votes
8
votes
How can I ignore an argument?
While you didn't ask for advice, you could do this without the explicit While looping:
...
- 13.9k
11
votes
Accepted
7
votes
How can I ignore an argument?
Use Reap and Sow instead of AppendTo.
Also you can do away with the ...
- 21.8k
9
votes
How can I ignore an argument?
Probably the easiest and clearest way would be to just overload mylist with another definition:
...
- 13.9k
5
votes
Accepted
How to make a function take another function as an input?
sildeben[expr_,{variable_,startvalue_,endvalue_,steps_}] := Table[
{variable,expr},{variable,Subdivide[startvalue,endvalue,steps]}];
- 11.6k
3
votes
How to make a function take another function as an input?
Syed's answer is fine. I am suggesting another for completeness
funct[steps_] := N@Table[{a Pi, Sin[a Pi]}, {a, 0, steps, 1/2}]
when you run
...
- 9,177
3
votes
How to make a function take another function as an input?
{#, Sin[#]} & /@ Subdivide[0, π, 2] // N
{{0., 0.}, {1.5708, 1.}, {3.14159, 0.}}
...
- 25.2k
5
votes
Automating interesting ways to write 2023
According to the Goldbach conjecture, 2023 can be written as a sum of 3 primes... we can find these using:
...
- 66.7k
11
votes
Automating interesting ways to write 2023
I thought it could be nice to use different domains of Mathematica to represent 2023 in different ways.
Outline:
Entities
Polynomial algebra
Linguistic Data
Number theory
Text analysis
Special ...
- 4,559
13
votes
Accepted
Automating interesting ways to write 2023
I would like to point out FrobeniusSolve, e.g. this yields nonnegative solutions $(x_1,x_2)$ of this equation $20 x_1 +23 x_2 =2023$
...
- 55.5k
10
votes
Automating interesting ways to write 2023
Happy new year!
IntegerDigits[2023, 2]
{1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1}
Edit: another interesting way
...
- 9,177
Top 50 recent answers are included
Related Tags
function-construction × 2291functions × 463
list-manipulation × 245
pattern-matching × 105
plotting × 102
evaluation × 102
calculus-and-analysis × 101
functional-style × 97
programming × 93
performance-tuning × 66
syntax × 64
scoping × 64
equation-solving × 63
argument-patterns × 61
variable-definitions × 60
matrix × 58
recursion × 51
replacement × 50
symbolic × 43
options × 43
expression-manipulation × 40
conditional × 39
differential-equations × 38
piecewise × 38
pure-function × 38