Dr. John May

## 2616 Reputation

16 years, 342 days
Maplesoft

## Social Networks and Content at Maplesoft.com

I have been a part of the Mathematical Software Group at Maplesoft since 2007. I have a Ph.D in Mathematics from North Carolina State University as well as Masters and Bachelors degrees from the University of Oregon. I have been working on research in computational mathematics since 1997. I currently work on symbolic solvers and visualization as well as other subsystems of Maple.

## randomness...

@JohnS Since there is some randomness in the choices of the "black" "pixels" the time it takes to find a prime can vary a lot.  I've found a prime of the Maple logo in less than two minutes, but I've also had it take more than 10 minutes on my three year old, but not especially powerful desktop computer.

## code only...

@Axel Vogt It's tricky to isolate the image to ASCII image stuff as "code only" since the threshhold value that works best in the conversion to 1-bit color depends a lot on the input image, therefore I wrote it from almost the begining as an interactive application.   But here is some of the code from a very early version:

```opic :=  ImageTools:-Read(foo);
m := ImageTools:-Height(opic); n := ImageTools:-Width(opic);

bwpic := ImageTools:-RGBtoGray(opic);

W := 78; # width of ASCII image
pic := ImageTools:-Scale(bwpic, (W-2)/(1.4*n), (W-2.)/n);

# pad with 1-character border - Array(Matrix is a hack, ArrayTools has a better way
spic := Array(Matrix(ImageTools:-PadImage(pic, top = 1, left = 1, border = 1, fill = 0.)));

black := RandomTools:-Generate(choose([3, 5, 6, 8, 8, 8, 8, 9, 0, 0]), makeproc = true);
white := RandomTools:-Generate(choose([1, 1, 1, 1, 1, 2, 4, 7]), makeproc = true);

# the 0.15 value may be far from optimal depending on the source image
pic := ImageTools:-Threshold(spic, 0.15, high = 0., low = 1.)

# this is the array of numerals that makes the picture:
ipic := Matrix(64, 64, datatype = integer,(i, j)-> `if`(pic[j,i] = 0, black(), white()));

# this proc prints the picture
displaymatrix := proc (A) local r, c, i, j; r,
c := rhs~([rtable_dims(A)])[];
for j to r do
for i to c do
printf("%d", A[i, j]);
end do;
printf("\n");
end do;
end proc;
```

## @fereydoon_shekofte Thanks!  Though...

@fereydoon_shekofte Thanks! I've always though of myself as more of a wizard than a sorceror

## Yes!  Pineapple and hot peppers!...

Yes!  Pineapple and hot peppers!

## Slight Improvement...

You can improve the rendering slightly by reordering so that you draw the kite beginning and ending at the origin.

```M:= [[[-.55, 0.95e-1], [-.733, .236], [-.49, .245]],
[[-.342, .536], [-.355, .859], [-.138, .622]],
[[.342, .536], [.355, .859], [.138, .622]],
[[.55, 0.95e-1], [.733, .236], [.49, .245]],
[[0, 0], [-.216, .216], [-.81, 0], [-.216, -.216], [0, 0]],
[[0, 0], [0, .376], [-.705, .705], [-.376, 0], [0, 0]],
[[0, 0], [.376, 0], [.705, .705], [0., .376], [0, 0]],
[[0, 0], [.216, -.216], [.81, 0], [.216, .216], [0, 0]],
[[0, 0], [.267, .267], [0, 1], [-.267, .267], [0, 0]]];```

I did:

```plots:-display(seq(plot(M[i], thickness = 8, color = cat("Niagara ", 10-i)), i = 1 .. numelems(M)),
plot([[0, -.5], [0, 0]], thickness = 8, color = "Niagara 1"), axes = none, scaling = constrained)```

## Double Underscore for subscript...

@quo Type double underscores in 2D math: m__a these will show up as subscripts and don't have some of the problems of using m[a] instead.

## @acer It's worth noting, that you do...

@acer It's worth noting, that you don't need the awkward evalf(Int( syntax.  You can use the 'numeric' option:

```int(Fg, [0..1, 0..2.2], numeric,  epsilon=1e-9);
```

or just make sure the limits of integration are floating point:

`int(Fg, [0.0..1.0, 0.0..2.2], epsilon=1e-9);`

## When I try it, it appears to work fine f...

When I try it, it appears to work fine for me in Maple 2016.2.  When checking be sure to: remove all the old output from your worksheet, restart, and re-execute.

## solve/parametric...

Maple will solve inequalities with parameters in them, but only if the expressions are rational functions.  So, the sqrt in your problem makes things tricker.

Here is an example of that where your expression has been multiplied by its conjugate:

```expr:=0 < 2*b^2*(10*a*K+3*K*b-sqrt((K+(2*a*K+1)/b)^2-4*K/b)*b+5)*(10*a*K+3*K*b+sqrt((K+(2*a*K+1)/b)^2-4*K/b)*b+5);
solve( expand~(expr), {a}, parametric);```

## @tomleslie Playing around, Digits:=30; m...

@tomleslie Playing around, Digits:=30; might be enough but Digits:=25 is not enough.

## avoid directly calling allvalues(RootOf(...

Just a note:  while solve may sometimes give a bare RootOf() as an answer, the usage pattern of allvalues( RootOf(equation, variable) );  is almost never better than calling solve(equations, variable); unless you know exactly what you are doing.

## msolve...

I think the command you are looking for is msolve.

## Are you just trying to test ideal member...

Are you just trying to test ideal membership or are you trying to do something more esoteric than that?

## Help for ?do...

You could start at the help page for repetition statemetns in Maple https://www.maplesoft.com/support/help/maple/view.aspx?path=do if you need more help than that, you may need to include more details about what you are trying to do.

 1 2 3 4 5 6 7 Last Page 2 of 19
﻿