6
votes
Accepted
Can I write a function that describes a hysteron?
To define a memory, you can define a variable and, for safety, put it in a separate name space, like e.g. ns`k.
Further, you did not specify what k should be if x==a or x==b and what K shloud be the ...
5
votes
Accepted
First argument -h is not a valid variable
h is a local to Series, you cannot use it as a functionargument.
Try
...
5
votes
Accepted
Map list of strings to appropriately nested functions
Not sure if this is what you need... If it is not, I will delete.
...
5
votes
Creating a list of functions with desired coefficients
Instead of using Subscript[x, 1], I suggest using x[1]. You can still use Format to display ...
4
votes
How to construct a custom-made matrix conditional on a set of rules?
EDITED in response to comment.
Your input:
m0 = {{1, 2, -3, 1}, {0, 2, -1, 5}, {-1, 2, 3, 1}, {0, 1, 2, 4}};
The function definition:
...
3
votes
Accepted
3
votes
Accepted
How to construct a custom-made matrix conditional on a set of rules?
I hope that the following will be useful a bit, and fun. There's a small flexing bit.
So, the question essentially boils down to the following two tasks:
How do I delete all negative elements of a ...
2
votes
How to obtain the function of a plotted Bezier curve?
I've made a function that can convert any BezierCurve of any degree into a set of curves, each parameterized from 0 to 1. First, convert the BezierCurve points to a new set of points:
...
2
votes
First argument -h is not a valid variable
Or
s[h_, n_ : 4] := Normal[f[t] + O[t, x]^(n + 1)] /. t -> x + h
s[h] + s[-h]
2
votes
Accepted
How can I Save function defintion without its DownValues?
Okay, something like this might work.
g[][x_] := x^2;
g[x_] := memo`g[x];
memo`g[x_] := memo`g[x] = g[][x]
When you save, exclude the ...
2
votes
How can I Save function defintion without its DownValues?
One way would be to use a separate symbol for the memoization. Here is a toy example:
...
2
votes
Write Integral in Ostrogradsky's Method Form
Defining a module to perform and display the Ostrogradski method
...
2
votes
Define function to test arguments and set value to 0 (application 0 Log [0] = 0)
Maybe
ClearAll @ g
SetAttributes[g, Listable]
Off[Infinity::indet]
g[0, 0 | 0.] := 0
g[x_?NumericQ, y_?NumericQ] := Re[x Log @ y]
g[__] := 0
g[10^-5, -10.^-8]
-0....
1
vote
Define function to test arguments and set value to 0 (application 0 Log [0] = 0)
Rather than define your function directly, you could define it based on the result of the log expression.
...
1
vote
Define function to test arguments and set value to 0 (application 0 Log [0] = 0)
I would define my own Log like e.g.:
ClearAll[myLog]
SetAttributes[myLog, Listable]
myLog[x_] = If[x <= 0, 0, Log[x]];
Now zero arguments are defined:
...
1
vote
Constructing a function that returns two distinct values by Mathematica
Using Query :
list = {{-4, -1}, {-5, 2}, {-5, -5}, {3, 1}, {-5, -1}};
Query[All, Apply /@ {Plus, Times}] @ list
{{-5, 4}, {-3,...
1
vote
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
function-construction × 2414functions × 505
list-manipulation × 264
plotting × 114
calculus-and-analysis × 110
pattern-matching × 110
evaluation × 103
functional-style × 100
programming × 97
performance-tuning × 71
equation-solving × 70
scoping × 67
syntax × 65
variable-definitions × 63
matrix × 62
argument-patterns × 62
replacement × 53
recursion × 51
symbolic × 47
options × 45
expression-manipulation × 44
differential-equations × 42
conditional × 40
piecewise × 39
pure-function × 38