# Tag Info

11

how to reproduce the default hashing behaviour when explicitly choosing a method In[1]:= Hash[1, "Expression"] Out[1]= 6568131406215528669 re-create the default hashing behaviour in different versions? Not possible as far as I know. The one-argument Hash implementation may change between versions. The algorithm has been most ...

9

Welcome in the amazing world of machine precision arithmetic! If you examine the binary representation of both numbers you see the following: RealDigits[1.2, 2] (* {{1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1}, 1} *) RealDigits[.2, 2] ...

7

Some version of the following might be useful: ClearAll[f]; Evaluate@Thread[f[{0, 1, 2}]] := {1, 2, 3}; In this case you could also use Set instead of SetDelayed (:=), because the arguments are "atomic", not patterns. Both = and := hold their first argument unevaluated by default, so that a construct like Thread as I am using it above will only work in ...

5

To directly get the opposite of Alternatives, you could negate each pattern with Except and then negate the Alternatives: also[patts__] := Except[Alternatives @@ Except /@ {patts}] Cases[Range[1, 15, 1/2], _Integer ~also~ _?(# > 10 &)] (* {11, 12, 13, 14, 15} *) Generally some other approach will be simpler, though, as discussed in the comments.

5

Implementing the suggestion of @Guesswhoitis in the comments: if the derivative of the inverse function is given by a function $x'(x)$, then the slope of the tangent line to the graph at $(x_0, y(x_0))$ will be given by $1/x'(x_0)$, and the line through the point $(x_0, y(x_0))$ will be $$y = \frac{x - x_0}{x'(x_0)} + y(x_0).$$ Implementing: a = 112.941; ...

4

This is possibly a duplicate, but the answers given in most cases seem probably more in depth than the OP is looking for, being a newcomer to Mathematica. First you should define f as a function. f[e_] := 7.523190091795795*^-18 (1.329223358440088*^17 - 3.9876700753202693*^18 e + Sqrt[-8.944600854152669*^34 + 1.4311361366644287*^37 e^2]); ...

4

Put this code after your merged cell and evaluate, it should print below all expressions separately. I don't know how solid it is but worth a try: Composition[ Scan[CellPrint[Cell[#, "Input"]] &, #] &, Thread, DeleteCases[#, "\[IndentingNewLine]" | "\n", {2}] &, First, NotebookRead ]@PreviousCell[]

4

What I think you are seeking: z[entropy_List] := beta \[Function] Evaluate[Sum[E^(entropy[[i, 2]] - beta entropy[[i, 1]]), {i, 1, Length[entropy]}]] Now: z[{{9, 1}, {3, 6}, {3, 4}, {4, 0}, {9, 5}}] Function[beta$, E^(1 - 9 beta$) + E^(5 - 9 beta$) + E^(4 - 3 beta$) + E^(6 - 3 beta$) + E^(-4 beta$)]

4

You can do the whole thing numerically by replacing the Heaviside function with a numerical version. For example: nHeaviside[x_] := If[x < 0, 0, 1] will work. You can choose which value it will assume at zero by changing the condition to x <= 0. Alterantively, the function Unitstep does a similar task: nHeaviside2[x_] := UnitStep[x] (Guess who ...

3

Alternatively, we could check to see if the derivative of the inverse is the reciprocal of the derivative of the original function. This will work nicely as long as your functions have neither vertical nor horizontal asymptotes. a = 112.941; b = 18.6588; f[x_] = a x (Cosh[b x^(1/4)/2] - 1)/(b x^(1/4) Sinh[b x^(1/4)/2]); fD[x_] = D[f[x], x]; fInverseD[x_] = ...

3

Sjoerd C. de Vries correctly diagnoses the problem and provides a resolution. An alternative is to work in exact numbers and convert to floating point at the end. Floor[Range[1, 2, 1/10], 2/10] (* Output: {1, 1, 6/5, 6/5, 7/5, 7/5, 8/5, 8/5, 9/5, 9/5, 2} *) N[Floor[Range[1, 2, 1/10], 2/10]] (* Output: {1., 1., 1.2, 1.2, 1.4, 1.4, 1.6, 1.6, 1.8, 1.8, 2.} ...

3

z[entropy_][beta_] := Sum[E^(entropy[[i, 2]] - beta entropy[[i, 1]]), {i, 1, Length[entropy]}]; f = z[{{1, 2}, {3, 4}}]; f /@ Range@5 (* {2 E, 1 + 1/E^2, 1/E^5 + 1/E, 1/E^8 + 1/E^2, 1/E^11 + 1/E^3} *) Avoid using uppercase initials for your own symbols, BTW... This still evaluates the sum, of course. You can achieve the desired goal with your ...

3

As I see it, this behavior does not depend on Hold properties. In fact, PDF[NormalDistribution[]] evaluates to a Function, so you can apply it to arguments using []: Head[PDF[NormalDistribution[]]] (* Function *) On the other hand, (scale PDF[NormalDistribution[]]) does not evaluate to an expression with head Function; in fact, it evaluates to an ...

3

Yes, it is possible to get Mathematica to accept TeXForm input in raw form without quotes, using a method similar to the one described in this answer. Using $PreRead to intercept the input before it is interpreted by Mathematica and then convert it to a string, we can define the latextoma function as a replacement rule with$PreRead = (# /. ...

3

You need to create a pure Function and Map it over the first level of tstlst like so: LinearModelFit[#, x, x] & /@ tstlst Now tstlst can have as many sets as you like without you having to know how many in advance.

3

Your current syntax is trying to Map the function {2} onto each element in the list generated transform2Time[#,10] &/@ {lst2,lst2,lst3} I think this is what you want? ulttst = N@Map[transform2Time[#, 10] &, {lst1, lst2, lst3}, {3}]

3

You For syntax is just wrong. Try r = Range[10] For[i = 1, i <= 9, i++, k = Complement[r, {i, i + 1}]; Print[k]] and avoid capital letters for your symbol names. K has a build-in meaning Information[K] K is a default generic name for a summation index in a symbolic sum.

3

Probably. A = Array[a, {3, 4}]; functionTable = A + A f@# &; functionTable[x]

3

The following antilogarithm function works: antiLog[b_: E, z_] := b^z . Then the base can be changed via b & since the default for Log is E, antiLog[Log[x]] produces x. However, as GuessWhoItIs pointed out in the comments, Power[~] is worth looking into first. Power[~] is actually exactly equivalent to this. Similarly, your own cologarithm function ...

2

Map[(f[# - 1] := #) &, Range[3]]; f[n_] := f[n] = f[n-1] + f[n-2] + f[n-3]; Or alternatively: (f[#-1]:= #)&/@Range[3]; f[n_] := f[n] = f[n-1] + f[n-2] + f[n-3]; Just in one line: f[n_] := If[MemberQ[Range[0, 2], n], n + 1, f[n - 1] + f[n - 2] + f[n - 3]];

2

So I managed to get what I wanted, thanks a lot for your replies, I am pretty new to Mathematica and they helped a great deal. Here is my code: r3 = r1 r4 = r2 T = 0.01 T1 = T T2 = T T3 = T T4 = T GainD[r1_, r2_, r3_, r4_] := (r4*(r1 + r2) + r2*(r3 + r4))/(2*r1*(r3 + r4)) GainDiv[r1_, r2_, r3_, r4_, T1_, T2_, T3_, T4_] := (((((r4/(2 r1 (r3 + r4)) - ((r1 ...

2

I've cleaned up your code a bit and although I kept your variable names you should be warned that it is never a good idea to start your variables with an uppercase character as this may conflict with built-in names (that always start with a capital). r3 = r1; r4 = r2; T = 0.05; T1 = T; T2 = T; T3 = T; T4 = T; GainD[r1_, r2_, r3_, r4_] := (r4*(r1 + r2) + ...

2

For exactly the reasons mentioned in another answer, (scale PDF[NormalDistribution[]])[0.5] doesn't work since the Head of the expression is Times rather than Function. This suggests that we should replace the innards of the Function. Something like scale = 10; f = PDF[NormalDistribution[]] /. (Function[b_] :> Function[scale b]); Then f @ 0.5 results ...

2

If curve is given a non-numeric input the Part specification is not valid and we get: curve["atom"] Part::pkspec1: The expression 1+Floor[100 atom] cannot be used as a part specification. >> Since symbolic analysis may be used by many Mathematica functions, including plotting, you should restrict the input of your curve function to numeric values ...

2

This eliminates the errors and displays some information. I do not know if this is everything you are looking for. functionname[x_] := Module[{}, Needs["Splines"]; Needs["ErrorBarPlots`"]; SetOptions[InputNotebook[], PrintPrecision -> 10]; filelocation = SystemDialogInput["FileOpen"]; rawfiledata = Import[filelocation, "Table"]; ...

2

To be honest, I was quite surprised that Mathematica finds an analytical solution when you just enter the problem in naively: Area[RegionIntersection[Disk[{l, 0}, l], Disk[{0, l}, l], Disk[{l/2, l/2}, l/2]]] On Mathematica 10.1 I don't get the expression with complex terms that Fernando got above, I get the purely real ConditionalExpression[-(1/4) ...

1

Summarizing J.M.'s comments you could use: Do[ f[m] = Table[i/11 + j/m, {i, 5}, {j, 5}], {m, 9, 12} ]; f[11] // MatrixForm \$\left( \begin{array}{ccccc} \frac{2}{11} & \frac{3}{11} & \frac{4}{11} & \frac{5}{11} & \frac{6}{11} \\ \frac{3}{11} & \frac{4}{11} & \frac{5}{11} & \frac{6}{11} & \frac{7}{11} \\ \frac{4}{11} ...

1

Usually one does not need what you ask for. E.g. a pattern for an even integer greater than 10: x_Integer?EvenQ /; x > 10 (_Integer is not strictly necessary here as only integers will pass EvenQ however it should make the pattern a bit more efficient.) But since it is an interesting quesiton here is one idea: matchAll[expr_, form_] := ...

1

The key here is to understand the Apply operator. There we want to apply f at level 1 to the list. Therefore, like Guess who it is suggested we can first apply the function f[x, y, z, ##] where ## gets filled in from your list because of the the @@@. Then Total adds up all the functions. Total[f[x, y, z, ##] & @@@ list]

1

This answer is not concerned with the error messages your code produces, but to suggest your problem could have been avoided by doing more up-front analysis with Mathematica. I will begin by looking at the behavior of your potential function. potential[x_, y_] := 20 (Cos[x]^2 + Cos[y]^2 + Cos[x] Cos[y]) Plot3D[potential[x, y], {x, 0, π/2}, {y, 0, π/2}, ...

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