Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
23 views

RegionPlot fails

Consider a function f[x_,y_]:=NIntegrate[g[x,y,z],{z,1.1*x,3000}] where g[x,y,z] is some function. The function f[x,y] is smooth and works perfectly when Plot it....
0
votes
0answers
45 views

How to handle the instability of the integral evaluation in the following case?

I want to integrate a function \[Kappa][gh, ms, ts, th, ph] (for all definitions, see a code below) with the distribution ...
0
votes
3answers
49 views

Removing the square-brackets and their contexts from an expression

Suppose I start with an expression like y[t] + x[t]: is there a function that lets me remove the [t] elements, so I obtain the ...
0
votes
0answers
17 views

Dot product returns symbolically when undesired [duplicate]

StateProb[state_, projector_] := Dot[state, projector, state]; StateProb[state1, Projector[{-(I/Sqrt[2]), 0, 0, 1/Sqrt[2]}]] State is {1/Sqrt[2], 1/Sqrt[2], 1/...
9
votes
3answers
187 views

How can I automatically replace [[ and ]] with the \[LeftDoubleBracket] and \[RightDoubleBracket] operators?

When you type ->, it is automatically turned into the \[Rule] character. Can we configure our frontends to do the same for ...
3
votes
1answer
100 views

Where to find order of arguments for default functions

Lets take for example the Laplacian. So I want to apply it in spherical coordinates, so I go the the associated documentation page (https://reference.wolfram.com/language/ref/Laplacian.html?view=all) ...
1
vote
0answers
53 views

Difficulty with ExternalEvaluate

I am trying to import a Python function or execute a Python script from inside Mathematica, but the ExternalEvaluate command drives me nuts. I proceed cautiously ...
3
votes
2answers
84 views

Overloading a function to pass in an expression rather that the name of a function

This is an example of procedural programming borrowed from Paul Wellin's book. It's a simple implementation of the Newton-Rhapson method. I overloaded the findRoot ...
3
votes
2answers
58 views

EntityValue timeline

I try to use EntityValue to get the returns of a stock from January 1st 2019 to today. When I use ...
0
votes
0answers
29 views

Having difficulties using results returned by Solve

I'm new to Mathematica, and I am still having some issues figuring out the general syntax. I've got to use Mathematica, as my research requires a powerful symbolic math program. I'm having trouble ...
6
votes
2answers
100 views

Separation of statements vs “space mul”, formal definition of Mathematica syntax?

In Mathematica, space can often be used to indicate multiply. For example "a b" = "a * b". On the other hand, in a *.m file, we also have multiple statements separated by newlines. How does the ...
0
votes
0answers
104 views

Remove background image and redraw lines in black

I do not know if the title is correct. The image that I upload has liked me a lot because of the characteristic that no matter the angle it seems that it is looking at you, you could indicate me how ...
10
votes
1answer
130 views

Why does Success[…][key] work and Failure[…][key] doesn't work?

I'm trying to figure out what is a quick way to add error reporting to my user defined functions. I was experimenting with Success and ...
1
vote
1answer
47 views

ListCountourPlot does not show any result [closed]

I was trying to show the heat conduction of Laplace equation problem.But the plot does not show properly ...
5
votes
2answers
87 views

Converting prefix to infix

Is there a way in Mathematica to convert prefix to infix notation (where precedence order is preserved)? For example, how would I convert S[a, S[b, c]] to ...
8
votes
2answers
208 views

Finding the point closest to a parameteric curve produced by a numerical method

Question How can I find the closest point to a parametric curve produced by a numerical method. General Context I have a parametric curve (which I will call $g$) produced from a averaging many ...
3
votes
2answers
76 views

Trying to plot the norm of the solutions to NDsolve

I have been tried to do two things with the solutions from NDSolveValue plot the norm of the solutions of a differential equation system versus time. plot one component of the solutions of a ...
0
votes
0answers
29 views

How to automatically see user defined function arguments list?

Having typed a user-created function's name I would like to be able to see either the concise syntax dropdown available for inbuilt functions (shown below left) or alternatively to be able to see the ...
0
votes
1answer
41 views

Maximize function subject to condition [closed]

What commands should I use in Mathematica to obtain the maximum or minimum of a function subject to conditions? For example, find the maximum of the following function? $\qquad T=\sqrt[3]{2\,x+5} + \...
1
vote
1answer
63 views

Defining iterative algorithms [closed]

Assume the iterative algorithm of interest to be as follows: ...
0
votes
0answers
27 views

Syntax Error, Text Style and escaping characters

I have a weird error (I guess it could be called a bug), where a file containing the text line (as in in a cell you create with Alt-7) gives a syntax error when called from the terminal using ...
1
vote
1answer
102 views

Rotation in physics [closed]

I have a mathematica problem in theoretical physics: There is a rotation axis $\vec{n}$ with $|\vec{n}|=1$. Each other vector $\vec{v}$ can be seperated in relation to $\vec{n}$ in a parallel part ...
2
votes
1answer
43 views

What's the difference between $Context<>“*” and “`*”?

When set context unique to this notebook: ClearAll @@ { $Context<>"*" } Clear["`*"] can both clear the variables I assigned. I just wonder what's the ...
2
votes
1answer
66 views

center of mass, total momentum

Has someone an idea how to solve the 1. question for ANY number of mass points and a clue to the 2. question? center of mass system, momentum
0
votes
1answer
82 views

center of mass system, momentum

when I have systems with 3 mass points ($m_i, i=1,2,3$) to a time $t=t_0$ on positions $\vec r_i(t_0)$ and velocity $\vec v_i(t_0)$. How could a syntax look like to calculate 1) center of mass 2) ...
3
votes
0answers
46 views

Pure function: using T[[#]] where # indicates a position [duplicate]

When using T[[#]] in which # indicates a position, how do you pass on the position # (which ...
0
votes
0answers
60 views

Implementing a function that exhibits linearity

I am trying to define a function $\mathbb{E}_t$ such that $\mathbb{E}_{t}[f[x_{s}]] = f[x_{s}]$ if s<=t, and $\mathbb{E}_{t}[f[x_{s}]] = \mathbb{E}_{t}[f[x_{s}]]$ if s>t. $\mathbb{E}_{t}$ is ...
0
votes
1answer
72 views

Plotting the condorcet jury theorem [closed]

I am trying to create a simple plot of the condorcet jury theorem: The function is: F[n_,i_,p_]:=((n!)/((n-i)!*i!))*((p^i) *(1-p)^(n-i)) embedded in a sum ...
0
votes
0answers
31 views

Is there a difference between these two ways to define a function? [duplicate]

(I took this example from another question) f[0] = 0; f[n_] := f[n] = DigitCount[n, 10, 1] + f[n - 1]; f[1016] I notice that this example defines f(n) in a ...
1
vote
1answer
66 views

Harmonic number of $r$ with order $r$ [closed]

Mathematica recently offered me this expression as the result of an evaluation: HarmonicNumber[r, -r]. I initially thought this must be equivalent to ...
2
votes
1answer
74 views

How to fit dated stock market data with non-linear model fit?

I am new to Mathematica and I am currently doing a project on predicting stock market trends using log-periodic power law. I am trying to fit stock market data to the following equation. y(t) = A + B (...
4
votes
2answers
124 views

RSolve not reducing for a certain recurrence relation

I'm trying to use RSolve as follows to solve a recurrence relation: ...
3
votes
1answer
160 views

What does “ Im' ” mean? [closed]

I am trying to take the curl/derivative of the function A. What does " Im' " mean here? Why does Mathematica attempt to take the derivative of the Im function here? ...
-1
votes
3answers
61 views

How to remove a line from the ListPlot?

Consider the following ListPlot: ...
0
votes
3answers
85 views

Finding the integer terms of a binomial expansion [closed]

What functions can I use to find how many integer terms the following expression has? $$\left (\sqrt[19]{19}+\sqrt[95]{95}\right )^{1995}$$ Edit 1 In the development of that binomial, at some point ...
0
votes
0answers
48 views

magic square with prime numbers of any order

how could you create a script in Mathematica that generates magic squares of order n, but that the numbers that form the square are all primes I've looked at what's in other answers but I can not ...
3
votes
1answer
138 views

Using “?” to get function details has changed?

I'm running Mathematica 11.0 (I should upgrade, I know) and it used to be that if I entered something like ?Integrate, Mathematica would output basically a mini ...
0
votes
0answers
43 views

Define a new Front End Syntax for Function Argument Checking & Debugging

In this question I asked a basic question about how to check argument types such that there was useful output from the front end when calling functions. Based on elements of the nice answer by @j-m-is-...
3
votes
2answers
148 views

How to align the plot legends in the following way?

Consider example ...
5
votes
1answer
44 views

how to comfortably concatenate substitutions

Often I have to do perform a succession of substitutions on some expression, and in a notebook the way I know to do that is ...
3
votes
1answer
106 views

Use of semi-colons in If[]

This is the code in Mathematica: h[x_] := (If[x > 5, Return[big]]; t = x^3; Return[t - 7]) I fully understand what the code does, with ...
6
votes
1answer
255 views

Solve PDEs with finite difference scheme by modifying NDSolve-based solver

Motivation As discussed here, NDSolve uses different difference orders for various spatial derivatives and the implicit design could cause trouble in certain cases....
1
vote
1answer
34 views

Replace function arguments multiple times?

I have a very large function f[x_,y_,z_] and it's too cumbersome to type it directly. So I wish to break the definition and use (...
1
vote
1answer
69 views

ImplicitRegion evaluates the region incorrectly when it must be empty

Consider the following implicit region: ...
2
votes
0answers
55 views

How do decrease uncertainty of Monte-Carlo integration?

I have some function of many arguments and need to integrate it over the region given by the products of Heaviside theta functions. Namely, I write, say, ...
3
votes
1answer
76 views

Own markers on the axis of the plot

Could you please tell me how to make the ticks on the axes not in the numeric form (say, 0, 0.1, 0.2) but in symbolic form (say, "zero", "zero point one" and so on), in the plot command?
3
votes
1answer
118 views

Force a function to report argument type mismatches

As a relative newcomer to Mathematica, I am still frequently caught out by coding errors that, at least by default, MMA does not indicate to the front end, in particular when I define a function and ...
1
vote
1answer
68 views

Evaluating an expression on one line

Is it possible to evaluate an expresson on one line? I have a linear algebra problem to re-write the straight line $-x=1-3y=-1-2z$ to a 'vector form'; ...
1
vote
0answers
42 views

Mathematica is acting as though d is a variable when it isn't [closed]

I have the Airy Stress Function ϕ[x_, y_] = 1/120 (P/(d^3))[5*(x^3 - x*L^2)*(y + d)^2*(y - 2*d) - 3*x*y*(y^2 - d^2)^2] That I need to take 2nd and 4th ...
0
votes
0answers
84 views

FullSimplify of Dirac Delta Function failed

I have t1 and t2 whose difference should be 0. But ...