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

  • SEARCH
  • Home
  • 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 325517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:13:27+00:00 2026-05-12T09:13:27+00:00

I’ve encountered a problem while trying to use the answer from a NDSolve in

  • 0

I’ve encountered a problem while trying to use the answer from a NDSolve in two separate plot commands. To illustrate the problem, I’ll use a simple differential equation and only one plot command. If I write something like this:

{Plot[x[t], {t, 0, 10}], x[4]} 
/. NDSolve[{x'[s] == - x[s], x[0] == 1}, x, {s, 0, 10}]

It solves the equation and calculates x[4] with no problem, but the plot turns empty, and I have no idea why.

In my actual problem, my equation is a quite complicated system for several functions, and instead of x[4] I draw a parametric plot of the solved functions. I ultimately intend to include all this in a Manipulate statement so I don’t want the NDSolve statement to appear more than once (takes too long) and I can’t just calculate it in advance (since it has a lot of parameters).


Edit: I would like to clarify and expand my question: What I actually want to do is to include my plotting statement in a Manipulate statement in the following way:

Manipulate[{Plot[x[t], {t, 0, 10}], x[4]} 
/. NDSolve[{x'[s] == - a*x[s], x[0] == 1}, x, {s, 0, 10}]
,{{a,1},0,5}]

Since only the Manipulate statement gives value to the parameter a, I can’t calculate the answer to the NDSolve beforehand. Also, since my actual equation system is very complicated and non-linear, I can’t use the symbolic function DSolve.

Sorry if it wasn’t clear before.

  • 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-12T09:13:27+00:00Added an answer on May 12, 2026 at 9:13 am

    Your problem is that Plot[] does some funny things to make plotting more convenient, and one of the things it does is just not plot things it can’t evaluate numerically. So in the expression you posted,

    Plot[x[t], {t, 0, 10}]
    

    just goes ahead and evaluates before doing the rule substitution with the solution from NDSolve, producing a graphics object of an empty plot. That graphics object contains no reference to x, so there’s nothing to substitute for.

    You want to make sure the substitution is done before the plotting. If you also want to make sure the substitution can be done in multiple places, you want to store the solution into a variable.

    sol = NDSolve[{x'[s] == - x[s], x[0] == 1}, x, {s, 0, 10}];
    {Plot[Evaluate[x[t] /. sol], {t, 0, 10}], x[4] /. sol} 
    

    The Evaluate[] in the Plot makes sure that Mathematica only does the substitution once, instead of once for each plot point. It’s not important for a simple rule substitution like this, but it’s a good habit to use it in case you ever want to plot something more complicated.


    In order to make this work in a Manipulate, the simple way is to use With[], which is one of Mathematica’s scoping constructs; it’s the one to use where you just want to substitute something in without using it as variable you can mutate.

    For example,

    Manipulate[
      With[{sol = NDSolve[{x'[s] == - x[s], x[0] == 1}, x, {s, 0, 10}]},
        {Plot[x[t] /. sol // Evaluate, {t, 0, 10}, PlotRange -> {0, 1}], 
         x[4] /. sol}],
      {{a, 1}, {0, 5}}]
    

    Use the PlotRange option to keep the y-axis fixed; otherwise things will jump around in an ugly way as the value of a changes. When you do more complex things with Manipulate, there are a number of options for controlling the speed of updates, which can be important if your ODE is complicated enough that it takes a while to solve.

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

Sidebar

Ask A Question

Stats

  • Questions 381k
  • Answers 381k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer UPDATE: Addresses the need to append unique values I'm no… May 14, 2026 at 10:15 pm
  • Editorial Team
    Editorial Team added an answer You should make car_id a primary key in cars. May 14, 2026 at 10:15 pm
  • Editorial Team
    Editorial Team added an answer Yes. May 14, 2026 at 10:15 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.