PatrickT

Dr. Patrick T

2083 Reputation

18 Badges

13 years, 268 days

MaplePrimes Activity


These are answers submitted by PatrickT

you may want to search mapleprimes too for previous discussions on the topic, just a few posts below yours is a discussion on the classification of algebras that may (or may not) provide some hints for you:

http://www.mapleprimes.com/forum/programmedoesntworkmaple11why

It would help if you formatted your expression in Maple style.

In the Maple Help menu you may want to have a look at Mathematics->Algebra and then see what best fits your needs.

If you cannot find an exact analytical form, you may have to develop approximate analytic results in order to develop a regression model. As Robert suggested, a Taylor series expansion is one way to go. This is a very common way in economics and finance. I'm saying this because your model looks like it might be some probability-based finance model.

Thanks acer, this is incredibly helpful. I understand every point and won't forget.

 

> restart: with(PDEtools): declare(prime):

     The prime differentiation variable has not been declared yet

> M := VectorCalculus[Jacobian]([(q-b1)*(b2-q)+(q-b)*(diff(f(x),x)-q)*eta(c)/(f(x)-c)],[x]);

  M :=

        [(q - b) f[x, x] eta(c)   (q - b) (f[x] - q) eta(c) f[x]]
        [---------------------- - ------------------------------]
        [       f(x) - c                             2          ]
        [                                  (f(x) - c)           ]

> M2 := simplify(subs( q-b=-mu*(f(x)-c), eta(c)=lambda*(f(x)-c)/(diff(f(x),x)-q), f(x)-c=eta(c)*(diff(f(x),x)-q)/lambda, diff(f(x),x,x)=(lambda*diff(f(x),x)-nu)/eta(c), M));

                            M2 := [mu nu]

 

I understand it would be a pain to attempt to copy the code in this picture, so here is the code below:

> restart: with(PDEtools): declare(prime):

     The prime differentiation variable has not been declared yet

> M := VectorCalculus[Jacobian]([(q-b1)*(b2-q)+(q-b)*(diff(f(x),x)-q)*eta(c)/(f(x)-c)],[x]);

  M :=

        [(q - b) f[x, x] eta(c)   (q - b) (f[x] - q) eta(c) f[x]]
        [---------------------- - ------------------------------]
        [       f(x) - c                             2          ]
        [                                  (f(x) - c)           ]

> M2 := subs( q-b=-mu*(f(x)-c), eta(c)=lambda*(f(x)-c)/(f[x]-q), f(x)-c=eta(c)*(f[x]-q)/lambda, eval(M));

             M2 := [-mu f[x, x] eta(c) + mu lambda f[x]]

> M2 := simplify(subs(f[x,x]=(lambda*f[x]-nu)/eta(c), eval(M2))): eval(M2);

        [                                                           2
        [- mu (-f[x, x] eta(c) f[x] + f[x, x] eta(c) q + lambda f[x]

                                     ]
         - lambda f[x] q)/(-f[x] + q)]

> restart: with(PDEtools): declare(prime):

     The prime differentiation variable has not been declared yet

> M := matrix(1,1,[(q-b)*f[x,x]*eta(c)/(f(x)-c)-(q-b)*(f[x]-q)*eta(c)/(f(x)-c)^2*f[x]]);

  M :=

        [(q - b) f[x, x] eta(c)   (q - b) (f[x] - q) eta(c) f[x]]
        [---------------------- - ------------------------------]
        [       f(x) - c                             2          ]
        [                                  (f(x) - c)           ]

> M2 := subs( q-b=-mu*(f(x)-c), eta(c)=lambda*(f(x)-c)/(f[x]-q), f(x)-c=eta(c)*(f[x]-q)/lambda, eval(M));
>

             M2 := [-mu f[x, x] eta(c) + mu lambda f[x]]

> M2 := simplify(subs(f[x,x]=(lambda*f[x]-nu)/eta(c), eval(M2))): eval(M2);

                               [mu nu]
 

P.S. Oh wow, that is actually readable math output. Didn't know that copy-paste from a worksheet worked.

It is beyond my ability to resize this image. The medium sized links don't seem to work. And resizing by hand has no effect. Apologies.

 

Since I'm also totally unable to combine text with an image, I will post the image below. Hopefully. And no, I am completely unable to make maple tags work.


The weird thing about the following is that if I define the matrix via the matrix command the subs works, while if I derive the matrix from a VectorCalculus[Jacobian] command, it doesn't work anymore. As you can see from the output, the two matrices look exactly the same. Any suggestions on how to deal with this?

Thanks again!

 

www.mapleprimes.com/files/9249_mapleprimes_post13_image.jpg

 

Insert/Edit Image won't work today. I swear I managed to use it yesterday. Isn't that an image posted right under my name? Oh well, it's just one of those days...

perhaps, but it does the job. So I'm HAPPY.

The matrix:

M := matrix(2,2,[(q-b)*f[x,x]*eta(c)/(f(x)-c)-(q-b)*(f[x]-q)*
> eta(c)/(f(x)-c)^2*f[x],(q-b)*(f[x]-q)*eta[c]/(f(x)-c)+(q-b)*
> (f[x]-q)*eta(c)/(f(x)-c)^2,1+(f[x]-q)*eta(c)/(f(x)-c)-(q-b)*
> eta(c)/(f(x)-c),0]);

The first series of substitutions involving lambda and mu:

M2 := subs( q-b=-mu*(f(x)-c), eta(c)=lambda*(f(x)-c)/(f[x]-q), f(x)-c=eta(c)*(f[x]-q)/lambda, eval(M));
 
The second series of substitution, a little contrived perhaps, but does the trick:


M2[1,1] := simplify(subs(f[x,x]=(lambda*f[x]-nu)/eta(c), eval(M2[1,1]))): eval(M2);

looks like:


<maple>matrix([[mu*nu, -mu*(f[x]-q)*eta[c]-lambda*mu], [1+lambda+mu*eta(c), 0]]) ;</maple>

 

[The above is basically the same image I posted above of the matrix after all the tranformations have been made.]

 

P.S. Sorry about the Maple tags. Once again I have forgotten how to use them. I am so afraid to toggle this nightmarish Source button, was that what I was supposed to do...

thanks for taking the trouble to explain that acer. A  few years back I used to keep an old version, I think it was version 5, because there had been some major changes to Maple and my older simulations would have had to be rewritten. In any case I don't do that anymore.

Hey thanks Jakubi, I'll remember this nifty trick in the future.

How about this:

M := matrix(2,2,[(q-b)*f[x,x]*eta(c)/(f(x)-c)-(q-b)*(f[x]-q)*eta(c)/(f(x)-c)^2*f[x],(q-b)*(f[x]-q)*eta[c]/(f(x)-c)+(q-b)*(f[x]-q)*eta(c)/(f(x)-c)^2,1+(f[x]-q)*eta(c)/(f(x)-c)-(q-b)*eta(c)/(f(x)-c),0]);

My matrix is actually 3X3, but the following should encompass all of its challenges!

what would be the workaround for this one?

I very much appreciate everyone's help, thanks again.

The ability to call an older kernel is a pretty useful feature that exists in Stata. But I suppose its usefulness is perhaps not sufficient to justify carrying forward an ever bigger program. It looks like acer has access to several kernels.

For some reason I no longer understand subs({(f[x]-z)/(f(x)-y)=lambda},eval(M)); wasn't working when I posted my second question, but it is now, so I must have done something wrong the first time. Thanks Acer for showing me the steps. I'm able to reproduce them for this example.

However, what I was after is actually a little more involved. I had provided a stripped-down example initially, but now I guess I have to show a bigger, and uglier matrix. Here is an example involving a matrix, where the same simplifiable expression occurs in several of the cells.

M := matrix(2,2,[(x^4+x^2+1)^2,z*(f[x]-z)/(f(x)-y),x*(f[x]-z)/(f(x)-y)^2,(f[x]-z)^2/(f(x)-y)]);

simplify(simplify(subs(f[x]=f[X],eval(M)),{(f[X]-z)/(f(x)-y)=lambda}));

In my version of Maple13, the simplify command simplifies the squares rather than doing the requested substitution, and I don't want that. I want the factored expressions inside the matrix to remain factored and the one substitution to be made in all the cells in which it can be made, including where there are some squares occurring, i.e. I need Maple to understand that (f[x]-z)^2/(f(x)-y) = (f[x]-z) * {  (f[x]-z)/(f(x)-y)  }, where the curly brackets are meant to indicate a "syntactic" unit, as Robert explained above.

I didn't expect it to be so tricky... It takes less than a minute to do it by hand   ;-)

Oh and is it possible to set the kernel to an older version? I'm unable to compare V12 and V13. I am running V13.

many thanks for your help!

Patrick.

P.S. I use to understand how to use Maple tags but I can't seem to get it to work anymore, it just spits out garbage, very sorry.

Thank you so much Robert, 

a follow-up if I may:

The simplification sought is actually to be applied to several elements of a matrix M.

Is there a way I can substitute all the f[x] for f[X] inside the matrix M so that I may then apply simplify in the way you suggested?

Something along the lines of (doesn't work):

M2 := subs(f[x]=f[X],eval(M));

simplify(simplify(M2,{(f[X]-z)/(f(x)-y)=lambda}));

Thanks

 

You can simplify your system. Since the first equation is quadratic:

> eq1 := diff(x(t), t)+2*(diff(x(t), t))^2-y(t)-.1*z(t) = 0:
> eq1b := diff(x(t),t)=convert(expand(solve(eq1,diff(x(t),t))),rational);

The other two equations can be turned into first-order ODEs by a change of variable, such as:

u(t) = diff(y(t), t) and v(t) = diff(x(t), t)

 

First 21 22 23 24 Page 23 of 24