Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4615918
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:54:32+00:00 2026-05-22T01:54:32+00:00

I needed some help with plotting a velocity vs forcing term diagram for a

  • 0

I needed some help with plotting a velocity vs forcing term diagram for a chaotic oscillator on mathematica.

Basically, I have to solve the following differential equation

x''[t] + b x'[t] - x[t] + x[t]^3 - f Cos[w t] == 0, x'[0] == 0, 
 x[0] == 0

and plot the velocity of my solution for times in the interval [0,1000] in increments of 2*Pi
for different values of f.

That is, for each f in the interval [0,2] (in increments of .05), I will have approximately 150 velocity points, and I must plot all of these points on one graph.

I though about using a do loop and came up with something like

Remove["Global`*"]

b = .1;
w = 1;
Period = 1;
tstep = 2 Pi/Period;

Do[{Do[{data = 
     Table[Flatten[
       Evaluate[{f, 
         x'[t] /. 
          NDSolve[{x''[t] + b x'[t] - x[t] + x[t]^3 - f Cos[w t] == 0,
             x'[0] == 0, x[0] == 0}, x[t], {t, 0, 1000}, 
           MaxSteps -> 59999]}]], {t, 0, 1000, tstep}]}, {t, 0, 1000, 
    1}]}, {f, 0, 2, .1}]

but had no luck.

How can I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:54:33+00:00Added an answer on May 22, 2026 at 1:54 am

    Does this do what you want?

    b = .1;
    w = 1;
    
    sol := {f, 
      NDSolve[{x''[t] + b x'[t] - x[t] + x[t]^3 - f Cos[w t] == 0, 
         x'[0] == 0, x[0] == 0}, x[t], {t, 0, 1000}, MaxSteps -> 59999][[1, 1, 2]]}
    
    interpsols = Table[sol, {f, 0, 2, 0.1}];
    
    ListPlot[Table[interpsols, {t, 0, 1000, 2 Pi}]]
    

    The Explanation

    First, let me focus on sol. This is close to your own code (with a change) but refactored for clarity, rather than buried inside the loops.

    • sol := is equivalent to SetDelayed[sol, ...
    • This holds the unevaluated definition that it is given on the right-hand-side
    • The NDSolve operation is therefore not performed until sol is used somewhere

    The change I made was to extract this portion from the result of NDSolve:

    InterpolatingFunction[{{0.,1000.}},<>][t]
    

    I do this with Part: NDSolve[...][[1, 1, 2]]

    It could also be done with x[t] /. First @ NDSolve[...]

    This extracted portion is paired with the current value of f in a list: {f, NDSolve[ ... } so that later they can be plotted.

    Now:

    interpsols = Table[sol, {f, 0, 2, 0.1}];
    

    builds a table of the changing value of sol as it globally changes the value of f. This is where NDSolve is performed.

    The result is a series of solutions for each value of f in this form:

    {{0.,InterpolatingFunction[{{0.,1000.}},<>][t]},
     {0.1,InterpolatingFunction[{{0.,1000.}},<>][t]},
     {0.2,InterpolatingFunction[{{0.,1000.}},<>][t]},
     {0.3,InterpolatingFunction[{{0.,1000.}},<>][t]},
     {0.4,InterpolatingFunction[{{0.,1000.}},<>][t]}
     ...
    

    Finally:

    ListPlot[Table[interpsols, {t, 0, 1000, 2 Pi}]]
    

    creates a table by evaluating the entire series of results created above for globally changing values of t, and ListPlots it.

    There are a few things more I would like to say but I am out of time. I will make a further edit in a few hours.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I needed some simple string encryption, so I wrote the following code (with a
I needed some help with creating custom trees given an arithmetic expression. Say, for
I made this and needed some help tweaking it so that it gives the
need some help from a regex jedi master: If I have a string of
I wanted to emulate a popular flash game, Chrontron, in C++ and needed some
Say there is some functionality needed for an application under development which could be
Is there some additional configuration needed before I can set thread priorities in a
I seem to be in need of some help (and by some, I mean
Hey guys! I need some help writing a code that creates an array in
What's up guys! I gonna need some help! Inside of this code return ControllTheDog(D,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.