13

I think the easiest way would be to define(name) the pure function f f = Sqrt[-1 + Tanh[#1 - #2]^2] & and use it accordingly f[x,y] (*Sqrt[-1 + Tanh[x - y]^2]*)


13

Well, the easy way is to evaluate it for [x,y]. f[x_, y_] = Sqrt[-1 + Tanh[#1 - #2]^2] &[x, y]; If you'd rather do it with a replacement, you should understand the FullForm because that's what replacement works on. Sqrt[-1 + Tanh[#1 - #2]^2] & // FullForm (* Function[Sqrt[Plus[-1,Power[Tanh[Plus[Slot[1],Times[-1,Slot[2]]]],2]]]] *) So, you want ...


11

There are couple of problems with your code. It is an image, it would be way nicer not to have to rewrite it. Plotting Series If you go to ref / Series / Application you will see that Normal is used to plot a Series as otherwise O[x]^n will make Plot confused. Function definition Functions are defined more or less like that f[x_]:=... but if x is an ...


11

Clear[first, second, third] names = {first, second, third} numbers = {{1, 1}, {2, 2}, {3, 3}} Table[Evaluate[names[[i]]] = numbers[[i]], {i, 3}] first second third


9

You attempt to solve the ODE at the time of definition of lsolve. At this point, q does not depend on x. You really want to use SetDelayed here: lsolve[r_, q_, a_, eta_] := y[x] /. First@DSolve[{y'[x] == r - q*y[x], y[a] == eta}, y[x], x]; nwe = lsolve[x, 2*x, 0, 0] // Simplify 1/2 - E^-x^2/2


8

Clear[first, second, third] names = {first, second, third}; numbers = {{1, 1}, {2, 2}, {3, 3}}; With[{names = names}, names = numbers]; first {1, 1}


7

With the following definitions: Clear[first, second, third] names = {first, second, third} numbers = {{1, 1}, {2, 2}, {3, 3}} a one-liner approach would be: Evaluate@names = numbers You can see how this works using Trace: Clear[first, second, third] names = {first, second, third} numbers = {{1, 1}, {2, 2}, {3, 3}} Trace[Evaluate@names = numbers] (* Out:...


6

f[g[x,t],t] /. g[___]->g (* f[g, t] *)


6

MapThread works well for this task. numbers = {{1, 1}, {2, 2}, {3, 3}}; Clear[first, second, third] names = {first, second, third}; MapThread[Set, {names, numbers}]; {first, second, third} {{1, 1}, {2, 2}, {3, 3}}


5

$Assumptions = {Element[t[_], Reals], a > t[_]}; Simplify[a > t[c]] True


5

{{a}, list1, list2, {b, c}} = Import[filename, "Table"] (* {{10}, {1, 2, 3}, {4, 5, 6, 7, 8}, {1000, 100}} *) Notice how the left-hand side mimics the structure of the right-hand side, which you can see in the output line: a nested list of lists representing the numbers on the different lines in the file.


4

It is good practice to refrain from naming any variable with an initial capital letter in the ordinary roman font, because such identifiers can clash with ones already defined in the System` context. As substitutes you can use any of the capital letters from the Letters tab of the Special Characters palette which can be display by clicking on Special ...


3

Split the variables into {x, y, z}, {t} instead of {c, y, z, t}: Solve[{p == x + y + z + t && x > 0 && y >= x && z >= y && t > 0}, {x, y, z}, {t}, Integers] (* {{x -> 1, y -> 1, z -> 1}, {x -> 1, y -> 1, z -> 2}, {x -> 1, y -> 1, z -> 3}, {x -> 1, y -> 2, z -> 2}} *)


3

There's an internal, undocumented utility that will do it for you: Integrate`getAllVariables[Cos[t x] E^y, {}] (* {t, x, y} *) OP's example: Table[Exp[Subscript[\[Eta], \[Phi], j]], {j, 1, 10}]; Integrate`getAllVariables[%, {}] Examples showing some variation: Integrate`getAllVariables[f[t x] E^y, {}] (* {y, f[t x]} --- f is not identified as a ...


3

EDIT 1: If you know additional constraints for each variable, you can add them in to the list of equations. sols = Solve[{ a + b + c == 164.35, d + e + f == 94.44, a^2 + d^2 == 20.06^2, b^2 + e^2 == 74.34^2, c^2 + f^2 == 123.27^2, a >= 0, b >= 0, c >= 0, ...


3

category[expr_] := Module[{fc = StringTake[ToString@expr, 1]}, Which[ MemberQ[CharacterRange["a", "z"], fc], 1, MemberQ[CharacterRange["A", "Z"], fc], 2, True, 3]]; categories[expr_] := Cases[expr, _[_?NumericQ ..], Infinity] // Union // (* SortBy[#, category] & // SplitBy[#, category] & *) GatherBy[#, category] & (* ...


3

total = 800; side1 = x; side2 = total - 2 x; f[x_] = side1*side2; Solve[f'[x] == 0, x] (* {{x -> 200}} *) or total = 800; side1[x_] = x; side2[x_] = total - 2 x; f[x_] := side1[x]*side2[x]; Solve[f'[x] == 0, x] (* {{x -> 200}} *)


2

Keep f as a list of functions, rather than a new function f[x]. func[expr_, var_] := Module[{f, x}, f = expr /. var -> x; Plot[f, {x, 0, 10}, PlotStyle -> {Red, Black}]] func[{Sin[y], Sin[2 y]}, y]


2

Maybe you can do something like the following: rearrange[eqn_] := Module[{v, arrays}, v = Union @ Cases[eqn, Subscript[x, _], Infinity]; arrays = CoefficientArrays[eqn, v]; arrays[[2]] . v == -arrays[[1]] ] For your example: rearrange[eqn] //TeXForm $x_3-2 x_4+x_5=-2 \zeta _3+\zeta _6+\zeta _7-\zeta _9-r_0$


2

You should look at DChange DChange[D[X[t], {t, 1}], eta == w*t, t, eta, X[t]] w X'[eta] Note: For change of variable, there should be one to one correspondence. So, it seems impossible to change $t$ to $\eta$ and $\xi$ at the same time. Correct me if I am wrong.


2

Here's a general function, which I think protects the body of the Function from being evaluated: def[Function[body_], f_] := With[{nvar = Max@Cases[Hold[body], Slot[k_] :> k, Infinity]}, With[{vars = Thread[ ToExpression[ Table["x" <> ToString@k, {k, nvar}], StandardForm, Hold], Hold]}, vars /. Hold[v_] :>...


2

put bracket around f in the Derivative-commands f -> [f]: Derivative[1, 0][f][g[x, t], t] ==f[g[x, t], t]*t + Derivative[2, 0][f][g[x, t], t] (*\!\(\*SuperscriptBox[\(f\), TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[g, t] == t f[g, t] + \!(\*SuperscriptBox[\(f\), TagBox[RowBox[{"(", RowBox[{"2", ",", "0"}],...


2

Expanding on @Lukas Lang's comment, the problem comes from the default level specification of Cases and the fact that f appears as the head (or rather, at part 0/only in level 0) in f[a,b,c]. From the Cases documentation The default value for levelspec in Cases is {1}. So when a level is specified, say for example as Cases[f[a, b, c], _f, Infinity], ...


2

Since inc is 65536 and BaseForm[inc, 2] is 10000000000000000, accu will always be zero. You can see this by observing the calculations samplingRate = 500; seconds = 1/5; bits = 16; maxV = 2^bits; freq = 500; samples = samplingRate seconds 100 inc = maxV freq/samplingRate 65536 BaseForm[inc, 2] Then, of course, BitAnd[inc, 255] gives zero ...


1

I think this is a good example of when you can use Set for defining a function, or rather when it's a good idea to not use SetDelayed. Since you want to assign the evaluated rhs of the composition to f (and the result has a closed form), instead of redoing the composition each time the new f is called (leading to the infinite recursion), you can directly ...


1

Clear["Global`*"] (M = {{a, g}, {g, b}}) // MatrixForm U = (1/Sqrt[2]) {{1, 1}, {1, -1}}; (M = U.M.ConjugateTranspose[U] // Simplify) // MatrixForm repl = Solve[{ w == (a + b)/2, d == (a - b)/2, p == w + g, m == w - g}, {a, b, g}, {w}][[1]] (* {a -> 1/2 (2 d + m + p), b -> 1/2 (-2 d + m + p), g -> 1/2 (-m + p)} *) (M = M /. repl /...


1

Here is a simple example that will get you started, x = {x1, x2, x3}; y = {y1, y2}; (xy = KroneckerProduct[x, y]) // MatrixForm (* get 3x2 matrix output *) (yx = KroneckerProduct[y, x]) // MatrixForm (* get 2x3 matrix output *) The parentheses are important --- compare the FullForm of the resulting "matrix" if you leave them out. Edit: In answer ...


1

Try Table[{t, x /. NSolve[{Astep[x, t] == 0, -4 Pi < x < 4 Pi}, x]}, {t,1, 10}] (* {{1, {-10.854, -7.71239, -4.5708, -1.4292, 1.71239, 4.85398, 7.99557,11.1372}} , {2, {-10.7124, -7.5708, -4.4292, -1.28761, 1.85398,4.99557, 8.13717, 11.2788}},...}*)


1

Perhaps that's the answe to your question expr=(1 + a + a x + a^2 x - a y)/(3 + 3 a +a^2) + (I (1 + a x + 2 a y + a^2 y))/(3 + 3 a + a^2); expr /. {x -> Re[z], y -> Im[z]} // FullSimplify (* ((1 + I) + a + a ((2 + I) + a) z - a Re[z])/(3 + a (3 + a))*)


1

exp = ConditionalExpression[(1 + a + a x + a^2 x - a y)/(3 + 3 a + a^2) + (I (1 + a x + 2 a y + a^2 y))/(3 + 3 a + a^2), (x | y) ∈ Reals && a > 0]; Simplify[exp, z == x + Sqrt[-1] y] ConditionalExpression[((1 + I) + a + I a y + a ((1 + I) + a) z)/( 3 + 3 a + a^2), (x | y) ∈ Reals && a > 0]


Only top voted, non community-wiki answers of a minimum length are eligible