# Tag Info

6

There is a way to get Mathematica to calculate the equation of a transformed cylinder, which can then be used to calculate the volume. First, since you're translating the cylinder, too, I rewrote your transformation to include the translation. We can also define inequalities to define the cylinder. xform[x_, y_, z_, a_, b_] := RotationTransform[a Pi/2, ...

5

Observation: First of all I think it is always a useful trick to plot your problematic integrand if possible. It gives us often the clue in case NIntegrate complained about the particular integrand. If we can track down the issue we can often come up with a remedy. Given the following input if one sweeps over the rDet we get the following plots. Given your ...

4

The problem with WhenEvent has to do with the OP's DE. For an event to be detected, there has to be a point at which the condition is crossed, that is, changes from False for t < t0 to True for t > t0. NDSolve then applies a root-finding algorithm to approximate the value of t0 at which the event occurs. In your DE, the solution p1[t] theoretically ...

4

bn[a_, T_, f_] := 2/T Integrate[f Sin[(2 π n)/T t], {t, a, T + a}, Assumptions -> T ∈ Reals] bn[0, L, Piecewise[{{0, 0 < t < L/3}, {w, L/3 < t < 2 L/3}, {0, 2 L/3 < t < L}}]]

3

You could try specifying the event differently (this will trigger when the absolute difference between p1 and p2 is smaller than some value): Ad1=10/1000^2; Ad2=1.5*1000^(-2); Ad3=1.5*1000^(-2); Cd1=0.67; Cd2=0.67; Cd3=0.67; V1=10/1000; V2=10/1000; Rho=875; beta=1000*10^6; ps=100*10^5; Q1=Ad1*Cd1*Sqrt[(2/Rho)*(ps-p1[t])]; ...

3

2 problems: You were comparing, in the WhenEvent, solution, which had complex value at that t, to real numbers. I used Abs. If this does not work for you, you can use Re, but can't compare complex number to real number using >. Second, your system is stiff, need to use StiffnessSwitching to help NDSolve. d1 = 10/1000^2; Ad1 = 10/1000^2; Ad2 = ...

2

This is not the answer to your problem, but perhaps this can help you find a solution to your plotting problem. I would start with defining the equations in terms of the parameters s and m: eq1[m_, s_] = f'''[y] + f[y] f''[y] - m f'[y] - f'[y]^2 - s (f'[y] + y/2 f''[y]) == 0; eq2[m_, s_] = g''[y] - (s/2(3 g[y] + y g'[y]) + 2 g[y] f'[y] - g'[y] f[y]) + ...

2

Define your scalar product of the h polynomials: p[h[n_], h[m_]] := 16 Pi S Sum[Binomial[8 S + 2, k] (8 S + 1 - n - m - k), {k, 0, 8 S - n - m}] / (2^(8 S + 1) (n + m + 2) (n + m + 1) Binomial[8 S + 2, 8 S - n - m]) Add these properties: p[c_ pol1_h, pol2_] := c p[pol1, pol2] p[pol1_, c_ pol2_h] := c p[pol1, pol2] p[sum_Plus, pol_] := p[#, pol] & /@ ...

2

The problem has to do with the sample points used to contruct the plot, and not with NDSolve. Mathematica automatically subdivides segments when the angle is greater than some limit, but it will do so only MaxRecursion times. One can increase PlotPoints to increase the number of initial sample points and increase MaxRecursion to let Mathematica subdivide ...

2

To solve for $y(t)$ and $y'(t)$ you simply add $y'(t)$ for the list of the dependent functions you want to solve for. m = 1; g = 9.82; sol = Flatten@ NDSolve[{y''[t] == -m g - 0.3 y'[t], y'[0] == 10, y[0] == 0, WhenEvent[y[t] < 0, tmax = t; "StopIntegration"]}, {y[t],y'[t]}, {t, 0, 3}]; Plot[{y[t] /. sol, y'[t] /. sol}, {t, 0, tmax}]

2

Here is another way to solve this issue. I know, it is written everywhere, but this is a common mistake to think that the orifice equation is Cd * Ad * Sqrt[ 2/Rho * ( ps - p1[t] ) ] and could give complex results ! There is no physics going imaginary in the real world. The equation is just wrong. When the pressure reverse, the flow reverse, at least. ...

1

Use a numerical derivative: Clear[band, en, w, fermi, k, T, S, a] << NumericalCalculus k = 86*10^-6; T = 4000; band[en_, w_] := 10000 Exp[-en^2/2 w^2]; fermi[en_, ef_] := 1/(Exp[(en - ef)/(k T)] + 1); S[ef_?NumericQ] := -k NIntegrate[(band[en, w] fermi[en, ef] Log[fermi[en, ef]]) /. w -> 1, {en, -Infinity, Infinity}] ...

1

I've made a number of changes to your code which may speed things up, but I honestly can't say with certainty. Rather than enumerating the changes, I'll just list the code here: ClearAll["Global*"]; integrand[k_?NumericQ, P0_?NumericQ, P1_?NumericQ, rho_?NumericQ, l_?NumericQ] := Module[{x, h}, x = P1*l + P0*(1. - l) - rho; h = HankelH2[0, ...

1

Ok, so this is my attempt at a short discussion and solution (after getting a little bit wiser). Due to these equations being stiff (Wikipedia) as pointed out by @Nasser, certain numerical methods have difficulty at tracking the solution, and thus, approximations of the orifice equations yield complex solutions at some point when p1[t]>ps and/or ...

1

This is the approach I usually use in this situation: f[(a_)?NumericQ, (x_)?NumericQ] := NIntegrate[a*x*k, {k, 0, 1}]; data = {{0, 0}, {0.2, 0.1}, {0.4, 0.2}}; param = FindFit[data, {f[a, x], 2 > a > 1}, a, x] The ?NumericQ predicate will prevent evaluation of f until it gets numerical values, since NIntegrate cannot work with symbolic integrands. ...

1

After correcting some syntax errors and setting consistent boundary conditions: ClearAll["Global`*"]; e = 0.1; pdeset = {Derivative[1, 0][U][t, x] == Derivative[0, 2][U][t, x], Derivative[1, 0][T][t, x] == Derivative[0, 2][T][t, x] + e Derivative[0, 1][U][t, x]^2} ics = {U[0, x] == 0, T[0, x] == 0}; bcs = {U[t, 0] == Sin[t], T[t, 0] == 0, ...

1

Since there is some concern about what the interval of integration should be, why not use a general procedure like this to create all the integrals you need? bIntegrate[f_, {x_, a_, b_}, dx_] := Block[{x0, n}, n = Floor[(b - a)/dx]; x0 = Ceiling[a/dx] dx; Table[Integrate[f, {x, x0 + k dx, x0 + (k + 1) dx}], {k, 0, n - 1}] ] It will split ...

1

The following does work in principle but gives a lot of warnings and I don't think you should trust the numbers it gives, although they roughly seem to reproduce the first plot (which is the only I checked but don't know the m it was produced with). I have tried to keep this simple but robust and try to show some techniques that I found helpful in the past. ...

1

I looked at 5 cases. Conclusion at bottom. ClearAll[x, a, b]; pdf = PDF[NormalDistribution[14, 3.7], x] a0 = pdf[[1]] b0 = pdf[[2, 2, 1]] Case 1 int1 = Integrate[ a Exp[b (-14 + x)^2], x] int1 /. {a -> a0, b -> b0} Simplify[(int1 /. x -> Infinity) - (int1 /. x -> 15)] Case 2 int2 = Integrate[ a Exp[b (-14 + x)^2], ...

1

This is just the working out of the full details of the approach suggested by Michael E2 in his comment of ybelukon's answer. b[i_, j_] := Evaluate @ With[{ f = ((Integrate[(x - i)^i x^j, x] /. Times[coeff_, hyper_Hypergeometric2F1] :> Simplify[coeff, i ∈ Integers && x > i] hyper) /. x ...

1

One can calculate this integral analytically Integrate[(x - i)^i x^j, {x, -5, 5}, Assumptions -> {(i | j) ∈ Integers, j > 0}] ConditionalExpression[(1/(1 + j)) 5^(1 + j) (-i)^i (Hypergeometric2F1[-i, 1 + j, 2 + j, 5/i] + Hypergeometric2F1[-i, 1 + j, 2 + j, -(5/i)] (Cos[j π] + I Sin[j π])), i < -5] Mathematica returns the result for i < ...

1

This is a perfect use case for the (new as of version 9) NDSolveValue function, which can return pretty complicated expressions based on the dependent variables in a system of numerically integrated differential equations. The following, for example, will plot both y and y'. With[{value = NDSolveValue[{y''[t] == -m g - 0.3 y'[t], y'[0] == 10, y[0] == ...

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