trigonometric identities

14 views
Skip to first unread message

68th

unread,
Jul 21, 2023, 11:29:13 AM7/21/23
to fricas...@googlegroups.com
Alright, I finally have (k²(1+cos(γ))+l²(1-cos(γ)))/2 as a result of the following commands:

c_square := c^2=a^2+b^2-2*a*b*cos(gamma)
a := a=(k+l)/2; b := b=(l-k)/2
ex1 := subst(rhs c_square,[a,b])
ex2 := ex1 :: DMP([k,l],Expression Integer)

It's not that terrible if you know right commands.

Now I want to use the tangent half-angle formulas:

tan_plus := tan(gamma/2) = sin(gamma)/(1+cos(gamma))
tan_minus := tan(gamma/2) = (1-cos(gamma))/sin(gamma)

How to make FriCAS substitute 1+cos(γ) and 1-cos(γ) in ex2 with sin(γ)/tan(γ/2) and sin(γ)tan(γ/2) respectively using tan_plus and tan_minus?

Ralf Hemmecke

unread,
Jul 21, 2023, 5:22:09 PM7/21/23
to fricas...@googlegroups.com
> Now I want to use the tangent half-angle formulas:
>
> tan_plus := tan(gamma/2) = sin(gamma)/(1+cos(gamma))
> tan_minus := tan(gamma/2) = (1-cos(gamma))/sin(gamma)

> How to make FriCAS substitute 1+cos(γ) and 1-cos(γ) in ex2 with
> sin(γ)/tan(γ/2) and> sin(γ)tan(γ/2) respectively using
> tan_plus and tan_minus?
Of course, you can do that, but I question the WHY.
1+cos(y) and 1-cos(y) look "simpler" to me than the expression with tan.

And note that you want to apply two different rules basically to the
same expression, namely cos(y). How can any CAS figure out that one rule
is for the first cos and the other for the second? You would have to
split the expression and then apply the rules separately and then you
have to put the results together again (but probably boxed so that they
don't change).

If I would now start to figure out how to transform your expression, I
would waste a lot of time. In this case, it is much simpler if you just
enter the substituted expression manually into FriCAS and be done.

Ralf


68th

unread,
Jul 22, 2023, 12:34:31 AM7/22/23
to fricas...@googlegroups.com
------- Original Message -------
On Friday, July 21st, 2023 at 9:22 PM, Ralf Hemmecke <ra...@hemmecke.org> wrote:

> If I would now start to figure out how to transform your expression, I
> would waste a lot of time. In this case, it is much simpler if you just
> enter the substituted expression manually into FriCAS and be done.
>
> Ralf

If that would take you a lot of time then I have very little chance of figuring it out on my own.

Looks like computer algebra systems are not the right tool to do elementary algebra. What kind of software is more suitable for transforming algebraic expressions? Or do human beings have to do it on paper despite all the hype how artificial "intelligence" and other fruits of digitalization make humans obsolete?

Ralf Hemmecke

unread,
Jul 22, 2023, 6:47:40 AM7/22/23
to fricas...@googlegroups.com
> If that would take you a lot of time then I have very little chance
> of figuring it out on my own.

Can you answer the question *why* you want to have such a transformation
of your expression?
Do you know any other CAS that can do such easily?

> Looks like computer algebra systems are not the right tool to do
> elementary algebra.

It depends on what you mean by "elementary algebra". As Waldek said,
there are two different aspects: (A) computing the correct result, (B)
showing it in a nice form.

It is actually (A) that is important. And whether a CAS gives you
(a+b)*c back or a*c+b*c should be irrelevant. They are equal and both
correct. Some CAS work on general expressions and focus on transforming
such expressions. FriCAS on the contrary does mainly (A) and if you want
(B), you have to convert to some respective type where the normal form
of this type prints in such a form that the user wants.

If you just aim at (B), you disregard a lot of the actual capabilities
of a CAS.

> What kind of software is more suitable for transforming algebraic
> expressions?

Well, should be a CAS. Maybe you start reading about the beginning of
computer algebra systems. Transforming *huge* expressions was one of
the orignal tasks of a CAS. Maybe you look at Reduce
http://www.reduce-algebra.com/. It has an overwhelmingly lot of options
to transform expressions into the way you like it. It was too much for
my taste, but your mileage may vary.

> Or do human beings have to do it on paper despite all
> the hype how artificial "intelligence" and other fruits of
> digitalization make humans obsolete?
Maybe you describe what your actual problem is that you want to solve.

A much more interesting problem would be: find formula for all solutions
of x^3 + p*x + q = 0 (depending on some variables p and q) or factor
x^4 - 1 over the integers or over a finite field of prime order or over
the Gaussion integers.

Look at https://fricas.github.io/fricas-notebooks/index.html for some
examples or browse through The FriCAS book
https://fricas.github.io/book.pdf in order to give you an impression
what a computer algebra system can do.

I hope that helps even if I refuse to transform your expression.

BTW, if it were only *one* transformation (and not two), you would have
probably figured out the following yourself.

eq := c^2 = a^2 + b^2 -(2*a*b)*cos(gamma)
ex := rhs eq
ex2 := subst(ex,[a=(l+k)/2,b=(l-k)/2,_
cos(gamma)=sin(gamma)/tan(gamma/2)-1])
Dkl ==> DistributedMultivariatePolynomial([k,l],Expression Integer)
ex2 :: Dkl

or you can let FriCAS translate your cos into tan with half angles.

(4) -> normalize(ex2)

2 gamma 2 2
l tan(-----) + k
2
(4) ------------------
gamma 2
tan(-----) + 1
2
Type: Expression(Integer)

Interestingly, by using normalize, you don't even have to add "::Dkl"
to make the output separate k and l.

Ralf



68th

unread,
Jul 22, 2023, 8:18:21 PM7/22/23
to fricas...@googlegroups.com
------- Original Message -------
On Saturday, July 22nd, 2023 at 10:47 AM, Ralf Hemmecke <ra...@hemmecke.org> wrote:

> Can you answer the question why you want to have such a transformation
> of your expression?

Because it lets me solve my problem on paper but I want to make sure there are no mistakes in the solution.

> (4) -> normalize(ex2)

That's it! Thank you very much! This one command gets me directly to the expression that I will use to find an antiderivative. I guess you'd say that I can simply integrate what I want and FriCAS will automagically do everything needed. Well, I tried it but I was not satisfied with the output. I think I'll get to that in a separate thread.

By the way, is there a way to show steps a command like 'normalize' takes to derive its result? It would help to pinpoint a mistake in my calculations if FriCAS gives a different result.

Ralf Hemmecke

unread,
Jul 23, 2023, 4:28:38 AM7/23/23
to fricas...@googlegroups.com
On 23.07.23 02:18, '68th' via FriCAS - computer algebra system wrote:
>> (4) -> normalize(ex2)
>
> That's it! Thank you very much! This one command gets me directly to
> the expression that I will use to find an antiderivative.

Ah!

> I guess you'd say that I can simply integrate what I want and FriCAS
> will automagically do everything needed. Well, I tried it but I was
> not satisfied with the output. I think I'll get to that in a separate
> thread.

Yes, that would be it. As far as I know, FriCAS applies "normalize"
before it does integration. But Waldek is the expert in integration.
FriCAS cannot solve every integral, but it would certainly be
interesting to learn why it fails to deliver the answer that you have in
mind.

> By the way, is there a way to show steps a command like 'normalize'
> takes to derive its result?

In general the answer is NO. I wouldn´t say that this is impossible, but
I'm afraid that in general recording the derivations is probably not
nicely human readable. For your hand calculation it is perhaps as easy
as replacing cos(x) by the respective expression in tan(x/2) and then
substitute a and b by (l-k)/2 and (l+k)/2 and simplify.


> It would help to pinpoint a mistake in my calculations if FriCAS
> gives a different result.

BTW, have you tried to enter your result into FriCAS and subtract
normalize(ex2) from it. Perhaps it's zero and your result is just a
different form of what FriCAS computed. Or simply apply "normalize" to
your entered expression. Waldek suggested that in one of his mails.

Ralf

Waldek Hebisch

unread,
Jul 23, 2023, 5:45:07 PM7/23/23
to '68th' via FriCAS - computer algebra system
On Sat, Jul 22, 2023 at 04:34:11AM +0000, '68th' via FriCAS - computer algebra system wrote:
>
> Looks like computer algebra systems are not the right tool to do elementary algebra. What kind of software is more suitable for transforming algebraic expressions? Or do human beings have to do it on paper despite all the hype how artificial "intelligence" and other fruits of digitalization make humans obsolete?

Well, actually FriCAS may be quite close to what want. As I wrote,
each FriCAS type has its own rules to perform calculation. So
you need appropriate FriCAS type. In the past I wrote a special
version of Expression that did no simplification on its own.
So internal form exactly represented input. All changes were
via application of transformation rules. I do not remember
what I did with printing, doing it naively would give ugly
result that exactly represented structure of the input. But
one can beautyfy it so that it looks like other expression.

One drawback is that when you input

x - x

you will get back x - x and need a rewrite rule to transform
it to 0. Another drawback is that even asking it x - x is
zero you will get no as an answer. Another question is
usefulness of this type.

To issustrate usfulness question consider even more elementary
math, namely we want to transform 42 into 25 + 17. One possibilty
would be to have very special "42" rule that transforms literal
42 into 25 + 17. Another way is more usual rewrite: rule
that transform any occurence of 42 in the input into 25 + 17.
This more general rule transforms cos(42) into cos(25 + 17).
But when writing general rules you may want rule that always gives
17 as second term (let me call it "17" rule), so transforms 43 into
26 + 17. But "17" rule must do some actual arithmetic, so the
question is how much artihmetic should be done? Should "17" rule
transform 25 + 18 into 26 + 17? Usual answer in rule systems
is that matching is mainly syntactic with possible
side condition. So normal "17" rule would do not artmetic
during matching, but a differnt rule could say math both literals
and sums. But rules get complicated quite quickly and instead
of giving commands you are really writing programs in a special
purpose programming language. Now, when you are writing programs
there is a lot of programming languages.


--
Waldek Hebisch

68th

unread,
Jul 24, 2023, 1:05:06 PM7/24/23
to fricas...@googlegroups.com
------- Original Message -------
On Sunday, July 23rd, 2023 at 9:45 PM, Waldek Hebisch <de...@fricas.math.uni.wroc.pl> wrote:

> One drawback is that when you input
> x - x
> you will get back x - x and need a rewrite rule to transform
> it to 0. Another drawback is that even asking it x - x is
> zero you will get no as an answer.

I believe a user should have an option to let FriCAS simplify the output or not if he doesn't like the result of the simplification.

> ... namely we want to transform 42 into 25 + 17. One possibilty
> would be to have very special "42" rule that transforms literal
> 42 into 25 + 17. Another way is more usual rewrite: rule
> that transform any occurence of 42 in the input into 25 + 17.
> This more general rule transforms cos(42) into cos(25 + 17).

I think such rules or functions should be even more general. Let's call this one 'summands'. A user should be able to specify a number of summands [or just one] of the corresponding or convertible types, and if their sum is not equal to the original value then another summand that makes the sum equal is automatically attached. This way the user only has to specify those summands he wants to see in the sum and doesn't have to calculate and specify the remainder.
Reply all
Reply to author
Forward
0 new messages