acer

32490 Reputation

29 Badges

20 years, 8 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Ronan No, there is a bug in plottools:-line that it works with unassigned names in the data. It should throw an error line `point` does. That's my opinions, anyway. Better is to delay evaluation, as I showed.

How about checking that dy/dx = 1/(-tan(t*(n+1)/n)) and consider when the denominator of that tends to zero? How often can that occur, given the bounds on t?

@vv Yes, I agree. I do not know offhand whether the following discrepancy is by design or oversight.

plottools:-line([0, 0, 0],[a,b,c]);
                   CURVES([[0., 0., 0.], [a, b, c]])

plottools:-point([a,b,c]);          
Error, (in plottools:-point) incorrect arguments for creating
 points structure, try providing the dimension option

plottools:-point([a,b,c],dimension=3);
Error, (in Plot:-Structure:-Points) points cannot be converted
 to floating-point values

@vv I gave three ways of doing it: using either unevaluation quotes, or the animate syntax (which splits command and its args), or both. Each of the three pairs (for line and point) have both calls being similar. No special difference as far as one (of the pair) goes versus the other,

I did this to contrast with your suggestion to use POINTS instead of point, which of course is indeed a special difference.

I suggest, therefore, that preventing premature evaluation (here, at least) by using uneval-quotes can work with a more consistent methodology than does replacement of command-name or use of internal structures. It's not alays true, but it is here, and often is.

@vv 
 

restart;

a := 21*arccos(RootOf(448*_Z^7+192*_Z^6-784*_Z^5-288*_Z^4
                    +392*_Z^3+108*_Z^2-49*_Z-6, index = 2))/Pi;

21*arccos(RootOf(448*_Z^7+192*_Z^6-784*_Z^5-288*_Z^4+392*_Z^3+108*_Z^2-49*_Z-6, index = 2))/Pi

b := -(21*I)*ln(RootOf(7*_Z^14+6*_Z^13+6*_Z+7, index = 2))/Pi;

-(21*I)*ln(RootOf(7*_Z^14+6*_Z^13+6*_Z+7, index = 2))/Pi

# The following works, but it's not altogether clear why.
#
evala(convert(convert(a-b,RootOf),arccos));

0

# The reason I say it's not clear is that the above works by
# virtue of turning `a` into the following form.
#
# NB. The conversion of `b` is more clear in this:
#    convert(convert(a-b,RootOf),arccos) + convert(b,arccos)
#
# NB. But that form of `a` is not done by just, say,
#    convert(convert(a,RootOf),arccos)
# which doesn't do anything.
#
simplify(convert(convert(a-b,RootOf),arccos) + convert(b,arccos));

21*arccos(-(1/2)*RootOf(7*_Z^14+6*_Z^13+6*_Z+7, index = 2)^13-(3/7)*RootOf(7*_Z^14+6*_Z^13+6*_Z+7, index = 2)^12+(1/2)*RootOf(7*_Z^14+6*_Z^13+6*_Z+7, index = 2)-3/7)/Pi

# The following turns that into `a`.
# But I would rather have the means to go the other way.
#
evala(Simplify( evalc(%) ));

21*arccos(RootOf(448*_Z^7+192*_Z^6-784*_Z^5-288*_Z^4+392*_Z^3+108*_Z^2-49*_Z-6, index = 2))/Pi

# So here is the first of two other methods to show that a = b .
#
# This works by finding a dependence relationship between
# the RootOfs.
#
evala(Indep(indets(a,specfunc(RootOf))
            union indets(b,specfunc(RootOf)),'s'));
eq := s[1];

false

RootOf(7*_Z^14+6*_Z^13+6*_Z+7, index = 2) = RootOf(-2*_Z*RootOf(448*_Z^7+192*_Z^6-784*_Z^5-288*_Z^4+392*_Z^3+108*_Z^2-49*_Z-6, index = 2)+_Z^2+1)

# The next step actually produces `a` explictly from `b`
# (That is often harder than computing that a - b = 0 and
# so this is much nicer.)
#
radnormal(convert(eval(b,eq),arccos));

21*arccos(RootOf(448*_Z^7+192*_Z^6-784*_Z^5-288*_Z^4+392*_Z^3+108*_Z^2-49*_Z-6, index = 2))/Pi

% - a;

0

# And here is another way to turn `b` into `a` directly.
#
evala(Simplify( evalc(radnormal(convert(b,arccos))) ));

21*arccos(RootOf(448*_Z^7+192*_Z^6-784*_Z^5-288*_Z^4+392*_Z^3+108*_Z^2-49*_Z-6, index = 2))/Pi

% - a;

0

# FWIW...
#
W := op(indets(b, specfunc(RootOf)));

RootOf(7*_Z^14+6*_Z^13+6*_Z+7, index = 2)

evala( evalc(abs(W)) );

1

 


Download conver.mw

[edited] When I say, "not altogether clear why" I mean that `evala` may be looking for the dependence between the RootOfs, so as to return the result having just one as preferred. So perhaps it clarifies by doing it in steps, etc.

@tomleslie By using the combine(...,units) command first you can reduce both sides to common (canonical) units, before stripping them off as unit_free.

See my Answer below, from earlier today.

@Gibberish123 I don't understand what your last Comment is about, sorry.

@Preben Alsholm The last time this occured I used the Mapleprimes Search facility, and then submitted the following as a bug report. I will add this current item.

Here's a full list of my search results, with an attempt at classification:

AB 22/11/2016 http://www.mapleprimes.com/questions/220122-Incomplete-Worksheet
       08/11/2016 http://www.mapleprimes.com/questions/219874-Cant-Open-Saved-Maple-Document
A    12/10/2016 http://www.mapleprimes.com/questions/219045-Maple-Wont-Open-My-File
A    06/10/2016 http://www.mapleprimes.com/questions/218743-There-Was-A-Problem-During-The-Loading
      20/06/2016 http://www.mapleprimes.com/questions/213635-Suddenly-I-Cant-Open-My-Maple-File
      08/06/2016 http://www.mapleprimes.com/questions/213228-There-Were-Problems-During-The-Loading
B    22/05/2016 http://www.mapleprimes.com/questions/212631-Error-When-Loading-Mw-File
A    18/01/2016 http://www.mapleprimes.com/questions/208582-Problem-With-Loading-Mw-File
B    12/12/2014 http://www.mapleprimes.com/questions/203064-Incomplete-Worksheet
       29/09/2014 http://www.mapleprimes.com/questions/202488-There-Were-Problems-During-Loading-Process
A    09/04/2014 http://www.mapleprimes.com/questions/201351-There-Were-Problems-During-The-Loading
       08/05/2012 http://www.mapleprimes.com/questions/133893-File-Open-Errore
       14/02/2012 http://www.mapleprimes.com/questions/130656-There-Where-Problems-During-The-Loading
       09/01/2012 http://www.mapleprimes.com/questions/129478-There-Was-Problems-During-The-Loading-Process
A    06/01/2012 http://www.mapleprimes.com/questions/129377-There-Were-Problems-During-The-Loading
       19/12/2011 http://www.mapleprimes.com/questions/128950-There-Were-Problems-During-The-Loading
A     09/10/2011 http://www.mapleprimes.com/questions/126390-There-Were-Problems-During-Loading-Process
A     09/09/2011 http://www.mapleprimes.com/questions/125503-Incomplete-Worksheet
A     06/09/2011 http://www.mapleprimes.com/questions/125457-There-Were-Problems-During-The-Loading-Process
B     08/03/2011 http://www.mapleprimes.com/questions/102290-HELP-Maple-Worksheet-Wont-Open-Problems
A     01/12/2010 http://www.mapleprimes.com/questions/99712-There-Were-Problems-During-The-Loading-Process
A     27/09/2010 http://www.mapleprimes.com/questions/97218-Incomplete-Worksheet
        09/03/2010 http://www.mapleprimes.com/questions/35559-Incomplete-Worksheet-Lost-File
        10/09/2008 http://www.mapleprimes.com/posts/38707-Maple-Worksheet-Loading-Error
B     25/03/2008 http://www.mapleprimes.com/posts/38707-Maple-Worksheet-Loading-Error

Problem A) Users who seem to be Danish, (opgave, projekt):
Sometimes there are invalid characters present. Eg.
  "PCDATA invalid Char value 3"
  "hj\303\246lp"
  "sammenh\303\246ngen"
  Unicode 0xb a vertical tab
Sometimes the saved file is just a great many zero bytes.

Problem B) Unclosed XML tags (usually following an element with corrupted content):
Could not the GUI close off the pending open tags as well as give the error message about the worksheet being incomplete? That is to say, why does it only show the content from fully closed tags?

I have edited my Comment and deleted a suggestion to divide by N. I stand by the rest of my Comment.

@student_md 

Try plots:-display(p1,p2) .

@Gibberish123 I see. So for your (n,e) RSA scheme you'll need to generate a number num from the plaintext string such that gcd(num,n)=1 , and 0<=num<n .

Once you can do that, the encryption/decryption might be as follows:

restart:

n := 17;
                                       n := 17

L := numtheory[lambda](n);
                                       L := 16

e := 5;
                                       e := 5

evalb( e < L ); # a requirement 
                                        true

evalb( gcd(e, L) = 1); # a requirement
                                        true

d := 1/e mod L;
                                       d := 13

num := 10;  # a number generated from the plaintext string
                                       num := 10

c := num^e mod n;  # the encrypted number
                                        c := 6

c^d mod n;  # decrypting back to num
                                          10

In Maple, for a large n, it is more efficient to use the following command for modular exponentiation (which avoids explicit computation of num^e which happens when executing num^e mod n ).

modp(Power(num,e), n); # efficient modular exponentiation
                                           6

modp(Power(c,d), n); # efficient modular exponentiation  
                                           10

So given a plaintext ascii string you have to use an n, as well as figure out a way to convert from string to number, and pad, so that (at least) the following conditions hold:

evalb( gcd(num,n)=1 and num<n );
                                         true

@tomleslie It looks to me like your suggestion [edited to remove suggestion to divide by N] is the composite trapezoidal rule (or the average of the left and right Riemann sums, but not a mid-point Riemann sum).

It's not a wrong approach. But quite often one might attain a more accurate result with a higher order interpolation scheme (ie. higher than linear). Of course "quite often" relates to the smoothness of well-behavedness of the underlying function approximated by the data.

The OP has not mentioned accuracy or performance, unfortunately.

 

@Gibberish123 Correct, I did not implement RSA encryption/decryption for you. Are you hoping for someone to implement a secure padding scheme such as this? By the way, is this course work?

@Markiyan Hirnyk Your previous comments to your own answer above had,

int(c[2]*(diff(c[1], v)), v = 0 .. 9);

instead of,

int(c[2]*(diff(c[1], v)), v = 1 .. 6);

which you now use. My reply to you is that your initial upper end-point range for the parameter (ie, 9), while integrating, was invalid, which I would have thought was obvious in my previous response. You have not shown how you got "6" here, either.

Let's hope that the OP's data represents a mathematical funcion (one y value only for each x value), and not a more general curve.

@Markiyan Hirnyk I posted an Answer to the OP's question, not a Reply to your Answer. The OP did not supply data, as far as I have noticed, and as I was not replying to your Answer I see no special reason to use the same example data as you have.

And I have also used different interpolating commands from you, yes. I don't think that BSplineCurve is necessarily the right thing to use: there is a reason why the 3rd entry in the list it returns may not be a range (for the parameter denoting x(v) and y(v) ) that extends the curve as a mathematical function y(x) over all the independent data. A B-spline is a beast of another color, and one should be extra careful if trying to force it to cover the full range of the (supplied) independent data if a function (mathematical sense) is desired.

By "independent range as returned by BSplineCurve" of course I mean a range for the parameter (not the independent data variable).


 

restart;

with(CurveFitting):

xydata := Matrix([[0,0],[1,1],[4,9],[6,10],[8,5],[8,3]]):

c := BSplineCurve(xydata,v):

c[3];   # independent range returned by BSplineCurve

v = 3 .. 6

min(xydata[..,1]) .. max(xydata[..,1]); # independent range in xydata

0 .. 8

min(xydata[..,2]) .. max(xydata[..,2]); # dependent range in xydata

0 .. 10

plot(c, view=[min(xydata[..,1]) .. max(xydata[..,1]),
              min(xydata[..,2]) .. max(xydata[..,2])]);

plot([c[1],c[2],v = min(xydata[..,1]) .. max(xydata[..,1])]);

 


 

Download bsplinething.mw

First 289 290 291 292 293 294 295 Last Page 291 of 595