How to declare a generic variable as a function of time in Maplesoft so that chainrule can be applied? - maple

I hope someone could give me some help on using Maple for symbolic computation.
Below is my code to declare a generic variable eta as a function of time:
I notice that when I differentiate eta with respect to time , 0 is returned. However, what I would like to have is eta_dot. Ultimately I would like to take the time derivative of column matrix at the very bottom in the screenshot above. How should I acheive this?

Your first line,
eta := t -> eta
is meaningless, and should be removed (to avoid it confusing things).
Elsewhere, if you intended eta to represent an (unspecified/placeholder) expression in t you should be using eta(t) instead.
For example,
restart;
# examples with unspecified functions of t
eta(t);
eta(t)
diff(eta(t), t);
d
--- eta(t)
dt
expr1 := sin(eta(t));
expr1 := sin(eta(t))
diff(expr1, t);
/ d \
|--- eta(t)| cos(eta(t))
\ dt /
expr2 := sin(eta(t)) * cos(beta(t));
expr2 := sin(eta(t)) cos(beta(t))
diff(expr2, t);
/ d \
|--- eta(t)| cos(eta(t)) cos(beta(t))
\ dt /
/ d \
- sin(eta(t)) |--- beta(t)| sin(beta(t))
\ dt /
You didn't explain what that Vector represents, so that part of you question is unclear. I will mention that I see what look like several missing multiplication signs (explicit *, or implicit space to denote that) in your 2D Math image. I suggest you be very careful with that, and if it's a recurring source of syntax mistakes for you, that you consider switching to 1D plaintext "Maple Notation" for input.

Related

Is there a way to add multiple conditions while doing the product in Maple?

Note: I've searched for the answer to this already but I can't find what I need. I may have overlooked something or maybe this is referred to in a different way. I'll delete this if someone points out that it is a duplicate, please let me know.
Question: How can I add multiple conditions to the product or mul in Maple?
Example: I am trying to re-create the following, I cannot seem to find a way to add both r != k and r=1 as parameters.
I've gone over the documentation of the product command and maybe I am missing something.
Conditional products can be achieved using sets for index range (in the example below R is a set or can be a list, but set is better in this case since it's easier to remove its members), but that set must not have unknown parameters (so it's a numeric range).
For example:
[> j:=6: k:=3:
R:={seq(s, s in {seq(s,s=1..j-1)} minus {k})};
mul(r/(r-k), r in R);
The output will be:
R := {1, 2, 4, 5}
10
You can do it without additional variable R too:
[> mul(r/(r-k), r in {seq(s, s in {seq(s,s=1..j-1)} minus {k})});
A comparison of mul and product:
mul works only for numeric ranges and there should be no infinity involved, it also works for r in R case.
product can work with symbolic ranges, also range can have infinity, but it doesn't work for r in R case.
product is more powerful, but mul is much faster, so for numeric ranges mul should be always used instead (similarly add should used instead of sum for numeric ranges).
You can use mul with parameters too, but the range should be numeric (R is defined above):
[> mul((a+r)/(b+r-k), r in R);
The output:
If you want the formula that you showed in your question to be displayed symbolically as you have, I don't have any idea at the moment in Maple. As you may have seen in the help page of product, it only accepts ranges of the form idx=n..m or idx=n and that's it. But if you have values in k and j and want to receive the result of your formula, you can use mul, not product. As #Robai did a comparison in her answer between mul and product, the important thing here is that product does not support its second argument (the range) to be in the form idx in set, no "in" for product and that means you can not use product for your case even with the formulation given in #Robai's answer.
Now for mul, other than the set-minus idea of #Robai's answer. Here is another approach (you can read more about it in another answer I posted for another question in this link https://stackoverflow.com/a/72498377/6195473).
j := 5:
k := 2:
idxs := select( x -> x <> k, [ seq( r, r = 1..j-1 ) ] );
(k/(j-k)) * mul( r/(r-k), r in idxs );
Here is a screenshot from the output.

Why does `evalb(((3*x + 1)^5)(3*x - 1)/x^6 = ((3 + 1/x)^5)(3 - 1/x)) assuming (0 < x)` return `false` in Maple?

The question should perhaps be why does (3*x + 1)^5 * (3*x - 1) / x^6 = (3 + 1/x)^5 * (3 - 1/x) evaluate to false in Maple, even with the assumption that x > 0. The same expression evaluates to true in Mathematica and, of course, the statement itself is mathematically true under the previous assumption.
Maple's help pages don't give any clue on why this happens, and I would like someone to explain this behaviour before I think that Maple's evalb() is kind of broken. It is the type of questions I'm asking myself lately, since I'm deciding wether I should learn Maple or rather drop it and focus on learning Mathematica.
Thank you in advance.
If both sides of the equation are of type numeric (or extended complex numeric, etc), then evalb will test the equality. But for your symbolic expressions the evalb command will only test that they are the very same expression (by comparing memory address).
But they are not the very same expression. They are merely two different symbolic expressions for which you wish to do a mathematical test of equivalence.
restart;
expr:=(3*x+1)^5*(3*x-1)/x^6=(3+1/x)^5*(3-1/x):
is(expr);
true
testeq(expr);
true
simplify((rhs-lhs)(expr));
0

how can I calculate order of an element in finite field using ntl?

I'm trying to calculate order of an element in finite field (Group) using ntl. but I did not find any function to do this!
can anyone guide me please?
I think there is no built in way to do this.
But you can write a script yourself.
A field F has two operations, addition (+) and multiplication (*). First you have to specify if you want to know the order of an element g in the group (F,+) or the group (F \ {0}, *).
Find the order of g in (F,+):
This is the easy case, since the order of every element in this group is p, if the field has pm elements.
Find the order of g in (F \ {0}, *):
This is a litte bit hard. The order of g in (F \ {0}, *) is also called the discrete logarithm. Basicly you can try gk for every k=1,...,pm. But this will take a while. A simple way would be the baby-step giant-step algorithm.
I have never tried it, but you may also take a look at this discrete logarithm implementation using NTL.

Can matlab (or mupad) evaluate symbolic expressions containing non-commuting operators?

Say I give something like AB+AB+BA to matlab (or mupad), and ask it to simplify it. the answer should be: 2AB+BA. Can this be done in matlab or mupad?
Edit:
Ok, this is feeling rediculous. I'm trying to do this in either matlab or mulab, and.. it's frustrating not knowing how to do what should be the simplest things, and not being able to find the answers right away via google.
I want to expand the following, multiplied together, as a taylor series:
eq1 := exp(g*l*B):
eq2 := exp(l*A):
eq3 := exp((1-g)*l*B):
g is gamma, l is lambda (don't know how to represent either of these in matlab or mulab). A and B don't commute. I want to multiply the three exponentials together, expand, select all terms of a given power in lambda, and simplify the result. Is there a simple way to do this? or should I give up and go to another system, like maple?
This is mupad, not matlab:
operator("x", _vector_product, Binary, 1999):
A x B + A x B + B x A
returns
2 A x B + B x A
The vetor product is used, simply because it matches the described requirements.

Fixed point arithmetic

I'm currently using Microchip's Fixed Point Library, but I think this applies to most fixed point libraries. It supports Q15 and Q15.16 types, respectively 16-bit and 32-bit data.
One thing I noticed is that it does not include add, subtract, multiply or divide functions.
How am I supposed to do these? Is it as simple as just adding/subtracting/multiplying/dividing them together using integer math? I can see addition and subtraction working, but multiplying or dividing wouldn't take care of the fractional part...?
The Microsoft library includes functions for adding and subtracting that deal with underflow/overflow (_Q15add and _Q15sub).
Multiplication can be implemented as an assembly function (I think the code is good - this is from memory).
C calling prototype is:
extern _Q15 Q15mpy(_Q15 a, _Q15 b);
The routine (placed in a .s source file in your project) is:
.global _Q15mpy
_Q15mpy:
mul.ss w0, w1, w2 ; signed multiple parameters, result in w2:w3
SL w2, w2 ; place most significant bit of W2 in carry
RLC w3, w0 ; rotate left carry into w3; result in W0
return ; return value in W0
.end
Remember to include libq.h
This routine does a left-shift of one bit rather than a right-shift of 15 bit on the result. There are no overflow concerns because Q15 numbers always have a magnitude <= 1.
It turns out that all basic arithmetic functions are performed by using the native operators due to how the numbers are represented. e.g. divide uses the / operator and multiply the * operator, and these compile to simple 32-bit divides and multiplies.