Questions tagged [equation-solving]

763 questions
2
votes
3 answers

Why won't SymPy directly solve for the normalization of this wavefunction?

Here is some minimal code demonstrating the problem. from sympy import * x = Symbol('x', real=True) t = Symbol('t', real=True) A = Symbol('A', real=True, positive=True) λ = Symbol('λ', real=True, positive=True) ω = Symbol('ω', real=True,…
Galen
  • 1,128
  • 1
  • 14
  • 31
2
votes
1 answer

Fast way to solve system of non-linear equations and linear inequalities?

I have a set of polynomial equations and linear inequalities for real numbers. How can I determine whether a solution exists? I need no symbolic solution or a guarantee that the answer is correct, but the algorithm should give the correct answer…
user505117
  • 269
  • 1
  • 2
  • 6
2
votes
1 answer

How might I find an approximate solution to this equation?

The following code is meant to find for how much Bitcoin one is meant to buy in order to break even given the expected inflation, the holding period, and the amount of savings in dollars: #!/usr/bin/env python3 from sympy import Eq, EmptySet,…
John Smith
  • 835
  • 1
  • 7
  • 19
2
votes
2 answers

How to solve equations in python

I try to write a script that simulates a resistor. It takes 2 arguments for example P and R and it should calculate all missing values of this resistor. The problem is that I don't want to write every single possible equation for every value. This…
minestone
  • 76
  • 5
2
votes
1 answer

Julia NLsolve gives DimensionMismatch-Error when dimension of codomain is larger than dimension of domain

using NLsolve function g!(G,x) G .= [x[1]^2-x[2] for i in 1:3] end nlsolve(g!,[0.1, 0.1]) This code gives a DimensionMismatch("array could not be broadcast to match destination") When I instead use G .= [x[1]^2-x[2] for i in 1:2] I don't get…
Caspar
  • 21
  • 1
2
votes
1 answer

Order of multiple variables in Matlab solve equations

I read Matlab documentation and still have difficulty understanding order of multiple variables in Matlab solve equations For example syms f1(R,L) f2(R,L); f1 = (80+R)^2 + (120*pi*L)^2 - 232^2; f2 = R^2 + (120*pi*L)^2 - 176^2; [R,L] = solve…
Hsu-Chi Chen
  • 27
  • 1
  • 7
2
votes
2 answers

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

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…
Emmi
  • 41
  • 7
2
votes
1 answer

Common animation / physics equation repository

For some time, I've been on the lookout for some type of centralized, online repository of commonly used animation / physics equations. Its easy enough to load up some physics framework like Box2d and call it a day, but I'm looking for a source that…
Bosworth99
  • 4,206
  • 5
  • 37
  • 52
2
votes
1 answer

Solving for a specific x-value from an nlsModel object

I am fitting a model in R by passing an SSasymp function to nls(): fit <- nls(y ~ SSasymp(log10(x), yf, y0, log_alpha), data = df) I would like to find the intersection of this curve with the line y = 0.1. I.e., where these two functions…
shbrainard
  • 377
  • 2
  • 9
2
votes
5 answers

Getting student grades with their names

I am trying to write this code with more efficient way.. I just couldn't figure it out (as you see if statements doesn't look nice) The problem is pretty simple.. I need to get students name at first, then their grades.. something like James - 45,…
2
votes
1 answer

How to solve a non-linear system in Python

I have three different 3D equations and i want to get the intersection between them (the solution of the system). My variables are x,y,z Equations: -0.006683 x**2 - 0.06893 x + 56.73- z = 0 0.002538 y**2 - 1.115 y + 56.73 - z =…
Diogo Mata
  • 143
  • 1
  • 2
  • 7
2
votes
0 answers

Maxima: equations: eliminate variable inside diff() expression

I have this code: (%i3)depends([y,x],t)$ eqsp: [y=2*x, v=diff(y,t,1)+y]; eliminate(eqsp,[y]); (eqsp) [y=2*x,v='diff(y,t,1)+y] (%o3) [-'diff(y,t,1)-2*x+v] And this is a picture for better visualization: PNG of code in wxMaxima I…
2
votes
2 answers

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

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…
Javier
  • 427
  • 2
  • 11
2
votes
1 answer

Finding the roots of a polynomial defined as a function handle in matlab

I need to be able to find the roots of a couple of polynomials that are almost characteristic functions, but not quite (rather than an eigenvalue, it's more like an eigen-block matrix). The function is defined as a function handle because I don't…
Ste Rose
  • 33
  • 3
2
votes
1 answer

Solve huge sparse linear system, where A is a result of a kron product

How can I solve the linear system (A ⊗ B + C ⊗ D) x = b in MATLAB without calculating the actual matrix that multiplies x (⊗ denotes the kronecker product). Even though A,B,C and D are sparse matrices, the naive approach, x = (kron(A,B) +…