User:Coderjoe/Sandbox2: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<lang |
<lang parigp>compose(f,g)={ |
||
x -> f(g(x)) |
|||
}; |
|||
fcf()={ |
|||
fun {Compose F G} |
|||
my(A,B); |
|||
fun {$ X} |
|||
A=[x->sin(x), x->cos(x), x->x^2]; |
|||
{F {G X}} |
|||
B=[x->asin(x), x->acos(x), x->sqrt(x)]; |
|||
end |
|||
for(i=1,#A, |
|||
end |
|||
print(compose(A[i],B[i])(.5)) |
|||
⚫ | |||
fun {Cube X} X*X*X end |
|||
⚫ | |||
Usage note: In Pari/GP 2.4.3 the vectors can be written as |
|||
fun {CubeRoot X} {Number.pow X 1.0/3.0} end |
|||
<lang parigp> A=[sin, cos, x->x^2]; |
|||
B=[asin, acos, x->sqrt(x)];</lang> |
|||
in |
|||
for |
|||
F in [Float.sin Float.cos Cube] |
|||
I in [Float.asin Float.acos CubeRoot] |
|||
⚫ | |||
{Show {{Compose I F} 0.5}} |
|||
end |
|||
⚫ |
Latest revision as of 20:38, 16 July 2011
<lang parigp>compose(f,g)={
x -> f(g(x))
};
fcf()={
my(A,B); A=[x->sin(x), x->cos(x), x->x^2]; B=[x->asin(x), x->acos(x), x->sqrt(x)]; for(i=1,#A, print(compose(A[i],B[i])(.5)) )
};</lang> Usage note: In Pari/GP 2.4.3 the vectors can be written as <lang parigp> A=[sin, cos, x->x^2];
B=[asin, acos, x->sqrt(x)];</lang>