Tag Info

3

Depending on what you want to do with it, you might use the built-in InverseLaplaceTransform: InverseLaplaceTransform[c s/(1 + r c s), s, t] c (-(E^(-(t/(c r)))/(c^2 r^2)) + DiracDelta[t]/(c r))

2

You can use the definition of Laplace. Assuming zero initial conditions, replace $s$ with $\frac{dy}{dt}$ and $s^2$ with $\frac{d^2y}{dt^2}$ and so on. tfToDiff[tf_, s_, t_, y_, u_] := Module[{rhs, lhs, n, m}, rhs = Numerator[tf]; lhs = Denominator[tf]; rhs = rhs /. m_. s^n_. -> m D[u[t], {t, n}]; lhs = lhs /. m_. s^n_. -> m D[y[t], {t, n}]; ...

3

Limit can actually approach a value from any direction in the complex plane. For instance Limit[__, Direction -> I] is valid. To have a bidirectional limit along the real line, you'll have to implement it yourself. Something like this should work pretty well I think. Basically just take limits in both directions and make sure they equal. ...

1

More of an extended comment, but I have found a single counterexample, where it's longer to pack, than to just do it. Edit: of course this needs <<Developer first. Do[Outer[Times, ToPackedArray[{3.}], ToPackedArray[{5.}]], {1000000}] // AbsoluteTiming (* {1.62244, Null} *) Do[Outer[Times, {3.}, {5.}], {1000000}] // AbsoluteTiming (* {0.929396, ...

4

To answer the second part of your question, use the efficient code from @DanielLichtblau, findPoints2, to generate some disks. SeedRandom[111]; pts = findPoints2[50, 0, 1, 0.03, 2.2*0.03] Intersections of the square and disks are given by RegionIntersection with two different heads: DiskSegment for disks along an edge of the square, and RegionIntersection ...

4

Since you are discarding all circles strictly in the interior, substantial time is spent generating them so that they do not intersect other circles and later determining that they are strictly interior to the boundary. Better is to only generate circles that intersect the boundary. This can be done by generating an x value between low and high, a y value ...

2

Here is a very simple way to determine if a generic circle intersects with a line-segment. Probably you can integrate with your code. Let's say the line-segment is defined by the points {x1,y1} and {x2,y2}. This gives the equation of line-segment in parametric form as x=(1 - t) x1 + t*x2 and y=(1 - t) y1 + t*y2 where t \in [0,1] The circle be defined by the ...

2

As suggested in comment by J.M., NonCommutativeMultiply might be useful here. Using //. and two replacement rules you can get desired results. \$ncmRules = { (* Change b ** a to q a ** b. *) x___ ** b^n_. ** a^m_. ** y___ :> q^(n m) x ** a^m ** b^n ** y, (* Replace adjacent powers of same multiplicands by single power. *) x___ ** y_^n_. ** ...

0

I don't have any points to comment on Daniel W's answer. But here's how you write this z[[1]]/z[[2]] /. z -> zz to not generate any part errors Indexed[HoldForm[z], 1]/Indexed[HoldForm[z], 2] /. HoldForm[z] -> zz Out[1]=3/4

1

This post is likely to be closed, partly because it is unlikely to help future users of the site. Here are some tips for you that should solve your specific problem. As george2079 mentioned in comments, move the code at the top of your code block to the bottom, so that it is not relying on yet-to-be-defined objects. You might also need to remove the ...

1

f = x^3 + y x z + z^3; grad = Plus @@ Map[D[f, #] &, {x, y, z}] 3 x^2 + x y + x z + y z + 3 z^2 Or grad = Plus @@ Grad[f, {x, y, z}]; Same result vals = Function[{x, y, z}, Evaluate@grad] @@@ {{2, 2, 2}, {3, 1, 7}, {1, 6, 3}, {4, 5, 1}, {0,4, 9}} {36, 205, 57, 80, 279} Mod[vals, 4] {0, 1, 1, 0, 3} Put together: Function[{x, ...

0

maybe this give you some idea: A[\[Alpha]_, \[Beta]_] := Abs[-1 + 1/(1 + \[Beta])] + Abs[-((1 + 2 \[Alpha] + Sqrt[1 + 4 \[Alpha] + 4 \[Alpha] \[Beta]])/(2 \[Alpha] + 2 \[Alpha] \[Beta]))]; f[a_, b_] := If[(Abs[b] < Abs[1 + 4 a]) && (A[a, b] < 1), {a, b}]; Tally@Flatten@ Table[f[RandomInteger[{1, 10000}], ...

0

This works: S=NDSolve[{y'[x]==(y[x]^2+y[x]+1)^(1/2),y[0]==0},y,{x,1,8}]; func1[x_]:=(y[x]/.First[S])^-3; Plot[func1[x],{x,1,2.5}] Often times you need to ensure your definition of func1 is only used when x has a numeric value. In that case use func1[x_?NumericQ] := ...

4

As far is I can tell, there is no built-in command to do so. However, typing ?*MatrixQ Into the front end and evaluating will give a list of the matrix properties you can test for in Mathematica. Based on the resulting list, I came up with the following simple function that you might find useful. This is just a helper function to make the output look ...

0

An approach similar to that of yarchik but non-commutative is CircleTimes[a, b] := Times[a, b] CircleTimes[b, a] := q Times[a, b] CircleTimes[z_, z_] := Times[z, z] CircleTimes[z__] := Module[{zz = {z}, tem}, tem = CircleTimes @@ zz[[-2 ;; -1]]; (CircleTimes @@ Join[zz[[1 ;; -3]], {First@tem}]) Rest@tem] Then, a⊗b (* a b *) b⊗a (* a b q *) ...

2

You may start with something like that equ = {-y'[t] + 1 + (1 + \[Epsilon]) y[t]^2}; y[t_] := Sum[x[i][t] \[Epsilon]^i, {i, 0, 10}] // Evaluate; First order solution (use SeriesCoefficient function to expand equation with series substituted) x[0] = x[0] /. First@DSolve[{First@SeriesCoefficient[equ, {\[Epsilon], 0, 0}] == 0, x[0][0] == 1}, x[0], ...

24

The symbols that are market [[EXPERIMENTAL]] in the documentation are in their own entity class of the "WolframLanguageSymbol" entity type named "UnderDevelopment". EntityClass["WolframLanguageSymbol", "UnderDevelopment"] Here is a list of all the 25 symbols currently (version 10.3) in EntityList[EntityClass["WolframLanguageSymbol", "UnderDevelopment"]] ...

1

Here's a sin wave with increasing amplitude: Plot[t Sin[2 Pi 20 t], {t, 0, 1}] If you want samples of this: sam = Table[t Sin[2 Pi 20 t], {t, 0, 1, 0.01}];

0

I am not sure get what you want or not but this is a simple approach: Table[RandomReal[]*Sin[x], {x, 0, 2 Pi, Pi/12}] Table[2 RandomReal[] + 3 Sin[x], {x, 0, 2 Pi, Pi/12}] Table[(-1)^RandomChoice[{0, 1}]*2 RandomReal[] + 3 Sin[x], {x, 0, 2 Pi, Pi/12}]

2

Define your multiplication by two rules CircleTimes[x_, y_] := q Times[x, y] for 2 arguments and CircleTimes[a___] := Module[{b, c}, If[Length[{a}] > 2, b = CircleTimes [{a}[[1]], {a}[[2]] ]; c = Join[{b}, {a}[[3 ;; All]] ]; Apply[CircleTimes, c]] ] It can be written shorter, here I separated into steps for clarity. Test: a⊗b⊗b⊗a (*a^2 b^2 ...

-1

Almost ... Clear[a, b, q] ab = ba = q a b; ba ab

3

The following shows a way to emulate the summary boxes using only documented constructs: grid[g_] := Column[Row /@ MapAt[Style[#, Gray] &, g, Table[{i, 1}, {i, Length[g]}]]] MakeBoxes[c : foo[___], form : (StandardForm | TraditionalForm)] := With[{boxes = RowBox[{"foo", "[", ToBoxes[Panel[ OpenerView[ ...

5

Just going on the figures I see in the linked page, it seems if you are dealing with two continuous distribution functions, defined for all real numbers, then the overlap is just the minimum of the two at all points. If they are allowed to go negative, then a different definition is needed I think. We'll look at the overlap between two Gaussians ...

6

This is a limitation in TemporalData that MovingMap was designed to work with. Note that TimeSeries and EventSeries are really just special cases. I don't know if it is a necessary limitation but a decision was made at the time they were created that the dimensionality of the data values need to be consistent. Now whether this restriction should be relaxed ...

3

There does not appear to be a solution. FindRoot gets as close as it can. Plot[{q1[t], -q2[t]} /. lagrangesolveg2 // Evaluate, {t, 0, 1}] Plot[{q1[t], -q2[t]} /. lagrangesolveg2 // Evaluate, {t, 0.05, 0.2}]

2

a = First[x /. Solve[x + 1 == 0, x]]

4

OK, let me extend the comment into an answer. If ft still contains InverseFunction, your goal can be achieved by (* Solution 1 *) tf = First@Head@ft (* Solution 2 *) tf = ft[[0, 1]] (* Solution 3 *) tf = InverseFunction@Head@ft (* Solution 4 *) tf = InverseFunction@ft[[0]] (* Solution 5 *) tf = InverseFunction@Function[t, #] &@ft Solution 5 should ...

8

Use the PermutationOrder function: In[1]:= elt = Cycles[{{1, 2}, {3, 4, 5}}]; In[2]:= PermutationOrder[elt] Out[2]= 6 This is indeed the answer you expect, and the smallest power you can raise elt to and get the identity permutation. In[3]:= PermutationPower[elt, #] & /@ Range[6] Out[3]= {Cycles[{{1, 2}, {3, 4, 5}}], Cycles[{{3, 5, 4}}], Cycles[{{1, ...

2

a = {1, 2, 3, 4}; b = {10, 11, 12}; To get all the values: vals = Outer[#2^#1 + #1*#2 &, a, b] (* {{20, 22, 24}, {120, 143, 168}, {1030, 1364, 1764}, {10040, 14685, 20784}} *) To get the averages: vals = Outer[#2^#1 + #1*#2 &, a, b]; Transpose[{b, Mean[vals]}] (* {{10, 5605/2}, {11, 8107/2}, {12, 5685}} *) To see what is happening, evaluate ...

3

For the second part: {#, Mean@Thread[f[a, #]]} & /@ b (* {{10, 5605/2}, {11, 8107/2}, {12, 5685}} *) For the first part: Outer[f, a, b]

1

This question is about to be closed and rightfully so, but while it's open... This ei[x_] :=Module[{e1 = {1,0,0},e2 = {0,1,0}, e3= {0,0,1}}, If[Mod[x,3]==0, Return[e1]] If[Mod[x,3]==1, Return[e2]] If[Mod[x,3]==2, Return[e3]] ]; is equivalent to this ei[x_] :=Module[{e1 = {1,0,0},e2 = {0,1,0}, e3= {0,0,1}}, If[Mod[x,3]==0, Return[e1]] If[Mod[x,3]==1, ...

2

You can visualize membership with NumberLinePlot[{-2 <= x < 1 || x > 3, x == -1}, x]

8

IntervalMemberQ[Interval[{-2, 6}], 3] (* => True *)

3

Have a look Range and MemberQ. As well Testing Expressions. myList = Range[-2, 6, 1] {-2, -1, 0, 1, 2, 3, 4, 5, 6} myVal = 3 3 MemberQ[myList, myVal] True

8

Mathematica 10.3 In Mathematica 10.3 there is a new function Between: Between[3, {2, 5}] True Previous versions of Mathematica You can define your own function with the same behavior: My take mybetween[a_, {b_, c_}] := TrueQ[b <= a <= c] or as suggested by @mmal mybetween[a_, {b_, c_}] := IntervalMemberQ[Interval[{b, c}], a] We can ...

2

list = {1, 2, 3, 4}; f[n_] := n f[n_?(MemberQ[list, #] &)] := n^2 f /@ Range@10 (* {1, 4, 9, 16, 5, 6, 7, 8, 9, 10} *)

1

Your variable is not gone, but otherwise noted. I think you should ask your question on Math. That said, you will find answers to your questions: How to | Create Definitions for Variables and Functions Defining Variables Defining Functions Just hit F1 and find the Help-Center, if your question ist about the software Mathematica, else as on Math. f[x_] = ...

5

The Mathematica way is to write Total[#2 Exp[# x] & @@@ list] The same with the part of the list: Total[#2 Exp[# x] & @@@ list[[2 ;; 4]]] Also you can write an explicit sum with EscsumtEsc:

4

I think you are confusing the behaviour of With and Block t = x; Block[{x = 1}, t] (* 1 *)

4

t = x; With[{x = 1}, Evaluate[t]]

3

Animate[ Graphics[{Red, GeometricTransformation[Rectangle[{-2.5, -0.5}, {2.5, 0.5}], RotationMatrix[\[Theta]]]}, Axes -> True, PlotRange -> {{-10, 10}, {-10, 10}}], {\[Theta], 0, 2 Pi}] As per your comment, if you do not want to use the built in RotationMatrix then please see this: ...and this:

1

Consider this simple case. w[x_, y_] := 1 + x y t[x_, y_, z_] := w[x, y]/z Then t[2, 3, 5] gives 7/5 which shows Mathematica recognized and evaluated the reference to w[x, y] in the definition of t, substituted the correct values of x and y, and got the correct result for t[2, 3, 5]. It will do the same for your definitions.

2

I think you are getting confused due to the naming convention you are using. For T you can use any symbol to represent the function W in T. It is perhaps best not to use the symbol W in T's definition because it is confusing you. Try using f instead. ClearAll[T, W]; W[L_, r_] := 1 + 3 L + 2 L^2 - 6 r*L - 6 L (r*L) + 6 (r*L)^2 T[L_, r_, d_, koff_, u_, f_] ...

0

You really want to define the collection of vs when you produce a realization of vel, so I'd replace this with vel[n_] := Module[{}, Table[ v[k] = v[k - 1] + f[k - 1] + Random[NormalDistribution[0, s]], {k, 0, n}] ] This generates a new set of vs every time you call vel[]. (The bulk of this could be replaced by NestList[], but I'm not convinced ...

13

Suggested solution If I understood the question right, then the simplest solution here would probably be to define a helper function like the following: vv[n_] := InternalInheritedBlock[{v}, v /@ Range[n]]; Then, you get vel = vv[m] and every run of vv would result in different set of values, while the values in the set will all come from the same ...

2

If you want to use equally sized intervals, you can do it symbolically (though @Michael E2's approach gives the full generality of the Riemann Sum and is generally cooler). In[1]:= With[{h = (b - a)/n}, Sum[h*(a + k*h)^2, {k, 0, n}]] Out[1]= ((a - b) (1 + n) (a^2 - 2 a b + b^2 + 2 a^2 n + 2 a b n + 2 b^2 n))/(6 n^2) In[2]:= Limit[%, n -> ...

4

I thought perhaps the limit of a Riemann Sum: Needs["NumericalCalculus`"] riemann[f_, {a_?NumericQ, b_?NumericQ}, n0_?NumericQ] := With[{n = Ceiling[n0]}, With[{partition = Union[{a, b}, RandomReal[{a, b}, n - 1]]}, With[{values = RandomReal /@ Partition[partition, 2, 1]}, Differences[partition].f[values] (* assumes f is Listable -- f /@ ...

2

Do you mean that you want to integrate x^2 from 0 to 3? If so it would be: Integrate[x^2, {x, 0, 3}]

0

You need to use PrimePi to find how many primes are less than 100 Array[Prime, PrimePi[100]]

2

You could use t=Table[FactorInteger[k],{k,1,100}] (* show the factors *) Cases[t,{{_,1}}] (* select only those with one factor with exponent 1 *)

Top 50 recent answers are included