Find area between the curve y = 1/(1+x^2) and the x-axis - area

Find area between the curve y = 1/(1+x^2) and the x-axis. This is Calculus 2. I think I have a and b correct, but not sure of c. Any help would be very much appreciated! :)
(a) from -10 to 10
Answer that I got: arctan(10)-arctan(-10) = 2.942
(b) from -A to A
Answer that I got: arctan(A)-arctan(-A)
(c) Find the area under the whole curve. (Calculate the limit of your answer in part (b) as A → ∞)
Have no idea, I think as A → ∞ then arctan(A) = pi/2, but do we also do it for -A? So would the answer be arctan(pi/2)-arctan(-pi/2)= 2?
Thanks for the help!

Good job.
(a) is correct.
(b) is correct and can also be written 2*arctan(A),
because arctan(-A) = -arctan(A).
(c) careful here: arctan(A)→pi/2 as A → ∞, and arctan(-A) → -pi/2 as A → ∞,
so arctan(A) - arctan(-A) → pi.

Related

Why is Mathematica producing a seemingly wrong answer for a derivative?

I'm puzzled by what I think is a mistake in a partial derivative I'm having Mathematica do for me.
Specifically, this is what I have:
Derivative I'd like to take
I'm trying to take the partial derivative of the following w.r.t. the variable θ (apologies for the formatting):
f=(1/4)(-4e((1+θ)/2)ψ+eN((1+θ)/2)ψ+eN((1+θ)/2-θd)ψ)-s
But the solution Mathematica produces seems very different from the one I get when I take the derivative myself. While Mathematica says the partial derivative of f w.r.t. θ is:
(1/4)eψ(N-2)
By hand, I get and am quite confident the correct answer is instead:
(1/4)eψ(N(1-d)-2)
That is, Mathematica is producing something that drops the variable d when it is differentiating. I've explored different functions that take a derivative in Mathematica, and the possibility that maybe some of the variables I'm using (such as d) might be protected or otherwise special, but I can't say that I know why the answer's so off. This is the first time in the notebook that d appears, so it is not set to 0. For context, I'm trying to confirm that the derivative of the function is positive for values of the variables in certain ranges, and we have d>0 and d<(1/2). Doing this all by hand works but I'm trying to confirm with Mathematica as I will be dealing with more complicated functions and need to make sure I'm having Mathematica produce the right derivatives.
Your didn't add spaces in eN and θd, so it thinks they're some other 2-character variables.
Adding spaces between them gives your expected result:
f[θ,e,N,ψ,d,s] = (1/4) (-4 e ((1+θ)/2) ψ + e N ((1+θ)/2) ψ + e N ((1+θ)/2 - θ d) ψ) - s;
D[f[θ, e, N, ψ, d, s], θ] // FullSimplify
(* 1/4 e (-2 + N - d N) ψ *)

Problem implementing Attentive Pooling Network for Question Answering

I'm following this paper to implement and Attentive Pooling Network to build a Question Answering system. In chapter 2.1, it speaks about the CNN layer:
where q_emb is a question where each token (word) has been embedded using word2vec. q_emb has shape (d, M). d is the dimension of the word embedding and M the length of the question. In a similar way, a_emb is the embedding of the answer with shape (d, L).
My question is: how is the convolution done and how is it possible that W_1 and b_1 are the same for both the operations? In my opinion at least b_1 should have a different dimension in each case (and it should be a matrix, not a vector....).
At the moment I've implemented this operation in PyTorch:
### Input is a tensor of shape (batch_size, 1, M or L, d*k)
conv2 = nn.Conv2d(1, c, (d*k, 1))
I find that the authors of the paper are trusting the readers to assume/figure out a lot of things here. From what I read, here is what I could gather:
W1 should be a 1 X dk matrix because that is the only shape that would make sense in order to get Q as c X M matrix.
Assuming this, b1 need not be an matrix. From the above, you could get a c X 1 X M matrix which could be reshaped to c X M matrix easily and b1 could be a c X 1 vector which could be broadcasted and added to the rest of the matrix.
Since, c, d and k are hyper parameters, you could easily have the same W1 and b1 for both Q and A.
This is what I think so far, I will re read and edit in case anythings amiss.

Algorithms (textbook) by Dasgupta. Prob. 1.36 Square Roots

To begin I want to say that this is NOT a homework problem. I know stackoverflow condemns people who ask for homework solutions. I merely doing this problem out of interest.
This is the question that I am working on:
Need help with part (b), not (a)
I believe I understand (a); I had my own answer but I managed to compare my solution with a Chegg preview solution (it doesn't show part (b)). So far from my understanding of part (b) is the following:
when they say
x is a square root of a modulo p if a = x^2(mod p)
they mean:
x = sqrt(a mod p) IF a = x^2(mod p).
Now, where it says,
if a has a square root modulo p, then a^((p+1)/4) is such a square root
confuses me a lot. I'm not really sure what this line means!
if a has a square root modulo p, then a^((p+1)/4) is such a square root
=
If there exists K such that K^2 mod p = a,
then
a^((p+1)/4) mod p = K

Deciding inhabitation?

Consider the basic system of simple types usually known as TAλ. One can prove that (as a consequence of the so called Subject Reduction Property and the fact that any typable term is strongly β-normalising)
If τ has an inhabitant, then it has one in β-normal form.
It follows that given an inhabitation problem Γ ⊢ X : τ we can effectively construct an algorithm that nondeterministically guesses step by step the shape of a normal solution: either (i) X is xY_1...Y_n or (ii) X is λz.Y:
(i) If for some n ≥ 0 there a judgment x : σ_1 → ... → σ_n → τ in Γ, then nondeterministically select it, set X = xY_1...Y_n and (only if n > 0) consider parallel problems
Γ ⊢ Y_1 : σ_1,...,Γ ⊢ Y_n : σ_n
(ii) If τ is τ_1 → τ_2, then for a fresh variable z, set X = λz.Y and consider the problem
Γ, z : τ_1 ⊢ Y : τ_2.
Furthermore, since all types in the constraints at each step of the algorithm are proper subtypes of the original input, the number of steps of the algorithm is at most polynomial in the size of τ. Therefore, the algorithm above is a decision procedure for the inhabitation problem.
My question is the following: what's wrong in the above reasoning? I've been searching all day for a decision procedure for the inhabitation problem for simple types, but all the proofs I can find are rather long and use complicated machinery (e.g. long normal forms, Curry-Howard isomorphism, etc...). There must be something that I don't see.
Sorry, I'm not used to unicode and SO doesn't support LaTeX. I also asked the same question on MO https://mathoverflow.net/questions/140045/is-there-an-easy-decision-algorithm-for-the-inhabitation-problem-for-simple-type, but the lambda calculus group doesn't seem too active there.

Mathematica: How to use a single equation with multiple parameters to calculate any parameter

Currently I use a single equation with different combination of known/unknown parameters. As I don't have any fancy calculator it would be much easier to define the equation in Mathematica and passing known parameters to calculate unknown values.
I would be very thankful if anyone of you could give an example solution (if possible using given equation).
Let's say we have an equation of satellite speed at given point in the elliptical orbit:
v = sqrt(u(2/r - 1/a))
where
v = speed
u = constant 3.986 * 10^14 m^3/s^2
r = radius (distance from the center of the Earth)
a = semi major axis of the ellipse
This equation can be used to calculate the speed or for example we know what is the speed needed for a manoeuvre to move the cargo to other orbit and have to model the orbit (a) at given radius (r)
Thanks!
You can define equations in Mathematica using the ":=" operator. To define the example equation:
v[u_, r_, a_] := Sqrt[u*(2/r-1/a)]
I'm not sure how to generalize it to solve for any unknown...If I figure it out I'll get back to you.
You may want to try something like:
Solve[v[1, r, 7]==15, r]
that will solve for r assuming you know v, u, and a... you can then change each of the paramaters for the unknown...
A little bit late :) ... but Reduce[] does what you want. We define a function:
solveForMe[rules_] := Reduce[( v == Sqrt[3.986*10^14 *(2/r - 1/a)]) /. rules];
and invoke it with any valid combination for the assignments. For example:
In[72]:= Off[Reduce::ratnz];
solveForMe[{a -> 7 10^6, r -> 7 10^6}]
solveForMe[{v -> 10, r -> 7 10^6}]
solveForMe[{v -> 10, a -> 7 10^6}]
The output is :
Out[73]= v == 7546.05
Out[74]= a == 3.5*10^6
Out[75]= r == 1.4*10^7
HTH! ...

Resources