NeraSnow

40 Reputation

3 Badges

1 years, 179 days

MaplePrimes Activity


These are questions asked by NeraSnow

I am slightly confused as I can't apply the seemingly correct function to a sequence. It seems like modp does not like my inverse. But I am not aware of any other way of finding the modular inverse.  

a := i -> (1025 - 2^(10 - 2^i))^(-1) mod (1025 - 2^(10 - 2*2^i));

proc (i) options operator, arrow; `mod`(1/(1025-2^(10-2^i)), 1025-2^(10-2*2^i)) end proc

(1)

a(1);

5

(2)

a(2);

17

(3)

map(i -> i + 1, {seq(1 .. 4)});

{2, 3, 4, 5}

(4)

map(i -> 1/(1025 - 2^(10 - 2^i)) mod (1025 - 2^(10 - 2*2^i)), {seq(1 .. 4)});

Error, invalid input: modp received 65599/64, which is not valid for its 2nd argument, m

 

map(a, {seq(1 .. 4)});

Error, invalid input: modp received 65599/64, which is not valid for its 2nd argument, m

 

NULL

NULL

Download example.mw

tot := 1:         
for z in 1, x, y, q^2, 3 do    
    tot += z;  
end do:  
tot;

When I run the code above, Maple gives me "Error, unterminated loop".

However, if I change the code to 

tot := 1;
for z in 1, x, y, q^2, 3 do
    tot := tot + z;
end do:
tot;

Maple computes the result correctly.

I don't see how the loop is unterminated. Am I not allowed to use operator assignments in loops?

I have the following example.

> A:= Vector(3,symbol=v)

A:= Vector(3,symbol=v)

>v[1]:= 5

v[1]:=5


> A

 Vector(3,symbol=v)

 

Is there any way such that v[1] is actually referring to the first element in the vector? In other words, changing v[1] actually modifies the vector A.

 

If the question does not make sense, then here is the actual scenario that I faced.

I need to solve a system of equations in the form of 

2 = c[2] + a[1],
2 = 2*c[3] + a[2],
-2 = -3*c[1] + a[3],
-1 = -2*c[2] + a[1],
-1 = -c[3] + a[2],
1 = a[3]

where a[i], c[i] refers to the entries in the vector.

solve returns the following:

[[a[1] = 1, a[2] = 0, a[3] = 1, c[1] = 1, c[2] = 1, c[3] = 1]]

I then did an assign(%). However, the entries in A and C are not changed. I want the answer returned by solve to be properly applied to the entries of the vectors.

a := x -> x + 1;
b := x -> a(x) + x^2;
a := x -> x + 5;
b(x);
                            2        
                           x  + x + 5

However, I wish my b(x) to be x^2 + x + 1. How could I do it?

 I have the following code snippet.

f := x^11 + 2*x^9 + 2*x^8 + x^6 + x^5 + 2*x^3 + 2*x^2 + 1;
g := 2*x^10 + x^7 + 2*x^4 + x;

Gcd(f, g) mod 3;
                        9      6    3    
                       x  + 2 x  + x  + 2
with(Algebraic);
Gcd(f, g) mod 3;
                              6    
                             x  + 1

It is surprising to me that using a package actually changes the behaviour of functions not in the package!

Is this a bug or a feature that I am not aware of?

Page 1 of 1