如何解决python中具有tanh()的等式

时间:2016-12-23 06:10:30

标签: python equation nonlinear-functions

我知道如何求解代数方程:x ^ 4-1 = 0如下

import java.util.Random;
public class GenerateCaptcha {
      /**
       * Generate Length between 5 and 8.
       * @return return length.
       */
      private static int generateRandomLength() {
            int length = 5 + Math.abs((random.nextInt()%4));
            return length;
      }

      /**
       *  Generate a CAPTCHA String consisting of random
       *  lower case & upper case letters, and numbers.
       */
      private static String generateCaptchaString(int length) {

            StringBuffer captchaBuffer = new StringBuffer();

            for (int i = 0; i < length; i++) {

                  /** Generate the Random Character between 0 to 61.
                   * NOTE: Take abs value, because there may
                   * be ArrayIndexOutOfBount
                   * Exception for negative number*/
                  int rndCharIdx = Math.abs(random.nextInt()) % 62;

                  char character = characters[rndCharIdx];

                  captchaBuffer.append(character);
            }
            return captchaBuffer.toString();
      }

      private static Character[] characters = {'a','b','c','d','e','f',
            'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u',
            'v','w','x','y','z','A','B','C','D','E','F','G','H','I','J',
            'K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y',
            'Z','0','1','2','3','4','5','6','7','8','9'};

      private static Random random = new Random();

      public static void main(String[] args) {

            int rndmCaptchaLen = generateRandomLength();

            String captcha = generateCaptchaString(rndmCaptchaLen);

            System.out.println("Random Captcha #"+captcha);
      }
}

但是我遇到了一个问题,因为我今天在我的等式中有tanh(),如下所示:

from sympy import solve, symbols
x = symbols('x')
solve(x**4 - 1, x)

预先指定了tanh(C1+x*C2) + tanh(C1-x*C2) = C3 ,然后如何解决C1,C2,C3

1 个答案:

答案 0 :(得分:0)

正如我从你的问题中所理解的,你需要像

这样的东西
$('.applyChange').on('click',function(){
  console.log($(this).attr('id'));
});