## 30350 Reputation

18 years, 258 days

## problems with nontrivial solutions are m...

The X and Y and just dummy names for the first and second component of the Vector x. You could just as easily call then x1 and x2. For example A := Matrix([[-1,0],[1,-2]]); B := Vector([1,-1]); x := Vector([x1(t),x2(t)]); xprime := map(diff,x,t); eqn1 := xprime[1]=(A.x+B)[1]; eqn2 := xprime[2]=(A.x+B)[2]; dsolve({eqn1,eqn2,x1(0)=1,x2(0)=0},{x1(t),x2(t)}); Look at how, in your own attempt, you mixed up Matrix equations and the scalar diff(x(t),t) since you did not define x as a matrix or vector. Look instead at how in my example the x and xprime are Vectors. So, I set everything up as a Matrix or Vector, that is, the A, the B, the x(t), and the dx(t)/dt . Then I pull out two equations, to form a system of differential equations. The first equation is take from the top row of all those Matrix and Vector objects, and the second equation is taken from the bottom row of them. Study that. Then I call dsolve, with the whole system. The reason that it is uninteresting is that the only solution, for the data you gave, is the trivial solution of {x1(t) = 1, x2(t) = 0}. That solution is the same, for all t, which is dull. For other choices of A, more interesting solutions which actually depend on t might arise. acer

## Are you sure you got the question down c...

Are you sure you got the question down correctly? I see that the sign of A[2,2] has changed, since your first attempt to post the question. A := Matrix([[-1,0],[1,-2]]); B := Vector([1,-1]); x := Vector([X(t),Y(t)]); xprime := map(diff,x,t); eqn1 := xprime[1]=(A.x+B)[1]; eqn2 := xprime[2]=(A.x+B)[2]; dsolve({eqn1,eqn2,X(0)=1,Y(0)=0},{X(t),Y(t)}); Are you sure that A wasn't something more interesting, like say Matrix([[-1,0],[-1,-2]]) ? acer

## your simple commands would be eval and d...

Note the capitalization of Pi. s:=8*cos((sqrt(2)/5)*Pi*t); eval(s,t=0); dsdt := diff(s,t); d2sdt2 := diff(s,t,t); # for fun plot(d2sdt2,t=0..10); acer

If you wish to code this yourself, use `add` instead of `sum`. But you might also use ArrayTools[AddAlongDimension] . acer

## Digits is set to 10, by default...

> Digits := trunc(evalhf(Digits)): > evalf(e_x0); 0.000272945525314361 > evalf[30](e_x0); .000272945527768874577097831048276 Look at the help-page ?Digits . Other systems may have a different default working precision (or accuracy goal). acer

## for example...

# Setting Digits higher than this may require fiddling # with the epsilon and digits options of evalf/Int # This is optional, regardless, so only increase if it's needed. Digits := 13; interface(rtablesize=15); # S is a list of the first 11 nonnegative roots of -BesselJ(1,x) ? # If so, then find these using fsolve with avoid={} option, or with plot. S := [0., 0.3831705970, 0.7015586670, 1.017346814, 1.332369194, 1.647063084, 1.68438, 1.961585851, 2.276008438, 2.590367209, 2.904682853, 3.218967991]: B := Vector(11,(i)->`if`(i=1,1,S[i]*coth(S[i]))): A := Vector(11,(i)->2/(100*BesselJ(0,S[i]*10)^2)): C := Matrix(11,11, (i,j)-> B[j]*A[i]/1 * ( evalf(Int(BesselJ(0,S[i]*x)*BesselJ(0,S[j]*x)*x^(15.0/200.0),x=0.0..0.075)) + evalf(Int(BesselJ(0,S[i]*x)*BesselJ(0,S[i]*x)*BesselJ(0,S[j]*x)*x,x=0.076..10.0)) ) ); CI := C + LinearAlgebra[IdentityMatrix](11); LinearAlgebra[MatrixInverse](CI); acer

## Digits for precision....

Setting Digits will change the precision for calculations. If you change it once, at the top-level, then that change persists. Setting interface(rtablesize) changes the cutoff for sizes, above which once sees the "summary" of a Matrix/Vector/Array and below which one sees all the entries printed explicitly. Here too, you only need to set it once, and the change persists until you change it again or restart your session. acer

## Tools -> Options -> Precision...

Try the Tools -> Options -> Precision tab, in the Standard GUI. If you want to control the number of displayed digits without changing the precision of calculations then toggle-on the first choice, labelled "Round screen display to". acer

## display_zero_complex_part...

Try this, kernelopts(display_zero_complex_part=false); to suppress the display of precisely zero imaginary components of the entries of a Matrix, Vector, or Array. You can also get finer control over the mechanism to remove the small imaginary components by mapping fnormal() over the object. This does produce a new object, and does remove such small components rather than just suppress them in printing. ps. I suppose that this kernelopts option could be more correctly named as 'display_zero_imaginary_part'. Also, it might be more appropriate as an interface() option than a kernelopts() option. And should it appear in the Standard GUI's Tools->Options menu? acer

## hard to figure out what you want...

It isn't all clear to me what you are after. I may be misunderstanding it all the way through. I really didn't understand what the ranges of the i and j indices of C_ik are. So I just used all eleven of them. So fix that up. For the rest of it, well, the chances are good that I made at least some transcription error, if not worse. So look for that. # S is a list of the first 11 nonnegative roots of -BesselJ(1,x) ? # If so, then find these using fsolve with avoid={} option, or with plot. S := [0., 0.3831705970, 0.7015586670, 1.017346814, 1.332369194, 1.647063084, 1.68438, 1.961585851, 2.276008438, 2.590367209, 2.904682853, 3.218967991]: B := Vector(11,(i)->`if`(i=1,1,S[i]*coth(S[i]))): A := Vector(11,(i)->2/(100*BesselJ(0,S[i]*10)^2)): C := Matrix(11,11, (i,j)-> B[j]*A[i]/1 * ( evalf(Int(BesselJ(0,S[i]*x)*BesselJ(0,S[j]*x)*x^(15.0/200.0),x=0.0..0.075)) + evalf(Int(BesselJ(0,S[i]*x)*BesselJ(0,S[i]*x)*BesselJ(0,S[j]*x)*x,x=0.076..10.0)) ) ); CI := C + LinearAlgebra[IdentityMatrix](11); LinearAlgebra[MatrixInverse](CI); I don't see how animation comes into it. acer

## rtable iterator...

A routine which would allow efficient iteration over an rtable (Array, Matrix, Vector) as well as allow simultaneous access to the indices as each element is accessed would be very nice. It's unfortunate that it does not exist; using side-effects with rtable_scanblock is inefficient and does not scale well. You can map or Map over an rtable, but not get access to the indices as each element is dealt with. The same goes for syntax like, for x in A do .... od: # for rtable A As for the NULLs in your example, select() and its friends produce the same sorts of objects that they are passed. And it seems that the size of an Array is a quality preserved by select. So, some value is needed, and NULL is better than a default of 0, since 0 might have some special meaning for a given example of selection. acer

## loops would do, as would rtable_scanbloc...

You can write a routine to do this, using loops. Or you could have it use rtable_scanblock, which can be made to walk over Arrays, Matrices, and Vectors in all sorts of useful ways. One neat aspect is that, while walking such a structure, rtable_scanblock has access to the indices and so can save them elsewhere as a side-effect. For example, FindIndex := proc(comparison,A) local checkindex,G; checkindex := proc(val,ind) if comparison(val) then G[val] := op(ind); end if; NULL; end proc: rtable_scanblock( A, [rtable_dims(A)], checkindex, [[1],A[1]]); convert(G,list); end proc: foo := Array( 1..10 , i -> i ) * 2; FindIndex( x -> evalb( x mod 3 = 0 ), foo ); You could make it more general, depending on whether you want it to handle rtables of several dimensions or to return something other than a list. acer

## use cat, or ||...

Consider this sort of looping, for i from 1 to 100 do cat( "p", convert(5000+i,string) ); od; So, you can produce strings, for names of files, programmatically. acer

## could you be more specific?...

It's not clear whether you expect to create elements which have 20 decimal places of information, or whether you just want the Matrix to be able to hold such numbers. Matrix(2,2,(i,j)->evalf[20](1/(i+j+1)),datatype=sfloat); If the datatype of the Matrix is 'sfloat', which stands for software float, then the entries can have any number of digits. The precision of what can be assigned into the entries, after creation of such a Matrix, would depend on the environment variable Digits. See the help-page, ?UseHardwareFloats . Other ways to get a datatype=sfloat Matrix are, restart: UseHardwareFloats:=false: Matrix(2,2,(i,j)->evalf[20](1/(i+j+1)),datatype=float); MatrixOptions(%,'datatype'); restart: Digits := 20: Matrix(2,2,(i,j)->evalf(1/(i+j+1)),datatype=float); MatrixOptions(%,'datatype'); acer
 First 310 311 312 313 314 315 316 Page 312 of 316
﻿