Subject: Re: Variance The built-in Variance function works on (a) built-in distributions and (b) samples (lists of numbers). It doesn't work on random variables -- which have no definition in Mathematica. If a, b, and c are independent, the variance of the expression is the sum of variances of the individual terms, and each term's variance is the variance of the random variable (a, b, or c) times the square of the constant. You can calculate that yourself, or you might try code something like this: Clear[variance] variance[a] = 0.01; variance[b] = 0.01; variance[c] = 0.01; variance[(x_) + (y_)] := variance[x] + variance[y] variance[(x_)*(y:a | b | c)] := x^2*variance[y] variance[0.7*a - 0.5*b - 0.8*c] 0.013800000000000002 To check that answer (or do it this way in the first place): 0.7^2*0.1^2 + 0.5^2*0.1^2 + 0.8^2*0.1^2 0.013800000000000003 Bobby > Can anybody help me out with this? I'm trying to make mathematica > calculate the variance of an expression, however I don't get the result > I expected, a numerical value. > In[144]:= > < a:=NormalDistribution[0,0.1] > b:=NormalDistribution[0,0.1] > c:=NormalDistribution[0,0.1] > z:=0.7a-0.5b-0.8c > Variance[z] > Out[149]= > Variance[-0.6 NormalDistribution[0,0.1]] -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Mathematica Categorization - Humor > state: > I sometimes get spam from myself! This is so funny that I laughed out > loud! > Then I ran off to tell my wife, but she started chanting her You love > Mathematica better than you love me! mantra so I guess she didn't get > it. > this > all day! > Bill Bohrer > P.S. Then I emailed it to both of my friends! BB > P.P.S. Then I printed a hard copy! I'm gonna show it to my therapist > on > Wednesday! If she thinks it is as funny as I do, then I will even > show it > to my Parole Officer! It may have sounded like a good joke to you but I don't think it was meant to be one. It is very easy to get spam from oneself. You can easily spoof any person's e-mail address and pretend that that is where the mail you are sending is coming from. This trick is so well known it has a special name: a joe-job. And, in particular, you can send someone a message that looks like it is coming from him. The spammer hopes than in this way the message will avoid being filtered. I used to get quite a few messages like that and I assure you they did not make me laugh. Now I don't because the filter on my mail server is set to reject any mail that seems to be coming from me. Andrzej Kozlowski === Subject: Re: Adding Vectors -- Newbie help please Ignore my previous reply to this message. I didn't notice that you were using curvilinear coordinates. Steve Luttrell > Ok; but I was hoping that there is a simpler way than the > following method to add two ac voltage vectors (for example): > (220V, 225 degrees) > (100V, 16 degrees) > Clear[r, x, y, Theta, rect, polar] > rect[r_,Theta_] := { r Cos[Theta Pi/180] , r Sin[Theta Pi/180]} > polar[x_, y_] := {Sqrt[x^2 + y^2], ArcTan[x, y]180/Pi} > (* Input vectors here *) > v1 := {220, 225}; > v2 := {100, 16}; > r1:= rect[v1[[1]], v1[[2]] ] // N; > r2:= rect[v2[[1]], v2[[2]] ] // N; > rt := p1 + p2 > polar[rt[[1]], rt[[2]]] // N > This just seems so cumbersome, especially when compared to a > scientific calculator. > Mathematica v5: How can I input vectors in polar form and > rectangular form? > Example: > a:= (r1, theta1) + (r2, theta2) Polar form. > b:= (re1 , j* im1) + (re2, j*im2) Rectangular form > I know this should be pretty basic, but I haven't found examples > of this kind of input. > I would guess it would be something like: > Polar[magnitude, phase] > Rectangular[Real, Imaginary] > but, apparently not. (This is for electronics engineering.) >>You can easily write a function to convert from polar to coordinate form: >>Note that this assumes your angles are measured in radians. Once all >>your vectors are in coordinate form you can add/subtract then directly: >>{1,2}+(3,4} >>produces >>{4,6} >>David Bailey === Subject: Re: Adding Vectors -- Newbie help please > Ok; but I was hoping that there is a simpler way than the > following method to add two ac voltage vectors (for example): > (220V, 225 degrees) > (100V, 16 degrees) > Clear[r, x, y, Theta, rect, polar] > (* Input vectors here *) > v1 := {220, 225}; > v2 := {100, 16}; No need for := here. Also, include Degree: v1 = {220, 225 Degree}; v2 = {100, 16 Degree} > rect[r_,Theta_] := { r Cos[Theta Pi/180] , r Sin[Theta Pi/180]} > polar[x_, y_] := {Sqrt[x^2 + y^2], ArcTan[x, y]180/Pi} Modify these to PolarToRectangular[{r_,Theta_}] := {r Cos[Theta] , r Sin[Theta]} RectangularToPolar[{x_, y_}] := {Sqrt[x^2 + y^2], ArcTan[x, y]/Degree} Alternatively, PolarToRectangular[{r_,Theta_}] := r Exp[I Theta] RectangularToPolar[z_] := {Abs[z], Arg[z]/Degree} > r1:= rect[v1[[1]], v1[[2]] ] // N; > r2:= rect[v2[[1]], v2[[2]] ] // N; > rt := p1 + p2 > polar[rt[[1]], rt[[2]]] // N The addition of vectors (phasors) now reads RectangularToPolar[PolarToRectangular[v1]+PolarToRectangular[v2] // N] which I find a little less cumbersome. > This just seems so cumbersome, especially when compared to a > scientific calculator. You could, of course, write a palette or program buttons to do this, just like a scientific calculator. Paul >> Mathematica v5: How can I input vectors in polar form and >> rectangular form? Example: a:= (r1, theta1) + (r2, theta2) Polar form. b:= (re1 , j* im1) + (re2, j*im2) Rectangular form I know this should be pretty basic, but I haven't found examples >> of this kind of input. I would guess it would be something like: Polar[magnitude, phase] >> Rectangular[Real, Imaginary] but, apparently not. (This is for electronics engineering.) >You can easily write a function to convert from polar to coordinate form: >Note that this assumes your angles are measured in radians. Once all >your vectors are in coordinate form you can add/subtract then directly: >{1,2}+(3,4} >produces >{4,6} >David Bailey -- 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) 35 Stirling Highway Crawley WA 6009 mailto:paul@physics.uwa.edu.au AUSTRALIA http://physics.uwa.edu.au/~paul === Subject: Re: Re: need help with integration Symbio seems to be right, but a solution CAN be salvaged. Here's Wolfgang's code from David's link, executed in Mathematica 5.0.1: x[t_] = 3*Exp[-t/2]*UnitStep[t] + DiracDelta[t + 3]; h[t_] = UnitStep[t] - UnitStep[t - 2]; eq1 = Integrate[x[a]*h[t - a], {a, -Infinity, Infinity}]; eq2 = Integrate[x[a]*h[t - a], {a, 0, Infinity}]; eq3 = Integrate[x[a]*h[t - a], {a, -Infinity, 0}]; Simplify[eq1, t [Element] Reals] FullSimplify[eq2 + eq3, t [Element] Reals] (1/2)*(-((6*(-2 + t))/ Abs[-2 + t]) + (6*t)/Abs[t] - (1 + t)/Abs[1 + t] + (3 + t)/Abs[3 + t]) -((1 + t)/(2*Abs[1 + t])) + (3 + t)/(2*Abs[3 + t]) + 6*((-1 + E^(1 - t/2))*UnitStep[-2 + t] + UnitStep[t] - UnitStep[t]/ E^(t/2)) Plot[{(1/2)*(-((6*(-2 + t))/Abs[-2 + t]) + (6*t)/Abs[t] - (1 + t)/Abs[1 + t] + (3 + t)/Abs[3 + t]), (1/2)*(-Sign[1 + t] + Sign[3 + t] + 12*(-UnitStep[-2 + t] + (E*UnitStep[-2 + t] - UnitStep[t])/ E^(t/2) + UnitStep[t]))}, {t, -10, 10}, PlotRange -> All] The Plots are NOT the same, so what worked for Wolfgang in Mathematica 4.0 doesn't work in 5.0.1. His Integrate with Assumptions gives yet a third expression (after a LOOOONG calculation): eq1 = Integrate[x[a]*h[t - a], {a, -Infinity, Infinity}, Assumptions -> t [Element] Reals] (1 + t + Abs[1 + t])/(-2 - 2*t) + (3 + t + Abs[3 + t])/(6 + 2*t) - 3*((2 - 2*E^(1 - t/2))* UnitStep[-2 + t] + 2*(-1 + E^(-t/2))*UnitStep[t]) This one plots the same as eq2+eq3, so that solves the problem.... ...IF we're convinced the original eq1 was wrong and the other two answers are right. I can't muster much confidence in that. Bobby > actually this is different, i used both assumptions and simplify but won't > work. Please try running the code, you'll see for yourself when you look at > the plots, they are different even if you use assumptions. > Below I define two functions x[t] and h[t], then in eq1 I integrate > the integrand ( x[tau] h[t-tau] ) from -inf to +inf and get one set of > results and plots, then I integrate the same integrand as before but this > time in two steps, once from -inf to 0 and once from 0 to +inf, but the > results and plots from the integration performed in two steps are NOT the > same as the results and plots from integration in one step. Is this a > bug and if so what's the work around? >> This looks essentially like what you asked here about two weeks ago in >> Integration of UnitStep has bugs!? help! >> I would have answered your question in the previous thread had you not >> already gotten two good answers. Look at them carefully. I suspect that >> the >> trouble you're having now is the same as you were having previously; if >> so, >> then your question has already been answered, twice. >> David > Try this in the input cell > In[19]:= > x[t_] = (3Exp[-.5t]UnitStep[t]) + DiracDelta[t + 3] > h[t_] = UnitStep[t] - UnitStep[t - 2] > eq1 = Integrate[x[[Tau]]h[t - [Tau]], {[Tau], -[Infinity], > [Infinity]}] Plot[eq1, {t, -10, 10}, PlotRange -> All] > eq2 = Integrate[x[[Tau]]h[t - [Tau]], {[Tau], 0, [Infinity]}] > Plot[eq2, {t, -10, 10}, PlotRange -> All] > eq3 = Integrate[x[[Tau]]h[t - [Tau]], {[Tau], -[Infinity], 0}] > Plot[eq3, {t, -10, 0}, PlotRange -> All] > You will get the following output expressions (I couldn't paste the plots > here, but if you run the above input cells you should get the plots too, > then it will be more obvious what the problem is) > Out[21]= > !(1/2 ((1 + (6.` @(((-2) + t))^2)/(((2.`)( > [InvisibleSpace])) - 1.` t) + (6.` @t^2)/t + @((3 + > t))^2/(3 > + t) - (1 + t + @((1 + t))^2)/(1 + t)))) > Out[23]= > !((((-6.`) + > 16.30969097075427` [ExponentialE]^((-0.5`) t))) UnitStep[ > (-2) + t] + ((((6.`)([InvisibleSpace])) - > 6.` [ExponentialE]^((-0.5`) t))) UnitStep[t]) > Out[25]= > !(1/2 (((-((1 + > t)/@((1 + t))^2)) + (3 + t)/@((3 + t))^2))) -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: A NIntegrate question Two of your inputs are incomplete: (1) Ze[s_, mu_:4.0 Pi 10^-7, rc_:0.0203454, rhoc_:8.82573*10^-8, rhosolo_:100.0] := s mu/(2 Pi) Log[2*(15.0 + Sqrt[rhosolo/(s mu)]/rc] which I guess should be Ze[s_, mu_:4.0 Pi 10^-7, rc_:0.0203454, rhoc_:8.82573*10^-8, rhosolo_:100.0] := s mu/(2 Pi) Log[2*(15.0 + Sqrt[rhosolo/(s mu)])/rc] (2) a[t_] := 2/Pi NIntegrate[ Im[A[I 2 Pi x]/(2 Pi x) Cos[2 Pi x t], {x, 0, [Infinity]}, MaxRecursion -> 50, Method -> Oscillatory] which I guess should be a[t_] := 2/Pi NIntegrate[ Im[A[I 2 Pi x]]/(2 Pi x) Cos[2 Pi x t], {x, 0, [Infinity]}, MaxRecursion -> 50, Method -> Oscillatory] Are these assumtions of mine correct? Further, what is the Mathematica version you are running your computations with? For what values of t you are getting the NIntegrate message? Anton Antonov, Wolfram Research, Inc > -------- Original Message -------- === > Subject: A NIntegrate question > I need to find the Inverse Fourier Transform of an expression > involving Sqrt, Exp and Bessel Functions. As my interest is in the > numerical response I am trying to use NIntegrate for frequency to time > transform. In fact I am using it to have a Fourier Cossine transform. > My problem is that I can only find an answer if I use interpolation > for the frequency domain function. I was wondering if anybody can give > me a help in trying to use NIntegrate to solve this problem. What I > have tried didn«t work that well. Any comments are welcome. > Antonio > Here comes my functions.... > zint[s_, rhoc_:8.82573*10^-8, rc_:0.0203454, mu_:4.0 Pi 10^-7] := > Sqrt[s mu/rhoc] rhoc/(2 Pi rc)BesselI[0, Sqrt[s mu/rhoc] > rc]/BesselI[ > 1, Sqrt[s mu/rhoc] rc] > Ze[s_,mu_:4.0 Pi 10^-7, > rc_:0.0203454,rhoc_:8.82573*10^-8,rhosolo_:100.0] := > s mu/(2 Pi) Log[2*(15.0+ Sqrt[rhosolo/(s mu)]/rc] > Zserie[s_]:=Ze[s]+zint[s]; > Y[s_,e_:1/(36.0 Pi 10^9)]:=s 2 Pi e /(Log[2*15.0/rf]) > A[s_]:=Exp[Sqrt[Zserie[s]*Y[s]]*-10000.0] > (* from the graphic one can see that this funciton is bounded and goes > to zero as s goes to either I*Infinity or -I*Infinity *) > a[t_]:=2/Pi NIntegrate[Im[A[I 2 Pi x]/(2 Pi x) Cos[ 2 Pi x t], > {x,0,[Infinity]}, MaxRecursion -> 50, Method->Oscillatory] > The error message did not help much for my case > Numerical integration stopping due to loss of precision. > Achieved neither the requested PrecisionGoal nor AccuracyGoal; > suspect one of the following: highly oscillatory integrand or > the true value of the integral is 0. If your integrand is oscillatory > try > using the option Method->Oscillatory in NIntegrate. === Subject: Re: List element replacement. > Et al, > HELP, I tried this once before but what I received back I could not > make it work. > Therefore I am following the adage that if at first you do not succeed > then wait > awhile, rethink, restate and resubmit. > I have three lists of objects, sorted but not unioned, that is there > are elements > which will be repeated. Let us label them 'initial' list, 'compare' > list, and > 'replace' list. If all of the elements in the 'compare' list, > including repeats, > are in the 'initial' list, then remove those elements remove from 'initial' or from 'compare' ? > and put in the elements from > the 'replace' list. put into 'initial' or 'compare' ? You have to be more specific. In[17]:= (Length[Position[init, #1]] & ) /@ comp will give you a list indicating how many times an element from comp was found in init. In[16]:= MemberQ[ (Length[Position[init, #1]] & ) /@ comp, 0] will give true if there was minimum one member of comp not in init. If it gives false then all members of comp was in init so then you can go ahead with the replacements. I hope it helps. J.87nos > Bob. ---------------------------------------------- Trying to argue with a politician is like lifting up the head of a corpse. (S. Lem: His Master Voice) === Subject: Re: suggestion for frontend To AES/newspost and Pierre Albarede: You can use the ButtonTools palette of Rolf Mertig to evaluate a notebook from a cell to both top or bottom of it. It has some other cool actions too. Check it out at http://www.mertig.com/mathdepot/ Hope this helps Julius === Subject: nonlinear programming with differential-algebraic constraints I want to estimate parameters p of a system of nonlinear differential equations y'=F(y(t),p) using measured time series. I guess one would use NMinimize to do that. My simple question is if someone knows of a freely available mathematica package or function that does that already. Best, joerg === Subject: newbie question DSolve Hello all I am trying to use DSolve to solve a ode with discontinuity in it (wave equation with a viscous damper injected at a location d) This is what i am using DSolve[{y''[x]-lamda^2*y[x]==DiracDelta[x-d]*y[x],y[0]==0,y[L]== =0},y[x],x] the problem I am facing is that y[x] on the right hand side (next the delta function) varies w.r.t to the location y[x]==y[x]&& 0<=x<=d y[x]==y[L-x]&&d<=x<=L I can solve the above equation without the y[x] coupled to the delta function Pratik Desai ps: This is my third attempt at posting my query, I hope this time it makes it to the list :) === Subject: Re: finding explicit rule for series > i have a series of numbers and would like to use Mathematica to find the > explicit algorithm in that way: > n(i)=5342543+n(i-1).... > I already spent some time with the manual, but didn't find anything. > Uwe If your series of numbers is finite (otherwise you would have a formula for n[i]) then you are, in effect, trying to fit an arbitrary function to a fixed set of points. There will be an infinite number of possible solutions to that problem. Maybe I am not understanding your question. However, you could produce a list of possible solutions with unknown parameters (alpha and beta in this case) - e.g. n[i]:=alpha*n[i-1]+beta - which would give you a set of simultaneous equations for the parameters. If you can fit more than one 'model' then you obviously need more points of your sequence. David Bailey === Subject: Re: finding explicit rule for series > i have a series of numbers and would like to use Mathematica to find the > explicit algorithm in that way: > n(i)=5342543+n(i-1).... > I already spent some time with the manual, but didn't find anything. > Uwe If you want to find a minimal length linear recurrence from a list of numbers you can use code posted at: I should point out that I have no reason to believe that code comprises the most efficient way to do this sort of thing. Daniel Lichtblau Wolfram Research === Subject: Re: finding explicit rule for series It turns out that n[i] == 5342543 i + n[0]. n[i_?Positive]:=5342543+n[i-1] n/@Range@5 5342543Range@5+n[0] {5342543+n[0],10685086+n[0],16027629+n[0],21370172+n[0],26712715+n[0]} {5342543+n[0],10685086+n[0],16027629+n[0],21370172+n[0],26712715+n[0]} I calculated a few terms both ways and the answers agree. Bobby > i have a series of numbers and would like to use Mathematica to find the > explicit algorithm in that way: > n(i)=5342543+n(i-1).... > I already spent some time with the manual, but didn't find anything. > Uwe -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Adding text labels and such to 3D plots? If I'm reading The Mathematica Book correctly, one adds Text and similar added graphic stuff to 3D graphics by positioning this added stuff at 3D or vector points in 3D space. But what if I'd just like to add text labels or other stuff at (scaled?) 2D points in the 2D frame within which the 3D graphic is drawn, entirely independent of the 3D graphic and its coordinate system? Any simple way to do this? (Would my favorite graphics command, DisplayTogether[ ], allow overlaying or superposing a 2D graphic on a 3D graphic? I can try this for myself, and will, but perhaps someone else already knows the answer.) === Hello Everyone, Is there a simple way to convert dates imported as Day/Month/Year to the Mathematica format of {Year, Month, Day}? My dates are one column in a matrix of data. Mathematica appears to be treating them as remains a string, of course. Any suggestions would be most appreciated. My alternative is to import date calculations would not be possible. Greg === Subject: Re: Variance >Can anybody help me out with this? I'm trying to make mathematica >calculate the variance of an expression, however I don't get the >result I expected, a numerical value. >In[144]:= ><a:=NormalDistribution[0,0.1] >b:=NormalDistribution[0,0.1] >c:=NormalDistribution[0,0.1] >z:=0.7a-0.5b-0.8c >Variance[z] >Out[149]= >Variance[-0.6 NormalDistribution[0,0.1]] The reason you are not getting a numerical value is the function Variance doesn't know how to compute the variance of a general expression. The simplest way to sovle your problem is to realize variance is location independent but not scale independent. That is the variance of m x + b will be m^2 variance(x) The other useful property of variance is it is additive, i.e., variance(x+y) = variance(x) + variance(y) So, the solution is: .1^2(.7^2 + .5^2 + .8^2) If you were did not know the properties of variance above, you could have Mathematica do the computation using the ExpectedValue function, i.e., ExpectedValue[(0.7 #)^2 & , NormalDistribution[0, 0.01]] 0.000049 Since ExpectedValue[x+y] = ExpectedValue[x]+ExpectedValue[y] it should be clear you could solve you problem as a sum of expected values which will clearly be the same result I showed above. -- === Subject: Re: Zero divided by a number... > BTW, concerning whether an improper element of an extended number > system should be called a number or not, it might be noted that: > Floating-point arithmetic is surely the most widely used number system > in the world, in terms of the number of computations performed per day. > There is an internationally accepted standard for that arithmetic. The > standard clearly distinguishes between those floating-point objects > which are numbers and those which aren't (the NaNs). According to > the standard, -Infinity and +Infinity are numbers (while things such > as 0*Infinity yield NaN). > According to Mathematica: > NumericQ[ComplexInfinity] > False > NumericQ[Infinity] > False I was either unaware or had forgotten that Mathematica considers out. And knowing that can indeed be important when programming in Mathematica. But as far as _mathematics itself_ is concerned, I had already said Seriously, both 0 and ComplexInfinity are quite peculiar, no doubt. And if you don't want to call ComplexInfinity a number, that's just fine. But it's essentially irrelevant whether we call it a 'number' or not. It's an element of C*, and what's important is knowing what you can (and can't) do with it. On second reading, perhaps it was not clear that I was talking about mathematics itself, rather than Mathematica, but C* was what I had in mind > It is to say the least controversial if numbers are what complex > analysts deal with. It would be absurd to suggest that numbers be _restricted_ to what's used in complex analysis. But I gather that that is not your point. > ComplexInfintiy and Infinity do not belong to any > family of numbers known to number theorists (who ought to be the people > who know best what numbers are), e.g. algebraic numbers, transcendental > numbers, or even computable numbers. Number theory is a specific branch of mathematics, as you know. There are types of objects used in mathematics which are often called numbers but which are not normally considered in number theory itself. Cantor's cardinal and ordinal numbers come to mind, for example. DrBob has objected previously in this thread that ComplexInfinity doesn't behave like a number; I'd say, rather, that it doesn't behave like a _finite_ number. Transfinite numbers do not behave like finite numbers; that's to be expected, of course. The mathematicians' drinking song Aleph_nought bottles of beer on the wall never ends (well, at least, in theory; in practice, we'd get too drunk to continue singing, I suppose). And 1 + omega is not the same as omega + 1. Earlier in this thread, you said The word 'number' is ambiguous... That's certainly true. There is no generally accepted definition of number. There are, of course, generally accepted definitions for _specific_ number systems. > A point on the Riemann sphere is not a number. Are you being pedantic? If so, I agree with you. We may say that the Riemann sphere is merely a way to visualize C*, just as the number line is a way to visualize R. And no point on the line or the sphere _is_ a number. But there is an obvious _correspondence_ between the points of the line and the elements of R and between the points of the sphere and the elements of C*. Each point on the Riemann sphere, except its North Pole, corresponds with an element of C, that is, with a complex number. The North Pole corresponds with oo, an element of C*. Whether we wish to call that element a number or not is essentially irrelevant, as I've said before. Please note that I have not said anywhere in this thread that I think it _should_ be called a number. It's adequate, as far as I'm concerned, merely to say that oo is an element of C*. > But I found this reply of yours to Bob particulalry incredible : >> ComplexInfinity isn't a number if you can't do >> arithmetic with it, > But you can do arithmetic with it. > Really? And presumably algebra too? I am curious how, Really! (And I can't imagine why you thought that was particulalry incredible.) In C*, we have oo + 1 = oo and 1/oo = 0, for example. That's doing arithmetic involving oo. Correspondingly, in Mathematica, we have In[1]:= ComplexInfinity + 1 Out[1]= ComplexInfinity In[2]:= 1/ComplexInfinity Out[2]= 0 > given that this > is the only number about which Mathematica does not even know if it > is equal to itself: First, note that I never said it was a number. And as you pointed out above, Mathematica considers it to be nonnumeric. > ComplexInfinity==ComplexInfinity > ComplexInfinity==ComplexInfinity In C*, oo = oo is true, of course. The fact that Mathematica cannot at present decide about ComplexInfinity==ComplexInfinity is, in my opinion, a deficiency. But of course, the designers may have had a good reason, unknown to me, for leaving ComplexInfinity==ComplexInfinity unevaluated. > But then perhaps analysts mean something different by arithmetic and > algebra from the rest of us ;-) Not that I'm aware of. Perhaps it would be helpful if I discuss the construction of C*. I'll also construct a more flexible system, much like the one that Mathematica uses. Of course, to keep this post to a reasonable length, this must be a discussion in a nutshell, just a bare-bones outline. I hope that readers will be able to follow it if they're familiar with the constructions of the reals from the rationals via Dedekind cuts and via equivalence classes of Cauchy sequences. (BTW, the constructions outlined will not be aesthetically optimal IMO, but rather optimal for speed of presentation here.) Assume that the positive rationals have already been constructed. We may then construct the nonnegative extended reals, [0, +oo], from the positive rationals either by cuts or by equivalence classes of appropriate rational sequences. Bertrand Russell used the former construction with the cut having lower class {q | q in Q, q > 0} being the real number infinity, to use his own words. For the other method of construction, we proceed as usual except that we also include an equivalence class which consists of all rational sequences which increase without bound. That equivalence class is +oo. [Those reading closely may protest that the sequences in that equivalence aren't Cauchy. But in fact, if desired, they can easily be made Cauchy simply by using an appropriate metric.] Note that, regardless of the method of construction chosen, +oo is the same type of object as the nonnegative reals which were constructed along with it. In that light, it would certainly not be unreasonable to call +oo a number. The (signed) reals, R, may then be constructed easily from the nonnegative reals. An extended complex number system may then be constructed in which the elements are equivalence classes of ordered pairs (r, theta) with r in [0, +oo] and theta in R, with ordered pairs (r, theta_1) and (r, theta_2) being in the same equivalence class whenever theta_1 = theta_2 mod(2 Pi). This system should in essence be the same as Mathematica's system of complex numbers together with _directed infinities_. (The only web reference I know to such a system is A family of compactifications accounting for all arguments of infinity by Gingold and Gingold at .) OTOH, if we lump all of the ordered pairs having r = +oo into a single equivalence class (without regard to theta), we get C*, which should in essence be Mathematica's system of complex numbers together with ComplexInfinity. [Note of course that, in C*, the undirected infinity oo is defined as a specific equivalence class, and so there is no doubt that oo = oo is true. That's why I'm surprised that Mathematica does not assert that ComplexInfinity==ComplexInfinity is true.] The system which Mathematica actually uses is equivalent neither to C with just directed infinities nor to C with just the undirected infinity. Rather, Mathematica uses a hybrid system having both the directed infinities and the undirected infinity available. This is laudable IMO, allowing a specific directed infinity to be given whenever feasible (and thereby retaining as much information as possible), but also allowing the undirected infinity to be given in cases when no direction can be specified. In this brief outline, I haven't yet mentioned the definitions of the arithmetic operations, but they can be defined in fairly obvious ways. Let's go back to the system [0, +oo], for example, and consider, say, 1/(+oo). To compute that, take a representative sequence of nonnegative rationals in the equivalence class 1 and a representative sequence of nonnegative rationals in the equivalence class +oo. The desired quotient is then the equivalence class containing the sequence . Since a_n converges to 1 and b_n increases without bound, a_n/b_n must converge to 0. Thus, 1/(+oo) = 0 in the system [0, +oo]. But what if we similarly attempt to compute, say, 0/0. We must consider two representative sequences, and , in the equivalence class 0, and look at . Alas, that sequence may very well not reside in _any_ of the equivalence classes constituting [0, +oo], and so we must say that 0/0 is undefined in this system. In floating-point arithmetic, when this situation arises, the result is called NaN (Not a Number); in Mathematica, it's called Indeterminate. Someone had asked me, in a private email concerning this thread, if such systems aren't fields, then what are they? Well, for a system like C* with another element (like NaN or Indeterminate) adjoined to handle cases such as 0/0, the term is wheel (and that extra element is often called bottom). The best source (known to me) of information on wheels is Jesper Carlstrom's thesis Wheels -- On Division by Zero, available at . Sorry that I didn't have time to go into more detail. David W. Cantrell === Subject: webMathematica: how to take objects passed into a JSP page and manipulate them in the MSP tags I'm having a difficult time integrating webMathematica 2 into our web app. I have a JSP page inside which I create a simple vector for test purposes: <% Vector test = new Vector(); test.add(new Double(10.0)); I really want to be able to send a data object to the page and then convert all the data that came from our database lookup into an array or something webMathematica will like. Anyways, the next thing I want to be able to do is get the array or vector into the MSP blocks. So I tried this: /> var1@HashCode[] The problem is that once the reference is passed in, I can't do anything with it. What I really want is just to be able to send an array into the MSP section and then ListPlot it. Any ideas? === Subject: Re: NonlinearFit problem > Hi All, > Could anyone give me any suggestion for the specified fitting function > f= r^a Exp[-b r]? > My data point was given below, > data={{0, 1.00002}, {2.31507, 26.4522}, {4.32033, 56.8265}, {6.63539, > 59.6674}, {8.64066, 39.5536}, {10.9557, 21.6862}, {12.961, > 10.1456}, {15.276, 4.39652}} > The following way, > NonlinearFit[data,f,r,{a,b}], gives the error message, > FindFit::njnum: > The Jacobian is not a matrix of numbers at (a,b)={1.,1.}. > How should I do this fitting without the problem? It is the first data point that is causing the problem. As the error message says, the Jacobian Outer[D, {r^a Exp[-b r]}, {a, b}] is not a matrix of numbers at (a,b)={1.,1.}, unless you take the limit as r->0. If you drop the first point, or perturb the x value away from 0, the fit proceeds without problem. For example, data={{0.0001, 1.00002}, {2.31507, 26.4522}, {4.32033, 56.8265}, {6.63539, 59.6674}, {8.64066, 39.5536}, {10.9557, 21.6862}, {12.961, 10.1456}, {15.276, 4.39652}} FindFit[data, r^a Exp[-b r], {a,b}, r] 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) 35 Stirling Highway Crawley WA 6009 mailto:paul@physics.uwa.edu.au AUSTRALIA http://physics.uwa.edu.au/~paul === Subject: Re: NonlinearFit problem > Hi All, > Could anyone give me any suggestion for the specified fitting function > f= r^a Exp[-b r]? > My data point was given below, > data={{0, 1.00002}, {2.31507, 26.4522}, {4.32033, 56.8265}, {6.63539, > 59.6674}, {8.64066, 39.5536}, {10.9557, 21.6862}, {12.961, > 10.1456}, {15.276, 4.39652}} > The following way, > NonlinearFit[data,f,r,{a,b}], gives the error message, > FindFit::njnum: > The Jacobian is not a matrix of numbers at (a,b)={1.,1.}. > How should I do this fitting without the problem? > Feng-Yin Chang, > Institute of Physics,NCTU,Taiwan If you remove your first data point you get a fit. The first data point can't fit because the value of f[r] at r=0 can only be 0, infinity, or indeterminate. It would be nice if the statistics package gave a better diagnostic for what must be a common occurrence! David Bailey === Subject: Re: NonlinearFit problem > Hi All, > Could anyone give me any suggestion for the specified fitting function > f= r^a Exp[-b r]? > My data point was given below, > data={{0, 1.00002}, {2.31507, 26.4522}, {4.32033, 56.8265}, {6.63539, > 59.6674}, {8.64066, 39.5536}, {10.9557, 21.6862}, {12.961, > 10.1456}, {15.276, 4.39652}} > The following way, > NonlinearFit[data,f,r,{a,b}], gives the error message, > FindFit::njnum: > The Jacobian is not a matrix of numbers at (a,b)={1.,1.}. > How should I do this fitting without the problem? > Feng-Yin Chang, > Institute of Physics,NCTU,Taiwan Since the derivative of f with respect to a contains Log[r], you should replace the first point in data by sth. like {10^-6,1.00002}. The solution is quite stable for r0=10^-3 or smaller. I get r^5.509797613785286/E^(0.9447850533338638*r) Good luck, Peter -- Peter Pein Berlin === Subject: Re: NonlinearFit problem > Hi All, > Could anyone give me any suggestion for the specified fitting function > f= r^a Exp[-b r]? > My data point was given below, > data={{0, 1.00002}, {2.31507, 26.4522}, {4.32033, 56.8265}, {6.63539, > 59.6674}, {8.64066, 39.5536}, {10.9557, 21.6862}, {12.961, > 10.1456}, {15.276, 4.39652}} > The following way, > NonlinearFit[data,f,r,{a,b}], gives the error message, > FindFit::njnum: > The Jacobian is not a matrix of numbers at (a,b)={1.,1.}. > How should I do this fitting without the problem? If you replace your first data point with {0.00001, 1.00002} it does work : NonlinearFit[data, f, r, {a, b}] r^5.50979/E^(0.94478*r) v.a. -- 0% de pub! Que du bonheur et des vrais adh.8erents ! Vous aussi inscrivez-vous sans plus tarder!! Message post.8e .88 partir de http://www.gyptis.org, BBS actif depuis 1995. === Subject: Re: NonlinearFit problem Here's the Jacobian of f with respect to {a,b}: jac = Outer[D[f, ##1] & , {a, b}, {a, b}] {{(r^a*Log[r]^2)/E^(b*r), (-E^((-b)*r))*r^(1 + a)* Log[r]}, {(-E^((-b)*r))* r^(1 + a)*Log[r], r^(2 + a)/E^(b*r)}} Notice the appearance Log[r], which is undefined for r == 0, which occurs at the first data point. Leaving that point out, we do get a solution: data = {{0, 1.00002}, {2.31507, 26.4522}, {4.32033, 56.8265}, {6.63539, 59.6674}, {8.64066, 39.5536}, {10.9557, 21.6862}, {12.961, 10.1456}, {15.276, 4.39652}}; f = r^a*Exp[(-b)*r]; NonlinearFit[Rest[data], f, r, {a, b}] r^5.509926608585867/ E^(0.9448215835344381*r) Consider this, too: f /. r -> 0 0^a There's no way to fit that to a y-value, so there's no point in including r = 0 in the data. Bobby > Hi All, > Could anyone give me any suggestion for the specified fitting function > f= r^a Exp[-b r]? > My data point was given below, > data={{0, 1.00002}, {2.31507, 26.4522}, {4.32033, 56.8265}, {6.63539, > 59.6674}, {8.64066, 39.5536}, {10.9557, 21.6862}, {12.961, > 10.1456}, {15.276, 4.39652}} > The following way, > NonlinearFit[data,f,r,{a,b}], gives the error message, > FindFit::njnum: > The Jacobian is not a matrix of numbers at (a,b)={1.,1.}. > How should I do this fitting without the problem? > Feng-Yin Chang, > Institute of Physics,NCTU,Taiwan -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: NonlinearFit problem The algorithm uses model's first or second derivatives, and in your case the partial derivative in respect to a is not numerical at r=0 because the Log[r]-function. D[ r^a Exp[-b r], a] = e^(-b r) r^a Log[r] and D[ r^a Exp[-b r], {a, 2}] = e^(-b r) r^a Log[r]^2 If you change your first datapoint to something like {0.0000001, 1.00002} instead of {0, 1.00002} the fit has no problems. -- Antti Penttil.8a Antti.I.Penttila@helsinki.fi.removethis Researcher Observatory tel. +358 50 5240968 00014 University of Helsinki === Subject: Re: Re: MathGroup /: Descriptive headings >Yikes, that's complicated!! It collapses of its own weight, I think. Well, I was not given the gift of synthesis, that's true : ))). But the mechanism is not as complicated as it may at first seem. Here's a sample of the mail to be sent to non complying users [1][2]: ______________________________________________ Posting to the MathGroup requires the use of a tag. Please choose one among the following ten cathegories: [Frontend] [Kernel] [I/O] [Programming] [Symbolics] [Numerics] [Graphics] [Application] [Package] [Newbie] (to see how to identify a category for your problem please visit www.xxxxx.xx ) If you are still uncertain as to which category assign your post, you could use the 'wildcard' tag: [] that allows other posters to add their own cathegorization. Posts without a tag will be automatically tagged with []. _____________________________________________ The site www.xxxxx.xx will give details on how to make a problem fit into a certain category, and will instruct the user on how to add subcathegories. The fact that subcathegories are only 'suggested' and can be 'user-defined' makes this scheme almost free from coercion. Posters who don't care to add a tag can still keep up with their attitude: the wildcard [] is claiming only two characters and can also be used as a filter for generic spam, and as a placeholder to avoid multiples Re:'s. [3] But, as I said, I've yet to see a NG where tagging is carried out consistently. I wonder if the Mathgroup would be such a group. : ] cheers, Peltio [1] THe moderator could set up a bot to send this letter only once for each e-mail. [2] The cathegories are only tentative, here. [3] A post like RE: Re: R: Fw: [] I can't get it done can be easily coerced to Re: [] I can't get it done. The room for the wildcard tag is no more hassle than a double Re: === Subject: BlockDiagonal Hello! I am using BlockDiagonal and it works perfectly with for example two squared matrices but I have some problem when I want to use it with Table. Is it possible to do something like this? SuperPop=Flatten[Table[BlockDiagonal[{SousPop[[k]][[j]]}] //MatrixForm,{k,1,2},{j,1,2}],1]; In order to create a matrix SuperPop from here 4 submatrices SousPop[[1]] [[1]], SousPop[[1]] [[2]] etc... When I try this I still have my submatrices but I don't have the final matrix SuperPop with the block on the diagonal. Is there a better (and clever) way to do this? Blandine.