<jupyter_start><jupyter_text>이차방정식 전개 및 풀이 로직<jupyter_code>def equation(fx):
    """
    fx : 완전제곱식 형태로 입력. (ax+b)^2 형태
    """
    # sympy를 사용하지 않고 전개 및 풀이해보기
    import re
    fx = re.sub('[\s]', '', fx)
    fn = []

    if fx[fx.index('^')+1] == '2':
        fn.append(f'{fx[fx.index("x")-1]}^2x^2')
        if fx[fx.index('x')+1] == '+':
            fn.append(
                f"+2*{fx[fx.index('(')+1]}*{fx[fx.index('+')+1]}*{fx[fx.index('(')+2]}")
        elif fx[fx.index('x')+1] == '-':
            fn.append(
                f'-2*{fx[fx.index("(")+1]}*{fx[fx.index("(")+2]}*{fx[fx.index("-")+1]}')
        fn.append(f"+{fx[fx.index(')')-1]}^2")

    expan = ''
    for i in fn:
        expan += i
    st = re.compile('[0-9]')
    if st.match(expan[0]) and st.match(expan[-3]):
        if fx[fx.index('x')+1] == '-':
            return f"x={float(fx[fx.index('x')+2:fx.index(')')])/float(fx[fx.index('(')+1:fx.index('x')])}"
        else:
            return f"x={(-1)*float(fx[fx.index('x')+2:fx.index(')')])/float(fx[fx.index('(')+1:fx.index('x')])}"
    else:
        return expan


f = "(8x + 3)^2"
equation(f)
f=[3,'b','c']
# type(f'{int(f[f.index("3")])**2}x')
type(f[0]) == int
fx="(3x+8)^2"
fx.index('(')
import re
k='a     b'
re.sub('[\s]','',k)
fx = "(6x+8)^2"
# float(fx[fx.index('x')+2:fx.index(')')])/float(fx[fx.index('(')+1:fx.index('x')])
# type(float(fx[fx.index('x')-1])) == float
fx[fx.index('(')+1:fx.index('x')]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.3219877467665078, 'fraction_numerical': 0.03063308373042886, 'mean_word_length': 3.0163934426229506, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '607548', 'license': 'MIT', 'n_tokens_mistral': 724, 'n_tokens_neox': 736, 'n_words': 81, 'path': '.ipynb_checkpoints/math_ex-checkpoint.ipynb', 'repo_name': 'Adrian123K/python_class', 'size': '1469'}