给出一个简单的等式,例如:
x = y + z
Run Code Online (Sandbox Code Playgroud)
如果你绑定另外两个变量,你可以获得第三个变量(即:y = x - z和z = x - y).将其放入代码中的简单方法:
def solve(args):
if 'x' not in args:
return args['y'] + args['z']
elif 'z' not in args:
return args['x'] - args['y']
elif 'y' not in args:
return args['x'] - args['z']
else:
raise SomeError
Run Code Online (Sandbox Code Playgroud)
我显然可以采用一个等式,解析它并简化它以达到同样的效果.但我相信这样做会重新发明轮子.那么我现成的车轮在哪里?
我的数学有问题:
假设我们有一个函数:F(x,y)= P; 我的问题是:为这个函数计算合适的(x,y)图的最有效方法是什么?这意味着我不需要坐标自理,但我需要一个数人.P在以下范围内:[0; 10 ^ 14]."x"和"y"是整数.它是使用强力解决还是有一些高级技巧(数学/编程语言(C,C++))来解决这个问题的速度足够快?
更具体地说,函数是:x*y - ((x + y)/ 2)+ 1.
FindRoot[
27215. - 7.27596*10^-12 x + 52300. x^2 - 9977.4 Log[1. - 1. x] == 0
,
{x, 0.000001}
]
Run Code Online (Sandbox Code Playgroud)
收敛到解决方案{x -> -0.0918521}但是如何让Mathematica在解决方案之前避免以下错误消息:
FindRoot::nlnum: The function value {Indeterminate} is not a list of numbers with dimensions {1} at {x} = {1.}. >>
Run Code Online (Sandbox Code Playgroud)
我正在使用FindRoot来解决一些非常混乱的表达式.我有时也收到以下错误,虽然Mathematica仍然会产生答案,但我想知道是否有办法避免它:
FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits …Run Code Online (Sandbox Code Playgroud) 我正在尝试实现一种算法,R其中包括求解积分的边界极限.例如,我想找到a以下积分:
integral_0^a exp(x) = 1/2
我有一个粗略的想法如何做到这一点matlab.但是如何解决这个问题R呢?
谢谢你的建议.
编写一个计算以下等式的程序.1分之100+2分之99+3分之98+ 97/4 +五分之九十六...98分之3+ 2/99 +一百分之一
我不是要求解决方案.是的,这是一个家庭作业问题,但我不是来复制粘贴答案.我让我的教授解释这个问题或者我该如何处理这个问题?她说:"我不能告诉你任何事情."
public static void main(String[] args){
int i;
for(i = 100; i >= 1; i--)
{
int result = i/j;
j = j+1;
System.out.println(result);
}
}
Run Code Online (Sandbox Code Playgroud) 我想找到以下解决方案:
-x^3+6*x^2+51*x+44=0
Run Code Online (Sandbox Code Playgroud)
但是有了R.有可能吗?
我找到了Ryacas包,但似乎没有人能够使它工作.
可能听起来微不足道,但我无法找到一个简单的方法来做到这一点......
你有其他选择吗?
多谢你们!
MATLAB有两种方法来解决非线性方程:
因此,可以使用以下方法来求解n非线性独立方程组:
fzerofsolvefsolve它们一起解决它们我的直觉是:
n由于复杂度(梯度计算)为0(n ^ 2),因此循环方法比单个系统更快n因为循环在MATLAB中具有较高的开销,并且可能存在一些恒定的启动时间fzero比fsolve单个非线性方程专用的更快.问题:解决此问题的最快方法是什么?应该使用哪些选项来加快流程?
相关主题
在JAVA中: -
给出字符串中的等式:String equation = "4*x^3-19*x^2+2*x-1=0";,如何找到它的度数?
我想到了通过字符串查找插入符号'^'的位置,得到插入符号之后的数字,其中最高的是等式的程度.但如果数字超过一位数怎么办?实现这个就是设计一个方程解析器!
所以你能告诉我其他任何方式吗?
编辑:
我想知道它的完成方式,例如使用其中一条注释而不是代码中所述的正则表达式.
ode我正在尝试使用包中的函数求解一阶微分方程deSolve。问题如下:药物在某些时间(输注时间)以恒定的输注速率给药,并以一阶速率消除。因此,该过程可以描述为:
if(t %in% Infusion_times){Infusion <- Infusion_rate} else{Infusion <- 0}
dC <- -Ke*C + Infusion
Run Code Online (Sandbox Code Playgroud)
其中t是时间,Infusion_times是包含给药时间的向量,C是药物的量,Ke是其消除常数,Infusion是在输注时取输注速率值的变量,否则值为 0。因此,假设我们想要注射 3 剂,从时间 0、24 和 40 开始,每次输注持续两个小时,假设我们想要deSolve每 0.02 个时间单位计算一次答案。例如,我们想要deSolve求解 0 到 48 之间时间的微分方程,步长为 0.02 倍单位。所以我们指定函数时间的向量ode将是:
times <- seq(from = 0, to = 48, by = 0.02)
Run Code Online (Sandbox Code Playgroud)
输注时间由下式给出:
Infusion_times <- c(seq(from = 0, to = 2, by = 0.02), seq(from = 24, to = 26, by = …Run Code Online (Sandbox Code Playgroud) 我想根据这个方程使用我自己的函数计算用户输入的正弦:
sin(x) = sum_(i=0)^n (-1)^i * (x^(2 i + 1)/((2 i + 1)!))

我有这段代码,据我所知,我所做的与等式中所写的完全相同:
#include <stdio.h>
#include <math.h>
int faculty(int factor)
{
int result = 1;
if (factor > 0)
{
for (int i = 1; i <= factor; i++)
{
result = result * i;
}
}
else
{
result = 1;
}
return result;
}
double my_sin(double x, int n)
{
double my_sin = 0;
for (int j = 0; j < n ; j++)
{
double i …Run Code Online (Sandbox Code Playgroud)