nhmacuk

25 Reputation

3 Badges

3 years, 161 days

MaplePrimes Activity


These are questions asked by nhmacuk

I want to do the substitution f(t) - ff(t) = epsilon for any variable t in Maple:

 

expand(myerror);
    2 f(x - 2 h)   f(x)   3 f(x + 3 h)   2 ff(x - 2 h)   ff(x)
  - ------------ - ---- + ------------ + ------------- + -----
        15 h       6 h        10 h           15 h         6 h

       3 ff(x + 3 h)
     - -------------
           10 h     


NULL;
myfunc := t -> f(t) - ff(t) = epsilon;
 myfunc := proc (t) options operator, arrow, function_assign;

    f(t)-ff(t) = epsilon end proc


algsubs(myfunc(t), myerror);
          2               1        3            
        - -- f(x - 2 h) - - f(x) + -- f(x + 3 h)
          15              6        10           
        ----------------------------------------
                           h                    

               2                1         3             
             - -- ff(x - 2 h) - - ff(x) + -- ff(x + 3 h)
               15               6         10            
           - -------------------------------------------
                                  h                     


NULL;
subs(f(-h*n + x) = 1, ff(-h*n + x) = 0, f(x) = 1, ff(x) = 0, f(h*m + x) = 1, ff(h*m + x) = 0, myerror)*epsilon;
                           4 epsilon
                           ---------
                             15 h   

 

How do I change equations from the 2D-output into definitions?

#! Change the order (this case second):
solve({-alpha[-1] + 2*alpha[2] = 1, 1/2*alpha[-1]*h + 2*alpha[2]*h = 0, alpha[-1]/h + alpha[0]/h + alpha[2]/h = 0}, {alpha[a], alpha[b], alpha[c]});
          /            -2             1             1\
         { alpha[-1] = --, alpha[0] = -, alpha[2] = - }
          \            3              2             6/

NULL;
lhs({alpha[-1] = -2/3, alpha[0] = 1/2, alpha[2] = 1/6}[1]) := rhs({alpha[-1] = -2/3, alpha[0] = 1/2, alpha[2] = 1/6}[1]);
     /            -2\       / /            -2             1  
  lhs|alpha[-1] = --| := rhs|{ alpha[-1] = --, alpha[0] = -,
     \            3 /       \ \            3              2  

               1\    \
    alpha[2] = - }[1]|
               6/    /

 

 

Why am I not able to replace O(h^3), and in what other way can I achieve the result (I want to get the coefficients of the f(x), D(f)(x), and D^(2)(f)(x) variables).

Q(h);
1 /          /                                       2    / 3\\
- |alpha[-2] \f(x) - 2 D(f)(x) h + 2 @@(D, 2)(f)(x) h  + O\h //
h \                                                            

   + alpha[0] f(x)

              /                     9                 2    / 3\\\
   + alpha[3] |f(x) + 3 D(f)(x) h + - @@(D, 2)(f)(x) h  + O\h /||
              \                     2                          //


NULL;


subs(f(x) = 1, D(f)(x) = 0, (D@@2)(f)(x) = 0, O(h^3) = 0, collect(Q(h), f(x)));
                         /     / 3\\            /     / 3\\
    alpha[0]   alpha[-2] \1 + O\h // + alpha[3] \1 + O\h //
    -------- + --------------------------------------------
       h                            h                      

 

How do I combine greek letters and latin letters in variable names? e.g. here I want to combine the greek letter Delta and the latin letter x to be used as one variable name:


Delta*x;
                            Delta x

Deltax;
                             Deltax

 

 

The original question (crossed through below) was too vague, so I tried to clarified it:

I have the following expression
Q(h);
 1 /  2                    1                 2    / 3\   1     
 - |- - f(x) - D(f)(x) h + - @@(D, 2)(f)(x) h  + O\h / + - f(x)
 h \  3                    2                             2     

      1                                        2    / 3\\
    + - f(x) + 2 D(f)(x) h + 2 @@(D, 2)(f)(x) h  + O\h /|
      6                                                 /


It doesn't expand this following way...
expand(Q(h));
      /                   1                 2    / 3\\       
    2 |f(x) - D(f)(x) h + - @@(D, 2)(f)(x) h  + O\h /|       
      \                   2                          /   f(x)
  - -------------------------------------------------- + ----
                           3 h                           2 h

                                              2    / 3\
       f(x) + 2 D(f)(x) h + 2 @@(D, 2)(f)(x) h  + O\h /
     + ------------------------------------------------
                             6 h                       


But it does expand when I add the multiplication symbols manually:
expand(2*(f(x) - D(f)(x)*h + 1/2*(D@@2)(f)(x)*h^2 + O(h^3))/(3*h) + f(x)/(2*h) + (f(x) + 2*D(f)(x)*h + 2*(D@@2)(f)(x)*h^2 + O(h^3))/(6*h));
                                                    / 3\
       4 f(x)   1           2                    5 O\h /
       ------ - - D(f)(x) + - h @@(D, 2)(f)(x) + -------
        3 h     3           3                      6 h  

How can I expand my output without having to add the multiplication symbols?


------------------------------------old question below, please disregard----------------------






Page 1 of 1