Identify this equation

BenjiHen

New member
Joined
Jan 22, 2021
Messages
9
Hello,

I need to identify and work out what this expression means as I have to convert this into Python code:

Scenario
Your task is to complete the code in order to evaluate the following expression:
b28be61cd2ada9483ab1e86e8be7b0b797d24674.png

Thankyou
 
It's mostly a matter of using parentheses correctly. Give it a try, and we can correct you if needed (or commend you if warranted).
 
Thankyou for the reply, but I am a bit dumb. I need to know what this mathematical expression is. Is it formulas, or a divisional expression? How do I break this down to its basic elements? Ich weise nicht!
 
Last edited:
Thankyou for the reply, but I am a bit dumb. I need to know what this mathematical expression is. Is it formulas, or a divisional expression? How do I break this down to its basic elements? Ich weise nicht!
Calling yourself dumb is dumb.
I am not aware of a name that can be used for this expression.
You break it down the same way you break down x(1+x). Use rules of precedence.
 
Thankyou for the reply, but I am a bit dumb. I need to know what this mathematical expression is. Is it formulas, or a divisional expression? How do I break this down to its basic elements? Ich weise nicht!
The expression is called a finite continued fraction, though the name doesn't help you do what you want to do.

But if you search for the phrase, you may find examples of such an expression written in-line, which I believe is what you want.

A typical piece of it is that \(\frac{1}{1+x}=1/(1+x)\).

Give it a try, and we can correct you if necessary.
 
Hello,

I need to identify and work out what this expression means as I have to convert this into Python code:

Scenario
Your task is to complete the code in order to evaluate the following expression:
b28be61cd2ada9483ab1e86e8be7b0b797d24674.png

Thankyou
Since your are talking about coding, one possibility is that you are meant to use a recursive algorithm.
 
Thanks for your help...I got

y =(1/(x+1)/(x+1)/(x+1)/x)
No, that doesn't work.

What you wrote means `y =(((1/(x+1))/(x+1))/(x+1))/x`.

It should be clear that that is wrong. You want it to look like this instead: `y =1/(x+1/(x+1/(x+1/x)`.

Now, since you apparently haven't been taught about recursive coding, we have no idea what is expected. Please tell us something about the context: What are you studying, how much Python have you learned, what were you most recently taught that this would be meant to give you practice with, and so on.
 
Hi, sorry for the late reply. I am studying Python as a beginner. It is a course that seems to come from the perspective of a mathematician. I expect because of the way python is used in certain environments, then maths is the approach they want to use.

This is the question in full:

Objectives
  • becoming familiar with the concept of numbers, operators and arithmetic operations in Python;
  • understanding the precedence and associativity of Python operators, as well as the proper use of parentheses.
Scenario
Your task is to complete the code in order to evaluate the following expression:
b28be61cd2ada9483ab1e86e8be7b0b797d24674.png

The result should be assigned to y. Be careful - watch the operators and keep their priorities in mind. Don't hesitate to use as many parentheses as you need.
You can use additional variables to shorten the expression (but it's not necessary). Test your code carefully.
Test Data
Sample input: 1
Expected output:
y = 0.6000000000000001
Sample input: 10
Expected output:
y = 0.09901951266867294
Sample input: 100
Expected output:
y = 0.009999000199950014
Sample input: -5
Expected output:
y = -0.19258202567760344

This is how it is meant to be presented to a python sandbox tool:

x = float(input("Enter value for x: "))

y = # put your code here( the code is meant to be presented on one line)

print("y =", y)
 
They don't want a recursive algorithm, as was suggested; they just want an expression, properly parenthesized. Just add parentheses as needed to the expression you wrote before. Think about what I said in post 10. You may even want to hit "reply" in that post and look carefully at how I formatted the expression ...

Give it a try and show it to us.
 
Thanks, I see what you did here, but it has to be set out to confirm to Python arithmetic rules and position of parenthesis.
For this to work in Python the expression would have to look like this: 1/(x+1)/(x+1)/(x+1)/x. This works under python, but the computational results are incorrect, which highlights that I have not got a grasp on the actual expression which will give the correct results.
 
Thanks, I see what you did here, but it has to be set out to confirm to Python arithmetic rules and position of parenthesis.
For this to work in Python the expression would have to look like this: 1/(x+1)/(x+1)/(x+1)/x. This works under python, but the computational results are incorrect, which highlights that I have not got a grasp on the actual expression which will give the correct results.
Yes, the results are incorrect because it MEANS the wrong thing!

The expression I wanted you to use is 1/(x+1/(x+1/(x+1/x))). Try using that in Python and see if you get the right results. I see now that what you quoted is missing the last two parentheses; I don't know how that got dropped, but the typesetter here apparently doesn't require matching parentheses, so it didn't notice. That must be what you meant by implying that it didn't work; presumably Python gave you an error. I apologize.

Your 1/(x+1)/(x+1)/(x+1)/x means "first divide 1 by x+1; then divide the result by x+1; then divide that result by x+1 again; and finally divide by x." That's wrong.

My 1/(x+1/(x+1/(x+1/x))) means just what the given expression means: Start in the innermost parentheses, adding x and 1/x; then in the next level of parentheses, add x and 1 divided by what you previously found; and so on.

All this should be things you learned in algebra about writing expressions; Python, on the whole, is no different.
 
Yes, the results are incorrect because it MEANS the wrong thing!

The expression I wanted you to use is 1/(x+1/(x+1/(x+1/x))). Try using that in Python and see if you get the right results. I see now that what you quoted is missing the last two parentheses; I don't know how that got dropped, but the typesetter here apparently doesn't require matching parentheses, so it didn't notice. That must be what you meant by implying that it didn't work; presumably Python gave you an error. I apologize.

Your 1/(x+1)/(x+1)/(x+1)/x means "first divide 1 by x+1; then divide the result by x+1; then divide that result by x+1 again; and finally divide by x." That's wrong.

My 1/(x+1/(x+1/(x+1/x))) means just what the given expression means: Start in the innermost parentheses, adding x and 1/x; then in the next level of parentheses, add x and 1 divided by what you previously found; and so on.

All this should be things you learned in algebra about writing expressions; Python, on the whole, is no different.
Hi Dr Peterson,

Thanks for the reply. Thank you for making me understand these basic formulaic expressions. That's just the explanation I wanted. That requires that I see the INNERMOST parentheses, that's what I missed, and it did suggest that in the Python course, I just missed that one. Thank you again, your help is much appreciated. I will try this and get back to you..
 
Hi Dr Peterson, it worked. I got the correct result when I inputted the value assigned for this exercise:

Code -
x = float(input("Enter value for x: "))

y = 1/(x+1/(x+1/(x+1/x)))

print("y =", y)

result -
Enter value for x: 1
y = 0.6000000000000001


Again thank you for your help..
 
Top