Tag Info

Hot answers tagged

6

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


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[]


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.


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


1

A For-loop is a poor choice for your calculation in Mathematica. Better, because it's simpler and faster, is sets = Table[Complement[Range[10], {i, i + 1}], {i, 9}]; which has the additional advantage that the results are available for further calculations. To get the results printed out nicely, use Column Column @ sets


1

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]];


1

You are running afoul of the (beneficial) scoping that is applied inside Manipulate constructs by way of DynamicModule (or the low-level equivalent). If you "inject" the expression containing g[1] etc. into the Manipulate before it is evaluated it should work correctly I believe: With[{body = gplot[1] == 0}, Manipulate[ ContourPlot3D[body, {x, -1, 1}, ...



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