Tag Info

New answers tagged

1

The use of NumericQ as mentioned by MarcoB and Guess who it is. in the comments seems to be important. Also, estimating the integral using a Total[Table[]] as in the code I posted in the second revision of the question makes this method computational feasible enough to solve my problem.


2

The reason that you get the error "r1/Rc is not a valid variable" is that Mathematica can't take a derivative with respect to an expression, and your definitions make it so that somewhere in your code, you are trying to do something like D[h[r1/Rc], r1/Rc] which doesn't make sense. Instead, I think the most straight-forward way to do this is via ...


3

I am using π rather than Pi in the equations you gave. I think this is what you wanted. When I substitute in 1 for the variables a, b, R and V0 it will not integrate in a closed form. Integrate[-((4 E^-r^2 r^2)/((1 + E^(-1 + r)) Sqrt[π])), {r, 0, Infinity}] However, NIntegrate works. NIntegrate[-((4 E^-r^2 r^2)/((1 + E^(-1 + r)) Sqrt[π])), {r, 0, ...


0

Modifying your second definition of FT to FT[kx_, ky_, z_] := 1/(2*Pi)* NIntegrate[ f[x, y, z]*Exp[-I*kx*x - I*ky*y], {x, -∞, ∞}, {y, -∞, ∞}, MinRecursion -> 4] // Chop solves your problem.


1

Say you have 4 Functions (see also Defining Functions): A1[x_] := 2*3 B1[x_] := 2*2 C1[x_] := 1/4 D1[x_] := 1/1000 you can use them with your own Function: f[x_] := (Sin[2 x]/((A1[x] - B1[x] Sin[2 x] + C1[x] Cos[x] - D1[x] Sin[x]))) For a first overview we make a Plot: Plot[f[x], {x, 0, 2 π}] NIntegrate works quite well NIntegrate[f[x], {x, 0, 2 ...


4

edit I have corrected omission of absolute value determinant. I am not currently able to access Mathematica but will correct image accordingly but till then just noted sign difference. Apologies. Just another way (including @belisarius region) change of variable (for this case can use affine transform to plot): mat = {{2, 1}, {1, -1}}; rect = Rectangle[{1, ...


3

Not the simplest solution, but a clever one: eqs1 = {2 x + y == 1, 2 x + y == 4}; eqs2 = {x - y == -1, x - y == 1}; cornerPts = Flatten[({x, y} /. Outer[Solve[#1 && #2, {x, y}] &, eqs1, eqs2]), 2]; or cornerPts = Flatten[({x, y} /. Outer[Solve[2 x + y == #1 && x - y == #2, {x, y}] &, {1, 4}, {-1, 1}]), 2]; ...


9

RegionPlot[1 < 2 x + y < 4 && -1 < x - y < 1, {x, -1, 2}, {y, -1, 3}]


4

This symmetrizes an arbitrary expression by adding it to itself with the variable names interchanged. As a result, any term in the original expression has a symmetry-related counterpart, making the expression manifestly symmetric in the only sense that can be reasonably applied to an arbitrary expression. It's a special case of my answer to What is the ...


2

f[a_, b_] := a (a + b) + a b + b^2 Simplify@(f[a, b] + f[b, a])/2 or for polynomials: SymmetricReduction[a (a + b) + a b + b^2, {a, b}][[1]] $(a + b)^2$ The first approach works for functions such as: f[a_, b_] := Cos[a] + Sin[a + b] Simplify@(f[a, b] + f[b, a])/2 $1/2 (Cos[a] + Cos[b] + 2 Sin[a + b])$


9

It's because it has no closed form, and the default numerical methods don't converge quite fast enough on it. NIntegrate returns -0.585566 given a higher-than-usual value of MaxRecursion: NIntegrate[ Exp[-r^2]*r^2*Log[Exp[-r^2]*r^2*(25/10 - r^2)*(25/10 - r^2)], {r, 0, 10}, MaxRecursion -> 20] Here's how to do it without specifying any MaxRecursion. ...


9

Not so fancy as transforming an image, but I like how the mesh in ParametricPlot shows the deformation. {chvar} = Simplify[ Solve[u == x y && v == y - x && y > 0 && x > 0, {x, y}, Reals], 1 <= u <= 4 && 0 <= v <= 2] (* {{x -> (2 u)/(v + Sqrt[4 u + v^2]), y -> 1/2 (v + Sqrt[4 u + v^2])}} *) ...


8

I will post this to avoid confusion - region has a new meaning in WL since Geometric Computation was introduced in V10. Relative to that meaning what you showed is not a WL region because you cannot compute over it, but of course is a visual of some mathematical region defined analytically and shown with help of Filling. To achieve the same via computable ...


19

Summary: Setting GenerateConditions -> False turns off safety checks. In my opinion, when the user does that and the result is erroneous, I would not call that a bug. Now WRI could decide to improve Mathematica in this case, but it might not be such a simple matter. On the other hand, it is entirely up to the user to decide whether or not he or she is ...


2

I think what you want is something like this: Conjugate[f[x_, y_, z_]] ^:= cf[x, y, z] Derivative[d__][cf][x__] := Conjugate[Derivative[d][f][x]] D[Conjugate[f[x, y, z]], x] Conjugate[Derivative[1, 0, 0][f][x, y, z]] All I did here is to define the derivative of the function f to be another function cf which then can be given the property you want. ...


0

Limit[(1 - z)/(1 - Conjugate[z]), z -> 1, Direction -> #, Assumptions -> Element[z, Complexes]] & /@ {-1, 1, I, -I} (* {1, 1, -1, -1} *) Output is identical to that of Limit[z/Conjugate[z], z -> 0, Direction -> #, Assumptions -> Element[z, Complexes]] & /@ {-1, 1, I, -I}


4

The integral in your Mathematica code is not the same integral as in your image. Integrate[t^a Exp[-I t^b], {t, 0, Infinity}] (* ConditionalExpression[Gamma[(1 + a)/b]/ (E^((I*(1 + a)*Pi)/(2*b))*b), Re[a] > -1 && Re[b] > 1 + Re[a] && Im[b] == 0] *) Using these stated conditions Assuming[{Re[a] > -1, ...


2

Right now (V10.2) NDSolve uses FEM for elliptic PDEs and that code does up to 2nd order spatial derivatives. The fact that this PDE can be viewed as a time dependent ODE is a coincidence in 1D as pointed out by @MichaelE2 and time dependent ODE are specified via explicit bounds. Another, harder, issue is that it is not trivial to write a general test to see ...


6

Assuming your parameters are real, you can replace Sin by its range: Limit[T /. Sin[_] :> Interval[{-1, 1}], Ε -> ∞] (* 1 *)


0

It seems that Residue (and Series on which it is based) is unable to analyze all the cases in which the formula for the residue might vary. Reduce can do it, within its limitations, if we reduce the system 1/function == 0 && nu == pole. Here's the OP's example. fn = (w^(n/2 + I nu) ws^(-(n/2) + I nu))/(n/2 + I nu)^2; We need to add some ...


4

$Version "10.2.0 for Mac OS X x86 (64-bit) (July 7, 2015)" The Direction of the limit should be -1 to approach 0+. From the documentation, "Direction -> -1 takes variables to approach their limits by decreasing from larger values." Limit[Integrate[(E^(-y*x) - 1)/y^3, {y, 1, \[Infinity]}], x -> 0, Direction -> -1] 0 Including the ...


1

Just another way to calculate volume of hypersphere and then relevant probability using recursion: vs[n_] := Most@Nest[{#[[2]]/(#[[3]] + 1), 2 Pi #[[1]], #[[3]] + 1} &, {1, 2, 0}, n] v[n_] := vs[n][[1]] The probabilities: Grid[Prepend[{#1, #2, N@#2} & @@@ ({#, v[#]/2^#} & /@ Range[10]), Style[#, Bold] & /@ {"n", ...


1

Another thing to look at is the difference between = and :=. For example, if you define your first function as f[a_, t_, c_] := Sum[c[[i]] Exp[-(a - t[[i]])^2], {i, 1, 3}] then you get no warnings and you can evaluate f[a, {t1, t2, t3}, {c1, c2, c3}] as you wish. You can also take derivatives D[f[a, {t1, t2, t3}, {c1, c2, c3}], a] without any ...


2

Here is some food for thought f[a_, t_List, c_List] /; Length @ t == Length @ c := Plus @@ MapThread[(#1 Exp[-(a - #2)^2]) &, {c, t}] f can be used as a numerical function or to generate symbolic expressions. The clause /; Length @ t == Length @ c enforces the constraint that the vectors t and c must have the same length. f[a, {t1, t2, t3}, {c1, ...


1

a = 2; y = 0.0000000001; d = y; z = I a + I y + d - I t; Plot[Im[Log[z^2 + a^2]], {t, -1, 5}, PlotRange -> All, GridLines -> {None, {-Pi, Pi}}] Everything looks ok to me, considering that the imaginary part is practically negligible. Plot[Re[z^2 + a^2], {t, -1, 5}, PlotRange -> All] Plot[Im[z^2 + a^2], {t, -1, 5}, PlotRange -> All]


1

As indicated in the comments, this has been fixed as of version 9.0.0. lst = {{a1, a2}, {b1, b2}, {c1, c2}}; Derivative[1][lst[[1]] + #*(lst[[2]] - lst[[3]]) &] (* lst[[2]] - lst[[3]] & *)


2

If I understand the question properly, you would like to differentiate the expression f = Sum[c[k] Exp[-(a - t[k])^2], {k, kmax}] with respect to t[n], where n is an integer between 1 and kmax, to obtain (* 2 E^-(a - t[n])^2 c[n] (a - t[n]) *) Almost certainly, a similar question has been raised before, but I cannot find it now. In any case, the ...


8

On a different occasion (Dirichlet coefficients as limits: wrong) I have shown that the sometimes limited capabilities of the function Limit[] can be improved by using an intermediate Series[]. Following this idea we can write for the limit in question Limit[Expand[ Normal[Series[(n - n Sqrt[1 + x])^2, {x, 0, 2}]] /. x -> 10/ n + Sin[n]/n^2], n ...


5

The choice of branch cuts is made by re-defining the argument of the complex number under the square root. This can be done by using the approach of this answer: arg[z_, σ_: - Pi] := Arg[z Exp[-I (σ + Pi)]] + σ + Pi; sqrt[x_, σ_: - Pi] := Sqrt[Abs[x]] Exp[I arg[x, σ]/2] Here, the parameter $\sigma$ is the location of the branch cut of the square root. ...


1

Here's how I would do it: Manipulate[ Plot[f[x], {x, a, b}, PlotStyle -> Thick, AxesLabel -> {"x", "y"}, Epilog -> Dynamic@{Table[{Opacity[0.05], EdgeForm[Gray], Rectangle[{a + i dx[n], 0}, {a + (i + 1) dx[n], f[a + (i + 1) dx[n]]}]}, {i, 0, n - 1, 1}], Text["N = " <> ToString[n] <> ", R = " <> ...


4

What about explicitly differentiating under the integral sign? dFlux[r0_?NumericQ, t_?NumericQ] := NIntegrate[ Derivative[0, 0, 1][B][r, s, t]*r, {s, 0, 2 Pi}, {r, 0, r0}, AccuracyGoal -> 3, PrecisionGoal -> 3, Method -> "Trapezoidal"]; Plot[Flux[0.2, t], {t, 0, 4*period}, AxesLabel -> {t, Flux}] Plot[dFlux[0.2, t], {t, 0, 4*period}, ...


1

In five days no one gave an answer, so I will post what I developed, although it is a poor solution: You can fill zeros of the tensor with variables that are not used, like z1,z2,z3,.... Now the derivative over this variables is zero, so I got desired result


2

If you want to teach the students to interpret level sets, then it is possible visualize the behavior of a function by manipulating the level. There are various ways to set it up, to cue the students' recognition of the type of extremum, etc. Here's one, whipped up rather quickly. Clear[f, x, y, z]; f = x^3 + x z^2 - 3 x^2 + y^2 + 2 z^2 cpts = {x, y, z} /. ...


2

You can visualise a function of 3 paramters by putting one of them as argument of Manipulate: Manipulate[Plot3D[f /. z -> z1, {x, -3, 3}, {y, -3, 3}], {z1, -3, 3}]


5

another test: f = x^3 + x*z^2 - 3*x^2 + y^2 + 2*z^2; cpts = Solve[Grad[f, {x, y, z}] == 0, {x, y, z}, Reals] {{x -> 0, y -> 0, z -> 0}, {x -> 2, y -> 0, z -> 0}} hesse = D[f, {{x, y, z}, 2}] /. cpts {{{-6, 0, 0}, {0, 2, 0}, {0, 0, 4}}, {{6, 0, 0}, {0, 2, 0}, {0, 0, 8}}} {ev1[l1,l2,l3], ev2[l1,l2,l3]} = Eigenvalues /@ hesse {{-6, 4, ...


4

The simplest method is to wrap xdummy in Quantity, e.g. result = Integrate[Quantity[3, "kN/m"] (1 - x/Quantity[10, "m"]), {x, Quantity[xdummy,"m"], Quantity[10, "m"]}] (* Quantity[(15000 - 3000 xdummy + 150 xdummy^2), ("Kilograms" "Meters")/("Seconds")^2] *) Since xdummy is now effectively unitless, you no longer need to include units in Plot, ...


5

When parameters to a integral are integers, I often fall back to calculating the "general" result, make a table where the parameter is explicitly given integer values, and then feed to FindSequenceFunction. In this case: table = Table[h[x, a, e] - g[x, a, e], {a, 1, 11}]; limits = Limit[#, e -> 0] & /@ table; f = FindSequenceFunction[limits]; ...


2

You could use a definite integral: Integrate[1/beta/(2*z0)/(1 - beta), {z0, 1, z}, Assumptions -> {z > 1, 0 < beta < 1}] (* Log[z]/(2 beta - 2 beta^2) *) Of course, this requires by-hand tuning of the lower limit, but if you want a certain form (i.e. a certain choice of offset), then that's required anyway.


4

The brute force method to arrive at your second solution f[z_] = 1/beta/(2*z)/(1 - beta); cl = CoefficientList[f[z], 1/z]; cl.Integrate[(1/z)^Range[0, Length[cl] - 1], z] Log[z]/(2*(1 - beta)*beta)


3

Perhaps what you are looking for is: A = {{2, -1, 0}, {-1, 2, -1}, {0, -1, 1}}; Integrate[Exp[(-x . A . x)/2], x ∈ FullRegion[3]] 2 Sqrt[2] π^(3/2)


5

Since your integrand does not approach zero but a finite positive number, Limit[Exp[-16.136 (1 - Exp[-0.012*t])], t -> Infinity] (* 9.82255*10^-8 *) the integral over {t, 0, Infinity} does not converge. By the way, the error in the NIntegrate[integrand, {t, 0, 1000}] should be about 10^-7, which seems better than R. In fact, the precision seems ...


4

When you try to NIntegrate your expression, the error messages include: "suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small". Your expression does not have a singularity, its integral is manifestly not zero, it is not oscillatory, so it must be a numerical precision problem. ...


1

This is taking your first modification of the original code and just changing the way f is defined, then using that function inside the module. It seems to work fine for me. Clear[x, y, f]; x = 10;(*Global values have no effect on Module...*) y = 12;(*Global values have no effect on Module...*) f[x_, y_] := E^(-x^2 - y^2) + x y; Manipulate[ Module[ {x, ...


4

Both Module and DynamicModule are shadowing the global variables x and y in the example in which you use them. The demonstration is best written without using either Module or DynamicModule. Manipulate[ ContourPlot[f, {x, -1, 1}, {y, -1, 1}, Contours -> 20, Epilog -> Dynamic[Arrow[{pt, pt + grad /. {x -> pt[[1]], y -> pt[[2]]}}]]], {f, ...



Top 50 recent answers are included