Staff – ReplaceAll Wierdness – Mathematica Stack Exchange

I encountered an oddity in ReplaceAll. Replacement works well outside of a module, but inside the module, some replacements do not happen where you might expect.

In[2]:= f = ListInterpolation[{1, 2, 3, 5, 8, 5}]

Out[2]= InterpolatingFunction[{{1, 6}}, <>]

In[3]:= g = D[f[x], x]

Out[3]= InterpolatingFunction[{{1, 6}}, <>][x]

In[4]:= h[u_] := Module[{x, z}, x + u /. {x -> z}]

In[5]:= h[g]

Out[5]= z$6446 + InterpolatingFunction[{{1, 6}}, <>][x]

In[6]:= x + g /. x -> z

Out[6]= z + InterpolatingFunction[{{1, 6}}, <>][z]

Note that outside the module, x is replaced by z in the two places where it appears in the expression. But inside the module, the parameter x of the interpolation function is not replaced by z.

Can someone explain this to me please?

plotting – Use Mathematica to draw a tensor type network

Thank you for contributing to Mathematica Stack Exchange!

  • Make sure you respond to the question. Give details and share your research!

But to avoid

  • Ask for help, clarification or respond to other responses.
  • Make statements based on opinion; save them with references or personal experience.

Use MathJax to format the equations. Reference MathJax.

For more information, see our tips on writing correct answers.

What is the difference between WolframAlpha[] and freeform entry in Mathematica?

WolframAlpha ("request") – https://reference.wolfram.com/language/ref/WolframAlpha.html

Free form input – https://reference.wolfram.com/language/workflow/EnterFreeFormInput.html

For example:

WolframAlpha("Solve(x^2+5x+6==0, x)")

and

= and after

Solve(x^2+5x+6==0, x)

Both have fairly similar output (can't include it here due to sophisticated formatting).

Questions:

  1. Do both use WolframAlpha?
  2. Is there a difference between them? If yes, what is the difference?

analysis – Boltzmann equations – Mathematica Stack Exchange

Thank you for contributing to Mathematica Stack Exchange!

  • Make sure you respond to the question. Give details and share your research!

But to avoid

  • Ask for help, clarification or respond to other responses.
  • Make statements based on opinion; save them with references or personal experience.

Use MathJax to format the equations. Reference MathJax.

For more information, see our tips on writing correct answers.

syntax – Definition domain of the following variables: is it possible to derive in Mathematica?

Consider 4 4 vectors
$$
P_ {0} = (E_ {0}, 0,0, sqrt {E_ {0} ^ {2} -m_ {0} ^ {2}}), quad P_ {i} = (E_ {i} , p_ {i} s ( theta_ {i}) c ( phi_ {i}), p_ {i} s ( phi_ {i}) s ( theta_ {i}), p_ {i} c ( theta_ {i})),
$$

with $ c equiv cos, s equiv sin $, $ p_ {i} equiv sqrt {E_ {i} ^ {2} -m_ {i} ^ {2}} $ and dot products
$$
P_ {i} cdot P_ {j} equiv P_ {i} ^ {0} P_ {j} ^ {0} – sum_ {k = 1} ^ {3} P_ {i} ^ {k} P_ { j} ^ {k}
$$

$ m_ {0-3}, E_ {0} $ play the role of real parameters, with $ E_ {0}> m_ {0}> m_ {1} + m_ {2} + m_ {3} $ and $ E_ {i} geqslant m_ {i} $, while $ E_ {i}, theta_ {i}, phi_ {i} $ are variables.

The implicit region of the definition of $ E_ {i}, theta_ {i}, phi_ {i} $ is given by
$$
tag 1 P_ {3} = P_ {0} -P_ {1} -P_ {2},
$$

$$
tag 2 s_ {12, text {min}} (s_ {23}) <s_ {12} <s_ {12, text {max}} (s_ {23}), quad s_ {23, text {min}} <s_ {23} <s_ {23, text {max}},
$$

or $ s_ {ij} = m_ {i} ^ {2} + m_ {j} ^ {2} + 2P_ {i} cdot P_ {j} $, and
$$
tag 3 s_ {12, text {min} / text {max}} = m_ {1} ^ {2} + m_ {2} ^ {2} – frac {1} {2s_ {23}} bigg (s_ {23} -m_ {0} ^ {2} + m_ {1} ^ {2}) (s_ {23} -m_ {2} ^ {2} -m_ {3} ^ {2}) pm \ pm sqrt { lambda (s_ {23}, m_ {0} ^ {2}, m_ {1} ^ {2}) lambda (s_ {23}, m_ {2} ^ {2} , m_ {3} ^ {2})} bigg),
$$

$$
tag 4 s_ {23, text {min}} = (m_ {2} + m_ {3}) ^ {2}, quad s_ {23, text {max}} = (m_ {0} -m_ {1}) ^ {2}, quad lambda (a, b, c) = (abc) ^ {2} -4bc
$$

I need to integrate a function $ f (E_ {i}, theta_ {i}, phi_ {i}) $ on the domain of definition $ (1) – (4) $ of the variables mentioned. Is it possible to derive the domain of definition in Mathematica, at least implicitly, in order to perform integration? There are so many variables …

nonlinear – Got Solutions to a set of non-liner equations in Matlab but not in Mathematica. Why?

I was trying to solve a set of nonlinear equations using NSolve in mathematics. I got a result saying that no solution ({}). My friend tried it in Matlab, he was able to get a solution to the same set of equations for the same given parameters. Now I doubt who to trust?

I add my functions below

    ClearAll(Evaluate(StringJoin(Context(), "*")))
    Needs("Utilities`CleanSlate`"); 
    CleanSlate(); 
    ClearInOut();  

d(xt_, xv_, xo_, xb_) := (1189*(3*xv^2*(8/5 + xt/10) + (6*xv*xt*xo)/5 + 
      (6/5 - xt/10)*xo^2)*Cos(xb)^3)/3000000;  

ma1(xt_, xv_, xo_, xb_) := (1189*((48*xv^2)/5 + (3*xv^2*xt)/5 + 
      (16*xv*xt*xo)/5 + (18*xo^2)/5 - (3*xt*xo^2)/10)*Cos(xb)^2)/48000000;  

ma2(xt_, xv_, xo_, xb_) := (5/4)*xo^2*Cos(xb)*Sin(xb);  

q1(xt_, xv_, xo_, xb_) := (1189*(3*xt*((16*xv^2)/5 + (6*xo^2)/5) + 
      (1/10)*(-6*xv^2 - 16*xv*xt*xo + 3*xo^2))*Cos(xb)^3)/48000000;  

f11(xt_) := NSolve({q1(xt, xv, xo, xb) == 0 && 
     d(xt, xv, xo, xb) - 133.05 == 0 && 
     ma1(xt, xv, xo, xb) - ma2(xt, xv, xo, xb) == 0}, {xv, xo, xb}, Reals, 
   WorkingPrecision -> 5)

f11(0.01) 

kindly someone help me

In Matlab, he obtained these values ​​xv = 232.9328, xo = 290.8831, xb = 1.7934 10 ^ (- 4); And the accuracy of solutions was up to 5 digits in matlab

plotting – ParametricPlot Incomplete – Mathematica Stack Exchange

I have a problem reproducing a graph. Follows the commands used:

X(r_) = -A Csc((Phi));
Y(r_) = Sqrt(B + a^2 Cos((Phi))^2 - A^2 Cot((Phi))^2);
A = (r^2 (3 M - r) - a^2 (M + r))/(a (r - M));
B = (r^3 (4 a^2 M - r (3 M - r)^2))/(a^2 (r - M)^2);
M = 1; a = 0.79; (Phi) = Pi/2;
ParametricPlot({X(r), Y(r)}, {r, 0, 2 Pi})

enter description of image here

However, the graph should be as follows:

enter description of image here

that is to say, I could not close the curve. Can anyone help? A clue?

inequalities – problem of resolution of inequalities $ x + 1 / x> -1 + 1 / x $. different answer in Mathematica and Wolfram Alpha

I tried to resolve the inequality $ x + 1 / x> -1 + 1 / x $ with Wolfram Alpha, and that gave me the answer $ (- 1,0) cup (0, + infty) $. It is correct.

But when I try to solve it in Wolfram Mathematica 12.0 (with Wolframscript), it gives me an answer $ (- 1, + infty) $ – with zero in the answer – this is wrong.

I used this command in Wolframscript: Reduce(x+1/x>-1+1/x,x,Reals).

What is wrong with my script command?

external calls – Interfacing Mathematica with the Tableau desktop

Are there any known methods or examples for connecting Mathematica to Tableau in any way?

Unidirectional or bidirectional, one or the other would be a valid solution. Something like RLink / MATLink or LibraryLink would be fine, but some sort of external evaluation would be best.

I am looking to collect links or other references in this answer to build such a bridge.

digital integration – Mathematica unable to evaluate the function it can write explicitly in a simple form

I have a function $ psi (x, n) $ in mathematics which is quite complicated. However, the connection $ n = 0 $ gives a simple form. Mathematica knows this (see below), but it is still unable to evaluate the function at any given time. This gives no errors but the output never returns, even if it's a calculation I can do in my head.

At this point, I am puzzled … here is the exit that confused me:

enter description of image here

Here is the definition of the function. $ psi $ is defined recursively as a function that remembers the values ​​found.

ψ0(x_) := 1/(2 π)^(1/4) Exp(-(x^2/4) - I k x);
ψr(x_?NumericQ, n_?NumericQ) := ψr(x, n) = 
   NIntegrate(
    SK(y, x, Δt) (
      Projector(x)/
      Sqrt(NIntegrate(Abs(Projector(x) ψr(x, n - 1))^2, {x, -∞, ∞}))
      ) ψr(x, n - 1), {y, -∞, ∞});
ψr(x_, 0) := ψ0(x);

Here are the definitions that go indirectly into the definition of the function:

ε = 0.2; 
Δt = 1.0;
L = 8.0;
tTypical = 10.0;
tMax = 20.0;
k = L/tTypical;
nMax = Floor(tMax/ Δt);
Projector(x_) := 1/(1 + Exp(-((L - x)/ε)));
SK(x1_, x2_, t_) := 1/Sqrt(2 π I t) Exp(-((x1 - x2)^2/(2 I t)));