New answers tagged

7

It turns out the Olivier function is already built-in, but in a disguised form: With[{n = 3, a = 2}, Table[j! SeriesCoefficient[1/MittagLefflerE[n, x^n]^a, {x, 0, j}], {j, 0, 40}]] {1, 0, 0, -2, 0, 0, 58, 0, 0, -6218, 0, 0, 1630330, 0, 0, -847053482, 0, 0, 766492673914, 0, 0, -1106653345942538, 0, 0, 2392407356983116538, 0, 0, -...


0

The following does what you say you want myVector to do, but I'm not sure that's what you really want, since you're playing with the "Notation`" package. But maybe it is. Function: myVectors[comp_List, names_List] := MapThread[Function[{vec, name}, Set[OverVector[name], vec]], {comp, names}]; Example: myVectors[{{a, b}, {c, d}}, {v1, v2}] (* {{a, b}...


4

This answer shows how to define a new NIntegrate rule that evaluates f in the list of two integrands {f[x],g[f[x]]+h[x]} only once per sampling point. The answer can be also easily modified into an answer of "NIntegrate over a list of functions". The definition of the NIntegrate rule LessEvaluationsRule given below is also aimed to be didactic and ...


4

First, NIntegrate[f1[x], {x, xmin, xmax}] usually proceeds by constructing an Experimental`NumericalFunction from the expression for f1[x]. This will circumvent an attempt to memoize f1 in the OP's manner, f1[x_] := f1[x] =.... One can prevent this by memoizing the function with ?NumericQ checks via f2[x_?NumericQ] := f2[x] = .... One thing to consider is ...


-1

Testing my comment does indicate that one can cut the number of evaluations of f[] in half easily. f[x_, y_, z_] := Module[{}, totCalls++; Exp[Sin[x]] + Cos[y + z] ] totCalls = 0; NIntegrate[ {f[x, y, z], Sqrt[f[x, y, z]] + x}, {x, 0, 10}, {y, 0, 10}, {z, 0, 10}, Method -> {"LocalAdaptive", "SymbolicProcessing" -> 0}, ...


3

I got around to actually evaluating your code and I realized that g is not remembering its values; DownValues[g] only has a length of three. The "solution" is to restrict the function to numeric values, per The difference between "SymbolicProcessing" -> 0 and restricting the function definition to numeric values only, but doing that actually ...


16

There is a difference between SetDelayed (:=) with or without semicolon, but it usually doesn't matter. The semicolon is actually a CompoundExpression which has Null as its last element - that's the one that gets returned. But SetDelayed returns Null, too. So the results returned with or without semicolon are the same. An exception to this statement ...


3

Avoid using capital letters as variables so that they don't conflict with Mathematica's existing definitions/functions (here "N" was part of the problem). There were some erroneous underscores as well, used when referencing a function from another function. rd = 1; n = 5; pb = 1; c[α_, r_, x_] := x^2 - x^2*Hypergeometric2F1[1, 2/ α, 1 + 2/ α, -x^α/(β*r^α)]; ...


3

Do you mean rd = 1; n = 5; pb = 1; c[α_, r_, x_] := x^2 - x^2*Hypergeometric2F1[1, 2/α, 1 + 2/α, -x^α/(β*r^α)]; β = 3.1623; α = 4; p = Integrate[((c[α, r, rd] - c[α, r, r])/(rd^2 - r^2))^(n - 1)*2*n*r*(1 - r^2)^(n - 1), {r, 0, 1}] Integrate[10*r*(1 - 0.08904220055024259*r^2 - Hypergeometric2F1[1/2, 1, 3/2, -(0.31622553204945764/r^4)])^4, {r, 0,...


4

To understand grouping and precedence, use HoldForm and PrecedenceForm. I'll insert a screenshot to make the output clearer: It is useful to know that // has even lower precedence than & and can save you some parentheses. You probably meant: ({#[[1]], #[[3]]} &) /@ ({#[[1]], #[[2]], #[[3]]} &) /@ {{"A", "B", "C"}, {1, 2, 3}} It is useful ...


2

Perhaps this example helps: 3 # & /@ Sin[#] & /@ {x, y, z} (*{Sin[3 x], Sin[3 y], Sin[3 z]}*) vs. 3 # & /@ (Sin[#] & /@ {x, y, z}) (*{3 Sin[x], 3 Sin[y], 3 Sin[z]}*)


3

This is just illustrative. f[z_] := ReIm[z + 1/z] Manipulate[ ParametricPlot[{f[Complex @@ v + r Exp[I t]], ReIm[Complex @@ v + r Exp[I t]]}, {t, 0, 2 Pi}, PlotRange -> {{-5, 5}, {-5, 5}}, Epilog -> {Text[v, {-3, 3}]}, AspectRatio -> Automatic, Frame -> True, PlotLabel -> (Complex @@ v + r Exp[I t])], {{v, {0, 0}}, {-4, -4}, {4,...


0

I am a little uncertain about exactly the behaviour that you hope to achieve. However, if Mathematica complains that something is protected you have the option of Unprotecting it. In this case, it is unlikely you are going to break any fundamental functionality (Unprotect elsewhere at your own risk!) Needs["Notation`"] Symbolize[ParsedBoxWrapper[...


8

PlusMinus formats nicely, but it does not have a built-in meaning. You may work around that: h = 0.08; t = 0.13; Plot[ Evaluate[ Sqrt[(1/4) + (1/64 h^2) - x^2] - (1/8 h) + {-1, 1} ((3/8) t (1 - 2 x) Sqrt[1 - (2 x)^2]) ], {x, -.5, .5} ] If need be, you could also define your own meaning for PlusMinus: Clear[PlusMinus] PlusMinus[a__] := {-1, 1} (a)...


1

After reading this and this answer, I noticed that the debugger is also useful for identifying the error source in this case. You just need to: Go to Evaluation and check on Debugger. Check on Break at Messages and click the Show Stack button (alternatively you can click the button after running the erroneous code) in the newly opened panel. Run the ...



Top 50 recent answers are included