Ask Your Question
1

Solving large trigonometric fucntions

asked 2016-11-23 14:33:39 -0500

Kevin Bryant gravatar image

updated 2016-11-24 15:36:20 -0500

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.

edit retag flag offensive close merge delete

Comments

Could you please tell us which result would you expect ?

tmonteil gravatar imagetmonteil ( 2016-11-23 19:10:39 -0500 )edit

@Kevin_Bryant

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 03:56:04 -0500 )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 15:43:34 -0500 )edit

@slelievre thanks and done

Kevin Bryant gravatar imageKevin Bryant ( 2016-11-24 15:44:25 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-12-06 07:14:17 -0500

mforets gravatar image

updated 2016-12-06 07:36:12 -0500

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

Stats

Asked: 2016-11-23 14:33:39 -0500

Seen: 61 times

Last updated: Dec 06 '16