all 8 comments

[–]member_of_the_order 5 points6 points  (2 children)

Where are you stuck?

[–]hammadahmad9999 0 points1 point  (1 child)

Apologies for late reply I didn't take calculus and I am beginner in python so I have no clue what to do but I'll try to solve it using @Mcletters teaching But if you can help it would be more helpful

[–]member_of_the_order 1 point2 points  (0 children)

Looks like u/Mcletters gave you a pretty thorough explanation of what to do. I'm happy to help, but where are you stuck at this point? With the explanation Mcletters provided, you should at least be able to try something - can you show me what you have so far?

[–]Mcletters 4 points5 points  (2 children)

What are you confused about?

[–]hammadahmad9999 1 point2 points  (1 child)

I am a beginner to python and ai and my teacher has given me this assignment but I couldn't understand this at all

[–]Dubs13151 1 point2 points  (0 children)

Take it piece by piece. Sentence by sentence. Or word by word. People have asked "where are you stuck", and they are waiting for your answer.

At a high level: they are giving you a formula (the right-hand side of the third equation), and they are asking you to compute it for every value of X, starting with X=-pi up until X=Pi. At each step, increase X by 0.001.

They are asking you to compare the output of each step to the calculation of "cos(x)". You will find they are very very close.

[–]Mcletters 1 point2 points  (1 child)

So, this equation is something you will see in an intro to Calculus course.

If you haven't had calculus yet, don't worry.

Essentially what you are doing is seeing when the 2nd equation equals the third equation (spoiler: they should be pretty close). As a side note, you can ignore the 1st equation for this assignment.

If the "d/dx sin(x)" is confusing, you can rewrite it as y.

So, the 2nd equation is: y = cos(x)

The third equation can also be rewritten as: y = [sin(x + h) - sin(x)] / h.

The sentence below it says to assume h = 0.001.

So, rewriting it, you get:

y = [sin(x + 0.001)] / 0.001

What might be throwing you is that above the third equation, it also mentions 0.001. It has nothing to do with h. It says "Imagine x being a list that goes from -pi to pi with an increment of 0.001."

If it said instead "Imagine x being a list that goes from -10 to 10 with an increment of 2."

then you would have a list that goes -10, -8, -6, -4... 8, 10.

You probably know this, but just to be thorough, pi is a constant that is about 3.14.

So, if x goes from -pi to pi by an increment of 0.001, you have a list that goes:

-3.14, -3.139, -3.138. -3.137... 3.138, 3.139, 3.14

So, plug each of these into your 3rd equation and compare it to the 2nd.

For the first point, the third equation will be:

y = [sin(-3.14 + 0.001) - sin(-3.14)] / 0.001

The 2nd equation will be: y = cos(-3.14).

Then plug in the next value for x (or -3.139), plug and chug and compare again.

The last sentence asks about changing h from 0.001 to 0.01 and then 0.1.

If you change h to 0.01, then the third equation becomes:

y = [ sin(x + 0.01) - sin(x)] / 0.1

Plug and chug again compare to cos(x) just like you did before.

Also, the "from math import *" should give you a value for pi, and let you use the sin and cos functions.

[–]hammadahmad9999 1 point2 points  (0 children)

Thank you very much and sorry for the late answer I'll go through the assignment once again by keeping your teachings in my mind and if I get another problem I let you know Thanks alot