## 962 Reputation

16 years, 38 days
University of Kent
Dr

## printf for list 0 format conversion help...

Maple 17

Hi all,

Say I have some list like this,

tmp:=[[0, 0, 1], [0, 1, 0], [0, 1, 1], [0, 1, 2], [1, 0, 0], [1, 0, 1], [1, 0, 2], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 2, 0]];

And I have worked out some probabilities for each of them, a,b,c,d, ect.

I want to print them like this

Pr( 001 ) = 1

Pr( 010 ) = 1-phi[2]+phi[2]*(1-p[3])*(1-phi[3])

Pr( 011 ) = phi[2]*p[3]*(1-phi[3])

and so on.

I there a way to do that?

The probabilities can be extracted from a Vector. I have no problem to print them.

I dont know how to convert the 0,1,2 into the desired format as shown above.

This is the best I can do.

Also, is it possible to convert all the subscripte [] to _ when printing the output?

and get ride of all * as well.

Thanks,

casperyc

## use expression as function input argueme...

Maple 17

Say I have the following loops:

for C from 1 to 10 do
r:=[]:
for K from 2 to 10 do
r:=[op(r),2*K+2*C-3];
end do:
print(r);
end do:

for C from 1 to 10 do
r:=[]:
for K from 2 to 10 do
r:=[op(r),K*C+K+C-2];
end do:
print(r);
end do:

I wonder how could I write a procedure, say use expressions "2*K+2*C-3" and "K*C+K+C-2" as input arguments?

so I can call up like :

myfun(K*C+K+C-2) or myfun("K*C+K+C-2")

myfun(2*K+2*C-3)

I dont care whether the output(s) are lists, tables, or matrices.

My main difficulty is to get the expression to be procedure inputs.

Though if the output can be a  10 by 9 matrix, it's better.

Thanks,

casper

## paired sequence in reverse order...

Maple 17

Hi,

tmp:=seq([phi[5-j]*(1-p[6-j]),phi[5-j]*p[6-j]],j=1..4);
Vector(8,[seq(op(tmp[i]),i=1..4)]);

"tmp" is basically what I want. Some kind of 'paired' terms, indexed in reverse order.

I wonder if there is a better (perhaps more efficient and "direct") way to do it?

Thanks,

casper

## Simplification algebraically siderules...

Maple 17

Hi all,

In short, I want to use

'ss' expression(1)

to simplify

'kappa' expression (2).

At the moment, I can only archieve it through solving for each variable and get to expression (5).

simplify using siderules failes in this case. Is there another way to do it?

Thanks,

Casper

## Creat reverse order sequence...

Maple 17

Hi all,

seq(a[i],i=1..3);

Works fine.

seq(a[i],i=3..1);

gives nothing.

But if what I really want, is a ordered sequence

for i from 3 by -1 to 1 do

r:=[op(r),a[i]];

end do;

a[3],a[2],a[1]

What's the best way to get it? (apart from writing a loop)

Casper

 First 8 9 10 11 12 13 14 Last Page 10 of 31
﻿