Ronan

1207 Reputation

14 Badges

12 years, 216 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are replies submitted by Ronan

@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

@acer Ideally I would like the link to open the file in geogebra,  or for the sake of the principle, open a MS Office file with Word, Excel, etc.

@Carl Love Yes, I do understand. I appreciate you help. I was wandering around trying different things.Easy miss the typos doing that.  That is what I was trying to communicate. 

@Carl Love Yes. I had tried the sequence of strings which worked in one test. Then when I hit problem I thought it might be the commands.  Yes I was trying the unevaluation quotes too. Just my bad typing.

@tomleslie  Thank you. The Isee came about because sometimes I want to use one of my routines from inside a package to answer a question here. showstat puts in line numbers and Describe doesnt normally give the whole procedure

Make it easy to copy and paste.

Isee(CrossingNumber);
proc(A::list, B::list, C::list, E::list)
    local s1, s2, s3, s4;
    description " Determines if AB crosses CE.   Returns 1 or -1 if cros\
    ses, 0 if does not cross or undefined if alined";
    s1 := RonanRoutines:-SignedArea(A, B, C);
    s2 := RonanRoutines:-SignedArea(A, B, E);
    s3 := RonanRoutines:-SignedArea(C, E, B);
    s4 := RonanRoutines:-SignedArea(C, E, A);
    if s1 = 0 and s2 = 0 and s3 = 0 and s4 = 0 then
        'undefined';
    elif 0 <= signum(s1) and signum(s2) <= 0 then
        if 0 <= signum(s3) and signum(s4) <= 0 then -1; end if;
    elif signum(s1) <= 0 and 0 <= signum(s2) then
        if signum(s3) <= 0 and 0 <= signum(s4) then 1; end if;
    else
        0;
    end if;
end proc
showstat(CrossingNumber);

RonanRoutines:-CrossingNumber := proc(A::list, B::list, C::list, E::list)
local s1, s2, s3, s4;
   1   s1 := RonanRoutines:-SignedArea(A,B,C);
   2   s2 := RonanRoutines:-SignedArea(A,B,E);
   3   s3 := RonanRoutines:-SignedArea(C,E,B);
   4   s4 := RonanRoutines:-SignedArea(C,E,A);
   5   if s1 = 0 and s2 = 0 and s3 = 0 and s4 = 0 then
   6       'undefined'
       elif 0 <= signum(s1) and signum(s2) <= 0 then
   7       if 0 <= signum(s3) and signum(s4) <= 0 then
   8           -1
           end if
       elif signum(s1) <= 0 and 0 <= signum(s2) then
   9       if signum(s3) <= 0 and 0 <= signum(s4) then
  10           1
           end if
       else
  11       0
       end if
end proc
Describe(CrossingNumber);

#  Determines if AB crosses CE. Returns 1 or -1 if crosses, 0 if does not cross 
# or undefined if alined
s=00000289E0D8ED68, invalid component 8,3 of PROC

 

First 11 12 13 14 15 16 17 Last Page 13 of 29