ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 06 Feb 2021 10:00:40 +0100limit of fourier serieshttps://ask.sagemath.org/question/55596/limit-of-fourier-series/I'd like to compute the limit of
$$\sum_{k=1}^{n}\frac{1}{k^2+1}\sin(kx)$$
I did the following already:
def b(k):
return(1/(k**2+1))
def a(k,x):
return(b(k)*sin(k*x))
def s(n,x):
s=0
for k in range(1,n+1):
s=s+a(k,x)
return(s)
var('x,n')
f=s(1000,x)
plot(f,0,2*pi)
I already tried computing it by hand, looked in Bronstein, searched the internet, but didn't find any solution. But I'm no specialist in Analysis, so perhaps somebody can help?
Clearly the series converges for every x in [0,2*pi] ...dantetanteSat, 06 Feb 2021 10:00:40 +0100https://ask.sagemath.org/question/55596/Simple trigonometric equation solvinghttps://ask.sagemath.org/question/55268/simple-trigonometric-equation-solving/I was a MapleV user in the past (~25 years ago) an I'm very pleased to find such an elegant solution the sage is.
I try to see how it works trying to solve an easy trigonometry calculation:
var('r,l,m')
ex = l/sin(m/2/r)-r
solve(ex,r)
[r == l/sin(1/2*m/r)]
Do not want, ok. To simplify I put some real values m and l and tried again:
exval = ex.subs(l=7.2,m=10)
solve(exval,r)
[r == 36/5/sin(5/r)]
still not solving, r=3.68357 is what I'm searching for. What would be a right way to proceed?
Thank you in advance, v42
vladimir42000Thu, 14 Jan 2021 14:46:18 +0100https://ask.sagemath.org/question/55268/Reduction to a rational expressionhttps://ask.sagemath.org/question/52656/reduction-to-a-rational-expression/I have the the following expression:
$ tan(m \cdot actan(x) + n \cdot arctan(y))$
For what values of $n,m \in \mathbb{N}$ is this expression reducible to a rational expression in $R[x,y]$, where $R$ is a generic ring?
Is there some rule $lhs => rhs $ that is needed in order to get a rational expression form the expression above?salFri, 24 Jul 2020 19:12:44 +0200https://ask.sagemath.org/question/52656/Sage doesn't simplify a fraction if it's multiplied by 2https://ask.sagemath.org/question/44544/sage-doesnt-simplify-a-fraction-if-its-multiplied-by-2/Hello, for some reason sage doesn't simplify a trigonometric expression:
sage: ( 2 * (1-cos(x)) / sqrt(1-cos(x)) ).simplify_full()
-2*(cos(x) - 1)/sqrt(-cos(x) + 1)
while I'd expect `sqrt(1-cos(x))`.
I also tried a nice `simplify_chain_real` function (thanks eric_g for [the hint](https://ask.sagemath.org/question/44414/canonicalize_radical-produces-incorrect-result/?answer=44421#post-id-44421)) but I've got the same result:
sage: from sage.manifolds.utilities import simplify_chain_real
sage: simplify_chain_real( 2 * (1-cos(x)) / sqrt(1-cos(x)) )
-2*(cos(x) - 1)/sqrt(-cos(x) + 1)
The weird thing is that it works without the `2*` part:
sage: ( (1-cos(x)) / sqrt(1-cos(x)) ).simplify_full()
sqrt(-cos(x) + 1)
And even replacing `-` with `+` makes it working:
sage: ( 2*(1+cos(x))/sqrt(1+cos(x)) ).simplify_full()
2*sqrt(cos(x) + 1)
I mean, obviously, it can do that kind of simplification. But I can't make it simplify the `2*(1-cos(x))/sqrt(1-cos(x))` expression. What do I miss?sagenoviceMon, 03 Dec 2018 04:22:20 +0100https://ask.sagemath.org/question/44544/.canonicalize_radical() produces incorrect resulthttps://ask.sagemath.org/question/44414/canonicalize_radical-produces-incorrect-result/I'm trying to simplify some trigonometric expressions using sage, and I noticed that .simplify_full() doesn't optimize those, unless a .canonicalize_radical() is used (thanks slelievre for [the hint](https://ask.sagemath.org/question/44391/simplify_full-doesnt-simplify-an-obvious-trigonometric-expression/?answer=44392#post-id-44392)). But that yields incorrect results for some expressions. For example:
sage: y = sqrt(sin(x)^2 + 4*sin(x) + 4) - sqrt(sin(x)^2 - 4*sin(x) + 4)
sage: y.simplify_full()
sqrt(sin(x)^2 + 4*sin(x) + 4) - sqrt(sin(x)^2 - 4*sin(x) + 4)
.canonicalize_radical() simplifies it further:
sage: y.canonicalize_radical()
4
But that is wrong! The answer should be `2*sin(x)`. Obviously it selected an incorrect sign for the second sqrt(...).
Is there a way to make .canonicalize_radical() smarter? Or any other way to simplify an expression like this correctly?sagenoviceSat, 24 Nov 2018 16:01:17 +0100https://ask.sagemath.org/question/44414/.simplify_full() doesn't simplify an obvious trigonometric expressionhttps://ask.sagemath.org/question/44391/simplify_full-doesnt-simplify-an-obvious-trigonometric-expression/Hello, I'm trying to simplify a trigonometric expression, and it didn't work as I expected. The original example was larger, but I reproduced the issue with a smaller one:
sage: y = (sin(x)+2) * sqrt( sin(x) / (sin(x)^2 + 4*sin(x) + 4) )
sage: y.simplify_full()
sqrt(sin(x)/(sin(x)^2 + 4*sin(x) + 4))*(sin(x) + 2)
Why doesn't that turn into `sqrt(sin(x))`? What do I miss?
sagenoviceFri, 23 Nov 2018 09:50:56 +0100https://ask.sagemath.org/question/44391/Difference between integral(csc(x)) and integral(1/sin(x))?https://ask.sagemath.org/question/40806/difference-between-integralcscx-and-integral1sinx/ integral(csc(x),x) gives -log(cot(x) + csc(x)) as expected. integral(1/sin(x),x) gives -1/2*log(cos(x) + 1) + 1/2*log(cos(x) - 1). Evaluation of the second log is problematic because cos(x)-1 < 0 for all x except n*2pi. Choosing the sympy or maxima algorithms makes no difference.
Also (and this is less reliable) if I perform a substitution t=tan(x/2) by hand in the first case I get ln(t), again as expected. But in the second ln(-t). That maybe my fault but I can't see what I did wrong.
Is there any fundamental difference between asking that same question in two different ways?
NickBaileySat, 27 Jan 2018 16:10:05 +0100https://ask.sagemath.org/question/40806/Convert exponential form to hyperbolic functionshttps://ask.sagemath.org/question/39602/convert-exponential-form-to-hyperbolic-functions/Is there a method to convert expression containing exponentials like (e^a + e^-a) / 2 to hyperbolic functions?
I tried to even call maxima functions directly, but thinks like
`
cosh(a)._maxima_().exponentialize().demoivre()
`
still don't give me `cosh(a)` back but instead return the form in exponentials.TobiasDThu, 16 Nov 2017 13:49:23 +0100https://ask.sagemath.org/question/39602/Solving large trigonometric fucntionshttps://ask.sagemath.org/question/35705/solving-large-trigonometric-fucntions/Hi everyone,
I'm new to sage and would like to use it to give me an exact solution to the derivative of a large trig function. I have been tinkering around with the different trig simplification routines to no avail. Here is the current incarnation of my code:
var("theta phi r I sigma_a1 sigma_a2 M_1 M_2 F_tu")
import sympy as sy
M1(phi)=M_1*cos(phi+pi/2)
M1=M1.trig_reduce()
M2(phi)=M_2*cos(phi+theta+pi/2)
M2=M2.trig_reduce()
sigma_b1(r,phi)=M1(phi - pi/2)*r/I+sigma_a1
sigma_b1=sigma_b1.trig_reduce()
sigma_b2(r,phi)=M2(phi - pi/2)*r/I+sigma_a2
sigma_b2=sigma_b2.trig_reduce()
sigma_alt(r,phi)=sigma_b1-sigma_b2
sigma_alt=sigma_alt.trig_reduce()
sigma_mean(r,phi)=(sigma_b1-sigma_b2)/2
sigma_mean=sigma_mean.trig_reduce()
sigma_alteq(r,phi)=F_tu*sigma_alt/(F_tu-sigma_mean)
sigma_alteq=sigma_alteq.trig_reduce()
sol=diff(sigma_alteq,phi)
sol_reduc=SR(sy.fu(sy.sympify(sol))); sol_reduc
show(sol_reduc)
solve(sol_reduc,phi)
Sorry, I do not know how to make the code appear in a window. The final result it gives me is:
[sin(phi + theta) == M_1*sin(phi)/M_2]
Can someone please help me or at least point me in the right direction. Thanks.Kevin BryantWed, 23 Nov 2016 21:33:39 +0100https://ask.sagemath.org/question/35705/Solve trigonometric equationhttps://ask.sagemath.org/question/34624/solve-trigonometric-equation/ How do I solve simple trigonometric equation 2*cot(2x)=0?
I tried solve, but it gives me one solution, I need solution with n.
Thank you.proySun, 28 Aug 2016 23:23:50 +0200https://ask.sagemath.org/question/34624/Graph x sin 0 to 720https://ask.sagemath.org/question/33583/graph-x-sin-0-to-720/We will now draw a graph of sin x from 0 to 720.
Enter the command to do this in Sage.
What command was used?
I'm assuming its something like
plot sin(x*pi/180) for 0<x<720
Usually i'd keep searching until i figure it out myself but i'm really behind on study and don't have the time.
If i could just get the code that would be great!
Many thanks.ZantheorMon, 30 May 2016 13:07:04 +0200https://ask.sagemath.org/question/33583/How to solve polynomial equation systemhttps://ask.sagemath.org/question/32506/how-to-solve-polynomial-equation-system/ Greetings,
I'm pretty new to Sage and excited in discovering new functions and ways to solve certain problems. Previously I've been massively working with sympy for solving equation systems. However I wanted to try out Sage.
Currently I'm facing a polynomial equation system (3x3 with three unknown variables a,b,d) where the polynom is of degree 2. However the equations include also trigonometric elements such as cos(a), sin(b) etc.
How can polynomial equations with trigonometric elements be solved in sage? (under the condition that the specific equation system is solvable at all). Is there a specific solver which is recommended to use for such type of equations?
Thank you in advance for any hints and
with best regards
DanDanTue, 09 Feb 2016 09:08:24 +0100https://ask.sagemath.org/question/32506/using 'solve' with trigonometric functionshttps://ask.sagemath.org/question/31191/using-solve-with-trigonometric-functions/
solve(tan(3*x)==1, x, to_poly_solve='force', explicit_solutions=True)
fails to produce answers while
solve(sin(3*x)==1, x, to_poly_solve='force', explicit_solutions=True)
works as expecteddrJMon, 30 Nov 2015 05:37:07 +0100https://ask.sagemath.org/question/31191/I don't know why Sage return 0 for integrate(sin(2*x).abs(),(x,0,pi)) when its value is 2https://ask.sagemath.org/question/25269/i-dont-know-why-sage-return-0-for-integratesin2xabsx0pi-when-its-value-is-2/When I try integrate(sin(x).abs(),(x,0,pi)) the program return the same thing. The numerical integration is correct, the program return (1.9999999999999998, 2.220446049250313e-14). I don't know if it is a bug or what. Any help? I have tried sage 6.2, 6.3, 6.4.1
Mathematica can do It without any problem http://www.wolframalpha.com/input/?i=Integrate[Abs[Sin[2*x]]%2C{x%2C0%2CPi}]
Neither Sympy nor Maxima can't compute this.ArturoSun, 14 Dec 2014 16:25:05 +0100https://ask.sagemath.org/question/25269/Simplify trigonometric expressionhttps://ask.sagemath.org/question/11365/simplify-trigonometric-expression/How can I do to obtain 0 in place of:
-1/2*sin(1/16*pi)*sin(3/16*pi)*sin(5/16*pi)*sin(7/16*pi) -
1/2*sin(1/8*pi)*sin(3/8*pi)*sin(5/8*pi)*sin(7/8*pi) -
1/2*sin(3/16*pi)*sin(9/16*pi)*sin(15/16*pi)*sin(21/16*pi) -
1/2*sin(5/16*pi)*sin(15/16*pi)*sin(25/16*pi)*sin(35/16*pi) -
1/2*sin(3/8*pi)*sin(9/8*pi)*sin(15/8*pi)*sin(21/8*pi) -
1/2*sin(7/16*pi)*sin(21/16*pi)*sin(35/16*pi)*sin(49/16*pi) -
1/2*sin(9/16*pi)*sin(27/16*pi)*sin(45/16*pi)*sin(63/16*pi) -
1/2*sin(5/8*pi)*sin(15/8*pi)*sin(25/8*pi)*sin(35/8*pi) -
1/2*sin(11/16*pi)*sin(33/16*pi)*sin(55/16*pi)*sin(77/16*pi) -
1/2*sin(13/16*pi)*sin(39/16*pi)*sin(65/16*pi)*sin(91/16*pi) -
1/2*sin(7/8*pi)*sin(21/8*pi)*sin(35/8*pi)*sin(49/8*pi) -
1/2*sin(15/16*pi)*sin(45/16*pi)*sin(75/16*pi)*sin(105/16*pi) +
1/2*cos(1/16*pi)*cos(3/16*pi)*cos(5/16*pi)*cos(7/16*pi) +
1/2*cos(1/8*pi)*cos(3/8*pi)*cos(5/8*pi)*cos(7/8*pi) +
1/2*cos(3/16*pi)*cos(9/16*pi)*cos(15/16*pi)*cos(21/16*pi) +
1/2*cos(5/16*pi)*cos(15/16*pi)*cos(25/16*pi)*cos(35/16*pi) +
1/2*cos(3/8*pi)*cos(9/8*pi)*cos(15/8*pi)*cos(21/8*pi) +
1/2*cos(7/16*pi)*cos(21/16*pi)*cos(35/16*pi)*cos(49/16*pi) +
1/2*cos(9/16*pi)*cos(27/16*pi)*cos(45/16*pi)*cos(63/16*pi) +
1/2*cos(5/8*pi)*cos(15/8*pi)*cos(25/8*pi)*cos(35/8*pi) +
1/2*cos(11/16*pi)*cos(33/16*pi)*cos(55/16*pi)*cos(77/16*pi) +
1/2*cos(13/16*pi)*cos(39/16*pi)*cos(65/16*pi)*cos(91/16*pi) +
1/2*cos(7/8*pi)*cos(21/8*pi)*cos(35/8*pi)*cos(49/8*pi) +
1/2*cos(15/16*pi)*cos(45/16*pi)*cos(75/16*pi)*cos(105/16*pi)emiliocbaTue, 06 May 2014 11:21:47 +0200https://ask.sagemath.org/question/11365/Sage does not simplify trigonometric expresionhttps://ask.sagemath.org/question/24256/sage-does-not-simplify-trigonometric-expresion/Hello,
the sage does not simplify the expression
a(phi) = (1 - cos(phi)) / sin(phi)
to tan(phi/2)
what wolfram alpha does...
is this a bug or a feature??top mixTue, 23 Sep 2014 14:26:55 +0200https://ask.sagemath.org/question/24256/Solve equation 1/3*x + sin(2*x)==1https://ask.sagemath.org/question/10833/solve-equation-13x-sin2x1/ Hi all.
I have the equations
y - 1 == 0,
y == 1/3*x + sin(2*x)
and I want solutions. I know by the intermediate value theorem that there are two solutions : about x=0.5 and x=1.25.
I'd like Sage to give me these solutions. I already tried to_poly_solve=True and/or explicit_solutions=True.
As an example of failure :
sage: solve( 1/3*x + sin(2*x)==1,x,explicit_solutions=True )
[]
What can I do ?
Thanks
Laurent ClaessensLaurent ClaessensSun, 15 Dec 2013 03:26:48 +0100https://ask.sagemath.org/question/10833/Trigonometric simplification for distance on a spherehttps://ask.sagemath.org/question/10369/trigonometric-simplification-for-distance-on-a-sphere/These are two equivalent equations for distance on a sphere:
hav(x)=sin(x/2)^2
dist1(lat1, lat2, dLon)=2*asin(hav(lat1-lat2)+cos(lat1)*cos(lat2)*hav(dLon))
dist2(lat1, lat2, dLon)=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(dLon))
(According to http://www.movable-type.co.uk/scripts/latlong.html )
Indeed numerically they evaluate equal.
But why their difference does not simplify to 0?
diff(x,y,z)=dist1(x,y,z)-dist2(x,y,z)
diff.simplify_full()
Am I doing something wrong? Is there a way to have Sage prove the two forms are equivalent, or to transform one to another?
Thanks!
Mihai PredaSun, 21 Jul 2013 06:53:30 +0200https://ask.sagemath.org/question/10369/Solving trigonometric functionshttps://ask.sagemath.org/question/9350/solving-trigonometric-functions/Hi
I have quite complex trigonometric function to solve, but sage only solves sin(alpha) and leaves some cos(alpha) on the other side. It is hard to explain, but see the link below:
http://sage.ehasa.org:8080/home/pub/2/
Update: the things in question:
var('x,p,k,y,g,v,alpha')
A=-(g/(2*(v*cos(alpha))^2))
k=((v*cos(alpha))/(v*sin(alpha)))
p=(g*x)/(v*sin(alpha)^2)
B=(k+p)
C=(y-k*x-p*x^2)
(A+B+C).solve(alpha)
(It would be also nice to generate dynamic function where I put v, x and y. Tried something but I wasn't able to do that, help please?)
happosadeTue, 25 Sep 2012 13:19:08 +0200https://ask.sagemath.org/question/9350/How to integrate sqrt(P(sinx)), where P(x) is a polynomhttps://ask.sagemath.org/question/8965/how-to-integrate-sqrtpsinx-where-px-is-a-polynom/Hello! I'm trying to calculate a finite parametric integral, but with no success
sage: var('a,b,c')
(a, b, c)
sage: f = a*sin(x)^2+b*sin(x)+c
sage: f
a*sin(x)^2 + b*sin(x) + c
sage: var('A')
A
sage: integrate(sqrt(f),x,-A,A)
integrate(sqrt(a*sin(x)^2 + b*sin(x) + c), x, -A, A)
Any help would be appreciated!
UPD: A < pi/2installeroThu, 10 May 2012 11:44:54 +0200https://ask.sagemath.org/question/8965/No simplification is done to invert trigonometric functions ?https://ask.sagemath.org/question/7994/no-simplification-is-done-to-invert-trigonometric-functions/I noticed that $\cos(\pi/6)$ gives $(1/2)\sqrt{3}$ as expected but $\arccos((1/2)\sqrt{3})$ gives $\arccos((1/2)\sqrt{3})$.
Is it a missing feature or is there an option that you must call explicitely to obtain $\arccos((1/2)\sqrt{3})=\pi/6$ ?
Thanks for your answerLLyaudetSun, 13 Mar 2011 10:27:57 +0100https://ask.sagemath.org/question/7994/expression has trig component or not?https://ask.sagemath.org/question/7937/expression-has-trig-component-or-not/Is there any way in Sage to find out whether an expression has any trigonometric component (e.g. sin, cos,... ) or not?ShuThu, 10 Feb 2011 14:49:09 +0100https://ask.sagemath.org/question/7937/