mm-729 === Subject: Re: Why this function does not return a single value If You run the code from my previous post You will see how my data looks like because I adjusted the parameters in the lists a, b, [Delta]L and [Delta]G so that it represents my data quite well. However I want to use NonlinearFit (or FindFit) to find the values of those parameters which best represent my data. Marek > Glad to help. >>Let me explain what I want to do (probably it was not entirely >>clear from my original post). I want to fit a sum of 15 Voight >>functions to a dataset. Initially I thought that by making all the >>parameters as an array I would be able to use Sum function so that >>a[i], b[i] and c[i] would refer to the parameters of i-th peak in >>the sum. However I could not get this to work. (see my original >>post). Following Paul's suggestions I did the following >>I defined the Voigt function >>Voigt[x_, (a_)?NumericQ, (b_)?NumericQ, ([Delta]L_)?NumericQ, >>([Delta]G_)?NumericQ] := >>(a*(2.*Log[2.]*[Delta]L)*NIntegrate[1/(E^t^2*(((Sqrt[Log[2.]]*[ >>Delta]L)/[Delta]G)^2 + ((Sqrt[4.*Log[2.]]*(x - b))/[Delta]G - >>t)^2)), {t, -Infinity, Infinity}])/(Pi^(3/2)*[Delta]G) >>then I defined lists of parameters >>a = {6224., 2122., 1936., 4261., 7275., 19059., 5057., 3209., >>3586., 3792., >>6182., 1993., 1615., 737., 3114.}; >>b = {5.49, 9.87, 11.17, 13.91, 14.83, 16.92, 17.91, 19.44, 21.91, >>22.8, 23.9, 26.0, 29.75, 30.97, 33.99}; [Delta]L = {0.5, 0.5, 0.5, >>0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5}; >>[Delta]G = {0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, >>0.5, 0.5, 0.5, 0.5}; >>Then I defined another function for plotting purposes like so: >>Fu[x_] := Plus @@ Thread[Voigt[x, a, b, [Delta]L, [Delta]G]] >>And that allows me to plot what I want >>Plot[Fu[x] + 4680.*Exp[(-Log[2.])*((x - 27.4)^2/15^2)] + >>6569*Exp[-x/2.57], {x, 0, 40}, ImageSize -> {600, 400}, PlotRange >>-> All] >>But I have no idea how to do the NonlinearFit with that function. >>Any help would be greatly appreciated > It still isn't clear to me what it is you want to do. Your code defines > parameters for 15 instances of your function which you sum. You say you > are trying to fit this sum to a data set using NonlinearFit. But you don't > really explain what you mean by fitting this sum to a data set. What does > your data set look like? What unknown parameters are you trying to > esitmate? > As an aside, I will mentiion the functionality of NonlinearFit is fully > contained in the built in function FindFit. I suspect (but haven't > verified) FindFit will be faster than NonlinearFit. Also, FindFit has a > bit more flexibility in that it provides for a mechanism to monitor > convergence and allows for different norms. > -- > To reply via email subtract one hundred and four === Subject: Re: Options in user-defined functions... try this code: Options[func]={option1->False,option2->True}; func[x1_,x2_,optns___]:=Block[{someInternalVariables,o1Flag,o2Flag}, o1Flag=option1/.{optns}/.Options[func]; o2Flag=... ] Manuel > Hi to all. > I've a little problem with a function. I've defined it in this way: > fun[x_,op1_:1,op2_:2,op3_:3]:= > Module[{....},f1[x,op1],f2[x,op2],f3[x,op3]] > So, when I use it, ops have their default values. > It works, but I'd like to use option; this why, if I want to change only > op3, I must to write every argument when I call the function, while I'd > like to write something like this: > fun[x,op3->4] > how can I do it? > Daniele === Subject: Re: plots with variation of arbitrary constant Plot[Evaluate[Table[Sin[x] + c, {c, 10}]], {x, 0, Pi}, PlotStyle -> Table[Hue[c/10], {c, 10}]]; Bob Hanlon === > Subject: plots with variation of arbitrary constant > How to show 2D plots for chosen range of a constant? > Show[Plot[Sin[x]+ c,{x,0,Pi}],{c,1,10,1}] does not work. === Subject: Re: plots with variation of arbitrary constant Hi Narasimham , > How to show 2D plots for chosen range of a constant? > Show[Plot[Sin[x]+ c,{x,0,Pi}],{c,1,10,1}] does not work. No, but Plot[Sin[x] + #, {x, 0, Pi}, PlotRange -> {1, 12}, PlotLabel -> ToString[#]] & /@ Range[10]; SelectionMove[EvaluationNotebook[], All, GeneratedCell]; FrontEndTokenExecute[OpenCloseGroup] FrontEndTokenExecute[SelectionAnimate] Does. There are many other solutions. Dave. === Subject: Re: operators for relations in sets > I'm having some difficulty understanding the behaviour of the > operators > for relations in sets in Mathematica. For instance, > TrueQ[{1}[SubsetEqual]{1}] > returns > False > I'm not getting what's going on here... First of all, [SubsetEqual] is not defined in Mathematica. You can define your own function SubsetEqual as: SubsetEqual[A_List, B_List] := Intersection[A, B] == A so that SubsetEqual[{1},{1,2}] True etc. If you really want with the help of the Notation package you can make the infix form A[SubsetEqual]B equivalent to Subsetequal[A,B] (although i would not bother). As for TrueQ, it serves a completely different purpose. Note that TrueQ always gives False whenever something is not explicitly true, for example TrueQ[Sin[x]^2+Cos[x]^2==1] False although TrueQ[Simplify[Sin[x]^2+Cos[x]^2==1]] True TrueQ has its uses but your example is not one of them!. Andrzej Kozlowski === Subject: Re: Proposal to get Stephen to Improve the lot ofSpace Shuttle Programmers Hi John, > Can I get a conversation started about this topic? > Will a tool to convert FORTRAN to mathematica code be useful? > The purpose would be to verify the integrity of the FORTRAN > code and then possibly recompile it to c++, using > Mathematica's features. > The goal would be to take all that FORTRAN code out there and > give Mathematicians more option when designing code for > embedded systems. I'd suggest that a tool going the other way (ie Mathematica to F95, F2K or some variety of c++) would be far more useful than a tool to convert Fortran code to Mathematica. In this way, we might combine rapid application development (Mathematica) with vastly superior execution speed (pretty much any compiled language). As for Mathematica output to compiled languages (as opposed to interpreted), there is already MathCore's very expensive addons viz. MathC++ and MathF90 (http://www.mathcore.com/index.shtml). Secondly, there is MathLink, which enables one to link _existing_ code running as an executable to Mathematica. I'd like to suggest that perhaps with version 6, WRI might consider revising their Fortran output so that it is at least free-format and takes advantage of even F90's more modern features than their current F77 output. In summary, no, I don't think your tool would be particularly useful. Dave. === Subject: Re: operators for relations in sets > I'm having some difficulty understanding the behaviour of the operators > for relations in sets in Mathematica. For instance, > TrueQ[{1}[SubsetEqual]{1}] > returns > False > I'm not getting what's going on here... A look at the documentation shows that [SubsetEqual] is interpreted as an Infix set relation operator. Also, by default, x [SubsetEqual] y is interpreted as SubsetEqual[x, y]. However, also from the documentation, there is no built-in interpretation rule for SubsetEqual. You can add your own. Once you do, expressions like {1}[SubsetEqual]{1}] will be interpreted using this rule. Paul _______________________________________________________________________ Paul Abbott Phone: 61 8 6488 2734 School of Physics, M013 Fax: +61 8 6488 1014 The University of Western Australia (CRICOS Provider No 00126G) AUSTRALIA http://physics.uwa.edu.au/~paul === Subject: Re: operators for relations in sets SubsetEqual is an 'operator' that has no predefined definition. But you could make a definition, something like the following: SubsetEqual[{1}, {1}] True SubsetEqual[{1, 2, 5, 7}, {5, 7, 7, 2, 1}] True SubsetEqual[{1, 2, 3}, {2, 4, 7}] False David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ I'm having some difficulty understanding the behaviour of the operators for relations in sets in Mathematica. For instance, TrueQ[{1}[SubsetEqual]{1}] returns False I'm not getting what's going on here... h === Subject: Re: Forums opened on Mathematica-users.org Has anyone looked at the Mathematica NotebookML structure? I imagine that it is a good XML Schema (or DTD) that can be well integrated with other XML data. I think there is already an associated stylesheet for displaying NotebookML in a browser (not sure tho - the stylesheet should transform NotebookML into XHTML + MathML). Anyway, a user wanting to specify Mathematica content could (as a first implementation), paste XHTML+NotebookML into the website editing window. The displayed output on the website could be the same notebook, but with all cells executed. > Above the wiki implementation in webMathematica, I added a forum > implementation (also in webMathematica and leveraging also the same wiki > syntax) > You can see a picture of what the forum can look like at: > http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=M > athematica_Forums > Or you can just start posting in the forums: > http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=S > pecial:Forum_Index > I will continue to add functionality this week, like email subscriptions > to forums, personality and display options to match what kind by found > in similar forums based on PunBB like http://forums.punbb.org/ > Luc -- Chris Chiasson http://chrischiasson.com/ 1 (810) 265-3161 === Subject: Re: Forums opened on Mathematica-users.org Luc, Mediawiki is tough to beat for a standalone wiki, but now that you are adding more stuff: Have you looked at Drupal? I just installed it on a web server yesterday. Like Wikipedia, it is a set of PHP scripts that accesses a database. It is probably the most popular open source content management system behind Mambo. It does have a wiki module available, but that would probably be unecessary given its node architecture. Users can submit pages, they can have blogs, they can collaborate on books, they can post to forums, etc... There is even a module that will submit a site index to Google when the site is updated (or that can just be used to create the site index and serve it when web spiders show up). Drupal: http://drupal.org/ Google Sitemap http://drupal.org/project/gsitemap Wiki-related: http://drupal.org/project/wiki http://drupal.org/project/interwiki http://drupal.org/project/freelinking > Above the wiki implementation in webMathematica, I added a forum > implementation (also in webMathematica and leveraging also the same wiki > syntax) > You can see a picture of what the forum can look like at: > http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=M > athematica_Forums > Or you can just start posting in the forums: > http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=S > pecial:Forum_Index > I will continue to add functionality this week, like email subscriptions > to forums, personality and display options to match what kind by found > in similar forums based on PunBB like http://forums.punbb.org/ > Luc -- Chris Chiasson http://chrischiasson.com/ 1 (810) 265-3161 === Subject: Re: Draw3D ColorFunction->Hue Janwillem, The problem is only that you have to turn off the Lighting in the Draw3DItems statement. Needs[DrawGraphics`DrawingMaster`] fsize = 14; tstyle = {FontFamily -> Helvetica, FontSize -> fsize, FontWeight -> Bold}; muConcrete = 2.3*0.05; LConcrete = 10; FConcrete = 0.14; lConcrete = 10; RnCorrection = 1 - F (L/lambda)Cosh[x/lambda]/Sinh[L/lambda] // FullSimplify f = RnCorrection /. {mu -> muConcrete, L -> LConcrete, F -> FConcrete}; Draw3DItems[ {Draw3D[f, {lambda, 5, 15}, {x, -LConcrete, LConcrete}, ColorFunction -> (Hue[0.75*(1 - #)] &)], {Text[ Correction factor, {5, -10, 0.85}, {-.6, 0}, {0, 1}, TextStyle -> tstyle]}}, Lighting -> False, Axes -> Automatic, AxesLabel -> {Path length (cm), Depth (cm), }, BoxRatios -> {1, 1, 0.7}, TextStyle -> tstyle, ImageSize -> 500]; Or, if you want the lighting on to obtain a little shading you can convert the Hue specifications to SurfaceColor specifications and use NeutralLighting. Draw3DItems[ {Draw3D[f, {lambda, 5, 15}, {x, -LConcrete, LConcrete}, ColorFunction -> (Hue[0.75*(1 - #)] &)] /. Hue[h_] :> SurfaceColor[Hue[h]], {Text[ Correction factor, {5, -10, 0.85}, {-.6, 0}, {0, 1}, TextStyle -> tstyle]}}, NeutralLighting[0.3, 0.5, 0.1], Axes -> Automatic, AxesLabel -> {Path length (cm), Depth (cm), }, BoxRatios -> {1, 1, 0.7}, TextStyle -> tstyle, ImageSize -> 500]; Hope that helps. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ I want to make a 3D surface plot of which the colour changes depending on the z-value over the full hue-range. With just Plot3D this works. However, I want the z-axis legend vertical and therefore thought of using David Park's package using Draw3D and Draw3DItems. This however refuses to take ColorFunction as an option. 1) Is there a solution for this colouring problem? 2) How do I get the z-label to the left of the plot and still have the box along the plot-axes? Janwillem <muConcrete,L->LConcrete,F[Rule]FConcrete}; p3d=Plot3D[f,{lambda,5,15},{x,-LConcrete,LConcrete}, ColorFunction[Rule](Hue[0.75*(1-#)]&), AxesLabel[Rule]{Path length (cm),Depth (cm),Correction factor}, BoxRatios[Rule]{1,1,0.7},TextStyle->tstyle,ImageSize[Rule]500]; pl=Draw3D[f,{lambda,5,15},{x,-LConcrete,LConcrete}]; Draw3DItems[{pl,{Text[Correction factor,{5,-10,0.85},{-.6,0},{0,1}, TextStyle[Rule]tstyle]}},Axes[Rule]Automatic, AxesLabel[Rule]{Path length (cm),Depth (cm),}, BoxRatios[Rule]{1,1,0.7},TextStyle->tstyle,ImageSize[Rule]500] === Subject: Re: plots with variation of arbitrary constant How about... Plot[Table[Sin[x] + c, {c, 1, 10}] // Evaluate, {x, 0, Pi}]; David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ How to show 2D plots for chosen range of a constant? Show[Plot[Sin[x]+ c,{x,0,Pi}],{c,1,10,1}] does not work. === Subject: Re: Re: Hardware question > How long--and how wide :-) > is now available), but I couldn't find a mother board that could take > 3GB of it--a limitation of the bridge chip.) > Also, does even Linux x86-64 allow 8GB without tweaking? I think you need to compile a Linux kernel with BIGMEM support. ('make menuconfig' -> Processor Type and Features -> High Memory Support -> 64GB). But I don't have x86-64 machine here, so this may be just a guess. === Subject: Re: Re: Hardware question Apple's G5 can take and use 8GB. J.87nos > does somebody know, what hardware is best for a huge mathematica > calculation, that needs lots of memory? > I think of minimum 8GB memory and the fastest possible processors > (probably opterons???). > However, it should be a personal computer. > Is it better to run it under Linux or Windows? > Manuel Schmidt >> Really, that is equivalent to the question How long is a piece of >> string. >> One thing that is important is that if you are going to get 8GB of >> memory, you must make sure you install the 64-bit version of >> Windows (or >> whatever) and the 64-bit version of Mathematica - otherwise, most of >> that memory will just sit there idle. >> risk in >> introducing a rational 64-bit architecture and forcing Intel to >> follow >> them - they deserve to get the business! >> Before spending a lot of money, it may be worth getting someone to >> look >> at your code because it is very easy to write Mathematica code that >> works, but is horrendously inefficient. > How long--and how wide :-) > is now available), but I couldn't find a mother board that could take > 3GB of it--a limitation of the bridge chip.) > Also, does even Linux x86-64 allow 8GB without tweaking? > --Ron Bruck ---------------------------------------------- Trying to argue with a politician is like lifting up the head of a corpse. (S. Lem: His Master Voice) === Subject: Batch I need to run a batch in Mathematica, so that I read data from several files and execute the calculations and generate the graphics. Then I read another group of data and perform the same calculation and that goes on until the data finish. I just manage to do this by putting all the calculation in a single cell, inside a Do. My cases are rather large, I am dealing with experimental data and I have to manipulate files with 1,000,000 points. I cannot just read all of them at once and start the calculus. My first go was to separate the calculations in notebooks and one nb called the next one. The first notebook called the following without a problem, but it did not evaluate it. I had to do it manually. And I have around 100 cases to analyse. I really need to automatize the procedure. -- 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 === Subject: Re: Re: smooth eigenvalues and eigenvectors as a function of frequency Hi Once I had this problem in another environment and I used Newton Raphson to identify the eigenvalues. The important thing to avoid switchover was to correctly give the seed. I have used as seed the previous calculated point and that worked. For instance, when dealing with non-transposed transmission line, the former seed should be the eigenvector for ideally transposed line. The following seeds should be calculated as I described above. >Antonio Carlos Siqueira schrieb im Newsbeitrag >>I am posting this message hoping that someone may have a better idea >>than me and point me in some direction to the solution. I have to fit a >>complex based function using a state-space approach and thus smooth >>eigenvectors and eigenfunctions are needed. Using Eigensystem I >>experienced some eigenvector/eigenvalues switchovers (from one >>frequency step to the next). >>I was wondering whether some sort of MapIndexed or some Sort can do the >>trick to switch the eigenvector back. I know that if I can track the >>direction of the eigenvalue.eigenvector dot product I might probably >>identify the switchover. >> >Hi Antonio, >without having looked into all the details of your code (it's not complete >anyway) I believe that your problem is one of identifying corresponding >eigenvectors of two closely related eigenvalue problems: Let A(p) denote a >square matrix whose entries are functions of a parameter p, and let deltap >denote a (small) perturbation of p. Let the two eigenvalue problems be >formulated as >(1) (A(p) - lambda.I) x = 0 >and >(2) (A(p+deltap) - lambda.I) x = 0 >Now assume that (lambda1_1, x1_1) is an eigenvalue/eigenvector pair of (1) >and that you are interested in finding the corresponding pair (lambda2_1, >x2_1) in the set of solutions {(lambda2_k, x2_k), k=1..n} of the perturbed >equation (2). This can be achieved with the help of the modal assurance >criterion (MAC), defined as > MAC(x1, x2) = abs(x1'.x2)^2/((x1'.x1)*(x2'.x2)) >where x' denotes the complex conjugate transpose of x. >The MAC ranges from 0 to 1. The eigenpair of (2) corresponding to >(lambda1_1, x1_1) is the one for which > MAC(x1_1, x2_k) >is closest to 1. >HTH, >Eckhard -- 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 --------------040509060604010109030607 Hi

    Once I had this problem in another environment and I used Newton Raphson to identify the eigenvalues. The important thing to avoid switchover was to correctly give the seed. I have used as seed the previous calculated point and that worked.

    For instance, when dealing with non-transposed transmission line, the former seed should be the eigenvector for ideally transposed line. The following seeds should be calculated as I described above.





Antonio Carlos Siqueira <acsl@dee.ufrj.br> schrieb im 
Newsbeitrag 
  
I am posting this message hoping that someone may have a better idea than me and point me in some direction to the solution. I have to fit a complex based function using a state-space approach and thus smooth eigenvectors and eigenfunctions are needed. Using Eigensystem I experienced some eigenvector/eigenvalues switchovers (from one frequency step to the next). I was wondering whether some sort of MapIndexed or some Sort can do the trick to switch the eigenvector back. I know that if I can track the direction of the eigenvalue.eigenvector dot product I might probably identify the switchover.

Hi Antonio,
without having looked into all the details of your code (it's not complete 
anyway) I believe that your problem is one of identifying corresponding 
eigenvectors of two closely related eigenvalue problems: Let A(p) denote a 
square matrix whose entries are functions of a parameter p, and let deltap 
denote a (small) perturbation of p. Let the two eigenvalue problems be 
formulated as
(1)     (A(p) - lambda.I) x = 0
and
(2)     (A(p+deltap) - lambda.I) x = 0
Now assume that (lambda1_1, x1_1) is an eigenvalue/eigenvector pair of (1) 
and that you are interested in finding the corresponding pair (lambda2_1, 
x2_1) in the set of solutions {(lambda2_k, x2_k), k=1..n} of the perturbed 
equation (2). This can be achieved with the help of the modal assurance 
criterion (MAC), defined as
  MAC(x1, x2) = abs(x1'.x2)^2/((x1'.x1)*(x2'.x2))
where x' denotes the complex conjugate transpose of x.
The MAC ranges from 0 to 1. The eigenpair of (2) corresponding to 
(lambda1_1, x1_1) is the one for which
  MAC(x1_1, x2_k)
is closest to 1.
HTH,
Eckhard
  


-- 
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
--------------040509060604010109030607-- === Subject: Re: Why am I getting this error? > I am attempting to solve a system with 3 pde's and I keep getting this error even though I think all of my equations have independent variables: > NDSolve::dvnoarg: The function v appears with no arguments. > If anyone could find the mistake in my code I would really appreciate it. C,V, and R are the dependent variables, and t (time) and x(distance-does not depend on time) are the independent variables. All other variables are constants. > !((rRHS = (d_r) D[r[t, > x], {x, 2}] + ëÓ ((1 - ((r[t, x] - r_base))/((k_r - > r_base)))) ((r[t, x] - r_base));)[IndentingNewLine] > (vRHS = (d_v) D[v[t, x], {x, 2}] - ì° v[t, x] - > ëá v[t, x] c[t, x]/((ëÒ_1 + v[t, x])) + If[ > q_large < q_min, ëÈ ((q_large - q_min)), 0];)[IndentingNewLine] > ((cRHS = D[c[t, x] v[t, x] D[v[t, x], x], x] + If[v[ > t, x] .89Å´ v_g, ìà v[t, x] c[t, > x] /((ëÒ_2 + > v[t, x])), ìÅ ((v[t, x] - > v_d)) c[t, x]];)([IndentingNewLine]) > )[IndentingNewLine] > (reqn = D[r[t, x], t] == rRHS;)[IndentingNewLine] > (veqn = D[v[t, x], t] == vRHS;)[IndentingNewLine] > (ceqn = D[c[t, x], t] == cRHS;)) > BC1 = Derivative[0, 1][r][t, 0] == 0; > BC2 = Derivative[0, 1][r][t, 1] == 0; > BC3 = Derivative[0, 1][v][t, 0] == 0; > BC4 = Derivative[0, 1][v][t, 1] == 0; > BC5 = c[t, 0] == 1; > BC6 = c[t, 1] v[t, 1] Derivative[0, 1][v][t, 1] == 0; > !((c_init = (c_o) Exp (((-150) x^2)) == c[0, > x];)[IndentingNewLine] > (r_init = ((K_r - > r_base)) Exp (((-100) x^2)) + r_base == r[0, x];) > [IndentingNewLine] > (v_init = ((v_g - v_d))/((2 v_o)) == v[0, x];)) > !((solution = NDSolve[{reqn, veqn, ceqn, q1_i, > q2_i, c_init, v_init, > r_init, BC1, BC2, BC3, BC4, BC5, BC6}, {r[t, x], v[t, > x], c[t, x], q1[t, x], q2[t, x]}, {t, 0, 1}, {x, 0, 1}];)) > Any help is much appreciated. > Katie Hi Katie, By default, Mathematica does not recognized subscripted variables as symbols but as more complex constructions. Say we want to solve the following ODE. Note that we are using two subscripted variables y_0 and y_air. In[1]:= eqn = Derivative[1][y][t] == (-p)*(y[t] - Subscript[y, air]) Out[1]= Derivative[1][y][t] == (-p)*(-Subscript[y, air] + y[t]) Here, everything looks fine. However, when we try to solve the ODE with initial value y{0} == y_0 In[2]:= sols = DSolve[{eqn, y[0] == Subscript[y, 0]}, y, t] DSolve::dvnoarg: The function y appears with no arguments. More... Out[2]= DSolve[{Derivative[1][y][t] == (-p)*(-Subscript[y, air] + y[t]), y[0] == Subscript[y, 0]}, y, t] Mathematica complains about the function y that is supposed to be called with no arguement. In fact, a mixed up in the interpretation of symbols and subscripts occurred. To fix this issue, you must use the *Notation* package and _from the notation palette_ use the function *Symbolize* to transform subscripted names into symbols. See the following example In[3]:= Needs[Utilities`Notation`] In[4]:= Symbolize[NotationBoxTag[(y_air)]] In[5]:= Symbolize[NotationBoxTag[(y_0)]] In[6]:= eqn = Derivative[1][y][t] == (-p)*(y[t] - y[UnderBracket]Subscript[UnderBracket]air) Out[6]= Derivative[1][y][t] == (-p)*(-y[UnderBracket]Subscript[UnderBracket]air + y[t]) In[7]:= sols = DSolve[{eqn, y[0] == y[UnderBracket]Subscript[UnderBracket]0}, y, t] Out[7]= {{y -> Function[{t}, (y[UnderBracket]Subscript[UnderBracket]0 - y[UnderBracket]Subscript[UnderBracket]air + E^(p*t)* y[UnderBracket]Subscript[UnderBracket]air)/E^(p*t)]}} Hope this helps, /J.M. === Subject: Re: Why am I getting this error? > I am attempting to solve a system with 3 pde's and I keep getting this error > even though I think all of my equations have independent variables: > NDSolve::dvnoarg: The function v appears with no arguments. > If anyone could find the mistake in my code I would really appreciate it. > C,V, and R are the dependent variables, and t (time) and x(distance-does not > depend on time) are the independent variables. All other variables are > constants. Some comments: [1] Although your equations are impossible to read due to some mysterious symbols, the equation involving r appears to be completely decoupled from the equations involving c and v -- so solve this one first. [2] You are using the symbols r and v as subscripts as well as using them as the names of functions in the pde's. This could cause problems (unless you symbolize such subscripted symbols using the Notation package). [3] To use NDSolve, all parameters must resolve to numerical values. There are a number of parameters in your equations for which no numerical values are defined or implied. [4] In the NDSolve command, you are solving for functions q1 and q2 -- these are not defined. Since you are at UIUC, I suggest that you attend the upcoming Wolfram Research TechConf . There will be a number of helpful sessions on solving differential equations using Mathematica. In addition, at the Training tab, you will see there are several Wolfram Education Group sessions that are likely to be of interest. Paul > !((rRHS = (d_r) D[r[t, > x], {x, 2}] + ëÓ ((1 - ((r[t, x] - r_base))/((k_r - > r_base)))) ((r[t, x] - r_base));)[IndentingNewLine] > (vRHS = (d_v) D[v[t, x], {x, 2}] - ì° v[t, x] - > ëá v[t, x] c[t, x]/((ëÒ_1 + v[t, x])) + If[ > q_large < q_min, ëÈ ((q_large - q_min)), 0];)[IndentingNewLine] > ((cRHS = D[c[t, x] v[t, x] D[v[t, x], x], x] + If[v[ > t, x] .89Å´ v_g, ìà v[t, x] c[t, > x] /((ëÒ_2 + > v[t, x])), ìÅ ((v[t, x] - > v_d)) c[t, x]];)([IndentingNewLine]) > )[IndentingNewLine] > (reqn = D[r[t, x], t] == rRHS;)[IndentingNewLine] > (veqn = D[v[t, x], t] == vRHS;)[IndentingNewLine] > (ceqn = D[c[t, x], t] == cRHS;)) > BC1 = Derivative[0, 1][r][t, 0] == 0; > BC2 = Derivative[0, 1][r][t, 1] == 0; > BC3 = Derivative[0, 1][v][t, 0] == 0; > BC4 = Derivative[0, 1][v][t, 1] == 0; > BC5 = c[t, 0] == 1; > BC6 = c[t, 1] v[t, 1] Derivative[0, 1][v][t, 1] == 0; > !((c_init = (c_o) Exp (((-150) x^2)) == c[0, > x];)[IndentingNewLine] > (r_init = ((K_r - > r_base)) Exp (((-100) x^2)) + r_base == r[0, x];) > [IndentingNewLine] > (v_init = ((v_g - v_d))/((2 v_o)) == v[0, x];)) > !((solution = NDSolve[{reqn, veqn, ceqn, q1_i, > q2_i, c_init, v_init, > r_init, BC1, BC2, BC3, BC4, BC5, BC6}, {r[t, x], v[t, > x], c[t, x], q1[t, x], q2[t, x]}, {t, 0, 1}, {x, 0, 1}];)) > Any help is much appreciated. > Katie _______________________________________________________________________ Paul Abbott Phone: 61 8 6488 2734 School of Physics, M013 Fax: +61 8 6488 1014 The University of Western Australia (CRICOS Provider No 00126G) AUSTRALIA http://physics.uwa.edu.au/~paul === Subject: Re: Why am I getting this error? Hi Katie, I copied the code you provided and pasted it into Mathematica. It looks like your code contains errors, probably due to converting symbols into text form. So it is impossible to reproduce your error. Yours, Serguei Nemenat === Subject: Re: Timed Notebooks for Student Take-home examinations I'm probably misunderstanding something, so correct me if I'm wrong: the package would reside on the student's computer and it would generate a notebook for the student to complete. At the time the student requests the notebook from your package, you write an encoded string to the notebook itself that basically assigns it a timestamp. Then the student would upload/send you that notebook and you would decode that string? (encoded string + time of upload = time spent) Is that the idea? A student could simply request a notebook from the package twice, say the second request 3 hours later. He would complete the assignment, open the notebook in any text editor and overwrite the encoded string with the new timestamp. I believe the best way to have this sort of thing is by having a system (say a website) where you can keep track of when a file is downloaded and uploaded and *you* keep track of the timestamps. This obviously deviates from your idea of creating a Mathematica package for that, but that's what schools seem to use. Like Chris mentioned, a web Mathematica application seems more appropriate. To prevent/diminish sharing of answers between students, you'd setup a web Mathematica application that required user authentication. Then, you'd be generate problems with different initial values for each student (or groups of students, whatever). Igor > I wonder if anyone has implemented this, if not I will give it a > try. > I'd like to create a template and package for student take home > exams. > The student would need to finish the notebook in a fixed amount of > time. The instructor, who has encoded the package, would be able to > determine how much time the student has used to finish the exam by > decoding a string that is written just before the notebook exits. > It would need to be moderately safe from cheating. > Advice would be most welcome. > W. Craig Carter > Lord Foundation Professor of Materials Science and Engineering > MIT, Dept. of Materials Science and Engineering 13-5018 77 Massachusetts Ave, Cambridge, MA 02139-4307 USA > 617-253-6048 ccarter@mit.edu http://pruffle.mit.edu/~ccarter http://pruffle.mit.edu/~ccarter/FAQS/ http://pruffle.mit.edu/~ccarter/I_do_not_use_microsoft.html -- Igor C. Antonio Wolfram Research, Inc. http://www.wolfram.com To email me personally, remove the dash. === Subject: Re: Timed Notebooks for Student Take-home examinations Interesting idea. Chris Chiasson commented on the security issue; I am not familiar with the capabilities of webMathematica, but if you implemented the exams via it on your server, username and password required, serving one problem at a time and logging logon and logoff times, that would seem to solve that issue. (So long as clever MIT students could not hack your server's logs!) I suppose that you could also serve them one problem at a time in notebooks (or text), again logging times, and then they work them in their local copy of Mathematica and return the notebook, obviating the need for webMathematica. Don't you still have the problem of students sharing solutions? For all you know, they could all be sitting in the same room working through them and then log on individually afterward. No matter what, there seems to be issues of trust, pride and wanting to learn thru the exam rather than just pass it. An in-person final covering the same material may still be necessary to insure they understand things. Kris Carlson kwc1564@gmail.com -----Original Message----- === Subject: Timed Notebooks for Student Take-home examinations It seems like you would need some form of DRM. What if a student copies the file before opening it? The student could then solve the notebook copy and transfer his or her answers to the original notebook. > I wonder if anyone has implemented this, if not I will give it a try. > I'd like to create a template and package for student take home exams. > The student would need to finish the notebook in a fixed amount of > time. The instructor, who has encoded the package, would be able to > determine how much time the student has used to finish the exam by > decoding a string that is written just before the notebook exits. > It would need to be moderately safe from cheating. > Advice would be most welcome. > W. Craig Carter > Lord Foundation Professor of Materials Science and Engineering MIT, > Dept. of Materials Science and Engineering 13-5018 77 Massachusetts > Ave, Cambridge, MA 02139-4307 USA 617-253-6048 ccarter@mit.edu > http://pruffle.mit.edu/~ccarter http://pruffle.mit.edu/~ccarter/FAQS/ > http://pruffle.mit.edu/~ccarter/I_do_not_use_microsoft.html -- Chris Chiasson http://chrischiasson.com/ 1 (810) 265-3161 === Subject: Re: Generate a palette with a FrontEnd Token Tom De Vries >I was wondering if it was possible to generate a palette with a >FrontEnd token command. You mean using only the FrontEnd? Below I give four examples of buttons that do not require the kernel. (I«m running Mathematica 5.1.) ---------------------------------- Example 1: Opening the BasicTypesetting palette: ButtonBox[Test1, ButtonFunction:>NotebookOpen[BasicTypesetting.nb], ButtonEvaluator->None, Active->True]//DisplayForm ---------------------------------- Example 2: Now using FrontEndExecute: ButtonBox[Test2, ButtonFunction:> FrontEndExecute[{FrontEnd`NotebookOpen[BasicTypesetting.nb]}], ButtonEvaluator->None, Active->True]//DisplayForm ---------------------------------- Example 3: Like the previous, except that we drop FrontEnd`: ButtonBox[Test3, ButtonFunction:> FrontEndExecute[{NotebookOpen[BasicTypesetting.nb]}], ButtonEvaluator->None, Active->True]//DisplayForm If I remember correctly, this does not work in versions 4.0 and 4.1. ---------------------------------- Example 4: A simple horizontal palette with two buttons: ButtonBox[Test4, ButtonFunction:> NotebookPut@ Notebook[{Cell[BoxData[GridBox[{{ButtonBox[1],ButtonBox[2]}}]]]}, WindowSize->{Fit,Fit},WindowElements->{}, ShowCellBracket->False,WindowFrame->Palette, WindowClickSelect->False, CellMargins->{{0,0},{0,0}}, WindowFrameElements->CloseBox, GridBoxOptions->{ColumnSpacings->0,RowSpacings->0}], ButtonEvaluator->None, Active->True]//DisplayForm ---------------------------------- Carlos C.8esar de Ara.9cjo Gregos & Troianos Educacional www.gregosetroianos.mat.br Belo Horizonte, MG, Brasil (31) 3283-1122 === Subject: Re: Simplify and Noncommutativity >I have a rather lengthy expression of abstract products of matrices > of the form > myDot[M1,M2,...] > If Inv[M] denotes the inverse matrix > i have told mathematica that > myDot[P1___,P2_,Inv[P2_],P3___]:=myDot[P1,P3]; > myDot[P1___,Inv[P2_],P2_,P3___]:=myDot[P1,P3]; > myDot[]=Unity; > and that > myDot[P1___,P2_+P3_,P4___]:=myDot[P1,P2,P4]+myDot[P1,P3,P4]; > and a lot more things. > My Problem is: > In big expressions i have huge cancellations of the form > myDot[M1,Inv[M1+M2+M3+....]] + myDot[M2,Inv[M1+M2+M3+....]] > + myDot[M3 ,Inv[M1+M2+M3+....]]+... > such that the summands M1,M2.... should be summed and then cancel > against the Inv[...] part. > I have a very slow workaround, > myDotSimp[HoldPattern[Plus[P6___, myDot[P5___, P1_, P3___], > myDot[P5___,P2_, P3___]]]] := P6 + myDot[P5, P1 + P2, P3]; > SetOptions[Simplify, TransformationFunctions -> > {Automatic,myDotSimp}]; > this thing, however, is immensly time consuming. > On the other hand, cancellations of the type > Simplify[b/(b+c)+c/(b+c)] > are extremly fast. > Is there a way to combine the power of Simplify on Rational functions > with a noncommutative multiplication? > robert schoefbeck One approach is to use regular multiplication, but to change your variables by adding ordering information. Here are the definitions: Clear[ov] Format[ov[ord_, var_]] := var ov /: ov[i_, x_] + ov[i_, y_] := ov[i, x + y] ov /: ov[i_, x_] ov[j_, Inv[x_]] := ov[Max[i, j], 1] /; Abs[i - j] == 1 ov /: a_. ov[i_, 1] := a /. ov[j_ /; j > i, x_] -> ov[j - 2, x] Since it is cumbersome to type in ov for each variable, I create a rule that converts noncommutative multiplication using CenterDot into regular multiplication with ov variables. However, since CenterDot can't be displayed in plain text, for the purposes of this post I use NonCommutativeMultiply instead: Unprotect[NonCommutativeMultiply]; NonCommutativeMultiply[a__] := Times @@ MapIndexed[ov[First[#2], #1] &, {a}] Protect[NonCommutativeMultiply]; If you try it out, use CenterDot (or something else that looks nice) and you won't need the Unprotect/Protect statements. Now, let's try out your problem: In[50]:= p2**p1**Inv[p1+p3+p4]**p5+p2**p3**Inv[p1+p3+p4]**p5+p2**p4**Inv[p1+p3+p4]**p 5 Out[50]= p2 p1 Inv[p1+p3+p4] p5+p2 p3 Inv[p1+p3+p4] p5+p2 p4 Inv[p1+p3+p4] p5 Notice that the proper order of the factors is maintained. The displayed form of ov[1,p2] is p2, but the ordering is based on the first argument of ov. Now, let's factor: In[51]:= Factor[%] Out[51]= p2 p5 Just what you wanted. Now, for a few comments on the ov definitions. It is possible that the ov definitions can by very slow due to combinatorial explosion associated with the pattern matcher. If this happens, I have more complicated definitions which will avoid the combinatorial explosion and will hence be much quicker. Second, the rule with a_. ov[i_,1] is there to reindex all of the ov variables, so that stuff like x y Inv[y] Inv[x] will simplify. If you like this approach, and decided to experiment, I would be happy to have a dialog about your results. Carl Woll Wolfram Research === Subject: Re: Set of strings reducing problem (Again!) Well, It was easier than I thought it would be!! Instead of: ncl = StringJoin @@@ ( cl //. {x___List, {a___, p_String, c___}, {a___, q_String, c___}, y___List} :> {x, {a, p + q /. r, c}, y} /; StringQ[p + q /. r]) I put: ncl = StringJoin @@@ ( cl //. {x___List, {a___, p_String, c___}, z___List, {a___, q_String, c___}, y___List} :> {x, {a, p + q /. r, c}, z, y} /; StringQ[p + q /. r]) It worked flawlessly!!!!!! Perfect! Now I see that Pattern Matching is a VERY powerful tool in Mathematica! Edson Ferreira Mechanical Engineer S.8bo Paulo - Brazil ----- Original Message ----- === Subject: Set of strings reducing problem (Again!) > Sometime ago I have posted a problem here and got some very clever > solutions which I would like to thank. > Currently I'm working with one solution I received, but It didn't make > the complete job. The strange behaviour is that for some cases it > works the way I want. > Let's post the problem (in italic) again (hope you remember): > Let's say a have a list of n equal length strings: > L={11111111, > 11112111, > 1111X111, > ... > ... > ... > 21122211} > The characters used in strings are only 1, X, 2, U, M, D and > T. > What I want is a reduced set of strings (with all the resulting strings > with the same length as all the original ones). > The rule to join two strings is the following: > If one string is different from the other by just one character then > take the characters that are different and apply the rule bellow: > 1 + X = D > 1 + 2 = M > 1 + U = T > X + 2 = U > X + M = T > 2 + D = T > For example, suppose I have these two elements in the list : 11112111 > and 1111X111 > The rule will transform these two strings into one : 1111U111 > After all the possible transformations (always using two strings with > only one different character and resulting another string) I will obtain > a reduced set of strings. > How can I do that with mathematica?? > I guess the first step is a function to identify is two strings are > different by just one ccharacter. > A loop then search in the set for any ocurrences of that and apply all > possible transformations until we can't get any redution. > For instance : {T11TTTTT} would be generated from a set with 729 > unique strings !!!!! > Some Observations: > - The strings are all unique. > - The different character, can ocurr at any position. > - The length of all strings is the same. > -All I want is a reduced set of string, thus when you compare two > strings and you find they differ by only one character, you ELIMINATE > the original ones and ADD the NEW one to the original set. > -The rules I gave are the only ones. > -It's impossible to encounter something like 1111M111 + 11112111 > -The two strings that will be joined have only one different character > at same position! > -You can't join 21111111 vs. 11111112 (characters at different > positions) > The clever solution I received for a set L is the following: > L = {111, 11X, 112, > 1X1, 1XX, 1X2, 121, > 12X, 122}; > cl = Characters /@ L; > r = Dispatch[{1 + X -> D, > 1 + 2 -> M, > 1 + U -> T, > X + 2 -> U, > X + M -> T, > 2 + D -> T}]; > ncl = StringJoin @@@( > cl //. {x___List, > {a___, p_String, c___}, > {a___, q_String, c___}, > y___List} :> > {x, {a, p + q /. r, c}, > y} /; StringQ[p + q /. > r]) > Which evaluates {1TT} > Now finally I can explain the problem (see the code bellow): > In[1]:= > Unprotect[D]; > In[2]:= > U={2,X}; > In[3]:= > M={1,2}; > In[4]:= > D={1,X}; > In[5]:= > T={1,2,X}; > In[6]:= > L=Flatten[Outer[StringJoin,T,T,T,D]]; > In[7]:= > L = Select[L, Count[Characters[#], 1] > 1 &]; > In[8]:= > cl = Characters /@ L; > In[9]:= > r = Dispatch[{1 + X -> D, > 1 + 2 -> M, > 1 + U -> T, > X + 2 -> U, > X + M -> T, > 2 + D -> T}]; > In[10]:= > ncl = StringJoin @@@ ( > cl //. {x___List, > {a___, p_String, c___}, > {a___, q_String, c___}, > y___List} :> > {x, {a, p + q /. r, c}, > y} /; StringQ[p + q /. > r]) > Out[10]= > {11TD, 121D, 12U1, 1X1D, 1XU1, 211D, 21U1, 2U11, X11D, X1U1, XU11} > If look at some pairs of positions in the result you see that some > combinations were not done: 2+4, 3+5, 6+9, 7+10 and 8+11 > The correct result is: {11TD,1U1D,1UU1,U11D,U1U1,UU11} > Now, finally, the question: > Why this code does not perform all possible combinations??? > It looks, as Stephen Layland once said, that this code will only find > sets of strings that differ by one character that are > right next to each other... > Any solution???? > Sorry for the looooooooooong history... > Edson === Subject: Re: Set of strings reducing problem (Again!) To avoid the problem pointed out by Stephen Layland, you can make a simple amendment to the pattern as indicated below: In[18]:= cl= {{1,1,1,1},{1,1,1,X},{1,1,2,1 },{1,1,2, X},{1,1,X,1},{1,1,X,X},{1,2,1 ,1},{1,2, 1,X},{1,2,2,1},{1,2,X,1},{1,X ,1,1},{1, X,1,X},{1,X,2,1},{1,X,X,1},{2 ,1,1, 1},{2,1,1,X},{2,1,2,1},{2,1,X ,1},{2,2, 1,1},{2,X,1,1},{X,1,1,1},{X,1 ,1,X},{X, 1,2,1},{X,1,X,1},{X,2,1,1},{X ,X,1,1}}; r = Dispatch[{1 + X -> D, 1 + 2 -> M, 1 + U -> T, X + 2 -> U, X + M -> T, 2 + D -> T}]; ncl=StringJoin@@@(cl//.{x___List,{a___,p_String,c___}, z___List,{a___,q_String,c___}, y___List}[RuleDelayed]{x,{a,p+q/.r,c},z,y}/;StringQ[p+q/.r]) Out[20]= {11TD,1U1D,1UU1,U11D,U1U1,UU11} === Subject: Re: Set of strings reducing problem (Again!) Edson, This is what I modified : -1- Make Dispatch table order independant -2- Insert z___List between p and q for not neighbor cases In[1]:= Unprotect[D]; U={2,X}; M={1,2}; D={1,X}; T={1,2,X}; L=Flatten[Outer[StringJoin,T,T,T,D]]; L = Select[L, Count[Characters[#], 1] > 1 &]; cl = Characters /@ L; r = Dispatch[{1 + X -> D, 1 + 2 -> M, 1 + U -> T, X + 2 -> U, X + M -> T, 2 + D -> T, X + 1 -> D, 2 + 1 -> M, U + 1 -> T, 2 + X -> U, M + X -> T, D + 2 -> T}]; ncl = StringJoin @@@ ( cl //. {x___List, {a___, p_String, c___}, z___List, {a___, q_String, c___}, y___List} :> {x, {a, p + q /. r, c}, z, y} /; StringQ[p + q /. r]) Out[10]= {11TD,1U1D,1UU1,U11D,U1U1,UU11} Seems to work... v.a. === Subject: Re: Options in user-defined functions... >I've a little problem with a function. I've defined it in this way: >fun[x_,op1_:1,op2_:2,op3_:3]:= >Module[{....},f1[x,op1],f2[x,op2],f3[x,op3]] >So, when I use it, ops have their default values. >It works, but I'd like to use option; this why, if I want to change >only op3, I must to write every argument when I call the function, >while I'd like to write something like this: >fun[x,op3->4] >how can I do it? Basically, you need to rewrite your function along the lines of: SetOptions[fun, op1->1, op2->2, op3->3]; fun[x_, opts___]:= Module[{....}, f1[x,op1]/.{opts,Options[fun]}; f2[x,op2]/.{opts,Options[fun]}; f3[x,op3]/.{opts,Options[fun]}] A couple of additional thoughts. The package Utilities`FilterOPtions` is quite handy when creating functions with options. It allows you to call other functions which have options, ensuring each function gets only those options applicable to it. Roman Maeder presents a very clear discussion of options versus default values in chapter 3 of his book Programming in Mathematica. -- To reply via email subtract one hundred and four === Subject: Nesting NMaximize Summary : I think I want to nest one NMaximize problem within another, but I can't get Mathematica to do it. Details, in English and Pseudo-code: I have a problem where one agent is choosing p to maximize f[p,Delta gamma,other parameters], taking Delta gamma as given, and then another agent choses Delta gamma to maximize WA[OptimumP(Delta gamma),Delta gamma, other parameters], where OptimumP(gamma) is the 1st agent's optimal choice of p. f and g cannot be solved analytically, so I need NMaximize, and when I specify other parameters and Delta gamma, Mathematica will solve NMaximize[f,{p}] However, when I try the equivalent of the pseudo-code below, Mathematica gives an error: OptimumP := NMaximize[f,{p}] Set parameters except Delta gamma NMaximize[WA /. OptimumP,{Delta gamma}] Mathematica error: The function value is not a number at p = Mathematica's initial value for p I recognize that the problem is that Mathematica is trying to solve OptimumP without a value for Delta gamma before it solves the outer NMaximize problem. How do I tell Mathematica to do the reverse: try to solve the outer NMaximize first and use the guesses for Delta gamma to solve for OptimumP? Derek !(Clear[] [IndentingNewLine] (Qmax := M;)[IndentingNewLine] (shareA1 := 0;)[IndentingNewLine] (M1 := 0;)[IndentingNewLine] (M2 := M;)[IndentingNewLine] (M3 := M;)[IndentingNewLine] (RA1 := 0;)[IndentingNewLine] (qAj1 := M1 shareA1;)[IndentingNewLine] ([CapitalDelta]RA2 := (([Gamma] - [CapitalDelta][Gamma])) qAj1/Qmax;)[IndentingNewLine] (RA2 := RA1 + [CapitalDelta]RA2;)[IndentingNewLine] (RU2 := 0;)[IndentingNewLine][IndentingNewLine] (shareA2 := [ExponentialE]^((-[Alpha]) PA2 + [Beta] ((1 - RA2)) + [Xi]A2)/([ExponentialE]^((-[Alpha]) PU2 + [Beta] ((1 - RU2)) + [Xi]U2) + [ExponentialE]^((-[Alpha]) PA2 + [Beta] ((1 - RA2)) + [Xi]A2));)[IndentingNewLine][IndentingNewLine] (qAj2 := shareA2 M2;)[IndentingNewLine] (revAj2 := PA2 qAj2;)[IndentingNewLine] (varcostAj2 := c qAj2;)[IndentingNewLine] (profitAj2 := revAj2 - varcostAj2 - oF;)[IndentingNewLine] (profitA2 := n profitAj2;)[IndentingNewLine][IndentingNewLine] (CSA2 := M ((2 + (-[Alpha]) PA2 + [Beta] ((1 - RA2)) + [Xi]A2));)[IndentingNewLine] (WA2 := CSA2 + profitA2;)[IndentingNewLine] ([CapitalDelta]RA3 := (([Gamma] - [CapitalDelta][Gamma])) ((qAj2 + ((n - 1)) qJ2))/Qmax;)[IndentingNewLine] (* have to adjust for non - monopoly*) [IndentingNewLine] (RA3 := RA2 + [CapitalDelta]RA3;)[IndentingNewLine] (RB3 := 0;)[IndentingNewLine] (RU3 := 0;)[IndentingNewLine][IndentingNewLine] (shareA3 := [ExponentialE]^((-[Alpha]) PA3 + [Beta] ((1 - RA3)) + [Xi]A3)/(([ExponentialE]^((-[Alpha]) PU3 + [Beta] ((1 - RU3)) + [Xi]U3) + [ExponentialE]^(((-[Alpha]) PA3)(+)([Beta] ((1 - RA3)))(+)([Xi]A3)( )) + x [ExponentialE]^(((-[Alpha]) PB)(+)([Beta] ((1 - RB)))(+)([Xi]B)( ))));)[IndentingNewLine] (qAj3 := shareA3 M3;)[IndentingNewLine] (revAj3 := PA3 qAj3;)[IndentingNewLine] (varcostAj3 := c qAj3;)[IndentingNewLine] (profitAj3 := revAj3 - varcostAj3 - oF;)[IndentingNewLine] (profitA3 := n profitAj3;)[IndentingNewLine] (CSA3 := M (((-[Alpha]) PA3 + [Beta] ((1 - RA3)) + [Xi]A3));)[IndentingNewLine] (WA3 := CSA3 + profitA3;)[IndentingNewLine] (WA := WA2 + m[Beta] WA3;)[IndentingNewLine] (profitAj := profitAj2 + m[Beta] profitAj3;)[IndentingNewLine][IndentingNewLine] [IndentingNewLine][IndentingNewLine] (PrevCost := c1 [CapitalDelta][Gamma]^c2;)[IndentingNewLine] (ProfitMaxed := NMaximize[ profitAj, {PA2, PA3}];)[IndentingNewLine][IndentingNewLine] (mPA2opt := (ProfitMaxed[([2])])[([1])];)[IndentingNewLine] (mPA3opt := (ProfitMaxed[([2])])[([2])];)[IndentingNewLine] [IndentingNewLine][IndentingNewLine] <---------------------------------------------------------> [IndentingNewLine][IndentingNewLine] (* Central Case *) [IndentingNewLine] [Alpha] = 1; b = 2; c = 0.1; oF = 0.1; R1 = 0; m[Beta] = 1; o[Beta] = 1; [Gamma]dflt = 0.5;[IndentingNewLine][IndentingNewLine] ([Gamma] = [Gamma]dflt;)[IndentingNewLine] ([CapitalDelta][Gamma] = 0;)[IndentingNewLine] (n = 1;)[IndentingNewLine][IndentingNewLine][IndentingNewLine] ([Beta] = 1;)[IndentingNewLine] (M = 1000;)[IndentingNewLine] ([Xi]A2 = 0;)[IndentingNewLine] ([Xi]A3 = 0;)[IndentingNewLine] (PB = 10;)[IndentingNewLine] (RB = 0;)[IndentingNewLine] ([Xi]B = 0;)[IndentingNewLine] (RU = 0;)[IndentingNewLine] (PU2 = 100;)[IndentingNewLine] (PU3 = 100;)[IndentingNewLine] ([Xi]U2 = 0;)[IndentingNewLine] ([Xi]U3 = 0;)[IndentingNewLine][IndentingNewLine] (x = 0;)[IndentingNewLine][IndentingNewLine] (c2 = 2;)[IndentingNewLine] (c1 = 5000/c2;)[IndentingNewLine][IndentingNewLine][IndentingNewLine] (WA /. mPA3opt) /. mPA2opt[IndentingNewLine] mPA3opt[IndentingNewLine] ([CapitalDelta][Gamma] =. ;)[IndentingNewLine] mPA3opt[IndentingNewLine] (NMaximize[{Evaluate[(WA /. mPA3opt) /. mPA2opt] - PrevCost, [CapitalDelta][Gamma] >= 0, [CapitalDelta][Gamma] <= [Gamma]}, {[CapitalDelta][Gamma]}];)[IndentingNewLine] ) === Subject: 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++)? I use Mathematica 5.0 in Linux, so this maybe would require a kernel module for the serial port. === Subject: Question concerning MakeBoxes Let's start a new Mathematica (5.1) session and note that FormatValues[And] is the empty list. I want to define a rule for formatting logical conjunctions and disjunctionsin in such a way that, for example, the conjunction p&&q&&r is formatted in TraditionalForm as RowBox[{[And], RowBox[{StyleBox[{,SpanMaxSize->[Infinity]], GridBox[{{p},{q},{r}},ColumnAlignments->{Left}], StyleBox[},ShowContents->False]}], }]//DisplayForm (As far as I know, the idea for this interesting and convenient grid notation is due to Bruno BuchBerger, but this is another history.) For me, one obvious solution to this problem should be something like Unprotect[And]; And/:MakeBoxes[And[c__],TraditionalForm]:= RowBox[{[And], RowBox[{StyleBox[{,SpanMaxSize->[Infinity]], GridBox[{#}&/@(MakeBoxes[#,TraditionalForm]&/@{c}), ColumnAlignments->{Left}], StyleBox[},ShowContents->False]}], }]; Protect[And]; In fact, p&&q&&r//TraditionalForm is now displayed as intended. However, it works only once: evaluating again p&&q&&r//TraditionalForm gives the built-in traditional formatting. After inspecting FormatValues[And] we see what is going on: my formatting rule is the LAST on the list. So, in order to force Mathematica to apply my definition first, I evaluate Unprotect[And]; FormatValues[And]=Reverse@FormatValues[And]; Protect[And]; This solves my problem, but in a somewhat inelegant way. My questions are: (1) what is the explanation for this behavior? (2) how can I get the intended result without reversing FormatValues[And]? Carlos C.8esar de Ara.9cjo Gregos & Troianos Educacional www.gregosetroianos.mat.br Belo Horizonte, MG, Brazil (31) 3283-1122 === Subject: Re: High precision NIntegrate problem. Please help! > I'm trying to numerically evaluate a particularly nasty integral, and ... > Anyhoo, *I think* the answer is neither zero nor infinity, at least not > for all combinations of arguments I'm trying, but I can't get a > consistent answer, especially for some funny symmetrical values of > {Xi,Yi}. I've tried writing a routine in c, and that hasn't been > sucessful yet. I think the function has cancelling singularities, but > I'm a little nervous throwing out points in my Reimann sums that > NAN/Indeterminite. Maybe NumericalMath`CauchyPrincipalValue is applicable to some extent (just guessing) ? > Soooooooo, is there any way to convince Mathematica to give me a guaranteed > level of precision, assuming I'm willing to wait a while for the > answer? I assume there is, but I'm baffled by the options. > Any help would be very greatly appreciated. > -john -- Peter Pein, Berlin GnuPG Key ID: 0xA34C5A82 http://people.freenet.de/Peter_Berlin/ === Subject: Re: plots with variation of arbitrary constant > How to show 2D plots for chosen range of a constant? > Show[Plot[Sin[x]+ c,{x,0,Pi}],{c,1,10,1}] does not work. << Graphics`Graphics` DisplayTogether[Plot[Sin[x] + #, {x, 0, Pi}]& /@ Range[10]] -- Peter Pein, Berlin GnuPG Key ID: 0xA34C5A82 http://people.freenet.de/Peter_Berlin/ === Subject: Re: plots with variation of arbitrary constant >How to show 2D plots for chosen range of a constant? >Show[Plot[Sin[x]+ c,{x,0,Pi}],{c,1,10,1}] does not work. True, but In[1]:= Show[Block[ {$DisplayFunction = Identity}, Plot[Sin[x] + #, {x, 0, Pi}]&/@Range[10]]]; works just fine -- To reply via email subtract one hundred and four === Subject: Re: plots with variation of arbitrary constant I'm near a computer with Mathematica now, so here is a more elegant display < Hue[c/10]], {c, 10}], DisplayFunction -> Identity], {( Hue[1 - 9#/10] &), 10, c=10, c=1, LegendPosition -> {1, -0.5}}] yehuda === Subject: Re: plots with variation of arbitrary constant The following code should work, although I do not Mathematica on this computer to check its final correctness (so, sorry for any typo) _____________________________________ < How to show 2D plots for chosen range of a constant? > Show[Plot[Sin[x]+ c,{x,0,Pi}],{c,1,10,1}] does not work. === Subject: Re: plots with variation of arbitrary constant > How to show 2D plots for chosen range of a constant? > Show[Plot[Sin[x]+ c,{x,0,Pi}],{c,1,10,1}] does not work. Try this, I guess this is what you wish to do: In[1] := Table[Sin[x] + c, {c, 1, 10, 1}] Out[1] := {1 + Sin[x], 2 + Sin[x], 3 + Sin[x], 4 + Sin[x], 5 + Sin[x], 6 + Sin[x], 7 + Sin[x], 8 + Sin[x], 9 + Sin[x], 10 + Sin[x]} In[2] := Plot[Evaluate[%],{x,0,Pi}] Note that 'Evaluate' is essential. === Subject: Re: plots with variation of arbitrary constant Hello Narasimham: Do you want: Table[Plot[Sin[x] + c, {x, 0, Pi}], {c, 1, 10, 1}] ? Matthias Bode. ----- Original Message ----- === Subject: plots with variation of arbitrary constant > How to show 2D plots for chosen range of a constant? > Show[Plot[Sin[x]+ c,{x,0,Pi}],{c,1,10,1}] does not work. === Subject: Re: plots with variation of arbitrary constant f[x] = Sin[x] + c /. c -> Range[10] Plot[Evaluate[f[x]], {x, 0.0, N[Pi]}] Yas > How to show 2D plots for chosen range of a constant? > Show[Plot[Sin[x]+ c,{x,0,Pi}],{c,1,10,1}] does not work. === Subject: Re: plots with variation of arbitrary constant > How to show 2D plots for chosen range of a constant? > Show[Plot[Sin[x]+ c,{x,0,Pi}],{c,1,10,1}] does not work. A straightforward way: Plot[Table[Sin[x] + c,{c,10}],{x,0,Pi},PlotStyle->Table[Hue[0.66*c/10],{c,10}] You may need to Evaluate[] on the first argument to Plot. === Subject: Re: plots with variation of arbitrary constant If you want an animation : Table[Plot[Sin[x] + c, {x, 0, Pi}, PlotRange -> {-1, 12}, PlotStyle -> Hue[c/10]], {c, 1, 10, 1}]; And then double-click on the bracket of the group of graphics. Then double-click the graph. If you want all the graphics in one : Plot[Evaluate[Table[Sin[x] + c, {c, 1, 10, 1}]], {x, 0, Pi}, PlotStyle -> Table[Hue[c/10], {c, 1, 10}]]; F.Jaccard -----Message d'origine----- DeÊ: Narasimham [mailto:mathma18@hotmail.com] Envoy.8eÊ: mardi, 13. septembre 2005 12:07 ËÊ: mathgroup@smc.vnet.net ObjetÊ: plots with variation of arbitrary constant How to show 2D plots for chosen range of a constant? Show[Plot[Sin[x]+ c,{x,0,Pi}],{c,1,10,1}] does not work.