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 xx and yy , as well as the left sides of the four answer choices. It is clear from the graphs that option 33 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

#Calculus

Note by Steven Chase
10 months, 3 weeks ago

No vote yet
1 vote

  Easy Math Editor

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.
  • Stay on topic — we're all here to learn more about math and science, not to hear about your favorite get-rich-quick scheme or current world events.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold

- bulleted
- list

  • bulleted
  • list

1. numbered
2. 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 1

paragraph 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×3 2 \times 3
2^{34} 234 2^{34}
a_{i-1} ai1 a_{i-1}
\frac{2}{3} 23 \frac{2}{3}
\sqrt{2} 2 \sqrt{2}
\sum_{i=1}^3 i=13 \sum_{i=1}^3
\sin \theta sinθ \sin \theta
\boxed{123} 123 \boxed{123}

Comments

@Steven Chase

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.

Krishna Karthik - 10 months, 3 weeks ago

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

Talulah Riley - 10 months, 3 weeks ago

Log in to reply

Numerical techniques don't do that for you

Steven Chase - 10 months, 3 weeks ago

Log in to reply

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

Talulah Riley - 10 months, 3 weeks ago

Log in to reply

@Talulah Riley 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
#>>> 

Steven Chase - 10 months, 3 weeks ago

Log in to reply

@Steven Chase @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??

Talulah Riley - 10 months, 3 weeks ago

Log in to reply

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

Steven Chase - 10 months, 3 weeks ago

@Talulah Riley 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🤣

Krishna Karthik - 10 months, 3 weeks ago

Log in to reply

@Krishna Karthik @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.

NJ STAR - 10 months, 3 weeks ago

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

NJ STAR - 10 months, 3 weeks ago

Log in to reply

@Nj Star 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.👍🏽

Krishna Karthik - 10 months, 3 weeks ago

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

Talulah Riley - 10 months, 3 weeks ago

Log in to reply

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=VRet/(3RC) I = \frac{V}{R} e^{-t/(3RC)}

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

Steven Chase - 10 months, 3 weeks ago

Log in to reply

@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

Talulah Riley - 10 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??

Talulah Riley - 10 months, 3 weeks ago

Log in to reply

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

Steven Chase - 10 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.

Krishna Karthik - 10 months, 3 weeks ago

Log in to reply

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.

Steven Chase - 10 months, 3 weeks ago

Log in to reply

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

Krishna Karthik - 10 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=5t=5 .

Talulah Riley - 10 months, 3 weeks ago

Log in to reply

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

Steven Chase - 10 months, 3 weeks ago

Log in to reply

@Steven Chase it is a current carrying conductor .

Talulah Riley - 10 months, 3 weeks ago

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

Talulah Riley - 10 months, 2 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
Thanks in advance.
Hope I am not disturbing you.

Talulah Riley - 10 months, 2 weeks ago

Log in to reply

I have uploaded the solution

Steven Chase - 10 months, 2 weeks ago

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

Talulah Riley - 10 months, 2 weeks ago

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

Talulah Riley - 10 months, 2 weeks ago

Log in to reply

Hello. I found this one online

https://doubtnut.com/question-answer-physics/the-electric-field-between-the-plates-of-a-parallel-plate-capacitor-is-e0-the-space-between-the-plat-15086045

Steven Chase - 10 months, 2 weeks ago

Log in to reply

@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 Qinduced=NetdipolemomentdQ_{induced}=\frac{Net dipole moment}{d}
How did he write this , I didn't able to understand??

Talulah Riley - 10 months, 2 weeks ago

Log in to reply

@Talulah Riley That seems consistent with the elementary definition given here

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

Steven Chase - 10 months, 2 weeks ago

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

Talulah Riley - 10 months, 2 weeks ago

Log in to reply

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

Steven Chase - 10 months, 2 weeks ago

Log in to reply

@Steven Chase I have posted a problem right now.

Talulah Riley - 10 months, 2 weeks ago

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

Talulah Riley - 10 months, 1 week ago

Log in to reply

Are you sure this is uniquely solvable?

Steven Chase - 10 months, 1 week ago

Log in to reply

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

Talulah Riley - 10 months, 1 week ago

Log in to reply

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

Steven Chase - 10 months, 1 week ago

Log in to reply

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

Talulah Riley - 10 months, 1 week ago

Log in to reply

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

Steven Chase - 10 months, 1 week ago

Log in to reply

@Steven Chase @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.

Talulah Riley - 10 months, 1 week ago

Log in to reply

@Talulah Riley So do they give a definite answer?

Steven Chase - 10 months, 1 week ago

Log in to reply

@Steven Chase @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.

Talulah Riley - 10 months, 1 week ago

Log in to reply

@Talulah Riley What capacitor voltages do they give?

Steven Chase - 10 months, 1 week ago

Log in to reply

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

Talulah Riley - 10 months, 1 week ago

Log in to reply

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

Steven Chase - 10 months, 1 week ago

Log in to reply

@Steven Chase @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.

Talulah Riley - 10 months, 1 week ago

Log in to reply

@Talulah Riley I will post a note on it

Steven Chase - 10 months, 1 week ago

Log in to reply

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

Talulah Riley - 10 months, 1 week ago
×

Problem Loading...

Note Loading...

Set Loading...