Ali Hashmi
• Member for 6 years, 10 months
• Last seen this week

we can use FixedPoint with Replace Cases[FixedPoint[Replace[{p___, {x_, y_}, q___, {w_, z_}, r___} /; Abs[y - z] < 0.02 :> {p, {{x, y}, {w, z}}, q, r}], Join[list1, list2]], {{_, _}, {_, _}}]...

a slight variant of @MarcoB 's answer (we can do without Unprotect): roi = {Circle[{0, 0}, 0.6`, {30 \[Degree], 80 \[Degree]}], Arrow[{{0, 0}, {1, 1}}]}; SetAttributes[regInt, HoldAllComplete]; ...

t = {{1, 2, 11}, {0, 2, 11}, {2, 1, 11}}; Extract[t, FirstPosition[Plus @@@ t, 14]] (* {1, 2, 11} *)

rules = {a->b, c->d, e->f, g->h}; Solve[expr /. rules] /. (Map[Reverse]@rules)

Thread[{list1[[All, 1]], list1[[All, 2]] - list2[[All, 2]]}] (* {{0.5, 0.2}, {0.75, -0.3}, {1.1, 2.1}, {1.3, 1.}, {2., 1.1}} *) Thread[{#1 & @@@ list1, (#2 & @@@ list1) - (#2 & @@@ list2)}...

list = (Permutations[Flatten@ConstantArray[Range@6, 4], {4}]); Length@Select[list, And@@Thread[#[[1 ;; 3]] >= 5] && #[[4]] < 5 & ]/Length@list (* 2/81 *)

asc = <|{1} -> "a", {0, 1} -> "b", {0, 0} -> "c"|>; func[assoc_Association, code : {(1 | 0) ..}] := Map[assoc[#] &][SequenceCases[code, Alternatives @@ Keys@assoc]]; func[asc,{1, ...

Flatten[Riffle[#, Ratios@Prepend[#2 & @@@ #, Last@First[#]]], 1]&@data~Partition~3 (* {{1, 3, 1}, {2, 4, 4/3}, {3, 5, 5/4}, {4, 6, 6/5}} *)

as suggested by @Szabolcs {{1.99719*10^7, 66451.9, 84170.3, 57308.1, 13392.5, 16138.1}, {130243., 1.21641*10^7, 61228.3, 66902.9, 53069.1, 30019.1}, {67442.3, 41337., 3.56545*10^6, 12429.4, 6761.89,...

pts = Transpose[{xx, yy}]; f = LinearModelFit[pts, {x}, x]; linepts = Thread[{#, Function[x, f[x], Listable][#]}] &@(Range @@ MinMax[xx]); distmat = DistanceMatrix[pts, linepts]; distance = ...

Function[x, If[x > 0.5, 5 x, x], Listable][list] (* {-1, 0, 5, 10, 15} *)

This implementation ensures that Sin would not evaluate immediately. ClearAll@times; SetAttributes[times, HoldAllComplete]; times /: times[Times[x_, Sin[y_]]] /; Positive[x] := x HoldForm[Sin[y]]; ...

This may be the fastest way in my analysis so far and may compete with Fold or perhaps perform better Module[{m = Range@10}, SetAttributes[func, HoldFirst]; func[x_, {}] := x; func[x_, y_] := (x[[y[[...

as mentioned by C.E. the preferred built-in function is: Partition[Range[5], 2, 1] (* {{1, 2}, {2, 3}, {3, 4}, {4, 5}} *) as pointed out by Simon Woods: SequenceCases[Range[5], {_, _}, Overlaps -&...

Fold[Replace[#1, f[expr___] -> #2[[1]][expr], {#2[[2]]}] &, f[f[f[]]], {{a, 0}, {b, 1}, {c, 2}}] (* a[b[c[]]] *) however since we are replacing all the heads iteratively at each level, the ...

With some credits to @C.E. (* which trajectory the point lies on *) whichTrajectory[grid_, startpos_] := With[{p = MorphologicalComponents[grid]}, With[{labels = (Union@Flatten@p)[[2 ;;]]}, {p, First ...

using Replace and recursion list1 = {{x1, y1}, {x2, y2}, {x3, y3}}; Clear@func; func[list_] := list /. {___, a : {_, _}, b : {_, _}, d : {_, _} ...} :> Join[{a, Mean[{a, b}]}, func[Join[{b}, {d}...

compacted notation by Bob Hanlon f[t_] := EuclideanDistance@@({x[t], y[t], z[t]} /.{sol1, sol2}) original attempt f[t_] := EuclideanDistance[({x[t], y[t], z[t]} /. sol1[[1]]), ({x[t], y[t], z[...

I personally prefer @Kuba's method of KeySort. You can always use Normalthen SortBy and then Association ClearAll[dice, sides]; dice := 3 sides := 6 <| SortBy[First]@Normal@CountsBy[ Times @@@ ...

RegionNearest can also be an option imp = Import["C:\\Users\\Ali Hashmi\\Downloads\\PI.mat","LabeledData"]; X = "KP" /. imp; Y = "KI" /. imp; threadeddata = Transpose[{Flatten@X, Flatten@Y}]; ...

previous post (may or may not be correct implementation) SumConvergence[(Sin[n])^2/n^p, p] (* this gives condition for convergence *) (* Abs[n] > 1 *) SumConvergence[(Sin[Abs@n > 1])^2/n^2, n] ...

you can use Select without having to create the list of Boolean values True, Falseexplicitly Select[Range[10], Divisible[#, 3] &] (* {3,6,9} *) Alternatively one can use Extract Extract[#, ...

here is how you can implement it yourself: Clear@if; if[x_, y_, z_] := Module[{f, g}, Which[Head[x] === List, (f = Length@x > 0; Switch[f, True, y, _, z]), Head@x === Integer, (g = Mod[x, 2]; ...

A slightly different approach: inside = Pick[pts, Map[# ∈ Disk[] &, pts], True]; outside = Complement[pts, inside]; Also as pointed in a comment above: inside = Pick[#, RegionMember[Disk[]][#], ...

there is a nasty way of doing this: orig = (Riffle[ToCharacterCode[fileNames], (Characters /@ fileNames)]) // Partition[#, 2] & // Thread[#] & /@ # & // #[[All, {21, 22}]] & (*{{{54,...

Perhaps not a good job but the closest i can get to: plot = Reap[ContourPlot[F[{x, y}], {x, -3, 3}, {y, -3, 3}, EvaluationMonitor :> If[5.95 < F[{x, y}] < 6, Sow[{x, y, F[{x, y}]}],]]][[2,1]]...

try this: FullSimplify[ -Cos[γ[1][t] - θ[1][t] - ψ[1][t]] l[f] + m[f] Sin[γ[1][t]] + c[f] Sin[γ[1][t] - θ[1][t]] - h[f] Sin[γ[1][t] - θ[1][t] - ψ[1][t]] + x[P1][t] == (-Cos[γ[2][t] - θ[2][...

try this: First@Flatten@Position[#, Max[#]] &@list alternative: Last@Ordering[list]

SearchAll[sequence_, search_] := Module[{map}, map = Map[# -> "\!\(\*StyleBox[\"" <> # <> "\",FontColor->" <> ToString@RGBColor[RandomReal[], RandomReal[], RandomReal[]]...