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
0answers
15 views
7
votes
4answers
179 views

How to avoid repetitive calculation when doing numerical integral?

Suppose I have a function f[x] which is very complicated, together with a function g[f[x]]+h[x] to integrate. That is: ...
1
vote
0answers
41 views

Simple list manipulation [closed]

I have two lists: {1,2,3} and {a,b,c} and I want this result: {{1,a},{2,b},{3,c}}. What is the right command? How does one call such an operation?
10
votes
1answer
212 views

Should I add a semicolon after a function definition? [duplicate]

should I write the program like this: f[x_]:=x^2; g[x_]:=x+2; or should I write the program like this: ...
4
votes
2answers
141 views

How to calculate this probability?

Here I want to find the probability $p$ which is given by $$p=\int_0^{r_d}\mathcal{L}_I(\beta r^{\alpha}|r)f_R(r)dr$$ with $r_d=1$ and $0 \le r\le r_d$. I want to calulate the probability for ...
4
votes
2answers
71 views

Grouping/precedence for “/@” operator

This returns errors: {#[[1]],#[[3]]} & /@ {#[[1]],#[[2]],#[[3]]} & /@ {{"A","B","C"},{1,2,3}} Part::partd: Part specification A[[1]] is longer than ...
3
votes
2answers
64 views

How to create assignments to OverVector programmatically

I wish to write a function that accepts two lists. The 1st argument is a list of lists, holding the components of a several vectors. Ex.: comp = {{a, b}, {c, d}}. ...
5
votes
2answers
140 views

Plotting an equation describing a Joukowski airfoil

I am trying to plot an equation that will give me a Joukowski airfoil and am having trouble getting any results. The equation that I am using is as follows: ...
0
votes
0answers
39 views

Question on Poincare section example

I'm trying to make a Poincare section. On the Wolfram Documentation Center they give an example that includes the lines ...
1
vote
1answer
81 views

integrating with multiple indicator functions depending on each other

I need to compute the following integral with three indicator functions, $I(x)$, $I_1(x_1)$ and $I_2(x_2)$, $$ \int_0^1\int_0^1I(x)\left( \ I_1(x_1)\,x_{1} + I_2(x_2)\,x_{2}-1 \right) dx_1 dx_2 $$ ...
21
votes
5answers
4k views

How do I increase the readability of this code?

Below is some code I am working on; being a beginner. How can I increase the readability of the part behind Manipulate? I can't read my own code anymore, because it is simply too long and unordered. ...
3
votes
1answer
134 views

How to get a best fit line on a scatterplot?

I know that I am supposed to call listplot inside of the show function but I can't seem to get that to work. The best I can get is this, which has the best fit line following the scatterplot. How do I ...
0
votes
0answers
66 views

Watched a Livestream with Christopher Wolfram, he used an operator that I can't find [duplicate]

I understand /., /@, /; and documentation exists in the normal way for all of those but I can find nothing on /*
0
votes
2answers
53 views

Problem with ParametricPlot with Im and Re [closed]

I have a problem, How can I plot theses functions from 0 to 2 Pi : Re(e^(iaϕ+(iϕ)^b)), Im(e^(icϕ+(iϕ)^d)) Re(e^((iϕ)^a) e^((iϕ)^b )), Im(e^(icϕ+(iϕ)^d)) Re(e^(iaϕ+(iϕ)^b)), Im(e^((iϕ)^c) e^((iϕ)^d)...
4
votes
3answers
247 views

How to set multiple parameters to zero?

Say I have the matrix A = {{a,b,c,d,e}, {f,g,h,j,k}} and I want to set some of these to zero. I have been doing this via ...
1
vote
2answers
146 views

Defining a variable with comma (or any other separator) in its name?

How can I define Mathematica variable/function with comma in it? For example, defineL00,1 as a variable? I plan to use L00,1 ...
0
votes
0answers
15 views

Problem with PolarPlot and Table [duplicate]

If I have a set of numbers, for example grid = N[Table[n^2/2, {n, 3, 24}]] And want to plot that as circles I can either use Graphics[] and Circle[], or ...
1
vote
1answer
64 views

Can't get a numerical value for this vector operation

I have written these codes: ...
1
vote
2answers
45 views

How can I specify the plot range of a BoxWhiskerChart? [closed]

I am combining multiple BoxWhiskerCharts using GraphicsGrid. This works properly, however I want the different charts to have ...
2
votes
1answer
39 views

A natural syntax for a Query that holds

Often I have an unevaluated expression in a RuleDelayed Key-Value pair and subsequently want ...
3
votes
2answers
157 views

Is it possible to assign numbers generated in an Error-Message?

If I have a differential equation of the form ...
0
votes
1answer
39 views

Replace argument of delayed function before it evaluates [duplicate]

How should I use replace so that f[x_] := x^2 Replace[f[3], 3 -> 1] OUT = 9 evaluates to 1, instead of 9? This way, the replacement of the argument is done ...
0
votes
1answer
76 views

Mapping over function's several parameters regions [closed]

About this post: Mapping multiple parameters of a function to specific values I wonder if the parameters a and b have ranges ...
1
vote
1answer
76 views

Generating sequence of averages of averages of partial sums

I have been given the following code that generates the sequence of averages (of the partial sums) of Grandi's series: ...
0
votes
0answers
55 views

Syntax for Neumann/Robin condition in NDSolve [duplicate]

I can't follow the logic of how a NeumannValue term is to be incorporated into a pde to provide a BC for NDSolve. The ...
0
votes
1answer
48 views

Experiment to test Infinite monkey theorem [closed]

I need to apply this experiment: For all numbers between [0,128] let be t {set total=0 repeat this experiment n times {set start=0 choose random number [0,255] lets be R While(R!=t) {...
3
votes
3answers
189 views

Replace For with If in Mathematica way

I have this code: ...
0
votes
1answer
72 views

Solving equations with change of variables is not working?

I want to express it in the form $$\text{expr=}\int_{-\infty}^{\infty}C_1\exp\left(-t^2\right)f(t)dt$$, i.e., the integrand is a bounded smooth function $f(t)$ times $\exp(-t^2)$ and the domain of ...
2
votes
1answer
127 views

Syntax f[x_][y_]

Need to understand the principle of the distinction between f[x_,y_] and f[x_][y_] It seems also that z[x_, y_][a_, b_, c_][α_, β_] := a (x + y)^b + c/(α-β) ...
0
votes
1answer
39 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
61 views

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

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
63 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 ...
5
votes
0answers
139 views

Is there an internal logic behind short form symbols, such as @ (Prefix), @@ (Apply), /@ (Map), /. (ReplaceAll) [closed]

To me, function names (such as Apply and Map) seem more intuitive than their symbols (e.g. @@...
1
vote
2answers
65 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
58 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
463 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
63 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
69 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? ...
3
votes
2answers
47 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
123 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
45 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
47 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
55 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
3answers
157 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 ...
3
votes
1answer
61 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] {{x->2,y->3,z->3,m->3},{x->3,y->...
1
vote
1answer
63 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
173 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. ...
5
votes
2answers
218 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
40 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 ...