# Tag Info

## Hot answers tagged functions

8

The problem is that the function name f is substituted into Function (&) which is HoldAll. This means f[t] will not be evaluated until the Function is evaluated, such as in the OP's example problem[one][17]. So the trick is to evaluate the integrand before inserting it into the Function. Here is one way. one[x_] := 1 (*the argument*) problem[f_] := ...

6

Here is a partial answer. I believe for Method -> {opts}, opts may be any of the following, and they will have whatever effect they have: InternalInequalitySolverOptions[] InternalReduceOptions[] Internal`NSolveOptions[] (* {"ARSDecision" -> False, "BrownProjection" -> True, "CAD" -> True, "CADAlgebraicCoefficients" -> True, ...

5

The following I hope will assist you: b = 0; blub[x_, p_] := Do[b += ((-1)^k/x^k), {k, 1, p}] blub[1, 100] b or achieving the output: f[x_, p_] := Module[{v = 0}, Do[v += ((-1)^k/x^k), {k, 1, p}]; v] There are many ways to achieve this result, e.g. s[x_, p_] := Sum[(-1)^k/x^k, {k, 1, p}] r[x_, p_] := Total[(-1)^#/x^# & /@ Range[p]]

5

As Guess says, List @@ expr should work. A weirder way: First@Replace[{a || b || c || d}, Or -> List, {2}, Heads -> True] A less weird way: ReplacePart[a || b || c || d, 0 -> List]

4

You can take advantage of how the rules associated with theta are stored behind the scenes by doing Length @ DownValues[theta][[1, 2, 1]] (* 40 *) This isn't robust, however. In the sense that if you have defined beforehand theta[10] = 5, for instance, then it won't find the right DownValue. Alternatively, you can build the checking into the function: ...

3

x is just your starting value for the iteration. The function to apply, and the stopping condition, should both be applied to the current value obtained by the iteration, and are probably best expressed using pure functions: collatz[x_] := NestWhileList[If[Mod[#, 2] == 0, #/2, #*3 + 1] &, x, # != 1 &] collatz[5] (* Out: {5, 16, 8, 4, 2, 1} *) ...

2

Oh well, the solution to my problem is trivial. I simply have to change the definition of my theta function, like this : Angles := {0.0902266, 0.0889051, 0.0869336, 0.0840726, 0.0838656, ...} theta[n_] := Angles[[n]] Then I can use the length command on the Angles : Nangles = Length[Angles];

1

I would like to share more universal method I use in my scientific manipulations involving trigonomeric expressions of real arguments. It does not require any identities used by hand and is mathematically coincise. The idea is to convert trigonometric expression to exponents, which in turn will play the role of monomials. Then you can use very powerful ...

1

If we can pull the function Rescaled outside of myPlot, as Guess who it is suggests, then it can be done in a fairly straightforward way. (If Rescaled is to depend on the arguments to myPlot, perhaps Rescaled can be written so that any needed parameters can be passed to it through the function call instead coded in its definition. Then the following method ...

1

You need anonymous functions. The way it's written currently will replace every instance of x on the right hand side with the number you provide as the argument for collatz. What you want is something which can act on the value produced by NestWhileList on each iteration. So use Clear[collatz] collatz[x_] :=NestWhileList[If[Mod[#, 2] == 0, #/2, #*3 + ...

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