Thank you Ralf for the explanation. Let's take the cosine formula c²=a²+b²-(2ab)cos(γ). I want to substitute a with (k+l)/2 and b with (l-k)/2 to get c²=(k²+l²+(k²-l²)cos(γ))/2. Then using the distributive property and factoring out k and l I want to get c²=(k²(1+cos(γ))+l²(1-cos(γ)))/2. How can I do this elementary algebra in FriCAS?
------- Original Message ------- On Tuesday, July 18th, 2023 at 7:04 PM, Ralf Hemmecke <r...@hemmecke.org> wrote: > Thank you for this question. I am currently trying to put a collections > of such simple things into a notebook. And I'll probably also take that > example. > > So please do not hesitate to ask such seemingly stupid questions. FriCAS > is known to have a steep learning curve. I would like to cure it by > providing many more examples that FriCAS beginners struggle with. > > Let me try to "solve" your problem. > > Would you call the following behaviour of FriCAS a bit weird? > > (204) -> (a+b)*c > > > (204) (b + a)c > Type: Polynomial(Integer) > > (205) -> (c+b)*a > > > (205) a c + a b > Type: Polynomial(Integer) > > No, it is not. And for that to understand you always have to keep in > mind that in contrast to most other computer algebra systems, every > object in FriCAS has a type, above you see Polynomial(Integer). > Type information can be switched on or off via > > )type on > )type off > > When you type something into a FriCAS session like (a+b)*c, then the > interpreter tries to make sense out of this information. In particular, > it tries to find an appropriate type for your input. In your case, > Polynomial(Integer). > > What is Polynomial(Integer). Mathematically, that is the ring Z[X] where > X is the set of any variable (symbol) you can think of, i.e. a ring in > infinitely many variables. All those variable are are sorted and this > sorting agrees with the order in the type Symbol. We have > > (207) -> a < b > > > (207) true > > (208) -> b < c > > > (208) true > > So c is the biggest variable. In fact your polynomial lives in > Z[a][b][c]. Yes, it is a polynomial in c with coefficients in Z[a][b]. > So (a+b)c is a polynomial in c (of degree 1 with coefficient (a+b) > being a polynomial (of degree 1) in b with leading coefficient 1 and the > "constant" being the polynomial a from Z[a]. > > Now how would you print a polynomial in c? Right, as a sum of terms of > the form coefficientc^n. The coefficient is (a+b) and n is 1 in your > case. So printing (a+b)c is perfectly fine. That explains (204) from above. > > What about (205)? Well, also (c+b)a is a polynomial of degree 1 in c > having the coefficient a. That explains the ac part. The "constant" > term of this polynomial is the polynomial ab (degree 1 in b and > coefficient a). > > Good. That explains what FriCAS does, but does not solve your problem. > > In fact, I do not know the solution myself. FriCAS certainly knows about > the distributive law, but the answer to your question depends on what > you actually want to achieve. Let me give you one solution. That simply > converts your input into a type that always prints its elements in a > distibuted form. > > (209) -> ((a+b)*c)::DistributedMultivariatePolynomial([a,b,c],Integer) > > > (209) a c + b c > Type: DistributedMultivariatePolynomial([a,b,c],Integer) > > However, now the type is something else. > > Please pose more questions if something is or becomes unclear. > > Ralf -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/xfyP2eW_bxrEcx8KOZ9-TVZPz_csQ048hvHwbjhRF3jzHof4qBH6YtP4Nmhq1wvMeBjkNpXWQ9W7mkzNf1kJHSYJJtmVG_FxSDposbsNPW8%3D%40proton.me.