current position：Home>Who can help me see why this program reports errors
Who can help me see why this program reports errors
2022-02-02 20:13:59 【CSDN Q & A】
from sympy import *import mathdef f_fa1(alpha): return math.sqrt(1 + alpha * alpha - alpha)def f_rho1(alpha): return (2 * alpha - 1) / (2 - alpha)def f_beta1(alpha): return 2 * f_fa1(alpha) / (2 - alpha)def f_epsilong2a(epsilong1a, alpha): return epsilong1a * f_rho1(alpha)def f_epsilonga(epsilong1a, alpha): return epsilong1a * f_beta1(alpha)def f_epsilong1b(epsilong1a, alpha2): return epsilong1a * (2 - alpha2) / (2 * alpha - 1)def f_epsilong3b(epsilong1b, epsilong2a): return 0 - epsilong1b - epsilong2adef f_epsilongb(epsilong1b, fa2, alpha2): return epsilong1b * (2 * fa2) / (2 - alpha2)def f_epsilong3a(epsilong1a, epsilong2a): return 0 - epsilong1a - epsilong2adef f(x, args1): f = (args1 + args1) ** args1 * (args1 * args1) ** args1 / args1 - args1 * ( args1 + args1 * (2 * math.sqrt(1 + x * x - x)) / (2 - x)) ** args1 * ( (2 * math.sqrt(1 + x * x - x)) / (2 * x - 1) * args1) ** args1 / math.sqrt(1 + x * x - x) * ( math.e ** ((args1 + (-args1 * (2 - args1) / (2 * args1 - 1) - args1)) - (args1 + args1))) return f# Newton's iteration def niu(args1): x = symbols('x') x0 = 0.01 x_list = [x0] i = 0 while True: if diff(f(x, args1), x).subs(x, x0) == 0: print(' Extreme points ：', x0) break else: x0 = x0 - f(x0, args1) / diff(f(x, args1), x).subs(x, x0) x_list.append(x0) if len(x_list) > 1: i += 1 error = abs((x_list[-1] - x_list[-2]) / x_list[-1]) if error == 0: return x_list[-1] else: passif __name__ == '__main__': f0 = 0.98 alpha = 0.3 epsilong1a = 0.005 epsilong3A = 0 epsilong3B = 0 epsilongA = 0 epsilongB = 0 n = -0.033 m = 0.172 epsilonga = f_epsilonga(epsilong1a, alpha) beta1 = f_beta1(alpha) fa1 = f_fa1(alpha) epsilong2a = f_epsilong2a(epsilong1a, alpha) epsilong3a = f_epsilong3a(epsilong1a, epsilong2a) args1 = [epsilongA, epsilonga, n, beta1, epsilong1a, m, fa1, f0, epsilongB, epsilong1a, n, epsilong2a, m, epsilong3B, epsilong2a, alpha, alpha, epsilong2a, epsilong3A, epsilong3a] alpha2 = niu(args1) fa2 = f_fa1(alpha2) epsilong1b = f_epsilong1b(epsilong1a, alpha2) epsilongb = f_epsilongb(epsilong1b, fa2, alpha2) iter = 0 while epsilongb / epsilonga < 10: iter += 1 epsilongA = epsilongA + epsilonga epsilongB = epsilongB + epsilongb epsilong3B = epsilong3B + f_epsilong3b(epsilong1b, epsilong2a) epsilong3A = epsilong3A + epsilong3a args1 = epsilongA args1 = epsilongB args1 = epsilong3B args1 = epsilong3A alpha2 = niu(args1) fa2 = f_fa1(alpha2) epsilong1b = f_epsilong1b(epsilong1a, alpha2) epsilongb = f_epsilongb(epsilong1b, fa2, alpha2) print("epsilong1a * The number of iterations is ：" + str(iter * epsilong1a)) print("epsilong2a * The number of iterations is ：" + str(iter * epsilong2a))
Refer to the answer 1：
First change the last two sentences to
print("epsilong1a * The number of iterations is ：" , (iter * epsilong1a))print("epsilong2a * The number of iterations is ：" , (iter * epsilong2a))
See if there's any hint
Refer to the answer 2：
author[CSDN Q & A],Please bring the original link to reprint, thank you.
The sidebar is recommended
- Generate images from HTML pages and download them into PDF files
- Two Python experiment questions
- Hidden display problems in HTML
- Is there any good analysis process for push box problem
- What's going on here?.,!
- Cyclic input and output. If the input is a number, it will print. If the input is not a number, it will print No
- C language freshman PTA input an English sentence, change the first letter of each word into capital letters.
- Question e: snake walking, please help me
- Why is the attenuation of wave height in numerical simulation serious?
- Difference between digital image processing and image signal processing (ISP)
guess what you like
Oracle a column of multi value update problem.
Write a program in Python.
How can Python write here to become a variable
Which rstudio is installed in win7 64 bit? Dear friends, the previous connection can install w10,8,7, but now it can only install W10. Cry.
Which is better, CCD camera tracking or gray sensor tracking
Virtual reality combined with AR space
How to click two label controls in QT to subtract the customized numbers in the control
Ask you why there is a period of garbled code in front of the output?
QR code generation of shopping scanning payment and third-party payment
The Internet is a large network composed of many small networks. Can a local area network also be such a small network? What's more, how large is the coverage of a small network in a large network?
- Write a function to randomly generate an array of length n with elements from 0 to 99
- I don't understand very well. Can you explain it?
- Help me look at the code (I'm just a freshman, so I only know C). Why the bill The data in txt will always become 0 (after each command 1 is executed and more than one order is entered, only the last order in txt is saved, and all the others become 0) (o
- After the Ubuntu language is switched to English, two desktops appear
- Ora-01555 snapshot is too old. Fallback segment number (name) is too small. Ora-22924 snapshot is too old
- Win10 system boot unlimited automatic repair, recycling the use of Baidu methods are invalid
- A node of database RAC cannot be accessed normally
- Android SDK does not have uiautomatorviewer Bat file
- How should this program be completed
- One to many query of mybatis. The query conditions are in multiple parties. PageHelper paging is integrated. How can this XML be better implemented
- Error in NPM run dev: unknown option '-- inline'
- Java database: error caused by: Java lang.ClassNotFoundException: Didn't find class 'java. sql. Sqltype 'problem, how to solve it?
- What attachments do SQL server send mail with?
- In the built-in browser in windows, if you can't open the direct search web page, you can open the web page by using the web address. How to solve it?
- Tomcat failed to start. Would you like to see help
- How does the StrCmp function compare string sizes? What is the method
- Find the first 30 numbers of sequence 1 1 2 3 5 8 13 21
- Java finds array elements of the specified type
- Vue3 uses Axios to request JSON files in the public folder, and there is always a 500 error!
- Is a graphic inheritance problem
- When two string attributes are defined in the class, an error is reported: 0xc005: an access conflict occurs when writing to the location 0xCC.
- Java finds array elements of the specified type
- Vue I used vant to do asynchronous shutdown. There is a mobile phone number in it. Make sure you keep turning around. Is there a solution
- PHP makes a web page, adding code to the body block in HTML causes the page to be garbled, and cannot modify header information - headers already sent is displayed
- How does Python docx set character spacing? Or is there any library that can set character spacing?
- Vue3 project jest configuration SCSS
- How to store subscripts in array in C language
- Warning during compilation: deprecated conversion from string constant to 'char *' [- wwrite strings];
- How do I ensure the file upload order when I use FileReader onload to upload files in JS
- Design of score statistics system
- Please tell me the circuit principle of this circuit diagram! Hurry!
- Why is the first output 40 and the second output 4?
- The virtual machine can't be opened, and this can't be changed
- What kind of code will this type of question be realized through
- What problem does artificial intelligence causal learning want to solve?
- Notebook win10 system, www.bing.com Com took too long to respond
- All prime numbers between 10 and 300 are output by programming, and 5 prime numbers are required to be output per line (implemented in Python language)
- If the stack is required to write four letters wrong, the operation chain should be reported
- C voice writing will not come. Let's have a look