Skip to main content
Tweeted twitter.com/StackMma/status/1236441685154021376
visually showing the roots i'm trying to find
Source Link
dpholmes
  • 683
  • 3
  • 13

I'm trying to reproduce the results from 1, which solve the equations of an elastic ring (a closed loop elastica) under various loadings. Here is the relevant part:

enter image description here

I need to solve the governing equations in (2), with m0 and p as unknown parameters for a range of prescribed values of f. They indicate in the text that they solve these equations using Mathematica with NDSolve and FindRoot.

I found the following question helpful as an example: How can I use FindRoot on an expression from NDSolve?, and so I implemented my code in a similar manner. However, I'm trying to use FindRoot to solve for two parameters, and I'm not sure how to use the results of NDSolve to get the necessary two equations. Here is my code:

sol[p_?NumericQ, m0_?NumericQ, f_?NumericQ] := {\[Theta], x, y, m} /. 
  First@NDSolve[{
     x'[s] == Cos[\[Theta][s]],
     y'[s] == Sin[\[Theta][s]],
     \[Theta]'[s] == m[s] + 2 \[Pi],
     m'[s] == f/2 Cos[\[Theta][s]] - p Sin[\[Theta][s]],
     x[0] == y[0] == \[Theta][0] == 0,
     m[0] == m0
     },
    \[Theta], {s, 0, 2 \[Pi]}]

FindRoot[{
  sol[p, m0, 200][[1]][1/2] == \[Pi], 
  sol[p, m0, 200][[2]][1/2] == 0}, {p, 0}, {m0, -10}]

FindRoot gives me an error that states:

FindRoot: The function value {-3.14159+0.[0.5],(-10)[0.5]} is not a list of numbers with dimensions (2) at {p,m0}={0.,-10.}.

It seems to me that FindRoot is evaluating things in the wrong order. This feels like the type of Mathematica question that is answered with "Use ?NumericQ", for example, however I am doing that here, so I'm confused. I have tried wrapping Evaluate around the functions in that list, but so far I've had no luck.

I suspect the issue is my lack of knowledge of how to call sol and use it in FindRoot in the presence of ?NumericQ. For example, it works just fine, and I can visually see the roots when I plot:

Plot3D[{sol[p, m0, 200][[1]][1/2], 
  sol[p, m0, 200][[2]][1/2], \[Pi]}, {p, -1, 1}, {m0, -50, 50}]

Roots for an arbitrary choice of f

So clearly, the information is there, I just can't access it correctly yet. Any help would be greatly appreciated.

1 L.N. Virgin et al., "Deformation and vibration of compressed, nested, elastic rings on rigid base", Thin-Walled Structures, 132, 167-175, (2018). Link (Paywall)

I'm trying to reproduce the results from 1, which solve the equations of an elastic ring (a closed loop elastica) under various loadings. Here is the relevant part:

enter image description here

I need to solve the governing equations in (2), with m0 and p as unknown parameters for a range of prescribed values of f. They indicate in the text that they solve these equations using Mathematica with NDSolve and FindRoot.

I found the following question helpful as an example: How can I use FindRoot on an expression from NDSolve?, and so I implemented my code in a similar manner. However, I'm trying to use FindRoot to solve for two parameters, and I'm not sure how to use the results of NDSolve to get the necessary two equations. Here is my code:

sol[p_?NumericQ, m0_?NumericQ, f_?NumericQ] := {\[Theta], x, y, m} /. 
  First@NDSolve[{
     x'[s] == Cos[\[Theta][s]],
     y'[s] == Sin[\[Theta][s]],
     \[Theta]'[s] == m[s] + 2 \[Pi],
     m'[s] == f/2 Cos[\[Theta][s]] - p Sin[\[Theta][s]],
     x[0] == y[0] == \[Theta][0] == 0,
     m[0] == m0
     },
    \[Theta], {s, 0, 2 \[Pi]}]

FindRoot[{
  sol[p, m0, 200][[1]][1/2] == \[Pi], 
  sol[p, m0, 200][[2]][1/2] == 0}, {p, 0}, {m0, -10}]

FindRoot gives me an error that states:

FindRoot: The function value {-3.14159+0.[0.5],(-10)[0.5]} is not a list of numbers with dimensions (2) at {p,m0}={0.,-10.}.

It seems to me that FindRoot is evaluating things in the wrong order. This feels like the type of Mathematica question that is answered with "Use ?NumericQ", for example, however I am doing that here, so I'm confused. I have tried wrapping Evaluate around the functions in that list, but so far I've had no luck.

Any help would be greatly appreciated.

1 L.N. Virgin et al., "Deformation and vibration of compressed, nested, elastic rings on rigid base", Thin-Walled Structures, 132, 167-175, (2018). Link (Paywall)

I'm trying to reproduce the results from 1, which solve the equations of an elastic ring (a closed loop elastica) under various loadings. Here is the relevant part:

enter image description here

I need to solve the governing equations in (2), with m0 and p as unknown parameters for a range of prescribed values of f. They indicate in the text that they solve these equations using Mathematica with NDSolve and FindRoot.

I found the following question helpful as an example: How can I use FindRoot on an expression from NDSolve?, and so I implemented my code in a similar manner. However, I'm trying to use FindRoot to solve for two parameters, and I'm not sure how to use the results of NDSolve to get the necessary two equations. Here is my code:

sol[p_?NumericQ, m0_?NumericQ, f_?NumericQ] := {\[Theta], x, y, m} /. 
  First@NDSolve[{
     x'[s] == Cos[\[Theta][s]],
     y'[s] == Sin[\[Theta][s]],
     \[Theta]'[s] == m[s] + 2 \[Pi],
     m'[s] == f/2 Cos[\[Theta][s]] - p Sin[\[Theta][s]],
     x[0] == y[0] == \[Theta][0] == 0,
     m[0] == m0
     },
    \[Theta], {s, 0, 2 \[Pi]}]

FindRoot[{
  sol[p, m0, 200][[1]][1/2] == \[Pi], 
  sol[p, m0, 200][[2]][1/2] == 0}, {p, 0}, {m0, -10}]

FindRoot gives me an error that states:

FindRoot: The function value {-3.14159+0.[0.5],(-10)[0.5]} is not a list of numbers with dimensions (2) at {p,m0}={0.,-10.}.

It seems to me that FindRoot is evaluating things in the wrong order. This feels like the type of Mathematica question that is answered with "Use ?NumericQ", for example, however I am doing that here, so I'm confused. I have tried wrapping Evaluate around the functions in that list, but so far I've had no luck.

I suspect the issue is my lack of knowledge of how to call sol and use it in FindRoot in the presence of ?NumericQ. For example, it works just fine, and I can visually see the roots when I plot:

Plot3D[{sol[p, m0, 200][[1]][1/2], 
  sol[p, m0, 200][[2]][1/2], \[Pi]}, {p, -1, 1}, {m0, -50, 50}]

Roots for an arbitrary choice of f

So clearly, the information is there, I just can't access it correctly yet. Any help would be greatly appreciated.

1 L.N. Virgin et al., "Deformation and vibration of compressed, nested, elastic rings on rigid base", Thin-Walled Structures, 132, 167-175, (2018). Link (Paywall)

added 282 characters in body
Source Link
dpholmes
  • 683
  • 3
  • 13

I'm trying to reproduce the results from 1, which solve the equations of an elastic ring (a closed loop elastica) under various loadings. Here is the relevant part:

enter image description here

I need to solve the governing equations in (2), with m0 and p as unknown parameters for a range of prescribed values of f. They indicate in the text that they solve these equations using Mathematica with NDSolve and FindRoot.

I found the following question helpful as an example: How can I use FindRoot on an expression from NDSolve?, and so I implemented my code in a similar manner. However, I'm trying to use FindRoot to solve for two parameters, and I'm not sure how to use the results of NDSolve to get the necessary two equations. Here is my code:

sol[p_?NumericQ, m0_?NumericQ, f_?NumericQ] := {\[Theta], x, y, m} /. 
  First@NDSolve[{
     x'[s] == Cos[\[Theta][s]],
     y'[s] == Sin[\[Theta][s]],
     \[Theta]'[s] == m[s] + 2 \[Pi],
     m'[s] == f/2 Cos[\[Theta][s]] - p Sin[\[Theta][s]],
     x[0] == y[0] == \[Theta][0] == 0,
     m[0] == m0
     },
    \[Theta], {s, 0, 2 \[Pi]}]

FindRoot[{
  sol[p, m0, 200][[1]][1/2] == \[Pi], 
  sol[p, m0, 200][[2]][1/2] == 0}, {p, 0}, {m0, -10}]

FindRoot gives me an error that states:

FindRoot: The function value {-3.14159+0.[0.5],(-10)[0.5]} is not a list of numbers with dimensions (2) at {p,m0}={0.,-10.}.

It seems to me that FindRoot is evaluating things in the wrong order. This feels like the type of Mathematica question that is answered with "Use ?NumericQ", for example, however I am doing that here, so I'm confused. I have tried wrapping Evaluate around the functions in that list, but so far I've had no luck.

Any help would be greatly appreciated.

1 L.N. Virgin et al., "Deformation and vibration of compressed, nested, elastic rings on rigid base", Thin-Walled Structures, 132, 167-175, (2018). Link (Paywall)

I'm trying to reproduce the results from 1, which solve the equations of an elastic ring (a closed loop elastica) under various loadings. Here is the relevant part:

enter image description here

I need to solve the governing equations in (2), with m0 and p as unknown parameters for a range of prescribed values of f. They indicate in the text that they solve these equations using Mathematica with NDSolve and FindRoot.

I found the following question helpful as an example: How can I use FindRoot on an expression from NDSolve?, and so I implemented my code in a similar manner. However, I'm trying to use FindRoot to solve for two parameters, and I'm not sure how to use the results of NDSolve to get the necessary two equations. Here is my code:

sol[p_?NumericQ, m0_?NumericQ, f_?NumericQ] := {\[Theta], x, y, m} /. 
  First@NDSolve[{
     x'[s] == Cos[\[Theta][s]],
     y'[s] == Sin[\[Theta][s]],
     \[Theta]'[s] == m[s] + 2 \[Pi],
     m'[s] == f/2 Cos[\[Theta][s]] - p Sin[\[Theta][s]],
     x[0] == y[0] == \[Theta][0] == 0,
     m[0] == m0
     },
    \[Theta], {s, 0, 2 \[Pi]}]

FindRoot[{
  sol[p, m0, 200][[1]][1/2] == \[Pi], 
  sol[p, m0, 200][[2]][1/2] == 0}, {p, 0}, {m0, -10}]

FindRoot gives me an error that states:

FindRoot: The function value {-3.14159+0.[0.5],(-10)[0.5]} is not a list of numbers with dimensions (2) at {p,m0}={0.,-10.}.

It seems to me that FindRoot is evaluating things in the wrong order. I have tried wrapping Evaluate around the functions in that list, but so far I've had no luck.

Any help would be greatly appreciated.

1 L.N. Virgin et al., "Deformation and vibration of compressed, nested, elastic rings on rigid base", Thin-Walled Structures, 132, 167-175, (2018). Link (Paywall)

I'm trying to reproduce the results from 1, which solve the equations of an elastic ring (a closed loop elastica) under various loadings. Here is the relevant part:

enter image description here

I need to solve the governing equations in (2), with m0 and p as unknown parameters for a range of prescribed values of f. They indicate in the text that they solve these equations using Mathematica with NDSolve and FindRoot.

I found the following question helpful as an example: How can I use FindRoot on an expression from NDSolve?, and so I implemented my code in a similar manner. However, I'm trying to use FindRoot to solve for two parameters, and I'm not sure how to use the results of NDSolve to get the necessary two equations. Here is my code:

sol[p_?NumericQ, m0_?NumericQ, f_?NumericQ] := {\[Theta], x, y, m} /. 
  First@NDSolve[{
     x'[s] == Cos[\[Theta][s]],
     y'[s] == Sin[\[Theta][s]],
     \[Theta]'[s] == m[s] + 2 \[Pi],
     m'[s] == f/2 Cos[\[Theta][s]] - p Sin[\[Theta][s]],
     x[0] == y[0] == \[Theta][0] == 0,
     m[0] == m0
     },
    \[Theta], {s, 0, 2 \[Pi]}]

FindRoot[{
  sol[p, m0, 200][[1]][1/2] == \[Pi], 
  sol[p, m0, 200][[2]][1/2] == 0}, {p, 0}, {m0, -10}]

FindRoot gives me an error that states:

FindRoot: The function value {-3.14159+0.[0.5],(-10)[0.5]} is not a list of numbers with dimensions (2) at {p,m0}={0.,-10.}.

It seems to me that FindRoot is evaluating things in the wrong order. This feels like the type of Mathematica question that is answered with "Use ?NumericQ", for example, however I am doing that here, so I'm confused. I have tried wrapping Evaluate around the functions in that list, but so far I've had no luck.

Any help would be greatly appreciated.

1 L.N. Virgin et al., "Deformation and vibration of compressed, nested, elastic rings on rigid base", Thin-Walled Structures, 132, 167-175, (2018). Link (Paywall)

got closer to solving the problem, rephrased the question
Source Link
dpholmes
  • 683
  • 3
  • 13

I'm trying to reproduce the results from 1, which solve the equations of an elastic ring (a closed loop elastica) under various loadings. Here is the relevant part:

enter image description here

I need to solve the governing equations in (2), with m0 and p as unknown parameters for a range of prescribed values of f. They indicate in the text that they solve these equations using Mathematica with NDSolve and FindRoot.

I found the following question helpful as an example: How can I use FindRoot on an expression from NDSolve?, and so I implemented my code in a similar manner. However, I'm trying to use FindRoot to solve for two parameters, and I'm not sure how to use the results of NDSolve to get the necessary two equations. Here is my code:

sol[p_?NumericQ, m0_?NumericQ, f_?NumericQ] := {\[Theta], x, y, m} /. 
  First@NDSolve[{
     x'[s] == Cos[\[Theta][s]],
     y'[s] == Sin[\[Theta][s]],
     \[Theta]'[s] == m[s] + 2 \[Pi],
     m'[s] == f/2 Cos[\[Theta][s]] - p Sin[\[Theta][s]],
     x[0] == y[0] == \[Theta][0] == 0,
     m[0] == m0
     },
    \[Theta], {s, 0, 2 \[Pi]}]

FindRoot[{
  sol[p, m0, 200][1]200][[1]][1/2] == \[Pi], 
  sol[p, m0, 200][[2]][1/2] == 0}, {p, 0}, {m0, -10}]

It is not working. Clearly, I'm asking FindRoot to look for two roots with only one equation. I'm not sure how to use FindRoot to satisfy the conditionsgives me an error that states:

x[1/2]FindRoot: ==The 0function value {-3.14159+0.[0.5],
\[Theta][1/2](-10)[0.5]} ==is not a list of numbers with dimensions (2) at {p,m0}={0.,-10.}.

I'm also not sure what a reasonable guessIt seems to me that FindRoot is forevaluating things in the wrong order. I have tried wrapping m0Evaluate around the functions in that list, but that is less of a concernso far I've had no luck. 

Any help would be greatly appreciated.

1 L.N. Virgin et al., "Deformation and vibration of compressed, nested, elastic rings on rigid base", Thin-Walled Structures, 132, 167-175, (2018). Link (Paywall)

I'm trying to reproduce the results from 1, which solve the equations of an elastic ring (a closed loop elastica) under various loadings. Here is the relevant part:

enter image description here

I need to solve the governing equations in (2), with m0 and p as unknown parameters for a range of prescribed values of f. They indicate in the text that they solve these equations using Mathematica with NDSolve and FindRoot.

I found the following question helpful as an example: How can I use FindRoot on an expression from NDSolve?, and so I implemented my code in a similar manner. However, I'm trying to use FindRoot to solve for two parameters, and I'm not sure how to use the results of NDSolve to get the necessary two equations. Here is my code:

sol[p_?NumericQ, m0_?NumericQ, f_?NumericQ] := \[Theta] /. 
  First@NDSolve[{
     x'[s] == Cos[\[Theta][s]],
     y'[s] == Sin[\[Theta][s]],
     \[Theta]'[s] == m[s] + 2 \[Pi],
     m'[s] == f/2 Cos[\[Theta][s]] - p Sin[\[Theta][s]],
     x[0] == y[0] == \[Theta][0] == 0,
     m[0] == m0
     },
    \[Theta], {s, 0, 2 \[Pi]}]

FindRoot[{sol[p, m0, 200][1]}, {p, 0}, {m0, 10}]

It is not working. Clearly, I'm asking FindRoot to look for two roots with only one equation. I'm not sure how to use FindRoot to satisfy the conditions:

x[1/2] == 0,
\[Theta][1/2] == 0

I'm also not sure what a reasonable guess is for m0, but that is less of a concern. Any help would be greatly appreciated.

1 L.N. Virgin et al., "Deformation and vibration of compressed, nested, elastic rings on rigid base", Thin-Walled Structures, 132, 167-175, (2018). Link (Paywall)

I'm trying to reproduce the results from 1, which solve the equations of an elastic ring (a closed loop elastica) under various loadings. Here is the relevant part:

enter image description here

I need to solve the governing equations in (2), with m0 and p as unknown parameters for a range of prescribed values of f. They indicate in the text that they solve these equations using Mathematica with NDSolve and FindRoot.

I found the following question helpful as an example: How can I use FindRoot on an expression from NDSolve?, and so I implemented my code in a similar manner. However, I'm trying to use FindRoot to solve for two parameters, and I'm not sure how to use the results of NDSolve to get the necessary two equations. Here is my code:

sol[p_?NumericQ, m0_?NumericQ, f_?NumericQ] := {\[Theta], x, y, m} /. 
  First@NDSolve[{
     x'[s] == Cos[\[Theta][s]],
     y'[s] == Sin[\[Theta][s]],
     \[Theta]'[s] == m[s] + 2 \[Pi],
     m'[s] == f/2 Cos[\[Theta][s]] - p Sin[\[Theta][s]],
     x[0] == y[0] == \[Theta][0] == 0,
     m[0] == m0
     },
    \[Theta], {s, 0, 2 \[Pi]}]

FindRoot[{
  sol[p, m0, 200][[1]][1/2] == \[Pi], 
  sol[p, m0, 200][[2]][1/2] == 0}, {p, 0}, {m0, -10}]

FindRoot gives me an error that states:

FindRoot: The function value {-3.14159+0.[0.5],(-10)[0.5]} is not a list of numbers with dimensions (2) at {p,m0}={0.,-10.}.

It seems to me that FindRoot is evaluating things in the wrong order. I have tried wrapping Evaluate around the functions in that list, but so far I've had no luck. 

Any help would be greatly appreciated.

1 L.N. Virgin et al., "Deformation and vibration of compressed, nested, elastic rings on rigid base", Thin-Walled Structures, 132, 167-175, (2018). Link (Paywall)

improved formatting and clarity
Source Link
dpholmes
  • 683
  • 3
  • 13
Loading
fixed typo
Source Link
dpholmes
  • 683
  • 3
  • 13
Loading
Source Link
dpholmes
  • 683
  • 3
  • 13
Loading