Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [syntax]

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.

Filter by
Sorted by
Tagged with
0
votes
0answers
51 views

Assumptions work for simple function but don't work for complicated function

Suppose the function f1[s1uppern_, s1lowern_]= I Sqrt[s1uppern - s1lowern]/(s1lowern - s1uppern)^(3/2) I want to simplify it assuming that ...
1
vote
1answer
63 views

Extra empty lists as function arguments

Consider the following piece of code: ...
0
votes
1answer
75 views

FindMinimum[]'s objective function evaluation works with EvaluationMonitor but not StepMonitor

I'm trying to monitor the progress of FindMinimum[] using StepMonitor. I'd specifically like to have the code print out the value of the objective function and the variable values. For example, <...
1
vote
0answers
51 views

Strange behavior of NIntegrate

I have some function f[x,y,a], where a is some parameter, defined as piecewise f[x,y,a] = Piecewise[{{g[x,y,a], a<m[x]}, {0, True}}] Here $m$ is some function....
3
votes
1answer
329 views

How to understand `DeleteCases` in this code?

I'm reading an excellent answer regarding Mobius transformation and I'm trying to understand the last line of the following code: ...
2
votes
0answers
68 views

What do these parentheses inserted after “Pretty Print” with StandardForm?

Background: I have a list containing individual elements and sublists. tab = {1, 2, 3, a, {4, 1}, {5, 2}} The individual elements are also to be converted into ...
0
votes
0answers
50 views

Which of the following inputs is correct for the desired operation?

sorry for another (very likely) dumb question, but I'm having trouble telling which of the following (if either) yields the desired operation. What I'd like is to define a function: $$ud = u(f/2) - \...
0
votes
0answers
400 views

(Basic Question) How to use nested functions properly?

UPDATED PORTION OF QUESTION AT THE BOTTOM First, let me apologize for two things: 1) I'm very new to Mathematica, so this question is certainly very stupid, 2) I looked for the solution to this both ...
3
votes
2answers
133 views

“&” instead of Function[ … ]

WRI provides the code below as a "neat example" of Fold. The code produces all of the subsets of {a, b, c}. As an exercise, I'...
0
votes
1answer
451 views

Formatting: Removing semicolon at the end of a line introduces multiply symbol [duplicate]

Focus on those 4 lines in the middle of the screenshot of the code. There are lines above and below those 4 lines which are not necessary for our discussion. Issue: In the 1st of those 4 lines, I ...
3
votes
3answers
142 views

Using Through on functions that take multiple arguments

I want simple syntax that results in this: {{f[1, 2], g[1, 2]}, {f[3, 4], g[3, 4]}} though I'm willing to settle for: ...
0
votes
1answer
77 views

Scan and lists of lists

I am trying the following construction but I get an error message. Let l be a list consisting of pairs of integers. Let further ...
0
votes
1answer
287 views

Mathematica in my computer vs Wolfram Alpha [closed]

I observe that if I execute in the url of wolfram alpha the integral of the function (3/x^2)Sin(x)Sin(x/3) with the limits between zero and infinity: integrate (3/x^2)sin(x)sin(x/3) from 0 to inf I ...
2
votes
1answer
91 views

Rule vs RuleDelayed in the context of StringReverse [duplicate]

{"test", 3} /. s_String :> StringReverse[s] {"test", 3} /. s_String -> StringReverse[s] The second line gives the error: StringReverse: String expected ...
4
votes
1answer
732 views

Meaning of (a : _ : 1)

This is an example from Leonid Shifrin's tutorial: ...
0
votes
0answers
74 views

Indicate level with Replace [duplicate]

Replace[{{x^2, Sqrt[x]}, {x + 1, x - 3}}, f_[x__] -> f, 1] Level 1 of Replace works here as expected with output {List,List} ...
6
votes
2answers
3k views

Difference between != and =!=

I (think I) understand the difference between == (semantic) and === (syntactic). So when comparing != and =!= I was expecting a similar difference. So can anyone explain why the third line in this ...
2
votes
1answer
79 views

Failure to minimize a given function under assumptions

Suppose the function ...
1
vote
0answers
67 views

How to check the positivity of a function depending on many variables?

Suppose we have some complicated function $f(x,y,z,v,u,w)$ with $\{x,y,z,v,u,w\} \in G$; precisely, each variable excepting one is defined in the sub-domain depending on other variables: $w \in G_{1}(...
2
votes
1answer
128 views

Mathematica doesn't want simplify the square root of the square even under assumptions

Suppose a simple function f[x_,y_] = Sqrt[(x-y)^2]+Sqrt[(y-x)^2] Knowing that $x>y>0$, without any commands like ...
0
votes
0answers
63 views

Relative speed of definite integration and indefinite integration with substitution

Suppose some complicated integrable function $f[x]$ (possibly depending on parameters). One can perform definite integration over $x$ inside the domain $[a,b]$ by using construction ...
1
vote
0answers
81 views

Mathematica can't evaluate the function at the point where it is smooth

Suppose the function ...
1
vote
1answer
93 views

The function is real, while its integral is complex [duplicate]

Suppose the function ...
9
votes
2answers
854 views

Why am I seeing what looks like a violation of operator precedence?

Why is it that when I evaluate 2*2.848529281693615`+3*-0.5155083247776808` I get (* -2.93688 *) which is wrong. ...
1
vote
1answer
35 views

Strange values and plot of the given function

Suppose the function f[s2_,m_,m2_] = (s2 - m^2 + m2^2 -Sqrt[m^4 - 2m^2(s2+m2^2) + (s2-m2^2)^2])/(s2 - m^2 + m2^2 +Sqrt[m^4 - 2m^2(s2+m2^2) + (s2-m2^2)^2]) ...
1
vote
1answer
173 views

How to force Mathematica to display output (after integration) with logs in the form of Log[a/b]?

Suppose the function ...
1
vote
0answers
124 views

Proper syntax for DeleteCases with conditions

List is an array of dimensions {61777, 3}. dist1 & dist2 are RegionDistanceFunctions. Using: ...
0
votes
1answer
424 views

Why won't my expression evaluate? [closed]

I have defined a function first and then I need to integrate something to find the time (it's theoretical mechanics). I think I don't have any syntax issues but what am I doing not the way I should? ...
2
votes
2answers
156 views

I can't collect the logs in the given expression

Please, see better this question, since it displays the problem better, i.e., more specifically. I have complicated function: ...
1
vote
2answers
167 views

How to manipulate a function (Append/Prepend) multiple times?

I'm having trouble trying to manipulate a function in a type of "loop" format. Essentially what I want to do is be able to manipulate the amount of Append functions ...
2
votes
1answer
264 views

How to force the expression to have common denominator? [closed]

Suppose there are two (or more) functions with inequivalent denominators, say f1[x] = F[x]/G[x], f2[x] = f[x]/g[x]. How in general to force the sum ...
1
vote
1answer
35 views

Function I have defined evaluates slowly when called

I need to call some function defined in a subsection of some section of mathematica's .nb file. The code of its evaluation and displaying looks like ...
1
vote
1answer
65 views

Not getting correct result when entering triple integral from Basic Math Assistant palette

I entered the following expression into my Mathematica notebook using the Basic Math Assistant palette. It gives $ x ^ 7/30 $ instead of $1/198$ that I got by hand. Where is the error? $\qquad\int _0^...
0
votes
1answer
46 views

How can I evaluate a series expressed with ellipses?

I want to evaluate an series given with ellipses. For example, 1/2 + 1/(2 + 4) + 1/(2 + 4 + 6) + ... + 1/(2 + 4 + 6 + ... + 20) Wolfram|Alpha works great, but ...
2
votes
2answers
156 views

Representing sets in Mathematica [duplicate]

What is the right ways to define a mathematical set in Mathematica? I wrote the line A = {1, 2, 3} and A := {1, 2, 3} ...
0
votes
1answer
67 views

how to turn off warning [duplicate]

This function that performs random apportionment works ...
0
votes
2answers
69 views

replacement SetDelayed instead of Rule

I have the following code: Solve[-(Sin[x]/(α*Gamma[α])) - Subscript[a, 0][x]/(α*Gamma[α]) == 0, Subscript[a, 0][x]] For replacement ...
0
votes
2answers
75 views

Difference between % and the variable it is representing?

I have this code. The problem I have is with the % in the Manipulate (after Grid). If I replace % with data, then the values are not evaluated anymore? But how come? Isn't the % refering to data? <...
9
votes
1answer
364 views

Part not behaving the way I expect it to

p = {{1, 0, 0}, {0, 1, 0}, {0, 1, 0}}; p[[All, 3]][[1 ;; 2]] = {1, 1}; p I want to replace the first two elements of the third column of a 3x3 identity matrix. ...
2
votes
1answer
56 views

Unexpected behavior from Apply [closed]

Right up front: I'm an absolute novice with Mathematica, never had to use it until very recently, and I'm entirely self-taught (with a little help from friends with some level of experience). I'm very ...
1
vote
3answers
83 views

Elementary syntax question

With the function P[n_] := Module[{s,t} , s = Sum[z^k/k!, {k, 0,Infinity}]; t = Series[s^x, {z, 0, n+1}]; f[x_] = n!^2 Coefficient[t, z, n] ] I get ...
0
votes
1answer
79 views

Generating problem text automatically

I want to randomly generate groups of radom parabolas to be graphed as follows: Graphing — Parabolas $\qquad f(x) = a\, x ^ 2$ (3 of them) $\qquad f(x) = a\, x ^ 2 + b\, x$ (3 of them) $\qquad f(x) =...
3
votes
1answer
118 views

Single argument operator form?

I've heard the explanation that functions like StringDrop[] are varargs and so that is why they do not have an operator form. But when you are only using the ...
6
votes
0answers
83 views

Infix non-ASCII operator needs a space to be parsed correctly in a script

Bug introduced in 9.0 or earlier and persisting through 11.1 First off: ...
3
votes
1answer
77 views

What is a good way to specify multiple types of an object?

In object-oriented programming paradigm, as far as I know(I'm also an amateur at that :-) ), one often defined some classes, say Dogs and ...
0
votes
2answers
74 views

SameQ shorthand [closed]

I thought that === is shorthand for SameQ? Then why do these two expressions yield True for one and False for the other? ...
3
votes
2answers
58 views

ClearAll except a data table

How can I ClearAll variables and tables, except a table of data? Suppose the data table is WRR. ...
4
votes
1answer
592 views

How exactly does Postfix notation work?

I guess I've been using the Postfix notation // wrongly for some time now. I assumed it was a quick way to apply a function to ...
0
votes
0answers
840 views

'Cannot be followed by..' error when implementing while loop

I am trying to implement the following (iterative) scheme (a preconditioned conjugate gradient method): ...
7
votes
1answer
363 views

curl in Mathematica, google link-shortener

I want to automatically get short links equivalents for things I CloudDeploy. I'd appreciate some tips on integrating command line workflow below into Mathematica ...