Joe Riel

9660 Reputation

23 Badges

20 years, 20 days

MaplePrimes Activity


These are replies submitted by Joe Riel

PrimeCol := proc(m::integer, n::integer)
local L;
    L := select(isprime, [seq(m..n)]);
    printf("%{t}d\n", Matrix([L]));  # ?rtable_printf for details. t transposes.
end proc:
PrimeCol := proc(m::integer, n::integer)
local L;
    L := select(isprime, [seq(m..n)]);
    printf("%{t}d\n", Matrix([L]));  # ?rtable_printf for details. t transposes.
end proc:

I believe Will gave me that priviledge; I do have a "full HTML" option.  I had used it before we changed to the new editor and it worked then (though I didn't try it with the output of htlatex, which uses a lot of tags). Not sure why I had problems this time, maybe it works on a subset of full html.

Hmm. I think I see the issue.  htlatex generates a cascaded style sheet for its generated html.  That is, given the source file myblog.tex, I get myblog.html and myblog.css.  Is it possible to embed the css into the html?  My html knowledge is minimal.

Over the weekend I worked on a blog entry.  I attempted to write it in LaTeX, then use htlatex to convert it to html and insert the whole thing into my blog.  That alas, didn't work.  It displayed properly in the input window, but not at all in the preview window.  Guess we're stuck with the restricted tags and hand editing.

Depending on what is to be preserved, we could do

id := x->x: `print/%id` := curry(``):
expr := ((x+1)^5/a+(x+2)^6/(y^2+y)^3 + 1) / (x^37-1) + ((a^2-a-b)^2)/(x-1) - 1/x:
expr2 := evalindets(expr, `+`^posint, %id):
expr3 := evalindets(expr2, `+`^negint, x -> 1/%id(1/x)):
value(numer(expr3));

Depending on what is to be preserved, we could do

id := x->x: `print/%id` := curry(``):
expr := ((x+1)^5/a+(x+2)^6/(y^2+y)^3 + 1) / (x^37-1) + ((a^2-a-b)^2)/(x-1) - 1/x:
expr2 := evalindets(expr, `+`^posint, %id):
expr3 := evalindets(expr2, `+`^negint, x -> 1/%id(1/x)):
value(numer(expr3));

Thanks for this suggestion; I need to remember the % technique.  You could assign

`print/%id` := curry(``):

then %id will typeset like the empty function. Maybe I'll have to stick that in my initialization file...

 

Thanks for this suggestion; I need to remember the % technique.  You could assign

`print/%id` := curry(``):

then %id will typeset like the empty function. Maybe I'll have to stick that in my initialization file...

 

Here's another approach.

expr := (x+1)^5/a+(x+2)^6/(y+1)^3:
numer(evalindets(expr, anything &+ integer, ``)):
eval(%, ``=(x->x));
                                              5        3          6
                                       (x + 1)  (y + 1)  + (x + 2)  a

Using the empty function (``) to suppress the expansion is nicer than using freeze in that the intermediate expressions mimic their value. Any inert function could be used, but the empty function is less obtrusive; too bad we cannot use expand to evaluate it.

Here's another approach.

expr := (x+1)^5/a+(x+2)^6/(y+1)^3:
numer(evalindets(expr, anything &+ integer, ``)):
eval(%, ``=(x->x));
                                              5        3          6
                                       (x + 1)  (y + 1)  + (x + 2)  a

Using the empty function (``) to suppress the expansion is nicer than using freeze in that the intermediate expressions mimic their value. Any inert function could be used, but the empty function is less obtrusive; too bad we cannot use expand to evaluate it.

So what is a nice way to handle that?  More generally, something a bit more complicated, so that we cannot just use op directly:

expr := (x+1)^5/a + (x+2)^6/b:

I don't believe frontend will work here.  We could use freeze/thaw:

expr2 := subs([seq(ex=freeze(ex),ex in [x+1,x+2])], expr);
                                                        5            6
                                               freeze/R0    freeze/R1
                                      expr2 := ---------- + ----------
                                                   a            b

thaw(numer(expr2));                                       
                                                  5            6
                                           (x + 1)  b + (x + 2)  a

Another approach is

expand(denom(expr)*expr,indets(expr, anything^{5,6})[]);
                                                  5            6
                                           (x + 1)  b + (x + 2)  a

That won't work with something like the following, where we want to keep the powers intact.

expr := (x+1)^5/a + (x+2)^6/(y+1)^3; 

freeze/thaw, of course, could be used here.  I find it curious that freeze doesn't have an option for returning an equation of the form expr = frozen_expr, since I suspect must usages of it need that form.  Presumably that shows the age of this useful relic.

So what is a nice way to handle that?  More generally, something a bit more complicated, so that we cannot just use op directly:

expr := (x+1)^5/a + (x+2)^6/b:

I don't believe frontend will work here.  We could use freeze/thaw:

expr2 := subs([seq(ex=freeze(ex),ex in [x+1,x+2])], expr);
                                                        5            6
                                               freeze/R0    freeze/R1
                                      expr2 := ---------- + ----------
                                                   a            b

thaw(numer(expr2));                                       
                                                  5            6
                                           (x + 1)  b + (x + 2)  a

Another approach is

expand(denom(expr)*expr,indets(expr, anything^{5,6})[]);
                                                  5            6
                                           (x + 1)  b + (x + 2)  a

That won't work with something like the following, where we want to keep the powers intact.

expr := (x+1)^5/a + (x+2)^6/(y+1)^3; 

freeze/thaw, of course, could be used here.  I find it curious that freeze doesn't have an option for returning an equation of the form expr = frozen_expr, since I suspect must usages of it need that form.  Presumably that shows the age of this useful relic.

Though it's hard to say, without seeing the actual code, I suspect that concats, etc, are actually local variables in a constructor that returns the random number generator. Something like

CreateRNG := proc()
local concats, offset; # etc
   proc() global seed; ...  end proc:
end proc:

RNG := CreateRNG(1..10):

 

Though it's hard to say, without seeing the actual code, I suspect that concats, etc, are actually local variables in a constructor that returns the random number generator. Something like

CreateRNG := proc()
local concats, offset; # etc
   proc() global seed; ...  end proc:
end proc:

RNG := CreateRNG(1..10):

 

You might also want to reduce the coefficients (integers) to 1.  An easy way to do that is

subsindets(poly, integer, 1);
Another approach, less dangerous looking, is
collect(poly, indets(poly,'name'), 1);
First 137 138 139 140 141 142 143 Last Page 139 of 195