# Tag Info

3

You mean something like: Subscript[1, ##] & @@@ R and: MapThread[ Subsuperscript[1, Row[#1, ","], #2]&, { R, Join[ ConstantArray["a", Length[R]/2], ConstantArray["b", Length[R]/2] ] } ] ? Edit If you want parentheses around the subscripts, you can use: Subsuperscript[1, Row[{"(", Row[#1, &...

3

Solve[{DCp1total == WA1*DCpA0 + WB1*DCpB0, DCp2total == WA2*DCpA0 + WB2*DCpB0, WA1 + WB1 == 1, WA2 + WB2 == 1, DCp1total == 0.6, DCp2total == 0.3, DCpA0 == 0.5, DCpB0 == 0.4}] {{WA1 -> 2., WA2 -> -1., WB1 -> -1., WB2 -> 2.}}

5

For the revised problem statement: DCp1Total = 3/5; DCp2Total = 3/10; DCpA0 = 1/2; DCpB0 = 2/5; eq = DCp1Total == WA1*DCpA0 + WB1*DCpB0 // Simplify; eq = DCp2Total == WA2*DCpA0 + WB2*DCpB0 // Simplify; eq = WA1 + WB1 == 1; eq = WA2 + WB2 == 1; min = Minimize[Total[(Subtract @@@ (eq /@ Range))^2], {WA1, WA2, WB1, WB2}] (* {0, {WA1 -> 2, ...

6

There is no solution. But you can use least squares approximation ps. do not use _ in variable names in Mathematica as _ is meant be used for pattern and you will get in trouble if you do that. (*from clean kernel*) DCpA0 = 1/2; DCpB0 = 4/10; WA0 = 7/10; WB0 = 3/10; DCp1Total = 6/10; DCp2Total = 3/10; eq1 = DCp1Total == WA1*DCpA0 + WB1*DCpB0; eq2 = ...

2

The scoping construct is only relevant in so far as it groups the code into a singly parsed block. Hence, the same "unexpected" behaviour results from any type of grouping (AaaTest[x_] := x + 1; context = "Aaa"; PrependTo[$ContextPath, context]; Context@Test ) (* "Global" *) Hence, the WL possesses a parsing/evaluation ... 1 It looks like the definitions for NonCommutativeMultiply don't make it to the parallel kernels. You can test this as follows: CloseKernels[]; Unprotect[NonCommutativeMultiply]; NonCommutativeMultiply[args___] := f[args]; Protect[NonCommutativeMultiply]; Quiet @ LaunchKernels[]; DistributeDefinitions[NonCommutativeMultiply]; ParallelEvaluate[Hold[Evaluate[3 **... 2 NHoldAll is designed for this. ClearAll[b]; SetAttributes[b, NHoldAll]; x = (Sqrt[3/(2 (1 + Sqrt/4))] b[0, π/3] - (1 + Sqrt[7/3]) b[(2 π)/3, (2 π)/3]) / (4 Sqrt 7^(1/4) Sqrt[1 + Sqrt/4]); N[x] (* 0.0843157 (0.905566 b[0, π/3] - 2.52753 b[(2 π)/3, (2 π)/3]) *) There are also NHoldFirst and NHoldRest. 0 What worked better than Expand for x consisting of a large number of terms like the ones above is: rules = {Sqrt[a_] :> N[Sqrt[a]], a_/b_ :> N[a/b] /; Mod[a, π] != 0, Power[x_, y_] :> N[x^y]}; Sorry I couldn't post a specific example for x as it consists of more than 20 terms added. 1 As simple as Collect[x, _b, N] 3 Clear["Global*"] Without a representative example, I cannot tell how the timing compares with using Expand x = (Sqrt[3/(2 (1 + Sqrt/4))] b[ 0, π/3] - (1 + Sqrt[7/3]) b[(2 π)/3, (2 π)/3])/(4 Sqrt[ 2] 7^(1/4) Sqrt[1 + Sqrt/4]); var = Cases[x, b[__], Infinity]; x2 = Total[Chop[N[CoefficientList[x, var]]] . var] (* 0.0763535 b[... 1 NO[Times[x__, y_NonCommutativeMultiply, z___]] := x z NO[y] NO[Times[x___, y_NonCommutativeMultiply, z__]] := x z NO[y] should do the trick in all situations: Depending of the canonical ordering of Times it might not be necessary to include both versions but better save then sorry. 1 You can use a Piecewise definition as well: Clear[f] f[x_, y_] := Piecewise[ {{1/(Sin[x] + Sin[y]), Mod[x, Pi] != 0 || Mod[y, Pi] != 0}}, 0 ] f[2, 3.] (* 0.952002 *) f[Pi, 3 Pi] (* 0 *) f[2, 10 Pi] (* Csc *) f[Pi, 2 Pi] (* 0 *) Here I made the default value$0\$ explicit for future code readability, but ...

2

f[x_, y_] := 0 /; Mod[x, π] == 0 && Mod[y, π] == 0 does the trick. Just figured it. Any comments are most welcome.

4

If you only need y'[end] as a result modify the ParametricNDSolve to ysend = ParametricNDSolveValue[{m y''[t] ==n[t] - m g, φ''[t] == (n[t] l Sin[φ[t]] +m x''[t] l Cos[φ[t]])/i, x''[t] == If[(x[t] - l*φ[t] == 0) // Evaluate,l (φ''[t] Cos[φ[t]] - φ'[t]^2 Sin[φ[t]]) // Evaluate, μk*n[t]/m// Evaluate], y == l*Cos[f],y' == -2.9, φ == f, φ' == h,x...

Top 50 recent answers are included