Also :

sage: b.simplify_trig()
1

Using specific simplifications in a specific order is often the key to get 
interesting results that the brute-force simplify_full cannot. Such 
simplifications are :

sage: import re
sage: print(", ".join([v[0] for v in list(map(lambda 
u:re.findall(".*simplify.*", u), dir(x))) if len(v)>0]))
factorial_simplify, full_simplify, hypergeometric_simplify, log_simplify, 
rational_simplify, simplify, simplify_factorial, simplify_full, 
simplify_hypergeometric, simplify_log, simplify_rational, simplify_real, 
simplify_rectform, simplify_trig, trig_simplify

to which you should add canonicalize_radical (with caution ! See this 
<https://docs.sympy.org/latest/tutorial/simplification.html#powers> for 
example), and the x._sympy_().simplify()._sage_() idiom, extremely 
interesting alternative to full_simplify.

HTH,
​
Le vendredi 29 avril 2022 à 11:59:50 UTC+2, maxime...@inria.fr a écrit :

> On 4/29/22 09:49, erentar wrote:
> > I would expect the following expression to evaluate to 1 but it does not.
> >
> > ```
> > var("a",domain="real")
> > simplify(cos(a)^2 + sin(a)^2)
> > ```
> >
> > How can i define a variable in this fashion that will result in the 
> > code evaluating to 1?
>
> Hi,
>
> you can use the "full_simplify" method for that:
>
>
> ```
> sage: var("a", domain="real")
> a
> sage: b = cos(a)^2+sin(a)^2
> sage: b.simplify()
> cos(a)^2 + sin(a)^2
> sage: b.full_simplify()
> 1
> ```
>
> Best,
>
> -- 
> Maxime
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/51209438-c1d5-4d8f-81a1-54491b338aean%40googlegroups.com.

Reply via email to