Ask Your Question

Solving large trigonometric fucntions

asked 2016-11-23 21:33:39 +0200

Kevin Bryant gravatar image

updated 2016-11-24 22:36:20 +0200

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
sigma_b1(r,phi)=M1(phi - pi/2)*r/I+sigma_a1
sigma_b2(r,phi)=M2(phi - pi/2)*r/I+sigma_a2
sol_reduc=SR(sy.fu(sy.sympify(sol))); sol_reduc

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.

edit retag flag offensive close merge delete


Could you please tell us which result would you expect ?

tmonteil gravatar imagetmonteil ( 2016-11-24 02:10:39 +0200 )edit


To display blocks of code, either indent them with 4 spaces, or select the corresponding lines and click the "code" button (the icon with '101 010').

Can you edit your question to do that?

slelievre gravatar imageslelievre ( 2016-11-24 10:56:04 +0200 )edit

@tmonteil I was expecting a set of 4 solutions over the interval of 0 to 2*pi for phi. I solved this problem earlier on Wolframalpha before I added the terms sigma_a1 and sigma_a2 to my equations and got the following for one solution (note that variable names are different but the problem was essentially the same)

t = -cos^(-1)((-sqrt((2 F X Y^2 Z cos(2 a) - 2 F X Y^2 Z)^2 - 4 (-4 F^2 X Y cos(a) + 2 F^2 X^2 + 2 F^2 Y^2) (4 F^2 X Y cos(a) - F^2 Y^2 cos(2 a) - X^2 Y^2 Z^2 cos(2 a) - 2 F^2 X^2 - F^2 Y^2 + X^2 Y^2 Z^2)) - 2 F X Y^2 Z cos(2 a) + 2 F X Y^2 Z)/(2 (-4 ...(more)

Kevin Bryant gravatar imageKevin Bryant ( 2016-11-24 22:43:34 +0200 )edit

@slelievre thanks and done

Kevin Bryant gravatar imageKevin Bryant ( 2016-11-24 22:44:25 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-12-06 14:14:17 +0200

mforets gravatar image

updated 2016-12-06 14:36:12 +0200

It seems to me that the hard work is already done properly by the solver. Finally, you got:

sage: var("theta phi M_1 M_2")
sage: f = (sin(theta+phi)-M_1/M_2*sin(phi)).simplify_full()
sage: f, solve(f, phi)

Which is: $$ \newcommand{\Bold}[1]{\mathbf{#1}}\left(\frac{{\left(\cos\left(\theta\right) \sin\left(\phi\right) + \cos\left(\phi\right) \sin\left(\theta\right)\right)} M_{2} - M_{1} \sin\left(\phi\right)}{M_{2}}, \left[\sin\left(\phi\right) = -\frac{M_{2} \cos\left(\phi\right) \sin\left(\theta\right)}{M_{2} \cos\left(\theta\right) - M_{1}}\right]\right) $$

Hence, the solution for $\phi$ is obtianed by intersecting the tangent function with a constant line, and by periodicity we can reason in the interval $[-\pi, \pi]$, recall that:

tangent function

  • if $\theta$ is an integer multiple of $\pi$, then ${0,\pm \pi}$ is the solution set.
  • in general, there are exactly $2$ intersections (and the solutions differ by $\pi$).
  • if the values of $M_1$ and $M_2$ allow it ($|M_1/M_2| \leq 1$), then there exists a value of $\theta$ for which the denominator vanishes, but the solution set is $\pm \pi/2$.

Remark. I'd be interested to know if there is a way to do this sort of "case study" automatically. I tried with some solver options (explicit, etc.), but it doesn't help. Neither with SymPy solve or the new solveset.. but maybe I'm missing to pass some extra information.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2016-11-23 21:33:39 +0200

Seen: 300 times

Last updated: Dec 06 '16