tomleslie

13876 Reputation

20 Badges

15 years, 181 days

MaplePrimes Activity


These are replies submitted by tomleslie

@guru kido 

This is so basic!!!

H0 is a 2 x 2 matrix
g0 is a 4 x 1 column vector,

so when you write

d0=-H0*g0

what do you expect????

Also, in  the 'while' condition Norm(g(v0)) > 1e-6, where is the definition of the function g() ???

@guru kido 

what is H0 ??

It dosn't *seem* to be initialized

You should upload your actual worksheet using the big green up-arrow in the Mapleprimes toolbar.

There isn't much that can be done with the non-editable, non-executable picture of your code.

If I had to guess ( from just reading what you supply), I would check all "multiplication" operators - you seem to have a mixture of

  '*',

a baseline '.',

and a midline '.',

@litun 

and is not helped by your decision to use tables rather than (say) Arrays as basic data structures.

Using Arrays would have greatly simplified your code for setting up the equation system.

However the following *seems* to work for your new test case

restart

with(LinearAlgebra); interface(rtablesize = 10); interface(version); Physics:-Version()

`Standard Worksheet Interface, Maple 2019.0, Windows 7, March 9 2019 Build ID 1384062`

 

"C:\Users\TomLeslie\maple\toolbox\2019\Physics Updates\lib\Physics Updates.maple", `2019, April 26, 7:48 hours, version in the MapleCloud: 353, version installed in this computer: 350.`

(1)

Ne, Ng := 25, 20

25, 20

(2)

Lambda := 20; `μe` := 20.0; `μg` := 4; r := .35; rb := 1-r; c := 20.0; fe, fg := 100, 50

20

 

20.0

 

4

 

.35

 

20.0

(3)

Pne := proc (i) options operator, arrow; add(Pvals[i+1, j+1], j = 0 .. Ng) end proc; Ce := proc (n) options operator, arrow; fe+c*(n+1)/`μe` end proc; Cg := fg+c/`μg`+r*fe+r*add(i*Pne(i), i = 1 .. Ne); Wepc := proc (T) options operator, arrow; add(Lambda*Ce(n)*Pne(n), n = 0 .. T-1)+add(Lambda*Cg*Pne(n), n = T .. Ne) end proc; Sepc := proc (T) options operator, arrow; add(Lambda*(Ce(n)-fe)*Pne(n), n = 0 .. T-1)+add(Lambda*(-fe*r+Cg-fg)*Pne(n), n = T .. Ne) end proc; Eepc := proc (T) options operator, arrow; add(i*Pne(i), i = 1 .. Ne)/Lambda end proc

Warning, `j` is implicitly declared local to procedure `Pne`

 

Warning, `n` is implicitly declared local to procedure `Wepc`

 

Warning, `n` is implicitly declared local to procedure `Sepc`

 

Warning, `i` is implicitly declared local to procedure `Eepc`

 

for T to 20 do for i to Ne do if i <= T then Id[i] := 1 else Id[i] := 0 end if; if i = T then Idt[i] := 1 else Idt[i] := 0 end if end do; eqn[0, 0] := Lambda*P[0, 0] = `&mu;g`*rb*P[0, 1]+`&mu;e`*P[1, 0]; for j to Ng-1 do eqn[0, j] := (Lambda+`&mu;g`)*P[0, j] = `&mu;g`*rb*P[0, j+1]+`&mu;e`*P[1, j] end do; for i to Ne-1 do eqn[i, 0] := (Lambda+`&mu;e`)*P[i, 0] = `&mu;g`*r*P[i-1, 1]+`&mu;g`*rb*P[i, 1]+Lambda*Id[i]*P[i-1, 0]+`&mu;e`*P[i+1, 0] end do; for j to Ng-1 do for i to T do eqn[i, j] := (Lambda+`&mu;e`+`&mu;g`)*P[i, j] = `&mu;g`*r*P[i-1, j+1]+`&mu;g`*rb*P[i, j+1]+Lambda*Idt[i]*P[i, j-1]+`&mu;e`*P[i+1, j]+Lambda*P[i-1, j] end do; for i from T+1 to Ne-1 do eqn[i, j] := (Lambda+`&mu;e`+`&mu;g`)*P[i, j] = `&mu;g`*r*P[i-1, j+1]+`&mu;g`*rb*P[i, j+1]+`&mu;e`*P[i+1, j]+Lambda*P[i, j-1] end do end do; eqn[0, Ng] := (Lambda+`&mu;g`)*P[0, Ng] = `&mu;e`*P[1, Ng]; for i to T-1 do eqn[i, Ng] := (Lambda+`&mu;e`+`&mu;g`)*P[i, Ng] = `&mu;e`*P[i+1, Ng]+Lambda*P[i-1, Ng] end do; eqn[T, Ng] := (`&mu;e`+`&mu;g`)*P[T, Ng] = `&mu;e`*P[T+1, Ng]+Lambda*P[T, Ng-1]+Lambda*P[T-1, Ng]; for i from T+1 to Ne-1 do eqn[i, Ng] := (`&mu;e`+`&mu;g`)*P[i, Ng] = `&mu;e`*P[i+1, Ng]+Lambda*P[i, Ng-1] end do; eqn[Ne, 0] := (Lambda+`&mu;e`)*P[Ne, 0] = `&mu;g`*r*P[Ne-1, 1]+`&mu;g`*rb*P[Ne, 1]; for j to Ng-1 do eqn[Ne, j] := (`&mu;g`*rb+`&mu;e`+Lambda)*P[Ne, j] = `&mu;g`*r*P[Ne-1, j+1]+`&mu;g`*rb*P[Ne, j+1]+Lambda*P[Ne, j-1] end do; eqn[Ne, Ng] := (`&mu;g`*rb+`&mu;e`)*P[Ne, Ng] = Lambda*P[Ne, Ng-1]; Normeq1 := add(add(P[i, j], i = 0 .. Ne), j = 0 .. Ng) = 1; Eqns1 := {Normeq1, seq(seq(eqn[i, j], i = 0 .. Ne), j = 0 .. Ng)}; V := [indets(Eqns1)[]]; nops(V); AB := GenerateMatrix(Eqns1, V, augmented); Vsol := LinearSolve(AB); Pvals := Matrix(Ne+1, Ng+1, proc (i, j) options operator, arrow; Vsol[(i-1)*(Ng+1)+j] end proc); printf("\t\t%2d  %12.6f  %12.6f  %12.6f\n", T, Wepc(T), Sepc(T), Eepc(T)) end do

                 1   1904.454382     64.954382      0.028763

                 2   1947.304616     59.183671      0.054903

                 3   1974.236578     61.392230      0.081735

                 4   1994.948679     66.874014      0.108933

                 5   2012.701759     73.922512      0.136032

                 6   2028.645438     81.854920      0.162888

                 7   2043.326486     90.365205      0.189571

                 8   2057.104559     99.276343      0.216150

                 9   2070.226182    108.473483      0.242659

                10   2082.859817    117.879284      0.269114

                11   2095.121868    127.440299      0.295522

                12   2107.094358    137.118662      0.321886

                13   2118.836354    146.886895      0.348208

                14   2130.391312    156.724624      0.374486

                15   2141.791844    166.616451      0.400721

                16   2153.062879    176.550546      0.426912

                17   2164.223793    186.517699      0.453059

                18   2175.289886    196.510657      0.479162

                19   2186.273415    206.523660      0.505221

                20   2197.184337    216.552105      0.531237

 

numelems(Eqns1); numelems(V)

547

 

546

(4)

 


 

Download lSol2.mw

@litun 

  1. You now have 442 equations in 441 unknowns so the sytem is "overdetermined" - I just hope it is still consistent! How many equations were you expecting??
  2. Final calculation of T, Wepc(T), Sepc(T), Eepc(T) depends on a function Pne() which is defined nowhere, which is why the 'printf()' statement doesn't work
  3. I'd avoid the 'assign()' statement. This will cause chaos the second time the loop executes becuase all of the "unknowns" in your equations will actually have been assigned values -(unless you are doing something really clever which I have missed).
  4. So far as I can tell the solution 'Vsol' of the LinearSolve() command is never used - except for the (very undesirable) assignment noted in (3) above. Is this deliberate?

 

 

If I examine the problem with T=1, then

numelems(Eqns1) returns 5752 - so 5752 equations

and

numelems(V); returns 5821 - so 5821 unknowns; this is not good!

The unknowns appear to be

P[0,,70, 0..80]  giving 5751 unknowns

Id[1..69]  a further 69 unknowns

idt[1] 1 more unknown

for a total of 5751+69+1=5821

I suggest you make sure that the number_of_equations = number_of_unknowns before going any further

@mmcdara 

So basically you now want colored text in colored boxes, as in the attached.

Or have I missed something?

  restart:

  with(LinearAlgebra):
  with(plots):
  with(plottools):
  interface(rtablesize=10):

  RM := RandomMatrix(10):
  p1:= textplot
       ( [ seq
           ( seq
             ( [ i-1/2,
                 j-1/2,
                 RM[i,j],
                 font=[times, bold, 20],
                 color = piecewise
                         ( RM[i,j]<-50,
                           cyan,
                           RM[i,j]<=0,
                           green,
                           RM[i,j]<=50,
                           blue,
                           red
                         )
               ],
               i=1..10
             ),
             j=1..10
           )
         ]
       ):
  p3:= display
       ( [ seq
           ( seq
             ( rectangle
               ( [i-1, j-1],
                 [i, j],
                 color = piecewise
                         ( RM[i,j]<-50,
                           red,
                           RM[i,j]<=0,
                           yellow,
                           RM[i,j]<=50,
                           green,
                           cyan
                         )
               ),
               i = 1..10
             ),
             j = 1..10
           )
         ]
       ):
  display([p1,p3], size=[1000,1000]);

 

 


 

Download pretty2.mw

@ecterrab 

everything working now

@wswain 

Can only suggest that you upload here

  1. An example of the sort of (big) Excel file (,xls or .xlsx) you are dealing with
  2. A Maple workheet illustrating (a couple of) thetypical  calculations/selections you are trying to perform, hopefully including some sort of indication of the output format required

For both of the above, use the big green up-arrow in the Mapleprimes toolbar for file upload

From the description(s) which you have supplied, I think I'd be tempted to convert the Excel data to a Maple dataframe (particularly if your original file comes with row/column "headers"), and then subsequently use select() functions to extract any desired entries for further processing.

Obviously, without the data or detailed specification of the requirement, this is pure guesswork on my part!

@itsme 

what is wrong with my original response?? Two possibilities

  1. Input to be translated is not valid Mathematica code
  2. Output is not valid Maple code

Which is it?

@itsme 

mathematica's lprint version of the greek letters in this case - note that they are actually correctly interpreted.

These characters are not correctly interpreted - otherwise you wouldn't have a problem.

  1. Don't ask Maple to translate the output of Mathematica's lprint() command.
  2. Try asking Maple to translate Mathematica commands
  3. (2) above works. (1) above doesn't. What is difficult to understand?

@vv 
the ode system

sqrt(x) * y'(x) = 1,  y(0) = 0.

at x=0, reduces to

sqrt(0)*y'(x)|x=0=1, y(0) = 0

or

0*y'(x)|x=0=1, y(0)=0

Now precisely what value of the quantity y'(x)|x=0 makes this true?

@Rouben Rostamian

that by "hmp method" the OP actually means the "HPM method" or "homology-perturbation method". There have been several questions here on this subject in the past.

The OP can examine previous discussions on the topic by entering either 'HPM' or 'homology perturbation' in the Mapleprimes search box .

Failing that, then the specific problem should be supplied

You should post worksheets, not "pictures of worksheets"

A picture of a a worksheet in not executable: it is not editable. So no-one here can do anything but read it before making suggestions.

Now imagine how easier it would be if you posted something people could edit/execute! Maybe even make minor edits to eliminate errors and supply you with corrected code.

Think how beneficial this would be

And all you have to do is

  1. Save your worksheet
  2. Upload the workdheet using the big green up-arrow in the Mapleprimes toolbar
  3. Probably quicker than using your 'picture' tool and so much more useful for anyone responding here
  4. So why not do it this way?

 

that you are trying to generate Malfatti circles, then you might want to take a look at the attached which does the first few stages in the construction.NB this is incomplete

I am short of time now (and over the next couple of days) so this may not be completed for a while (even if it is what you want - which is just a wild guess)

#
# Initialize
#
  restart;

#
# Load some packages and use the interface(rtablesize=10)
# command, just to ensure that this worksheet will display
# OK on the MApleprimes website
#
  with(plots):
  with(geometry):
  interface(rtablesize=10):
#
# Start the real work by defining three points and using
# them to construct a triangle and its incircle
#
  point( A, [-1, 5]):
  point( B, [-7, -1]):
  point( C, [12, -1]):
  triangle(T, [A, B, C]):
  incircle(ic, T, `centername`=IC):
#
# Generate three sub-triangles whose vertexes
# are two of those in the original triangle,
# plus the centre of the incircle - so these
# three triangles have vertexes
#
#      [A, B, IC]
#      [A, C, IC]
#      [B, C, IC]
#
# And generate the incircles of these triangles
#
  triangle(T__AB, [A, B, IC]):
  triangle(T__AC, [A, C, IC]):
  triangle(T__BC, [B, C, IC]):
  incircle(i__AB, T__AB, `centername`=c__AB):
  incircle(i__AC, T__AC, `centername`=c__AC):
  incircle(i__BC, T__BC, `centername`=c__BC):
#
# Calculate the points where each of these
# subsidiary incircles "touches" the edge
# of the original triangle
#
# Name these as
#
# the point X is where incircle i__AB touches edge AB
# the point Y is where incircle i__BC touches edge BC
# the point Z is where incircle i__AC touches edge AC
#
  intersection(X, line(lAB, [A,B]), i__AB):
  intersection(Y, line(lBC, [B,C]), i__BC):
  intersection(Z, line(lAC, [A,C]), i__AC):
#
# Construct a diagram showing the triangle, the three
# sub- triangles, the inCircle of the original triangle,
# and the incircles of the sub-triangles (just because
# visualization always helps)
#
  d1:= draw( [ A(color=black,     symbol=solidcircle, symbolsize=12),
               B(color=black,     symbol=solidcircle, symbolsize=12),
               C(color=black,     symbol=solidcircle, symbolsize=12),
               X(color=green,     symbol=solidcircle, symbolsize=12),
               Y(color=green,     symbol=solidcircle, symbolsize=12),
               Z(color=green,     symbol=solidcircle, symbolsize=12),
               IC(color=black,    symbol=solidcircle, symbolsize=12),
               c__AB(color=black, symbol=solidcircle, symbolsize=8),
               c__AC(color=black, symbol=solidcircle, symbolsize=8),
               c__BC(color=black, symbol=solidcircle, symbolsize=8),
               T(color=blue),
               T__AB(color=cyan,  linestyle=dot,      thickness=4),
               T__AC(color=cyan,  linestyle=dot,      thickness=4),
               T__BC(color=cyan,  linestyle=dot,      thickness=4),
               ic(color=red,      linestyle=dot,      thickness=4),
               i__AB(color=green),
               i__AC(color=green),
               i__BC(color=green)
             ],
             scaling=constrained,
             axes=none,
             size=[1200,1200]
           ):
#
# Produce some text annotations for the diagram
#
  t1:= textplot( [ [coordinates(A)[], "A"],
                   [coordinates(B)[], "B"],
                   [coordinates(C)[], "C"],
                   [coordinates(X)[], "X"],
                   [coordinates(Y)[], "Y"],
                   [coordinates(Z)[], "Z"],
                   [ coordinates(IC)[],    convert(`IC`, string)    ],
                   [ coordinates(c__AB)[], convert(`c__AB`, string) ],
                   [ coordinates(c__AC)[], convert(`c__AC`, string) ],
                   [ coordinates(c__BC)[], convert(`c__BC`, string) ]
                 ],
                 font=[times, roman, 20], align=above
               ):
#
# Display the diagram with the annotations, just to see
# where we are at
#
# There is still a long way to go in order to generate
# Malfatti circles!
#
  display([t1, d1]);

 

 


 

Download malf.mw

 

First 68 69 70 71 72 73 74 Last Page 70 of 207