mm-649 === Subject: Re: Strange Elements in Table > I use a couple IF's which specify the elements in a 2x10 table. When I > look at the table after calculation, I get a 2x11 table. Why??? All the > needed results are in the first 10 columns, the 11th states the If > commands. It is difficult to pinpoint your mistake without the actual code; however, I hope that the following line will help you to understand how to fix the weird result you got. Say we want all the entries of a 2x10 matrix being equal to the product of their indices except when the indices are equal: In[1]:= Table[If[i == j, 0, i*j], {i, 1, 2}, {j, 1, 10}] Out[1]= {{0, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {2, 0, 6, 8, 10, 12, 14, 16, 18, 20}} Hope this helps, /J.M. === Subject: Integration problem I have a periodic function f=1(2pi) (1-e^{-2a})/(1-2e^{-a}cos(x-x0)+e^{-2a}), and I want to calculate the first Fourier coefficient, which corresponds to Integrate[f cos(x),{x,0,2pi}]. The result mathematica tells me is -Cos[x0] Sinh[a]. (The correct result would be Cos[x0] e^{-a}.) If I set x0 to zero, I get the correct result e^{-a}: Simplify[Integrate[(f /. x0 -> 0) Cos[x], {x, 0, 2 [Pi]}], a > 0] e^{-a} The problem is, that for x0=0 both outputs don't match. Can anyone tell me what's wrong? Heidi === Subject: Re: NonlinearFit - Logistic Function-CalcCenter3 expr=a/(1+b*Exp[-c*t]); param={a,b,c}; data1={{-0.06,-0.05},{0.97,-4.2}, {1.99,-9.79},{3,-12.44}, {3.99,-14.57},{5.92,-16.85}, {7.87,-17.27},{11.89,-17.69}, {15.8,-17.74},{19.74,-17.77}, {23.67,-18.19}}; param1=FindFit[data1, expr, param, t] {a -> -17.5291,b -> 8.78665,c -> 1.05894} Plot[expr/.param1, {t,Floor[Min[data1[[All,1]]]], Ceiling[Max[data1[[All,1]]]]}, Frame->True,Axes->False, PlotRange-> {Floor[Min[data1[[All,2]]]]-1, Ceiling[Max[data1[[All,2]]]]+1}, PlotStyle->Blue, Epilog->{Red,AbsolutePointSize[4],Point/@data1}]; data2={{-0.08,0.05},{0.96,-3.19}, {1.93,-6.4},{2.98,-10.32}, {3.97,-11.8},{5.92,-13.98}, {7.88,-14.12},{11.85,-15.34}, {15.79,-14.61},{19.7,-15.43}, {23.67,-15.83}}; For the second data set, specify the Method as either Gradient or QuasiNewton FindFit[data2, expr, param, t, Method->QuasiNewton] {a -> -14.9178,b -> 10.2846,c -> 1.00721} param2=FindFit[data2, expr, param, t, Method->Gradient] {a -> -14.9179,b -> 10.2927,c -> 1.00749} Plot[expr/.param2, {t,Floor[Min[data2[[All,1]]]], Ceiling[Max[data2[[All,1]]]]}, Frame->True, Axes->False, PlotRange-> {Floor[Min[data2[[All,2]]]]-1, Ceiling[Max[data2[[All,2]]]]+1}, PlotStyle->Blue, Epilog->{Red,AbsolutePointSize[4],Point/@data2}]; Bob Hanlon === > Subject: NonlinearFit - Logistic Function-CalcCenter3 > I can fit a logistic function of the form > a/(1 + b*Exp[-c*t]) > to the data points -0.06 -0.05 > 0.97 -4.2 > 1.99 -9.79 > 3 -12.44 > 3.99 -14.57 > 5.92 -16.85 > 7.87 -17.27 > 11.89 -17.69 > 15.8 -17.74 > 19.74 -17.77 > 23.67 -18.19 > I can not fit the same function to the data points > -0.08 0.05 > 0.96 -3.19 > 1.93 -6.4 > 2.98 -10.32 > 3.97 -11.8 > 5.92 -13.98 > 7.88 -14.12 > 11.85 -15.34 > 15.79 -14.61 > 19.7 -15.43 > 23.67 -15.83 > I have tried to do it with Mathematica without success. > I have no problem when I use a progam called CurveExpert. === Subject: Re: solve for a squared variable > Hi everyone, > Why does > Solve[x^2 + y == 1, x^2] > give and error message? How can I solve for x^2? > Ruth Hi Ruth, Since the error message is _General::ivar : x^2 is not a valid variable. More..._ so we must do a change of variable as in the following example: In[1]:= expr = x^2 + y == 1 Out[1]= x^2 + y == 1 In[2]:= Solve[expr /. x^2 -> X, X] Out[2]= {{X -> 1 - y}} In[3]:= x -> Sqrt[X /. %[[1]]] Out[3]= x -> Sqrt[1 - y] In[4]:= expr /. % Out[4]= True /J.M. === Subject: Re: solve for a squared variable > a more elegant procedure, perhaps using patters or whatever. > ----- Original Message ----- === > Subject: [work] Re: solve for a squared variable >>That's because x^2 is not recognized as a symbol. >>let t = x ^ 2, then Solve[t + y == 1, t], you will get the result >>immediately. >>-- >>Li Zhengji >>------------------------------------------------------------- >>If all you have is a hammer, everything is a nail. >>------------------------------------------------------------- Hi Ruth, I guess you have a function in mind, which does this: In[9]:= SolveExpression[x^2 + y == 1, x^2] Out[9]= {{x^2 -> 1 - y}} or even this: In[10]:= SolveExpression[{Tan[t] == b/a, c Cos[t] == a}, a^2 + b^2] Out[10]= {{a^2 + b^2 -> c^2}} ? Well, far from being elegant, the function in this q&d hack does it (almost surely with as many bugs as possible): Needs[Utilities`FilterOptions`]; Clear[SolveExpression]; Options[SolveExpression] ^= UseReduce -> False; (* when to solve for symbols only, use built - in functions *) SolveExpression[eqns_List, Module[{f = If[TrueQ[UseReduce /. {opts}], Reduce, Solve]}, f[eqns, vars, FilterOptions[f, opts]] ]; SolveExpression[eqns_List, vars_List, opt___] := Module[{eq2, va2, t, nosyms, syms, sol, nsvars, usered = TrueQ[UseReduce /. {opt}], varnames = Cases[#1, x_Symbol /; !NumericQ[x], Infinity] & }, nosyms = Complement[vars, syms = varnames[vars]]; t = Table[Unique[], {Length[nosyms]}]; eq2 = Join[eqns, Thread[t == nosyms]]; va2 = Join[syms, t]; nsvars = varnames[nosyms]; sol = If[usered, Reduce[eq2, va2, Backsubstitution -> True, FilterOptions[Reduce, opt]], Solve[eq2, va2, nsvars, FilterOptions[Solve, opt]] ] /. Thread[t -> nosyms]; sol = sol /. (Rule | Equal)[x_, _] | _ == (x_) /; MemberQ[nsvars, x] :> Sequence[]; If[usered, LogicalExpand[sol] /. (a_) == (b_) /; MemberQ[vars, b] :> b == a, Union[sol] ] ]; SolveExpression[e_List, v_, o___] := SolveExpression[e, {v}, o]; SolveExpression[e_, v_List, o___] := SolveExpression[{e}, v, o]; SolveExpression[e_, v_, o___] := SolveExpression[{e}, {v}, o]; -- Peter Pein, Berlin GnuPG Key ID: 0xA34C5A82 http://people.freenet.de/Peter_Berlin/ === Subject: 5.2 Install issues I am having trouble installing Mathematica 5.2 on numerous computers in my department. Most of these had no problem with version 5.1. While the InstallShield Wizard is preparing to install, I get an error that site that said to run isscript8.msi. When I do this, I get an error that the installed doesn't have permission to write to C:Program FilesCommon Filesinstallshielddriver8intel32. When I check file permissions, administrator and system have full control. Is there a solution to this other than formatting and reinstalling the operating system? === Subject: Re: Batch Hello again, I will just copy a simple code below to describe what I am getting. The output in the first notebook is a = a; b = b ; ... What I want is to execute this like a routine, so nb2 should be evaluated before the Print[]. I understand that my program may need some improvement and I will work on that, but I really want to know how to solve the problem I have just described. Maria Cristina ++++++++++++++++++++++++++++++++++ notebooks ++++++++++++++++++++++++ This is the former notebook ; Do[ { c = 3, nb2 = NotebookOpen[tt1.nb], SelectionMove[nb2, All, Notebook], Print[k main , k], SelectionEvaluate[nb2], Print[a = , a], Print[b = , b], Print[ac = , ac], Print[bc = , bc], }, {k, 1, 1}] tt1.nb : Print[k = ,k, nb2] a=k+2 ac=c+2 nb3=NotebookOpen[tt2.nb] SelectionMove[nb3,All,Notebook] SelectionEvaluate[nb3] saida=ToString[k] saida=StringInsert[saida,.tt1.sai,StringLength[saida]+1] NotebookSave[nb2,saida] tt2.nb Print[k = ,k, tt2] b=k+10 bc=c+10 saida=ToString[k] saida=StringInsert[saida,.tt2.sai,StringLength[saida]+1] NotebookSave[nb3,saida] >Hi Maria, >> I thank both Dave and Luc very much, I manage to go one >>step further. >> I have tryed SelectionEvaluation before, but I could not >>identify the notebook properly. Now after you told me I tryed >>with NotebookOpen and it couldn't find the file ($Failed). I >>had to include my working directory in the preferences, and >>now it works. >> I prepare a very simple test, just a notebook calling a >>second nb which calls a third one. It works perfectly, >>opened and executed each notebook without a problem. >> Then I put these callings inside a loop (Do) which would >>just print the loop iteration number. >> Now I come to another problem. All the expressions inside >>the loop are executed and only afterwards the execution of >>the second notebook is performed. Only after that the >>execution of notebook 3 is evaluated. >> This is not what I need. I need that the calling of the >>notebook evalutaion is treated like if it were a routine, >>the program is deviated to the second notebook and after >>evaluating it completely it would come back to the following >>command inside the loop. >> Can anyone give me another advice ? >> >Just to ensure I understand you, you have > nb01 -> nb02 -> nb03 >Which works. However, you need > nb01 -> Do[nb02, {iter}]] -> nb03. >To me (and assuming I've got it right), this sounds like a perfect >application for a package. The minimum you need to do is save the notebook >as a package (Save as special -> package). Commands in the package (it's >difficult to tell exactly what you've done) can then be called as part of a >loop, much as you would call any of the standard packages. >Hope that helps, >Dave. -- Profa Maria Cristina Tavares Faculdade de Engenharia El.8etrica e de Computa.8d.8bo CP 6101 - CEP 13083-970 tel : (19) 3788 3738 fax : (19) 3289 1395 http://www.dsce.fee.unicamp.br/~cristina --------------070400090109010604090601
Hi Maria,I thank both Dave and Luc very much, I manage to go one step further. I have tryed SelectionEvaluation before, but I could not identify the notebook properly. Now after you told me I tryed with NotebookOpen and it couldn't find the file ($Failed). I had to include my working directory in the preferences, and now it works. I prepare a very simple test, just a notebook calling a second nb which calls a third one. It works perfectly, opened and executed each notebook without a problem. Then I put these callings inside a loop (Do) which would just print the loop iteration number. Now I come to another problem. All the expressions inside the loop are executed and only afterwards the execution of the second notebook is performed. Only after that the execution of notebook 3 is evaluated. This is not what I need. I need that the calling of the notebook evalutaion is treated like if it were a routine, the program is deviated to the second notebook and after evaluating it completely it would come back to the following command inside the loop. Can anyone give me another advice ?Just to ensure I understand you, you have nb01 -> nb02 -> nb03 Which works. However, you need nb01 -> Do[nb02, {iter}]] -> nb03. To me (and assuming I've got it right), this sounds like a perfect application for a package. The minimum you need to do is save the notebook as a package (Save as special -> package). Commands in the package (it's difficult to tell exactly what you've done) can then be called as part of a loop, much as you would call any of the standard packages. Hope that helps, Dave.
-- Profa Maria Cristina Tavares Faculdade de Engenharia Elétrica e de Computação CP 6101 - CEP 13083-970 tel : (19) 3788 3738 fax : (19) 3289 1395 http://www.dsce.fee.unicamp .br/~cristina--------------070400090109010604090601-- === Subject: Re: number of digits in n^p Hi George, if you don't want to use DigitCount[] command (eg. Total[DigitCount[n^b]] or Plus@@DigitCount[n^b] ), let's suppose that d is the number of digits in n^b then n^b = a*10^d where 0.1 <= a < 1. Taking the log base 10 of both sides of the equation and solving in d we get d = b*log(n) - log(a) where -1 <= log(a) < 0. Thus, since d is an integer, truncate b*log(n) to an integer and add 1. In Mathematica we can write: In[1]:= f[n_Integer, b_Integer]:= IntegerPart[b Log[10,n]]+1 /; n>0&&b>0 In[2]:= f[67,89] Out[2]= 163 ~ Scout ~ > i wonder if there is a formula, a function, or a method in mathematica to > know the number of digits in n raised to the power of p without > calculating the result, such as 67^89 will give us a number with 163 > digits in it, is there a way to know this result without actually > calculating 67^89 > George === Subject: Re: number of digits in n^p > i wonder if there is a formula, a function, or a method in mathematica to know the number of digits in n raised to the power of p without calculating the result, such as 67^89 will give us a number with 163 digits in it, is there a way to know this result without actually calculating 67^89 > George Hi George, Is this what you are looking for? In[1]:= Plus @@ DigitCount[67^89] Out[1]= 163 /J.M. === Subject: Re: number of digits in n^p Not extremely difficult! The function (Floor[Log[10, x]] + 1) gives the number of digits (before the decimal point) of a positive number. Use the logarithm laws to obtain digitsofpower[n_Integer /; n > 0, p_Integer /; p >= 0] := Floor[p*Log[10,n]]+ 1 E.g. digitsofpower[67, 89] returns 163 Ingolf Dahl Sweden -----Original Message----- === Subject: number of digits in n^p i wonder if there is a formula, a function, or a method in mathematica to know the number of digits in n raised to the power of p without calculating the result, such as 67^89 will give us a number with 163 digits in it, is there a way to know this result without actually calculating 67^89 George __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com === Subject: Re: solve for a squared variable Ruth, Manipulate the equation 'by hand'.... x^2 + y == 1 # - y & /@ % x^2 + y == 1 x^2 == 1 - y David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Hi everyone, Why does Solve[x^2 + y == 1, x^2] give and error message? How can I solve for x^2? Ruth === Subject: Extracting coefficients for sinusoidals Suppose I have a signal signal = Sin[p] and a non-linear function f[x_] := x - x^3/3 then f[signal] = Sin[p] - Sin[p]^3/3 but I don't want this form (with powers of the Sin function), but rather the form with multiples of p. TrigReduce can solve that: signal // f // TrigReduce (9*Sin[p] + Sin[3*p])/12 It's easy to extract the coefficients by visual inspection, 9/12, 1/12 but how can it be done programmaticaly? With a more complex non-linear function, for example a1*x + a1*x^2 + a1*x^3 + a4*x^4 + a5*x^5 using signal // f // TrigReduce // InputForm resulting in (8*a1 + 6*a4 - 8*a1*Cos[2*p] - 8*a4*Cos[2*p] + 2*a4*Cos[4*p] + 28*a1*Sin[p] + 10*a5*Sin[p] - 4*a1*Sin[3*p] - 5*a5*Sin[3*p] + a5*Sin[5*p])/16 visual ispection is no longer simple enough. So how can I get the coefficients, individually or as a list? I'm not sure how I want the Cos and Sin terms to be treated; probably a*Cos[x] should correspond to a*I*Sin[x] when the coefficients are collected. -- Helge Stenstr.9am === Subject: NDSolve acceleration by forcing use of LAPACK functions I'm looking at two Mathematica notebooks. The first is Michael Trott's Mathematics of Tsunamis (http://mathworld.wolfram.com/news/2005-01-14/tsunamis/) http://mathworld.wolfram.com/news/2005-01-14/tsunamis/Tsunami.nb and the second is the Mathematica 5.2 promoting Modeling, Simulating and Analyzing a Tsunami (http://library.wolfram.com/infocenter/Demos/5699/) by Robert Knapp et al (noted animations on Jeff Bryant's pages). The Trott version has an NDSolve[] method options set up that invokes LAPACK's dgetrf() function. The Knapp version does not. Why this is important will now become more clear: The LAPACK function dgetrf() performas an LU matrix factorisation which is dominated by a matrix-matrix multiplication (i.e. Dot[] in Mathematica, also called 'dgemm' in BLAS/LAPACK speak). I work for ClearSpeed in the UK and we have PCI-X co-processor cards that deliver 50GFLOPS of dgemm performance. We wish to show the capability improvement users will see running 'hard' computations. Each of the notebooks is easily scalable. In fact, the Knapp example was designed to demonstrate the impact of this scaling. By increasing the resolution of the computation, the wave propogation is smoother and more faithful. Until now, the cost of this more refined analysis has been presented in minutes turning into hours of compute. Using our card, I have measured a six-fold time-difference for the LAPACK-function (given a large enough problem size) versus a 3.4GHz Xeon. Obviously, it would be more interesting to use the Knapp version since it shows the wave propogation on a per-step basis and has a more interesting sea-bottom. I have thus far failed to comprehend the changes required to make the method options in the Knapp version invoke the LAPACK functions. I would appreciate some helpful pointers. James Irwin ClearSpeed Technology PLC === Subject: calling a C executable from within Mathematica Would someone please help me with the function call within Mathematica? I would like to use a C program within Mathematica. Here is what the program looks like when run under a DOS window. I have included some paratheses where I comment. E:Analysis>simulation5.ext alpha.txt params.txt output.txt 5 rows of data read from alpha file. enter level of temp, volatility, 100 year mean, thermal coefficient 63 .2 3.6 1.2 (entered with spaces) what percent is man-made carbon effect? 12 threshold (%)? 95 how many simulations? 9999 average number of years between 20%, 15%, 10%, and 5% peturburances? 50 25 15 5 (entered with spaces) here is the alpha text file that is located in the same directory as the C executable: 60 .20 61 .23 62 .25 63 .29 64 .33 Here is the params text file that is located in the same directory as the C executable: 1000000.0 0.0 4.58 0.0 2.0 99.0 85.0 10.0 15.0 2.0 50.0 20.0 10.0 20.0 We can change the input/output code in the C code to best suit Mathlink. Steve -- Steven Taracevicz 310.749.6666 cell 702.355.6396 310.388.3265 fax === Subject: The question of equality,... Ok I thought I understood this stuff but maybe not,... If I wanted to check for bit-for-bit equality of two arbitrary precision numbers (without regard to how many of those digits are meaningful) like the way it would be done using the == operator in C, then correct? For == the 5.1 Appendix A says: Approximate numbers are considered equal if they differ in at most their last eight binary digits (roughly their last two decimal digits). SameQ requires exact correspondence between expressions, except that it considers Real numbers equal if their difference is less than the uncertainty of either of them So what can I use then? Any and all help is much appreciated. Terry === Subject: Re: Complete solution to a modular System of equations > In coding theory one is intersted to find the dual code of a given > code. To do this one has to solve a modular linear equation such as: > eq = {a + b + d == 0, a + c + d == 0, b + c + d == 0} > lhs = {{1, 1, 0, 1}, {1, 0, 1, 1}, {0, 1, 1, 1}}; rhs = {0, 0, 0}; > LinearSolve[lhs,{0,0,0},Modulus->2] > Out[52]= > {0,0,0,0} > as you see it returns only one solution. How can I find all solutions. > The number of solutions is a power of 2. For about example there is > exacly one more solution which is > {1,1,1,0}. > Is there any function in Mathematica to do this? or I should start > writing my own code? > chekad You can get a full set of generators to the null space using (no surprise here) NullSpace. In[11]:= NullSpace[lhs, Modulus->2] Out[11]= {{1, 1, 1, 0}} If your linear system is inhomogeneous you can get a particular solution using LinearSolve. You can then form all possible solutions by adding all possible null vectors, which in turn is done by adding all possible linear combinations of null space basis vectors. I would not try this over fields of large (or very small) characteristic. Daniel Lichtblau Wolfram Research === Subject: Re: Complete solution to a modular System of equations > In coding theory one is intersted to find the dual code of a given > code. To do this one has to solve a modular linear equation such as: > eq = {a + b + d == 0, a + c + d == 0, b + c + d == 0} > lhs = {{1, 1, 0, 1}, {1, 0, 1, 1}, {0, 1, 1, 1}}; rhs = {0, 0, 0}; > LinearSolve[lhs,{0,0,0},Modulus->2] > Out[52]= > {0,0,0,0} > as you see it returns only one solution. How can I find all solutions. > The number of solutions is a power of 2. For about example there is > exacly one more solution which is > {1,1,1,0}. > Is there any function in Mathematica to do this? or I should start > writing my own code? Use Reduce: In[11]:= Reduce[{Mod[lhs . {a, b, c, d} - rhs, 2] == 0, 0 <= a < 2, 0 <= b < 2, 0 <= c < 2, 0 <= d < 2}, Integers] Out[11]//OutputForm= (a == 0 && b == 0 && c == 0 && d == 0) || (a == 1 && b == 1 && c == 1 && d == 0) > chekad Carl Woll Wolfram Research === Subject: Re: Complete solution to a modular System of equations > In coding theory one is intersted to find the dual code of a given > code. To do this one has to solve a modular linear equation such as: > eq = {a + b + d == 0, a + c + d == 0, b + c + d == 0} > lhs = {{1, 1, 0, 1}, {1, 0, 1, 1}, {0, 1, 1, 1}}; rhs = {0, 0, 0}; > LinearSolve[lhs,{0,0,0},Modulus->2] > Out[52]= > {0,0,0,0} > as you see it returns only one solution. How can I find all solutions. > The number of solutions is a power of 2. For about example there is > exacly one more solution which is > {1,1,1,0}. > Is there any function in Mathematica to do this? or I should start > writing my own code? > chekad You can get a full set of generators to the null space using (no surprise here) NullSpace. In[11]:= NullSpace[lhs, Modulus->2] Out[11]= {{1, 1, 1, 0}} If your linear system is inhomogeneous you can get a particular solution using LinearSolve. You can then form all possible solutions by adding all possible null vectors, which in turn is done by adding all possible linear combinations of null space basis vectors. I would not try this over fields of large (or very small) characteristic. Daniel Lichtblau Wolfram Research === Subject: Re: Complete solution to a modular System of equations > In coding theory one is intersted to find the dual code of a given > code. To do this one has to solve a modular linear equation such as: > eq = {a + b + d == 0, a + c + d == 0, b + c + d == 0} > lhs = {{1, 1, 0, 1}, {1, 0, 1, 1}, {0, 1, 1, 1}}; rhs = {0, 0, 0}; > LinearSolve[lhs,{0,0,0},Modulus->2] > Out[52]= > {0,0,0,0} > as you see it returns only one solution. How can I find all solutions. > The number of solutions is a power of 2. For about example there is > exacly one more solution which is > {1,1,1,0}. > Is there any function in Mathematica to do this? or I should start > writing my own code? Use Reduce: In[11]:= Reduce[{Mod[lhs . {a, b, c, d} - rhs, 2] == 0, 0 <= a < 2, 0 <= b < 2, 0 <= c < 2, 0 <= d < 2}, Integers] Out[11]//OutputForm= (a == 0 && b == 0 && c == 0 && d == 0) || (a == 1 && b == 1 && c == 1 && d == 0) > chekad Carl Woll Wolfram Research === Subject: Re: Complete solution to a modular System of equations > In coding theory one is intersted to find the dual code of a given > code. To do this one has to solve a modular linear equation such as: > eq = {a + b + d == 0, a + c + d == 0, b + c + d == 0} > lhs = {{1, 1, 0, 1}, {1, 0, 1, 1}, {0, 1, 1, 1}}; rhs = {0, 0, 0}; > LinearSolve[lhs,{0,0,0},Modulus->2] > Out[52]= > {0,0,0,0} > as you see it returns only one solution. How can I find all solutions. > The number of solutions is a power of 2. For about example there is > exacly one more solution which is > {1,1,1,0}. > Is there any function in Mathematica to do this? or I should start > writing my own code? > chekad eq = {a + b + d == 0, a + c + d == 0, b + c + d == 0}; Reduce[eq, {a, b, c, d}, Modulus -> 2] a == C[1] && b == C[1] && c == C[1] && d == 0 Here C[1] is an arbitrary constant in Z/2, in other words it can be either 0 or 1, hence the two solutions are exactly {0,0,0,0} and {1,1,1,0}. Andrzej Kozlowski === Subject: Re: Complete solution to a modular System of equations > In coding theory one is intersted to find the dual code of a given > code. To do this one has to solve a modular linear equation such as: > eq = {a + b + d == 0, a + c + d == 0, b + c + d == 0} > lhs = {{1, 1, 0, 1}, {1, 0, 1, 1}, {0, 1, 1, 1}}; rhs = {0, 0, 0}; > LinearSolve[lhs,{0,0,0},Modulus->2] > Out[52]= > {0,0,0,0} > as you see it returns only one solution. How can I find all solutions. > The number of solutions is a power of 2. For about example there is > exacly one more solution which is > {1,1,1,0}. > Is there any function in Mathematica to do this? or I should start > writing my own code? > chekad Igor Gachkov's package _Error-correcting codes with Mathematica_ may be of interest. Check http://library.wolfram.com/infocenter/MathSource/5085/ Hope this helps, /J.M. === Subject: Re: Complete solution to a modular System of equations eq={a+b+d==0,a+c+d==0,b+c+d==0}; soln=Reduce[eq,{a,b,c,d},Modulus->2] a == C[1] && b == C[1] && c == C[1] && d == 0 List@@Last/@soln/.{{C[1]->0},{C[1]->1}} {{0, 0, 0, 0}, {1, 1, 1, 0}} Bob Hanlon === > Subject: Complete solution to a modular System of equations > In coding theory one is intersted to find the dual code of a given > code. To do this one has to solve a modular linear equation such as: > eq = {a + b + d == 0, a + c + d == 0, b + c + d == 0} > lhs = {{1, 1, 0, 1}, {1, 0, 1, 1}, {0, 1, 1, 1}}; rhs = {0, 0, 0}; > LinearSolve[lhs,{0,0,0},Modulus->2] > Out[52]= > {0,0,0,0} > as you see it returns only one solution. How can I find all solutions. > The number of solutions is a power of 2. For about example there is > exacly one more solution which is > {1,1,1,0}. > Is there any function in Mathematica to do this? or I should start > writing my own code? > chekad === Subject: NDSolve acceleration by forcing use of LAPACK functions I'm looking at two Mathematica notebooks. The first is Michael Trott's Mathematics of Tsunamis (http://mathworld.wolfram.com/news/2005-01-14/tsunamis/) http://mathworld.wolfram.com/news/2005-01-14/tsunamis/Tsunami.nb and the second is the Mathematica 5.2 promoting Modeling, Simulating and Analyzing a Tsunami (http://library.wolfram.com/infocenter/Demos/5699/) by Robert Knapp et al (noted animations on Jeff Bryant's pages). The Trott version has an NDSolve[] method options set up that invokes LAPACK's dgetrf() function. The Knapp version does not. Why this is important will now become more clear: The LAPACK function dgetrf() performas an LU matrix factorisation which is dominated by a matrix-matrix multiplication (i.e. Dot[] in Mathematica, also called 'dgemm' in BLAS/LAPACK speak). I work for ClearSpeed in the UK and we have PCI-X co-processor cards that deliver 50GFLOPS of dgemm performance. We wish to show the capability improvement users will see running 'hard' computations. Each of the notebooks is easily scalable. In fact, the Knapp example was designed to demonstrate the impact of this scaling. By increasing the resolution of the computation, the wave propogation is smoother and more faithful. Until now, the cost of this more refined analysis has been presented in minutes turning into hours of compute. Using our card, I have measured a six-fold time-difference for the LAPACK-function (given a large enough problem size) versus a 3.4GHz Xeon. Obviously, it would be more interesting to use the Knapp version since it shows the wave propogation on a per-step basis and has a more interesting sea-bottom. I have thus far failed to comprehend the changes required to make the method options in the Knapp version invoke the LAPACK functions. I would appreciate some helpful pointers. James Irwin ClearSpeed Technology PLC === Subject: Re: Mathematica: access serial port? > Is there any way to make a Mathematica program access the serial port? > I need this to link to external electronical device. > Maybe using MathLink (but I don't know programming in C/C++)? A while back I created a package that does this. After reading your message I cleaned it up a little and contributed it to the Mathematica InfoCenter