10
votes
Accepted
9
votes
How to raise a vector to powers contained in a vector, change the list into a product, and do this for all the lines of a matrix, efficiently?
Use Inner
Inner[Power, var, #, Times] & /@ expo
(* {x[1],x[2],x[3] x[4],x[2] x[5]} *)
7
votes
How to raise a vector to powers contained in a vector, change the list into a product, and do this for all the lines of a matrix, efficiently?
This feels like I was just following the directions in the OP:
Times @@ (var^#) & /@ expo
6
votes
Accepted
How to find the x-coordinate of the point circled(non-differentiable points) in this trigonometric function graph?
FunctionSingularities.
...
5
votes
Transform a list of rules into a list of function definitions
rules = {f[x] -> a + 3 h[x], g[x] -> 2 a + c + 6 h[x]}
...
5
votes
How to find the x-coordinate of the point circled(non-differentiable points) in this trigonometric function graph?
These are discontinuities caused by Abs[Sin[w x]].
...
5
votes
Accepted
Can this code be simplified further?
This is personal style. I never like long chained commands. I like to make variables and small functions.
It makes it easier for me to read my own code one week after I write it.
So I would write your ...
5
votes
Function to find the most common numeric ordered pairings (value, count)
If you like the GroupBy functionality, there are functions that work on associations "transparently".
If you know how many "largest" counts you ...
5
votes
Accepted
Function to find the most common numeric ordered pairings (value, count)
Maybe not exactly what you're asking for, but related. Your data is basically a weighted data structure, and Commonest will work on that kind of data.
...
4
votes
Function to find the most common numeric ordered pairings (value, count)
The GroupBy function has a form that can apply Total to get your result. We group using the first element of ...
4
votes
How to raise a vector to powers contained in a vector, change the list into a product, and do this for all the lines of a matrix, efficiently?
Here is another Inner strategy:
Inner[OperatorApplied[Power], expo, var, Times]
4
votes
How to define a function for Schmitt trigger?
The Schmitt trigger is not a function because it has memory,
but it is a respectable object in the sense of Object Oriented Programming.
Of course, in this new context some difficulties appear :
When ...
4
votes
Accepted
How to define a function for Schmitt trigger?
Obviously, we need a function with memory. For this we may use a module with a localized variable:
...
3
votes
Transform a list of rules into a list of function definitions
To achieve this, we need to manipulate the "DownValues" of the function names. We use "Scan" to operate on all elements of the rule list. As "DownValues" has the ...
3
votes
Is there a technical name for functions that end in Q?
I used to think of them as question functions, but like @David, I've called them query functions for a while, having picked this up long ago from other Mathematica users. Unfortunately, we now have <...
3
votes
Is there a technical name for functions that end in Q?
I call these "predicate functions" because they always return either True or False
3
votes
Series does not deal with the branch cut for the power function correctly [bug]
This appears to have been fixed in v13.2
...
2
votes
How to optimize performance with DeleteDuplicates?
I build upon A. Kato's idea to use a normalization: First turn each element into a unique representative of the equivalence class. Then run vanilla DeleteDuplicates....
2
votes
How to optimize performance with DeleteDuplicates?
This answer is for the case where the order does matter. While OP's question asks for case where the order does not matter at any level.
First of all rules can be ...
2
votes
How can I simplify this out put?
Resolve[ForAll[x,x>-d/c,f'[x]>0],Reals]
(c!=0&&b c-a d<0)||(d!=0&&b c-a d<0)
2
votes
2
votes
Transform a list of rules into a list of function definitions
If the left-hand sides of each rule depend on the same variable, @Craig Carter's solution is sufficient, but if not, we can generalize this process using ReplaceAll ...
2
votes
How to raise a vector to powers contained in a vector, change the list into a product, and do this for all the lines of a matrix, efficiently?
expo . Log@var // Exp
(* {x[1],x[2],x[3] x[4],x[2] x[5]} *)
2
votes
Accepted
Making a video of dynamic output
Initialize an empty list of frames:
frames = {};
Then add a new frame after each iteration:
...
2
votes
Accepted
How do #1 and #2 work in a function defined by 2 variables?
#1 is a placeholder for the first functionargument, # 2 for the second.
For example
function=#1 #2^2&
defines a function for two arguments
...
2
votes
Issue with variable within Sum[] bounds
There is a closed-form solution for $n=1, 2, 3, 4, 5$. I've had no luck in finding a general solution.
...
1
vote
Accepted
How to put prime before value during a substitution?
One approach to get your desired result, of course, is to just put the time dependence explicitly,
...
1
vote
1
vote
Can this code be simplified further?
If you don't like MapThread, you can make the pure function Listable and apply it directly to the two lists:
...
1
vote
Accepted
Finding the position of a list element using functions like Max on lists that might contain 'Indeterminate' values
Here is an approach. Not sure if it integrates well with your workflow. There might be better ways to do this in your context, but just based on what you've shown, something along these lines might ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
functions × 3853function-construction × 532
list-manipulation × 456
plotting × 448
calculus-and-analysis × 263
equation-solving × 202
evaluation × 137
matrix × 123
programming × 111
performance-tuning × 102
simplifying-expressions × 100
graphics × 86
replacement × 86
complex × 85
syntax × 85
differential-equations × 83
variable-definitions × 76
numerical-integration × 72
pattern-matching × 72
functional-style × 71
mathematical-optimization × 70
numerics × 66
symbolic × 63
probability-or-statistics × 61
core-language × 60