Ronan

1361 Reputation

16 Badges

13 years, 213 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are replies submitted by Ronan

@acer I am interested in $include usage in a package. That may solve a long term problem of storing all the procedures inside the package. Now this question from @mmcdara referencing module members within the module - MaplePrimes was linked in my email notification. I tried to copy what was done by @Joe Riel but could not get it to work. He states " To build the mla you would use a shell command". I do not know what that it or how to impliment it.
Basically I have copied an old package and cut it down to experiment with using two procedures I often use.

restart

Date()

_m2615960902368

cat(kernelopts(homedir), "/Documents/maple/Alibrary/Procedures")

"C:\Users\Ronan/Documents/maple/Alibrary/Procedures"

SignedArea := proc (a::{Vector, list}, b::{Vector, list}, c::{Vector, list, null} := null) local M, A; description "signed area of a line segment or 3 points"; if c = null then A := (1/2)*a[1]*b[2]-(1/2)*a[2]*b[1] else A := (1/2)*(b[2]-c[2])*a[1]+(1/2)*(-b[1]+c[1])*a[2]+(1/2)*c[2]*b[1]-(1/2)*c[1]*b[2] end if; return A end proc

proc (a::{Vector, list}, b::{Vector, list}, c::{Vector, list, null} := null) local M, A; description "signed area of a line segment or 3 points"; if c = null then A := (1/2)*a[1]*b[2]-(1/2)*a[2]*b[1] else A := (1/2)*(b[2]-c[2])*a[1]+(1/2)*(-b[1]+c[1])*a[2]+(1/2)*c[2]*b[1]-(1/2)*c[1]*b[2] end if; return A end proc

save SignedArea, "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/SignedArea.mpl"

NULL

NULL

`⊕` := proc (a, b) (a+b)/(1-a*b) end proc

proc (a, b) (a+b)/(1-b*a) end proc

NULL

save `⊕`, "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/⊕.mpl"

NULL

NULL

NULL

NULL

NULL

NULL

restart
mylibdir := cat(kernelopts(homedir), kernelopts(dirsep), "maple", kernelopts(dirsep), "toolbox", kernelopts(dirsep), "personal", kernelopts(dirsep), "lib")

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

NULL

libname := mylibdir, libname

"C:\Users\Ronan\maple\toolbox\personal\lib", "C:\Users\Ronan\maple\toolbox\2022\Physics Updates\lib", "C:\Program Files\Maple 2022\lib", "C:\Users\Ronan\maple\toolbox\CodeBuilder\lib", "C:\Users\Ronan\maple\toolbox\DirectSearch\lib", "C:\Users\Ronan\maple\toolbox\OEIS\lib", "C:\Users\Ronan\maple\toolbox\personal\lib", "C:\Users\Ronan\maple\toolbox\UTF8\lib"

libname

"C:\Users\Ronan\maple\toolbox\personal\lib", "C:\Users\Ronan\maple\toolbox\2022\Physics Updates\lib", "C:\Program Files\Maple 2022\lib", "C:\Users\Ronan\maple\toolbox\CodeBuilder\lib", "C:\Users\Ronan\maple\toolbox\DirectSearch\lib", "C:\Users\Ronan\maple\toolbox\OEIS\lib", "C:\Users\Ronan\maple\toolbox\personal\lib", "C:\Users\Ronan\maple\toolbox\UTF8\lib"

"AlgCalc:=module()  option  package;  export   `⊕`,                  SignedArea ;    local ModuleLoad ;  #` ModuleLoad := proc`()       #`end proc;`    $include  "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/SignedArea.mpl";  $include  "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/⊕.mpl";                     end module:"

Error, invalid `$` operator

"AlgCalc:=module() option package;  export `⊕`,  SignedArea ;   local ModuleLoad ;  #` ModuleLoad := proc`()       $include  "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/SignedArea.mpl";  $include  "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/`⊕`.mpl";            end module:"

savelib('AlgCalc')

NULL

NULL

restart

with(AlgCalc)

Error, invalid input: with expects its 1st argument, pname, to be of type {`module`, package}, but received AlgCalc

NULL

NULL


 

Download 29-10-22_Q_$include_Alg_Calc_Routines.mw

@acer I am away till next Thursday. I will look at your advice when I'm back.

@acer Thank you.  I am surprised I haven't been caught out by that before. For me I will use

gnrpoly:=proc(M::Matrix,var:=n)
.
.
.

return  p  

 end proc

 

@MathPrincess123 Is this what you want?

q := p^2;
nsr1 := simplify(NSR, 'assume = nonnegative');

nsr:=Quotient(nsr1,deltaa,p,'r')
r;

@MathPrincess123  Use the green arrow button to upload the worksheet

@Christian Wolinski ok I realised what you mean. That situation is not likely to occour for me. thank you.

@Christian Wolinski 

In the first post I had set a,b,c,d.  See attached. If this fatally flawed? I dont quite understand your answer.

restart

NULL

a, b, c, d := 1, -1, 1, -1

1, -1, 1, -1

a

1

b

-1

c

1

d

-1

``

Test := proc (a, b, c, d) if (a, b, c, d) = (1, 0, 1, -1) then print("foo") elif (a, b, c, d) = (1, 1, 1, -1) then print("bar") elif (a, b, c, d) = (0, -1, 1, -1) then print("foo-bar") elif (a, b, c, d) = (1, -1, 1, -1) then print("no-foo-bar") else print("no match") end if end proc

proc (a, b, c, d) if (a, b, c, d) = (1, 0, 1, -1) then print("foo") elif (a, b, c, d) = (1, 1, 1, -1) then print("bar") elif (a, b, c, d) = (0, -1, 1, -1) then print("foo-bar") elif (a, b, c, d) = (1, -1, 1, -1) then print("no-foo-bar") else print("no match") end if end proc

NULL

Test(a, b, c, d)

"no-foo-bar"

d := 0

0

Test(a, b, c, d)

"no match"

NULL

Download Q_19-9-22_test_if.mw

I worked it out

a, b, c, d := 1, -1, 1, -1;
if (a, b, c, d) = (1, 0, 1, -1) then
    print("foo");
elif (a, b, c, d) = (1, 1, 1, -1) then
    print("bar");
elif (a, b, c, d) = (1, -1, 1, -1) then
    print("foo-bar");
elif (a, b, c, d) = (0, -1, 1, -1) then
    print("no-foo-bar");
end if;

 

@tomleslie I ran into a situation where the procedure didn't work. I got to work. 

a[h]/(h + 1) as a coefficient caused a failure
getCP1 := proc(t, var := x) 
local cf, varpwr; 
if not has(t, var) then 
return <0, t>;
 elif op(-1, t) = var then
 return <1, `*`(op([1 .. -2], t))>;
    else varpwr, cf := selectremove(has, [op(t)], var);
    return <op(-1, op(varpwr)), `*`(op(cf))>; 
end if; 
end proc;

 

@dharr @tomleslie   Dharr. That is clever. Totally missed it myself.  Tomsile yes that is what I am looking for.

@vv @acer The docoument contained a various mixture of things I had tried.  continuous I see why now plotting from alpha=-1..1, m=2,n=3 there is a cusp.

    The square root of 3 can be positive or negative. So how should sign know which one should be referenced?

@acer Thank you. Maple could make the hyper insertion box select a bit more general. Shall study those links tonight.

@dharr  Oh mine ".ggb" opened with Geogebra fine. Also tested a PDF which opened with Adobe too. Thanks for the explination.

 

@dharr Thank you. This works fine for me.  file://localhost\C:\Users\Ronan\Documents\GeoGebra\UHG 4.ggb

but file:\\localhost\C:;\Users\.......   forces to  http://file:\\localhost\C:\Users\Ronan\Documents\GeoGebra\UHG 4.ggb which does not work.

I notice you used all forward slashes "/ " which also work. 

Is there a particular rule on the use of  \ and / in directory and file naming. I know I have had problems  on this before with Maple and library's

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