equation-solving

Why does my sin calculating code in C return the wrong value?

牧云@^-^@ 提交于 2021-02-19 05:20:28
问题 I want to calculate the sinus of user inputs using my own functions based on this equation: sin(x) = sum_(i=0)^n (-1)^i * (x^(2 i + 1)/((2 i + 1)!)) I have this code and to my understandings I do exactly the same as what's written in the equation: #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;

R- ode function (deSolve package): change the value of a parameter as a function of time

泪湿孤枕 提交于 2021-02-11 05:07:57
问题 I am trying to solve a first-order differential equation using the function ode from the deSolve package. The problem is as follows: a drug is administered by a constant infusion rate at some times (infusion times) and eliminated in a first-order rate. Thus, the process can be described by: if(t %in% Infusion_times){Infusion <- Infusion_rate} else{Infusion <- 0} dC <- -Ke*C + Infusion where t is the time, Infusion_times is a vector containing at what times the drug is administered, C is the

R- ode function (deSolve package): change the value of a parameter as a function of time

妖精的绣舞 提交于 2021-02-11 05:04:42
问题 I am trying to solve a first-order differential equation using the function ode from the deSolve package. The problem is as follows: a drug is administered by a constant infusion rate at some times (infusion times) and eliminated in a first-order rate. Thus, the process can be described by: if(t %in% Infusion_times){Infusion <- Infusion_rate} else{Infusion <- 0} dC <- -Ke*C + Infusion where t is the time, Infusion_times is a vector containing at what times the drug is administered, C is the

R- ode function (deSolve package): change the value of a parameter as a function of time

坚强是说给别人听的谎言 提交于 2021-02-11 05:04:07
问题 I am trying to solve a first-order differential equation using the function ode from the deSolve package. The problem is as follows: a drug is administered by a constant infusion rate at some times (infusion times) and eliminated in a first-order rate. Thus, the process can be described by: if(t %in% Infusion_times){Infusion <- Infusion_rate} else{Infusion <- 0} dC <- -Ke*C + Infusion where t is the time, Infusion_times is a vector containing at what times the drug is administered, C is the

How can I solve exponential equation in Maxima CAS

家住魔仙堡 提交于 2021-02-10 12:54:54
问题 I have function in Maxima CAS : f(t) := (2*exp(2*%i*%pi*t) - exp(4*%pi*t*%i))/4; here: t is a real number between 0 and 1 function should give a point on the boundary of main cardioid of Mandelbrot set How can I solve equation : eq1:c=f(t); (where c is a complex number) ? Solve doesn't work solve( eq1,t); result is empty list [] Result of this equation should give real number t ( internal angle or rotation number ) from complex point c EDIT: Thx to comment by @JosehDoggie I can draw initial

How to solve nonlinear equations using a for loop in python?

最后都变了- 提交于 2021-02-08 11:45:27
问题 I am trying to solve for non linear equations in python. I have tried using the solver of the Sympy but it doesn't seem to work in a for loop statement. I am tyring to solve for the variable x over a range of inputs [N] . I have attached my code below import numpy as np import matplotlib.pyplot as plt from sympy import * f_curve_coefficients = [-7.14285714e-02, 1.96333333e+01, 6.85130952e+03] S = [0.2122, 0, 0] a2 = f_curve_coefficients[0] a1 = f_curve_coefficients[1] a0 = f_curve

Matlab - Solving a system of 2 matricial equations : building each element of matrix solution

时光怂恿深爱的人放手 提交于 2020-12-15 01:51:37
问题 With Matlab, I have a matrix solution to find from 2 matricial equations (size matrix is 7x7). Here the 2 equations to solve with " a " and " b " are the unknow matrices and where F1, F2, P1 and P2, D, D2, D are known. Solving "a" and "b" would allow me to build a new matrix P = a . P1 + b . P2 . (remark : D matrix is equal to : D = a.a.D1 + b.b.D2 with D1and D2 diagonal matrices) : a.a + a.P1.b.P2^T + b.P2.a.P1^T + b.b - Id = 0 (equation 1) F1.a.P1 + F1.b.P2 + F2.a.P1 + F2.b.P2 − (a.P1 + b

Matlab - Solving a system of 2 matricial equations : building each element of matrix solution

女生的网名这么多〃 提交于 2020-12-15 01:50:32
问题 With Matlab, I have a matrix solution to find from 2 matricial equations (size matrix is 7x7). Here the 2 equations to solve with " a " and " b " are the unknow matrices and where F1, F2, P1 and P2, D, D2, D are known. Solving "a" and "b" would allow me to build a new matrix P = a . P1 + b . P2 . (remark : D matrix is equal to : D = a.a.D1 + b.b.D2 with D1and D2 diagonal matrices) : a.a + a.P1.b.P2^T + b.P2.a.P1^T + b.b - Id = 0 (equation 1) F1.a.P1 + F1.b.P2 + F2.a.P1 + F2.b.P2 − (a.P1 + b

Matlab - Solving a system of 2 matricial equations : building each element of matrix solution

旧城冷巷雨未停 提交于 2020-12-15 01:46:15
问题 With Matlab, I have a matrix solution to find from 2 matricial equations (size matrix is 7x7). Here the 2 equations to solve with " a " and " b " are the unknow matrices and where F1, F2, P1 and P2, D, D2, D are known. Solving "a" and "b" would allow me to build a new matrix P = a . P1 + b . P2 . (remark : D matrix is equal to : D = a.a.D1 + b.b.D2 with D1and D2 diagonal matrices) : a.a + a.P1.b.P2^T + b.P2.a.P1^T + b.b - Id = 0 (equation 1) F1.a.P1 + F1.b.P2 + F2.a.P1 + F2.b.P2 − (a.P1 + b

Matlab - Solving a system of 2 matricial equations : building each element of matrix solution

丶灬走出姿态 提交于 2020-12-15 01:45:43
问题 With Matlab, I have a matrix solution to find from 2 matricial equations (size matrix is 7x7). Here the 2 equations to solve with " a " and " b " are the unknow matrices and where F1, F2, P1 and P2, D, D2, D are known. Solving "a" and "b" would allow me to build a new matrix P = a . P1 + b . P2 . (remark : D matrix is equal to : D = a.a.D1 + b.b.D2 with D1and D2 diagonal matrices) : a.a + a.P1.b.P2^T + b.P2.a.P1^T + b.b - Id = 0 (equation 1) F1.a.P1 + F1.b.P2 + F2.a.P1 + F2.b.P2 − (a.P1 + b