Questions on correct (or improved) formulation of Mathematica code to achieve particular results. Use this tag (not "symbol") for questions about all those odd @@ /@ # & and ~ characters.

learn more… | top users | synonyms

0
votes
1answer
36 views

Solving equations with change of variables is not working?

I have the following expression $$\text{expr=}\int_0^{\infty}\frac{C\exp(-\frac{mx^2}{\Omega})}{\Omega^m}\frac{1}{\sqrt{2\pi}\lambda\Omega}\exp\left(-\frac{(\ln ...
0
votes
1answer
17 views

Is it the correct syntax with TransformedDistribution?

I define a function as f[x_] := ...;which is in fact the PDF of a random variable $X$. The PDF if given by $f_X(x)$. Let $Y$ is a random variable, which is the ...
0
votes
1answer
57 views

Why doesn't Mathematica solve this non linear (fractional) ODE? [on hold]

a1 = NDSolve[{y1''[x] - 0.1 y1[x]^0.25 == 0, y1'[0] == 0, y1[1] == 1}, I get the following errors - Power::infy: "Infinite expression 1/0.^0.75 encountered ...
1
vote
1answer
40 views

List of Inequalities in RegionPlot with different colors [duplicate]

Starting from the example of the Documentation: RegionPlot[{x^2 < y^3 + 1, y^2 < x^3 + 1}, {x, -2, 5}, {y, -2, 5}] Which gives a nice plot with two ...
4
votes
0answers
104 views
1
vote
2answers
53 views

MMA gives error when a different PDF expression is used for the same distribution

I have the following MMA code. Note that the function I declared at the very beginning is the PDF of square of a Nakagami Distributed random variable. With $m=1$ and $P=1$, $f(h)$ becomes Exponential ...
2
votes
2answers
57 views

Substituting within a function definition that includes Simplify

I would like to define a function like myfunc[f_] := Simplify[(f/g)] where g will be substituted/replaced with the current value of g at the time of definition. ...
2
votes
2answers
453 views

What is the meaning of “/.”? [closed]

I've looked to the built-in help of Mathematica, but I still can't understand the usage of /., like in the following expression: ...
0
votes
1answer
52 views

Partial derivative of function of two variables

This question is not enlightening nor is it difficult. But some part of my notation or how I have defined my functions is messing up the D[f,x] function. ...
1
vote
1answer
27 views

Mathematica Empty Plot FourierSinSeries function

I'm trying to get a plot of different order Fourier series of the function x-1, why does Mathematica give me an empty plot? ...
2
votes
2answers
41 views

Better alternative to Hold/ReleaseHold for postfix application of Monitor

Trying to Monitor a process using the postfix notation, as in Table[Pause[n/10], {n, 5}] // Monitor[#, n] & fails: the ...
9
votes
0answers
115 views

Is there a linter to help write good Mathematica code?

I don't do much real programming, but I've recently been turned on to Atom, which has linter plugins for over 50 languages to make coding easier (most drawing on pre-existing lint-like programs). In ...
0
votes
1answer
42 views

Applying multiple functions to a single column in a table

I've seen similar questions, but I'm having trouble applying solutions found there to my situation. My sorting function: ...
1
vote
0answers
46 views

Is it possible improve the code scanning beyond what SyntaxQ does? [closed]

Please, consider this package (* ::Package:: *) BeginPackage["HelloWorld`"]; a::usage="A"; b::usage="B"; Begin["`Private`"]; a=1; b= End[]; EndPackage[]; ...
3
votes
1answer
52 views

Undocumented “Output” alignment argument to “Column?”

In this SE question, Inheriting Stylesheets when using CreateDocument, I noticed the literal string argument "Output" to Column. ...
3
votes
1answer
56 views

How to set similar constraints on multiple variables in Solve

In this equation: var = {x, y, z, m}; Solve[x + 2y + z + m == 14 && And @@ Thread[2 <= var <= 3], var, Integers] ...
3
votes
3answers
144 views

How to get the long logic expression with a terse method

I have a long logic expression (x==2||x==3||x==4)&&(y==2||y==3||y==4)&&(z==2||z==3||z==4)&&(m==2||m==3||m==4) How to get it by a terse ...
1
vote
1answer
55 views

How to assign options to a variable?

I want to redefine a function similar to Plot like this: ...
0
votes
0answers
38 views

Syntax question for declaring variables [duplicate]

I have a very basic syntax question for declaring $X_{hb}$ a variable. f[Subscript[X, hb_]] := Subscript[X, hb] In mathematica instead of writing the ...
3
votes
3answers
172 views

how to convert a bundle of if statements into a simple one.

hi i am just trying to create a matrix depending on some specific conditions for which i designed these codes which work fine but i want to concise these codes. ...
9
votes
6answers
2k views

Superscript prime symbol

x\[Prime] looks like $x_{'}$, ugly right? Is there a way to make a symbol with prime to look like $x'$? That's what I'm trying right now: ...
7
votes
1answer
162 views

Why is Reap result nested? [closed]

A minimal (toy) example for my question: i= 1; Reap[Do[Sow[i = (i + 1)^2], {4}]] (* {Null, {{4, 25, 676, 458329}}} *) I presume the entire result is a ...
5
votes
2answers
212 views

Why SetDelayed won't work

I'm trying to do this: Riffle[list = {a, b, c, d, e, f}, tem = RandomInteger[1, Length@list-1]] {a, 0, b, 0, c, 1, d, 0, e, 0, f} But I think this method is ...
1
vote
1answer
37 views

How to use Composition when the functions have two parameter

There are some basic instructions about Composition on this site, but I'm still confused on how to use it when the functions I am composing have two parameter, such ...
5
votes
3answers
220 views

Relational operators on vectors

How do I use relational operators on vectors? {1, 2, 3} > {0, 1, 2} (*outputs {1, 2, 3} > {0, 1, 2}*) More generally, I want ...
0
votes
3answers
58 views

Plotting with NestList[]

So I want to use the NestList[] function, but i'm not sure how to achieve this for a system of equations like I have here $P_{n+1} = (rP_n +sQ_n)(1 - \frac{P_n + ...
0
votes
1answer
52 views

Solving a System of Equations syntax confusion

I have a system of two equations which I would like to solve in terms of a third unknown variable $s$. ...
1
vote
1answer
48 views

Basic Syntax Question — Variables for a function

I am looking at the following mathematica code Subscript[ff, r1_, r2_, CC_][x_, y_] := (r1 x + r2 y) (1 - (x + y)/CC) Subscript[gg, r1_, r2_, CC_][x_, y_] := x ...
4
votes
0answers
93 views

Why does FromDigits transpose its argument (sometimes)?

a = {{1, 2}, {3, 4}, {5, 6}} ; FromDigits /@ Transpose@ a == FromDigits @ a (* True *) The only "strange" syntax I've found in the docs is But it doesn't ...
9
votes
4answers
4k views

Matrix Multiplication in context of row and column vectors

I've been looking at some matrices in Mathematica and I've noticed something very weird: They're extremely temperamental when it comes to dot products! For example, if I have the following, ...
1
vote
1answer
104 views

Module that prints first m positive odd integers and returns the square root of the sum of them

I am working on this problem and I feel like I've come so close. Write a module that takes as input a positive integer m, prints the first m positive odd numbers and returns the square root of the ...
10
votes
6answers
1k views

can the color in MeshStyle be specified by a ColorFunction, such as “SunsetColors” for example. If so, what is the correct syntax?

This is an example given in Help: Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, MeshStyle -> Gray] Could this be changed to something like ...
2
votes
1answer
76 views

how to manipulate indices in a table/vector

Perhaps I'm missing something very basic. Could somebody guide me how to manipulate indices of a list. For example, if I have ...
1
vote
1answer
31 views

Iterating my function by $4$ using NestList — Syntax Confusion [duplicate]

I want to iterate my function $f(x) = 13xe^{-x}$ by $4$ multiple times. That is, $f, f^{4}, f^{8}, f^{12},\cdots$. Using Nestlist[f,x,4] I can get $f,f^{(2)}, ...
3
votes
0answers
51 views

Pre-define list of variables to set them in bulk

I understand this is likely tremendously simple, but I cannot work out how to do the following: vars = {b,c} *define variables* vars = {1,2} *set them* Then I ...
7
votes
3answers
364 views

Where did I go wrong with my implementation of the trapezoidal rule?

One method for doing quadrature, called the trapezoidal rule, improves accuracy by connecting the points on the curve corresponding to the points of subdivision with line segments, forming trapezoidal ...
1
vote
2answers
102 views

Extract all elements from a list that belong to a set or have a set element as an argument

EDIT: Added that I want to extract not only the variables from a specific set, but also functions involving variables from a specific set. Given the set ...
13
votes
1answer
1k views

Problem with Fourier coefficients

I have just started using Mathematica with v9.0. I am trying to follow a computation from a book on Fourier series with the function $f(x)=x$ on the interval $-\pi < x < \pi$. Here is the code ...
1
vote
1answer
51 views

Using the Nest function — Confusion on my output

I have the following code and output where the original function is $f(x,a) = a^2 - x^2$. ...
-1
votes
1answer
58 views

Syntax Error for the following code

I have the following code in mathematica ...
2
votes
1answer
47 views

Recognition Power Head for numeric value

We know: Map[Head, {a, a^2, a^3}] (* {Symbol, Power, Power} *) and Map[Head, {2, 2^2, 2^3}] all of them will be known as ...
13
votes
6answers
900 views

Calling Table with custom iterator

I often find myself in situations where I, for example, need to build a table for some expression, but want to set the number of points rather then the step size, so the code ends up looking like this ...
1
vote
1answer
86 views

What explains non-working (black) variables?

I'm a bit new in Mathematica 10.3 and have had strange problem. Sometimes, variables appear in black and obviously prompt and error when used. ...
1
vote
1answer
80 views

Double arguments and place of the underscore

Could someone explain me of this bit of code below is correct: Is it possible to define a function with a second bracket, see below, i.e. f[x_][y_]? And what does ...
0
votes
1answer
72 views

what do those signs #1, #1^2, #1^3, & mean here? [duplicate]

I have read common pitfalls page and the documentation page but I still don't understand what do those signs mean here? ...
12
votes
2answers
8k views

How do I identify the source of a “Tag times protected” error?

I have some code that looks like Table[ a = 1; b = {2, 3} c = i;, {i, 2} ] which gives an error: Set::write: Tag Times in c {2,3} is ...
4
votes
3answers
1k views

Orthonormalization of non-hermitian matrix eigenvectors

When using Orthogonalize[] one can specify which definition of "inner product" is to be used. For example, ...
2
votes
1answer
52 views

Why do Wolfram Alpha and Mathematica give different answers? [closed]

I've just got my hands on Wolfram Mathematica and tried to see if I can figure out how to use it by myself. I've plugged in an integral $\int \frac{dx}{(1-x^2)^{2/3}}$, knowing that the result is ...
7
votes
3answers
155 views

Morse Code Spacing

Trying to make a function to convert text into morse code and play the sound. Have it pretty much completed, but I cannot get mathematica to emit no sound so I can have a pause between the dots and ...
0
votes
2answers
114 views

Referencing elements of ArrayRules

How do I call elements of ArrayRules by their indices rather than by Part[ArrayRules[list],i]? I'd like to call the element that ...