有没有一种方法可以显示Sage中的近似值?

问题描述

这可能是一个愚蠢的问题,但是我用Sage求解了一个线性方程组,并且得到了精确的解决方案,其中涉及很多e ^ a的线性组合(a是一个常数)。我知道Sage是用于符号表达式的,但是在这种特殊情况下,老实说,我只想要一些实数值。

有没有一种简单的方法可以告诉Sage近似这些答案?像强制将e ^ a转换为浮点数的方法吗?

我将不胜感激。

解决方法

您可以使用N functionnumerical_approx functionpublic PreparedStatement insertaReprocesos(TimerLog timer,List<ReprocesosDTO> listaInsertaProcesos) throws SQLException,Exception{ Connection conexion = null; CallableStatement cstmt = null; String query = null; try { conexion = JDBCUtils.getConnection(UtilProperties.DATASOURCE); Connection conexion2 = JDBCUtils.getImplementsConnectionAllServer(conexion); query= UtilProperties.SP_INSERTA_REPROCESOS; cstmt = conexion.prepareCall(query); Object[] recordArray = new Object[6]; Struct[] structs = new Struct[listaInsertaProcesos.size()]; int registroCont = 0; Clob myClob = conexion2.createClob(); for(ReprocesosDTO registro : listaInsertaProcesos) { Reader reader = registro.getFcregistro().getCharacterStream();//esta variable la esta declarada como Clob BufferedReader br = new BufferedReader(reader); myClob.setString(1,br.readLine()); recordArray[0] = registro.getFiprocesoId(); recordArray[1] = registro.getFdfecha(); recordArray[2] = (registro.getFisecuencia()); recordArray[3] = registro.getFistatusid(); recordArray[4] = myClob;// este dato en BD esta declarado como CLOB recordArray[5] = registro.getFcusuario(); structs[registroCont++] = conexion2.createStruct(UtilProperties.TYP_REPORTE_PROCESOS,recordArray); } Array oracleRecord = ((OracleConnection) conexion2).createOracleArray(UtilProperties.TYPE_TAREPORTE,structs); cstmt.setArray(1,oracleRecord); cstmt.registerOutParameter(MonitorConstants.PA_CODIGO_SALIDA_2,OracleTypes.VARCHAR); cstmt.registerOutParameter(MonitorConstants.PA_MENSAJE_SALIDA_3,OracleTypes.VARCHAR); cstmt.execute(); } catch (SQLException e) { LOGGER.error("Mensaje "+e.getMessage()+"Causa: "+e.getCause()); timer.setTiempoParcial(MonitorConstants.MONITOR_DAO,MonitorConstants.INSERTA_PROCESOS); throw new SQLException(e); } catch (Exception e) { timer.setTiempoParcial(MonitorConstants.MONITOR_DAO,MonitorConstants.INSERTA_PROCESOS); throw new Exception(e); } return cstmt; } 方法(它们互为别名)从精确值中获取小数。

numerical_approx