# Sanity Checking Diff Eq Solution Using Numerical Integration

Here is a rather complicated looking differential equation.

The code below solves the diff eq numerically using explicit Euler integration, and plots $x$ and $y$, as well as the left sides of the four answer choices. It is clear from the graphs that option $3$ is the correct answer, since it is the only one which plots as a constant. Also, using implicit differentiation on the third answer choice confirms that it is correct.

I also want to note that this differential equation seems to be rather badly behaved from a numerical perspective, so caution is advised when simulating it.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 import math dx = 10.0**(-6.0) count = 0 x = 2.0 y = 3.0 num = 3.0*(x**2.0)*(y**4.0) + 2.0*x*y denom = x**2.0 - 2.0*(x**3.0)*(y**3.0) yd = num/denom print "x y q1 q2 q3 q4" while x <= 4.0: x = x + dx y = y + yd*dx num = 3.0*(x**2.0)*(y**4.0) + 2.0*x*y denom = x**2.0 - 2.0*(x**3.0)*(y**3.0) yd = num/denom q1 = (y**2.0)/x - (x**3.0)*(y**2.0) q2 = (x**2.0)/(y**2.0) + (x**3.0)*(y**3.0) q3 = (x**2.0)/y + (x**3.0)*(y**2.0) q4 = (x**2.0)/(3.0*y) - 2.0*(x**3.0)*(y**2.0) count = count + 1 if count % 10000 == 0: print x,y,q1,q2,q3,q4 

Note by Steven Chase
5 months, 4 weeks ago

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

• Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
• Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
• Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold
- bulleted- list
• bulleted
• list
1. numbered2. list
1. numbered
2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in $$ ... $$ or $ ... $ to ensure proper formatting.
2 \times 3 $2 \times 3$
2^{34} $2^{34}$
a_{i-1} $a_{i-1}$
\frac{2}{3} $\frac{2}{3}$
\sqrt{2} $\sqrt{2}$
\sum_{i=1}^3 $\sum_{i=1}^3$
\sin \theta $\sin \theta$
\boxed{123} $\boxed{123}$

Sort by:

Hi Neeraj Anand Badgujar came to me for some help with numerically computing a really complicated integral for his new problem or something. The image is posted in the newest note I have made. I have created and compiled a piece of code, and I think the integral is divergent. Thanks and cheers.

- 5 months, 3 weeks ago

@Steven Chase Thanks.
Suppose if I didn't give you options then how you will find that expression of answer.
Hope I am not disturbing you.

- 5 months, 4 weeks ago

Numerical techniques don't do that for you

- 5 months, 4 weeks ago

@Steven Chase I am giving one more problem.
Thanks in advance. Hope I am not disturbing you.

- 5 months, 4 weeks ago

Here it is. The answer is the fourth option:

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 import math pisq = math.pi**2.0 dx = -(10.0**(-6.0)) x = math.pi/2.0 y = 0.0 num = 4.0*x - y*math.cos(x) denom = math.sin(x) yd = num/denom ############################################### while x >= math.pi/6.0: x = x + dx y = y + yd*dx num = 4.0*x - y*math.cos(x) denom = math.sin(x) yd = num/denom ############################################### print dx print y print "" opt1 = -4.0*pisq/9.0 opt2 = 4.0*pisq/(9.0*math.sqrt(3.0)) opt3 = -8.0*pisq/(9.0*math.sqrt(3.0)) opt4 = -8.0*pisq/9.0 print opt1 print opt2 print opt3 print opt4 #>>> #-1e-06 #-8.77298206228 #-4.38649084493 #2.53254167012 #-5.06508334023 #-8.77298168986 #>>> 

- 5 months, 4 weeks ago

@Steven Chase Yes you answer is correct. Thanks.
By the way check my solution for your new problem.
By the way I want to ask 3-4 small questions on electrostatics?
Aree you free now??

- 5 months, 3 weeks ago

Yeah, I saw your solution. Nice job. I'm going to bed now, but I'll be back tomorrow

- 5 months, 3 weeks ago

Lol the funny thing is that US and India are on opposite sides of the globe, so you'll only get to talk to Steven Chase when he's going to bed. Lmao🤣

- 5 months, 3 weeks ago

@Krishna Karthik Day and Night are same for me.
I can easily spend my whole night discussing physics with him.
I can do anything for studying physics.

- 5 months, 3 weeks ago

@Krishna Karthik I generally talk with him in night only, so it will be morning in USA.

- 5 months, 3 weeks ago

Ha yea, that's funny. Anyway, what's even funnier is that I'm going to bed now as well🤣 So good bye, have a great time.👍🏽

- 5 months, 3 weeks ago

@Steven Chase Hello.
Can you help me in the above problem
Thanks in advance. Hope I am not disturbing you.

- 5 months, 3 weeks ago

I think this is just a complicated way of asking for the energy dissipated in the resistor over all time. This is because the voltages across the two capacitors are the same, so the charge on capacitor A is always half that of capacitor B. The current through the resistor is (let the source voltage be V):

$I = \frac{V}{R} e^{-t/(3RC)}$

Then integrating $I^2 R$ over all time results in $\frac{3}{2} V^2 C$

- 5 months, 3 weeks ago

@Steven Chase Thanks. I am facing difficulty in RC and RL circuits.
I didn't have questions of these topics also.
Can you post some questions

- 5 months, 3 weeks ago

@Steven Chase Hello.
I am making a problem to dedicate it to you, but not able to solve.
Will you help me??

- 5 months, 3 weeks ago

Sure, I can take a look. Probably not until this evening though

- 5 months, 3 weeks ago

@Steven Chase Hey, have you tried using Runge-Kutta 4th order by any chance?

When I get home from school, I might try running this on my RK engine. I'm on my Mac Craptop at the moment; will try running it on my gaming PC later on. Nice job!😄Cool stuff.

- 5 months, 3 weeks ago

Indeed, I have used RK4. The interesting part is that a higher order method doesn't necessarily guarantee numerical stability. That depends more on the time step, as well as whether the method is implicit or explicit.

- 5 months, 3 weeks ago

@Steven Chase Yes, very true. The only think RK4 would guarantee is a better result at the same timestep. That's some nice code :)

- 5 months, 3 weeks ago

@Steven Chase I think it is evening now. here is the problem
Find the displacement between the centre of mass of rod and origin at $t=5$ .

- 5 months, 3 weeks ago

How can there be current in that wire segment? It is not a closed loop

- 5 months, 3 weeks ago

@Steven Chase it is a current carrying conductor .

- 5 months, 3 weeks ago

@Steven Chase Just imagine that a battery is applied between the ends of rods and due to that $I_{0}=10$ current is flowing.
Now, if you see carefully, then unbalanced toque will be applied by magnetic force. Interesting!

- 5 months, 3 weeks ago

@Steven Chase sir what is the meaning of into the source?
You have posted similar question like this one before also., but in that the people who are uploading solutions, they JUST say I have taken numerical route

They should have to elaborate or post a python code in that problem.
By saying numerical route doesn't mean that your solution is ideal and well-completed.
This above line are my views and my opinion.
Please don't take in wrong way.
Can you post a numerical whole solution of this problem
Hope I am not disturbing you.

- 5 months, 3 weeks ago

- 5 months, 3 weeks ago

@Steven Chase can you post a similar one more problem, like you posted yesterday? Please
BTW how are you?

- 5 months, 3 weeks ago

@Steven Chase Hello
Can you help me in this problem?
Thanks in advance. Hope I am not disturbing you.

- 5 months, 2 weeks ago

Hello. I found this one online

- 5 months, 2 weeks ago

@Steven Chase Hello.
I also go to there before asking you, and in that video I didn't understand the step 2:26.??
At that step he writes that $Q_{induced}=\frac{Net dipole moment}{d}$
How did he write this , I didn't able to understand??

- 5 months, 2 weeks ago

That seems consistent with the elementary definition given here

https://en.wikipedia.org/wiki/Electricdipolemoment

- 5 months, 2 weeks ago

@Steven Chase are you free now? I want to ask some doubts?

- 5 months, 2 weeks ago

You can post them. I'm not really free, but I'm checking Brilliant periodically throughout the day

- 5 months, 2 weeks ago

@Steven Chase I have posted a problem right now.

- 5 months, 2 weeks ago

@Steven Chase Hello.
I have also searched for online solution but no one explains a good way.
Hope I am not disturbing you.

- 5 months, 2 weeks ago

Are you sure this is uniquely solvable?

- 5 months, 2 weeks ago

@Steven Chase what do you mean sir? I didn't able to understand.

- 5 months, 2 weeks ago

Is there only one set of capacitor voltages that works, or are there many?

- 5 months, 2 weeks ago

@Steven Chase again I didn't able to understand. Sorry

- 5 months, 2 weeks ago

It looks to me like there are many sets of capacitor voltages that satisfy the circuit constraints

- 5 months, 2 weeks ago

@Steven Chase Yeah! When I was seeing online solution they were removing the upper and bottom capacitor.
So, that is what I think you also want to say. By the way, in my opinion why they are removing this capacitor, in online solutions they just remove it in in a careless way without giving a good explanation.

- 5 months, 2 weeks ago

So do they give a definite answer?

- 5 months, 2 weeks ago

@Steven Chase yeah they give me definite answer at the last, but they doesn't discuss that how they removes this 2 capacitor in a good explanatory way.

- 5 months, 2 weeks ago

What capacitor voltages do they give?

- 5 months, 2 weeks ago

@Steven Chase how did they removed this 2 capacitors, this is the only thing which I want to ask.

- 5 months, 2 weeks ago

That is indeed one possible solution. But it is not the only possible solution. So the question is not formulated properly

- 5 months, 2 weeks ago

@Steven Chase Yeah! And I am expecting a perfect solution from you.
And give me some advice that how the question should be formulated.
Note:This questions in India are of JEE level and you are a man of high level who have studied things in university level, according to my teacher this questions is perfectly formulated.
Therefore it is obvious you will feel some question not properly demonstrated. It is ok. No problem.

- 5 months, 2 weeks ago

I will post a note on it

- 5 months, 2 weeks ago

@Steven Chase But when?
And please don't forget to write my name in this way.
This question was asked by Neeraj recently.
Bye

- 5 months, 2 weeks ago