Ronan

1022 Reputation

14 Badges

13 years, 160 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are replies submitted by Ronan

Edit....The below works and is lot simpler than what I was trying.  The fundamental problem is creating a procedure or module that has 2 stage inputs, data tables probably just add to that complexity.

 

@acer  Thank you. That is good.I simplified things by just using the matrix input pallet. And then using the the procedure to convert the matrix.


BiPolyNum := proc (N)
description "Creates Bi Polynumbers";
return ArrayTools:-Alias(N, [0 .. LinearAlgebra:-RowDimension(N)-1, 0 .. LinearAlgebra:-ColumnDimension(N)-1])
end proc;
                BiPolyNum := proc(N)  ...  end;

@acer Thank you. I have made some progress. I was using and array. Seems to cause the problem on slowness. Could be a bug.

I have it working outside of the procedure now. Still Struggling with the proc itself

I dont understand this statement "If I understand the question properly, then my Answer is as follows. The name of the unique Array/rtable/Matrix/Vector associated with a particular DataTable can be the argument to a procedure call, as can the unique string identity of a particular DataTable."

 Can you explain or show what that means?
 

restart

with(DocumentTools:-Components)

[Button, CheckBox, CodeEditRegion, ComboBox, DataTable, Dial, Label, ListBox, MathContainer, Meter, Microphone, Plot, RadioButton, RotaryGauge, Shortcut, Slider, Speaker, State, TextArea, ToggleButton, VideoPlayer, VolumeGauge]

(1)

with(DocumentTools:-Layout)

[Cell, Column, DocumentBlock, Equation, Font, Group, Image, InlinePlot, Input, Output, Row, Section, Table, Textfield, Title, Worksheet]

(2)

with(DocumentTools)

[AddIcon, AddPalette, AddPaletteEntry, Components, ContentToString, CreateTask, Do, GetDocumentProperty, GetProperty, InsertContent, InsertTask, Layout, RemovePalette, RemovePaletteEntry, RemoveTask, Retrieve, RunWorksheet, SetDocumentProperty, SetProperty, Tabulate]

(3)

NULL

ary := Matrix(4, 4)

Matrix(%id = 18446746160571978686)

(4)

 

 

NULL

DT := DataTable(identity = "DataTable0", variable = 'ary', rowheader, columnheader, columnnames = [beta^0, beta, beta^2, beta^3], rownames = [alpha^0, alpha, alpha^2, alpha^3])

xml := Worksheet(Group(Input(Textfield(DT))))

DocumentTools:-InsertContent(xml)

ary

Matrix(%id = 18446746160571978686)

(5)

PN1 := ArrayTools:-Reshape(convert(ary, Array), 0 .. 3, 0 .. 3)

Array(%id = 18446746160572000846)

(6)

Matrix(PN1)

Matrix(%id = 18446746160630366566)

(7)

PN1[0, 0]

8

(8)

``

ArrayDims(PN1)

0 .. 3, 0 .. 3

(9)

``

BiPolyNum := proc (a := 4, b := 4) local ary, mat, DT; description "Creates Bi Polynumbers"; mat := Matrix(a, b); DT := DataTable(identity = "DataTable1", variable = 'mat', rowheader, columnheader, columnnames = [1, beta, beta^2, beta^3], rownames = [1, alpha, alpha^2, alpha^3]); DocumentTools:-InsertContent(xml); return ArrayTools:-Reshape(convert(mat, Array), 0 .. a-1, 0 .. b-1) end proc

proc (a := 4, b := 4) local ary, mat, DT; description "Creates Bi Polynumbers"; mat := Matrix(a, b); DT := DocumentTools:-Components:-DataTable(identity = "DataTable1", variable = 'mat', rowheader, columnheader, columnnames = [1, beta, beta^2, beta^3], rownames = [1, alpha, alpha^2, alpha^3]); DocumentTools:-InsertContent(xml); return ArrayTools:-Reshape(convert(mat, Array), 0 .. a-1, 0 .. b-1) end proc

(10)

NULL

NULL

f := BiPolyNum()

Array(%id = 18446746160572026998)

(11)

f

Array(%id = 18446746160572026998)

(12)

Matrix(f)

Matrix(%id = 18446746160630355718)

(13)

``


 

Download DataTable_Experiment_rev_1.mw

this a further.

 

 

@one man Ok it all works fine now. That is a good link you posted.

Hello Tried to run your code,I get an error. It would be instructive to add explinations to your code.  

 

@_Maxim_ Hi, 

sb := Groebner:-NormalForm(Phi[1], `~`[`-`]([tobesbstd], [sbeqmaple18]), (tdeg@op@indets)(Phi[1]))

Could you possible explain the syntax of this line? It works great. 

@_Maxim_Thank you.  I am weak on Groebner basis. Shall experiment and see.

In Maple 18 the expand term is not needed inside algsubs.

for k to 4 do
for i to 6 do
`sbΦ`[1] := simplify(algsubs(tobesbstd[i] = sbeqmaple18[i], expand(`sbΦ`[1])))      #   This expand
end do
end do;
simplify(`sbΦ`[1]); sort(expand(evalf(`sbΦ`[1])))      #and this expand not needed in maple 18

"this is repeated until the leading monomial in f is less than the leading monomial in a" .  I think I understand this.

In my loop above set k to 1 so it only does the whole substitution once, the equation will still contain highter order terms.  On the second time around the loop in this equation they all reduce. So round 3 and 4 not needed in this case. It the coefficients are different they might be.  I had 12 other equations one required repeating the substitution set 6 times.

THe example of using algsubs(x^2 = x*y, x^3); is very simple the the complexitits don't arise.

@acer   I just tried your code. Problem occurs with 3.1, 3.41, 4.22, evalf(10/3) all returm false

Now 4.2, 10/3,  135265467/791  will return true.  Some short decimals work.

Basicially seems to be a problem with how decimals are handled

using `Maple 2017.3, X86 64 WINDOWS, Sep 27 2017, Build ID 1265877`

@Carl Love That would be interesting to see.

@Ramakrishnan Hello,

The workbook didn't upload. Can you try again please. If it doesn't upload could you describe the solution if there is one.

Ronan.

Assuming there is no friction. Say the weight is on a pulley. As the pulley is not rotating the forces/torques on the pulley balance.

Each point in the rope is static, i.e is a state of equilibrium. So so the forces balance producing no net motion  So as T1 and T2 act is opposite directions at any given point in the rope they are equal and opposite. T1+T2=0 T2= -T1.  The tension in the rope is just T1. Rope does not break. 

This can be hard to see if you are not used to thinking about it. As simpler example would be a vertical rope attached to the ceiling with a weight hang from it. Say 100N. So there is a reaction force of 100N in the opposite direction at the ceiling. You would not sum the the force and reaction force to get 200N tension in the rope. But as the reaction force negative to the applied force each point in the string experiences both forces which sum to zero.  So each point is static.

Hope that helps explain.

@John Fredsted Thank you. I got $include to work. Just had to be specific on the folder to look in.

TestjEdit:=module()
option package;
export Testr1;
$include "C:/Users/Ronan/Documents/jEdit/Testr1.mpl"
end module;

Regerding question 1. Can jEdit be made to automatically indent the code.? That is what I would like or is this all manual?

Regarding 2 read is displaying a procedure ok with or without the ; How do I get it to display the contents of a module?

read "C:\\Users\\Ronan\\Documents\\jEdit\\TestjEdit.mpl";
                  TestjEdit :=module(0 ... end module

which is not informative.

Q3...as I suspected

@acer I hadn't meant to insist on reading in a .mla. I presume you are refering to my last nights reply "What for the syntax...".

I was posting that before I saw your reply. Rest assured you answer here has dissuaded me from that route. I made the mistake of trying to write a .mpl file to the library archive a few days ago. 

As an aside. It is such a pity the search on Primes is so limited. In a couple of years you answers will be burried and almost impossible to find. 

@acer  Thank you. Your explinations are very well thought out.

Methord 1 is simple though inefficient as you say. I at least I got it to work easily last night.

I gather when you say a plain text file you mean the file was created in a code editor (Emacs, notepad or someother). I thing I understand you reasoning here. So you would not recomend creating a procedure in Worksheet 1 and saving that out as a .mlp then reading or using $include to get the .mlp into the module because that creates 2 files. I haven't used code editors. Don't have a programming background so my think is probably different to a programmers. Hence my unusual approach, aka lack of knowledge.

Method 2. Yes, I see the neatness. I had tried $include before but couldn't get it to work inside Maple. Programming guide says use command line to run it.

I downloaded the Codebuilder package at the weekend. Still failed to get $include to work.  Are you familiar with this package? i posted this question at the weekend https://www.mapleprimes.com/questions/222558-How-Do-I-Use-The-CodeBuilder-Package 

I see this would still create 2 files i.e. the CodeBuilder worksheet and the exported .mlp file. But it may get me used to the idea of a code editor and still be insidde Maple, so can test on the fly.

Conclusion I need to learn a simple code editor. Which would you recomend?

 

@phil2 Ok. Thank you.  I know how to basicially make a package. Hadn't used savelib before though. With your nice example as there are 2 exports f and g, lets keep f as it is (for reference).  Now can you prior to makeing M save g as a proc or module then read/load it into M. Then savelib ('M', lib) , restart, with(M) , f(x) will still work fine but will g work. I have been unable to get g(x) to work. This is the problem I have been having.

@Mac Dude  Ok, I duplicated what you did and that worked as you showed. I then restarted and loaded package with(Rtestm).  Then the Rtest would not work as shown. Any idea why? At least the problem is narrowed down somewhat.

restart

Rtest := proc () ` `*print("this is a test") end proc

proc () ` `*print("this is a test") end proc

(1)

Rtest()

` `*()

(2)

``

currentdir("C:\\Users\\Ronan\\Documents\\MAPLE\\Rational_Trinonometry")

"C:\Users\Ronan\Documents\MAPLE\Rational_Trinonometry"

(3)

libname

"C:\Program Files\Maple 2017\lib", "C:\Users\Ronan\maple\toolbox\personal\lib"

(4)

libdir := libname[2]

"C:\Users\Ronan\maple\toolbox\personal\lib"

(5)

save Rtest, "Rtest.mpl"

restart

Rtest()

Rtest()

(6)

Rtestm := module () export Rtest; option package;  read cat(currentdir(), "/Rtest.mpl") end module

_m2688721854496

(7)

``

LibraryTools:-Save(Rtestm, cat(libdir, "/Rtestm.mla"))

``

``

``

Rtest()

` `*()

(8)

restart

``

currentdir(); libname; libdir := libname[2]

"C:\Users\Ronan\maple\toolbox\personal\lib"

(9)

``

with(Rtestm)

[Rtest]

(10)

``

Rtest()

Rtestm:-Rtest()

(11)

Rtestm:-Rtest()

Rtestm:-Rtest()

(12)

``


 

Download xtest.mw

 

First 14 15 16 17 18 19 20 Last Page 16 of 24