How to simplify the size of the equation using predefined variables in maple?

65 Views Asked by At

I am working on some simple calculations using maple for my assignment. I have an equation say $x=a$, I assigned it in maple like $$x:=a$$ Later in my calculation I got some $y$ as

$$y=a^2+\sin(a)$$

I need $y$ in terms of $x$ not in $a$ like $y=x^2+\sin(x)$.

Please help me in this regard.

1

There are 1 best solutions below

1
On BEST ANSWER

You don't need to execute the assignment x:=a; in order to utilize an equation like x=a.

Similarly, you don't have to execute the assignment n:=(y -> sqrt(b/v)*y); in order to utilize that as a definition of an operator for n.

The same thing goes for 2D Input syntax, where you don't need to execute the assignment n(y):=sqrt(b/v)*y; in order to utilize that as a definition for n as an operator.

In other words, if these assignments are getting in your way, then simply don't make them. You can use similar equations instead of those assignments. And you can even utilize them selectively, so that they don't affect all your computations.

For your first example, you can produce either form, with a or with x.

restart;

defn1 := x = a:

y := x^2 + sin(x):

Now y is in terms of just x.

y;

             2         
            x  + sin(x)

And you don't need to produce the following (unless you want to),

eval(y, defn1);

             2         
            a  + sin(a)

Let's look at your followup example.

The same technique from the earlier example can be used.

restart;
defn := n = (y -> sqrt(b/v)*y):
nu := -sqrt(b*v)*f(n(y)):

Notice that we have not assigned anything to n.

raw := diff(nu,y);

                     (1/2)            / d      \
        raw := -(b v)      D(f)(n(y)) |--- n(y)|
                                      \ dy     /

We can make a new equation from defn,

new := diff(n(y),y) = eval(diff(n(y),y), defn);

                                    (1/2)
                       d         /b\     
               new := --- n(y) = |-|     
                       dy        \v/     

Again, we have not assigned anything to n. But we can re-evaluate the result raw above and utilize the new equation to make a replacement (substitution).

ans := eval(raw, new);

                                          (1/2)
                      (1/2)            /b\     
         ans := -(b v)      D(f)(n(y)) |-|     
                                       \v/     

I suspect that you have omitted some assumptions that b and v are both positive. Under those assumptions the radicals in the result ans will simplify, and we have a choice of commands that will do that.

combine(ans) assuming b>0, v>0;

                     -b D(f)(n(y))

simplify(ans) assuming b>0, v>0;

                     -b D(f)(n(y))

The moral of the story is this: don't make assignments that you don't want. You can use the eval command with equations to perform selective substitution.