algebra

Mathematically Find Max Value without Conditional Comparison

旧城冷巷雨未停 提交于 2019-11-28 06:54:04
----------Updated ------------ codymanix and moonshadow have been a big help thus far. I was able to solve my problem using the equations and instead of using right shift I divided by 29. Because with 32bits signed 2^31 = overflows to 29. Which works! Prototype in PHP $r = $x - (($x - $y) & (($x - $y) / (29))); Actual code for LEADS (you can only do one math function PER LINE!!! AHHHH!!!) DERIVDE1 = IMAGE1 - IMAGE2; DERIVED2 = DERIVED1 / 29; DERIVED3 = DERIVED1 AND DERIVED2; MAX = IMAGE1 - DERIVED3; ----------Original Question----------- I don't think this is quite possible with my application

C program that can expand quadratics

不问归期 提交于 2019-11-28 06:20:51
问题 I want to have a C program that allows me to input (x+1)(x+3) and other stuff like that, including x^2. So far I have a very complex system using linked lists but I think that there should be an easier solution. The output from input, (x+1)(x+3) would be x^2+4x+3 printed out. So far I'm passing around a struct _term with an int, char and int for coefficient,pro numeral and power. so 2x^4 would be saved as |2|'x'|3|. I should also mention that I'm only 16, and still in high school. 回答1:

Draw equidistant points on a spiral

谁说我不能喝 提交于 2019-11-27 18:23:30
I need an algorithm to calculate the distribution of points on a spiral path. The input parameters of this algorithm should be: Width of the loop (distance from the innermost loop) Fixed distance between the points The number of points to draw The spiral to draw is an archimedean spiral and the points obtained must be equidistant from each other. The algorithm should print out the sequence of the Cartesian coordinates of single points, for example: Point 1: (0.0) Point 2: (..., ...) ........ Point N (..., ...) The programming language isn't important and all help greatly appreciated! EDIT: I

Algebra equation parser for java

送分小仙女□ 提交于 2019-11-27 14:00:41
I need a library to be able to parse an equation an give me the result giving the inputs. For example something like this: String equation = "x + y + z"; Map<String, Integer> vars = new HashMap<String, Integer>(); vars.add("x", 2); vars.add("y", 1), vars.add("z", 3); EquationSolver solver = new EquationSolver(equation, vars); int result = solver.getResult(); System.out.println("result: " + result); And evaluates to: 6 Is there any kind of library for java that can do that for me? Thanks You could make use of Java 1.6's scripting capabilities: import javax.script.*; import java.util.*; public

Is there an expression using modulo to do backwards wrap-around (“reverse overflow”)?

你说的曾经没有我的故事 提交于 2019-11-27 11:40:32
问题 For any whole number input W restricted by the range R = [ x , y ], the "overflow," for lack of a better term, of W over R is W % (y-x+1) + x . This causes it wrap back around if W exceeds y . As an example of this principle, suppose we iterate over a calendar's months: int this_month = 5; int next_month = (this_month + 1) % 12; where both integers will be between 0 and 11, inclusive. Thus, the expression above "clamps" the integer to the range R = [0,11]. This approach of using an expression

Sign of a symbolic algebraic expression

末鹿安然 提交于 2019-11-27 06:21:31
问题 Is there any algorithm that can find the sign of an arbitrary symbolic algebraic expression given in a "Tree - Form"? I know that a general algorithm doesn't exist because the zero recognizion problem is undecidable for an arbitrary expression, but how should I approach the problem of finding the sign of an expression? (how is this done in computer algebra?) For example: sign(sqrt(2)-1) = ? 回答1: Evaluate the function value You need function evaluator engine for that (it is not that hard to

How to transform black into any given color using only CSS filters

一世执手 提交于 2019-11-27 06:08:23
My question is: given a target RGB color, what is the formula to recolor black ( #000 ) into that color using only CSS filters ? For an answer to be accepted, it would need to provide a function (in any language) that would accept the target color as an argument and return the corresponding CSS filter string. The context for this is the need to recolor an SVG inside a background-image . In this case, it is to support certain TeX math features in KaTeX: https://github.com/Khan/KaTeX/issues/587 . Example If the target color is #ffff00 (yellow), one correct solution is: filter: invert(100%) sepia

What's the opposite of JavaScript's Math.pow?

南楼画角 提交于 2019-11-27 02:11:32
问题 I'm having a mental block here, and algebra not really being my thing, can you tell me how to re-write the JavaScript code below to derive the variable, c , in terms of a and b ?: a = Math.pow(b, c); c = ? Thanks! 回答1: c = Math.log(a)/Math.log(b) 回答2: Logarithms. You want the logarithm of a. B is the base, c is the exponent, so log b a = c 来源: https://stackoverflow.com/questions/4016213/whats-the-opposite-of-javascripts-math-pow

Mathematically Find Max Value without Conditional Comparison

两盒软妹~` 提交于 2019-11-27 01:35:37
问题 ----------Updated ------------ codymanix and moonshadow have been a big help thus far. I was able to solve my problem using the equations and instead of using right shift I divided by 29. Because with 32bits signed 2^31 = overflows to 29. Which works! Prototype in PHP $r = $x - (($x - $y) & (($x - $y) / (29))); Actual code for LEADS (you can only do one math function PER LINE!!! AHHHH!!!) DERIVDE1 = IMAGE1 - IMAGE2; DERIVED2 = DERIVED1 / 29; DERIVED3 = DERIVED1 AND DERIVED2; MAX = IMAGE1 -

Draw equidistant points on a spiral

梦想与她 提交于 2019-11-26 19:24:40
问题 I need an algorithm to calculate the distribution of points on a spiral path. The input parameters of this algorithm should be: Width of the loop (distance from the innermost loop) Fixed distance between the points The number of points to draw The spiral to draw is an archimedean spiral and the points obtained must be equidistant from each other. The algorithm should print out the sequence of the Cartesian coordinates of single points, for example: Point 1: (0.0) Point 2: (..., ...) ........