You're right -- the "will be equal to ..." part threw me off. I should have said that "will be equal to more than" is equivalent to "will be more than," which, in addition, is less obfuscating.
"Bolded" and "emboldened" have different meanings, with "bolded" usually used in the context of printed text, and "emboldened" usually used to describe an emotional state. I have bolded the preceding text. I was at first fearful, but became emboldened to write this reply to your post.
The array in the input file has 9 rows, each with two numbers. The for loop in your code runs 10 times. See if changing the condition part of your loop from i <= 9 to i < 9 fixes your problem.
Thread locked. Your image files can't be viewed without logging into another site. Please start a new thread with any images attached in your work, not as links to external sites.
Here's a different approach from the one presented by @wle, that uses the idea hinted at by @Klystron. This code will fill the array with 0000, 0001, 0002, ... , 7777.
Nested loops aren't ideal for performance, as they cause the CPU pipeline to be invalidated, but I don't think this is a concern...
Given that the OP asked about an interview problem, this is probably good enough, but this algorithm suffers from not calculating leap days correctly (e.g., the rule is different in centuries that are divisible by 100 vs. those that are divisible by 400). It is also problematic in doing...
Yes, that is more-or-less correct. The expression ##\frac{d(\tan(x))}{dx}## is the derivative of the tangent function, with respect to its variable x.
The substitution was ##u = \tan(x)## from which the differentials of the two sides would be as you have below. Note that we would usually write...
No. Are you just guessing?
Do you know the formula for calculating the slope of the line between two points?
In your first post in this thread you wrote:
That is not the formula for the slope of a line.
I said I got a number less than 1.
From your graph, it appears that the points you're using are (-2, -1) and (3, 2). You have labeled this points, but the image is too poor for me to read them -- I just counted squares on the grid.
If you know two points on a line, how do you find the slope of...
Our life, and yours, would have become easier if you had explained what ##t^n## means right at the beginning of this thread.
I realize that English is not your first language. To concatenate two strings means that the two strings are joined together to form a single string. For example, the...
Are you asking about problem 5? If so, your answer is wrong. For the two points you marked, what is the rise (vertical change) and what is the run (horizontal run)?
I get a slope that is less than 1.
In the future, if you post an image, please make more of an effort to post a legible picture...
Please use parentheses. In the first equation, 1/2tan2x means ##\frac 1 2 \tan(2x)##. If you don't use LaTeX, it should be written as 1/(2 tan(2x)).
In the second equation, what you wrote on the right side means ##\frac{2\tan(x)}1 - \tan^2(x)##, which is probably not what you meant. As inline...
@zak100, you will never be able to do this problem if you can't answer the question @QuantumQuest asked way back in post #2.
His hint that ##t^n## represents the concatenation of a string t with itself some number of times seems to be the best interpretation of this notation.
Well, this is exactly what you need to prove.
Of course you can't -- you can't use something that you're supposed to prove.
Take a look again at what I wrote in post #10:
ODE45 and NDSolve don't know anything about the analytic solution. All they have to go on are the differential equation and initial conditions, and they use this information to get another solution point. The farther away you get from, in this case, t = 0, the less accurate the computed solution is.
See post #9.
From the documentation for the method you're using. They should give you some idea of the accuracy of the method in terms of the interval around the initial conditions.
Differentiability isn't necessary. If both limits on the right side of the equation I wrote exist, and the limit in the denominator is not zero, then the quotient of the limits equals the limit of the quotients.
I don't do Mathematica, but there are a couple of things in your screen shot that puzzle me.
First, when you define the exact solution, xE[t_], you have a different parameter in the definition:
$$xE[t_\ ] := \frac{Tanh[b + \frac t {\sqrt 2}]}{\sqrt{-\alpha \epsilon}}$$
Shouldn't you have t_ on...
Numerical solutions don't necessarily give good solutions over a large interval. Your numeric solution matches the exact solution pretty well when x is close to 0, the value used in the initial conditions. When x is relatively far away from 0, the numeric solution varies considerably from the...
I don't think so. ##t^n## probably represents a string with n characters, and ##|t^n|## might mean the length of such a string. Since you aren't sure, you better make sure that's the case.
I would start with a base case of n = 1, a string that contains one character.
This is the Induction...
I don't believe there is a numpy (or scipy) function named either npsavetext or .npsavetext. There is a function named savetext(), but it is limited to saving a single one- or two-dimension array to a text file.
Based on the documentation I found...
Is this really what you meant? For a function ##f : \mathbb C \to \mathbb C##? You have an extra two dimensions. For the domain you need only two dimensions, not four.