Tag Info

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 ...

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)...

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 ...

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 ...

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,...

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 ...

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,...

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]}*)

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 ...

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