I am trying to graph an infinite series (with cosh, sinh and sin in the function) for n=odd numbers but can't figure out how. Can I do this from the function grapher? Or does it need to be in the command line?
I guess you will have to program that function yourself. As a start use the function grapher and create a new function with a single summand. Afterwards, click on show code. Now you can modify that function that it sums up the individual terms. You will need a finite upper limit (n_max) for that -- do not use "inf" (This might be a parameter for the function as well).
For odd numbers : start the summing procedure with one and use a step size of two in the loop.
If your series is guaranteed to converge, you can monitor the size of the latest component compared to the size of the accumulated sum, and terminate when you are at acceptable accuracy.
Also think about convergence radius etc. in a case that johnweeks mentioned.
I'd keep an upper limit for the number of summands (it might be rather large than in the above example). It might be useful to detect non-convergence (divergence and oscillating cases) and will terminate the calculation in such a case (maybe you want to set a flag?).
Thanks for the help! I got my infinite series working well. I have a follow up question. I'm trying to get a matrix where each value is a function of x and y. So I have a wave of x values and a wave of y values and I need a matrix of velocity magnitude at each x and y value as calculated by a velocity function. The formula I'm using for velocity is a summation using a for loop, as y'all suggested previously.
Specifically, I'm having a hard time with the indexing. As in assigning each value to the appropriate position in the matrix.
The formula for velocity looks like:
velocityP += (Pressure/(viscosity*L))*4*(H^2)/(pi)^3*(1/n^3)*(1-(cosh(n*pi*positionsx/H))/(cosh(n*pi*w/(2*H)))*sin(n*pi*(positionsy)/H))
with positionsx and positionsy being the input waves.
[quote=eapurcel]
Specifically, I'm having a hard time with the indexing. As in assigning each value to the appropriate position in the matrix.
The formula for velocity looks like:
velocityP += (Pressure/(viscosity*L))*4*(H^2)/(pi)^3*(1/n^3)*(1-(cosh(n*pi*positionsx/H))/(cosh(n*pi*w/(2*H)))*sin(n*pi*(positionsy)/H))
with positionsx and positionsy being the input waves.
[/quote]
I assume you mean, when the number of points in x and y are equal, velocityP will be an N x N matrix. To index x from top to bottom (row values) and y from left to right (column values), I believe that you need this notation ...
For odd numbers : start the summing procedure with one and use a step size of two in the loop.
You might end up with something like this:
The two if statements prevent the grapher from being stuck with some coefficient combinations....
HJ
February 15, 2017 at 12:20 am - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
February 15, 2017 at 12:06 pm - Permalink
I'd keep an upper limit for the number of summands (it might be rather large than in the above example). It might be useful to detect non-convergence (divergence and oscillating cases) and will terminate the calculation in such a case (maybe you want to set a flag?).
HJ
February 15, 2017 at 02:55 pm - Permalink
A.G.
WaveMetrics, Inc.
February 17, 2017 at 09:41 am - Permalink
Specifically, I'm having a hard time with the indexing. As in assigning each value to the appropriate position in the matrix.
The formula for velocity looks like:
velocityP += (Pressure/(viscosity*L))*4*(H^2)/(pi)^3*(1/n^3)*(1-(cosh(n*pi*positionsx/H))/(cosh(n*pi*w/(2*H)))*sin(n*pi*(positionsy)/H))
with positionsx and positionsy being the input waves.
Thanks.
February 27, 2017 at 09:56 am - Permalink
Specifically, I'm having a hard time with the indexing. As in assigning each value to the appropriate position in the matrix.
The formula for velocity looks like:
velocityP += (Pressure/(viscosity*L))*4*(H^2)/(pi)^3*(1/n^3)*(1-(cosh(n*pi*positionsx/H))/(cosh(n*pi*w/(2*H)))*sin(n*pi*(positionsy)/H))
with positionsx and positionsy being the input waves.
[/quote]
I assume you mean, when the number of points in x and y are equal, velocityP will be an N x N matrix. To index x from top to bottom (row values) and y from left to right (column values), I believe that you need this notation ...
You can switch the p and q indices to rotate the matrix with x left to right and y top to bottom.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
February 27, 2017 at 12:51 pm - Permalink