8
votes
Stopping mathematica from rearranging elements in a list
You can use DeleteElements which came with V 13.1:
...
8
votes
Accepted
How to draw an image similar to a periodic function (f [x+1]=2 f [x])?
Edit
For x<0,we rewrite f[x+1]=2f[x] to `f[x]=f[x+1]/2;
...
7
votes
Accepted
7
votes
How to fit function with data?
NonlinearModelFit default settings work ok with simpler model and thena and b can be derived,...
7
votes
How to draw an image similar to a periodic function (f [x+1]=2 f [x])?
Plot[With[{qr = QuotientRemainder[x, 1]},
2^First[qr] Last[qr] (Last[qr] - 1)], {x, 0, 3}]
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
How can I zoom in on a specific region?
You could always implement your own poor's man zoom.
Code
...
5
votes
Stopping mathematica from rearranging elements in a list
set1 = {-1/x, -1/x + x/2 - 2 Log[x] - Log[x]/x, 1};
Fold[DeleteCases, set1, {-1/x}]
(* {-1/x + x/2 - 2 Log[x] - Log[x]/x, 1} *)
5
votes
Stopping mathematica from rearranging elements in a list
UniqueElements[{set1,{ -1/x}}][[1]]
(* {-x^(-1)+x/2-2*Log[x]-Log[x]/x,1} *)
5
votes
Accepted
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
4
votes
Pattern matching vs. condition in a function
For g4, your condition doesn't evaluate to True or False. Specifically, ...
4
votes
Accepted
4
votes
Accepted
4
votes
Different answers when attempting replacement of function argument
fib1 should be limited not to evaluate unless $n$ is an explicit integer number, so let's redefine it as such (in the following I've also used a version with ...
3
votes
3
votes
To draw a function within an interval
It is still a bit unclear exactly what kind of an answer would help you most. The way I read the last comment is that you want all $x,y,z$ to be plotted. In other words, you want a 3D-plot. The ...
3
votes
Stopping mathematica from rearranging elements in a list
or use filter, in Mathematica it's Select
{-(1/x), -(1/x) + x/2 - 2 Log[x] - Log[x]/x, 1} //
Select[# =!= -1/x&]
3
votes
Stopping mathematica from rearranging elements in a list
Instead of applying "Complement" to the whole list set1, you may apply it to the single elements of set1 like:
...
3
votes
Trying to plot the Fourier transform solution to the heat equation on Mathematica
See if this does what you want
Code
...
3
votes
3
votes
Is there a neat code to swap elements of a list?
list = Range[9];
swap = {{2, 5}, {3, 6}};
Fold[SubsetMap[RotateRight, #1, #2] &, list, swap]
{1, 5, 6, 4, 2, 3, 7, 8, 9}
3
votes
Different answers when attempting replacement of function argument
Look at:
fib1[n]
-1 + n
fib1[n] /. n->10
9
And for fib2:
fib2[n]
2
Here the ReplaceAll does nothing.
2
votes
How to apply a constant function to a vector of values?
Using Query
func = {1 &, Cos, Sin};
xval = {a, b, c, d};
Query[Transpose, func] @ xval
gives
...
2
votes
Listable (on certain level) custom function
pts = {{x1, y1}, {x2, y2}};
Just use Map:
Map[myf, pts]
{myf[{x1, y1}], myf[{x2, y2}]}
Or ...
2
votes
Stopping mathematica from rearranging elements in a list
If I understand correctly, this is what you need
set1 = {-(1/x), -(1/x) + x/2 - 2 Log[x] - Log[x]/x, 1}
SortBy[Complement[set1, {-1/x}], Position[set1, #] &]
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....
2
votes
Simplify inverse of function
If you need to implement the result in Excel, you might want to consider solving the problem completely in Excel. Excel is certainly not the equivalent of Mathematica but it does have a lot of ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
functions × 3694function-construction × 506
list-manipulation × 438
plotting × 432
calculus-and-analysis × 246
equation-solving × 188
evaluation × 133
matrix × 120
programming × 107
performance-tuning × 98
simplifying-expressions × 89
syntax × 83
differential-equations × 80
graphics × 80
replacement × 80
complex × 78
variable-definitions × 75
numerical-integration × 68
functional-style × 68
pattern-matching × 66
mathematical-optimization × 65
numerics × 64
symbolic × 60
core-language × 59
probability-or-statistics × 57