0

Sorry if that title confused you its kinda hard for me to ask this without explaining it. I am writing a (fairly) simple program to find the roots of a quartic (biquadratic) function. My main question (I should know this >.>) is how do i get x in the quartic function (ax^4 * bx^3 * cx^2 * dx * e = 0) to stay as x and not be given a value. just sorta a place holder. this is part of it: ( b1 * x * c1 / 2 ); so i dont want x to be replaced. i just want it to stay as x and everything else around it multiply as you normaly would when solving the problem by hand.

My second question is from this site:

http://easycalculation.com/algebra/learn-quartic-equation.php

We haven't covered Quartics in school yet but We have covered cubics and quadratics so I know enough that i can follow a long for the most part except for right after it talks about the discriminant.

y2=(- term1 + r13*cos(q3+(2∏)/3) )

y3=(- term1 + r13*cos(q3+(4∏)/3) )

i dont get the parts with 2∏ and 4∏. If you know a simple way to explain it, please do :D if not i can always look it up and try to figure it out from there.

And my last question. I know how with the discriminant of quadratics depending on what it is depends on one root, no roots, or two roots. How does that apply with quartics and what should i do to check for that in my code (if you think i cant figure it out lol).

ummm i believe thats it. i can add info if needed. I dont think my code would be needed but i would prefer not to post it either way.

Thanks for the help. -Ryan

Ryan - Llaver
  • 528
  • 4
  • 19
  • Perhaps you'll want to use a programming language or system that was built specifically for this functionality -- to manipulate equations and solve them algebraically -- such as Mathematica, Maple or Matlab/Octave. e.g., [computer algebra systems](http://en.wikipedia.org/wiki/List_of_computer_algebra_systems) – Hovercraft Full Of Eels Jan 02 '12 at 22:18
  • 1
    Most of this sounds like a pure-maths question, not a programming question... – Oliver Charlesworth Jan 02 '12 at 22:19
  • Ask the [mathy questions here](http://math.stackexchange.com/). There are any number of equation-solving algorithms, I'd probably try searching for those first and coming back when you have a specific question regarding one of them. – Dave Newton Jan 02 '12 at 22:32
  • No I'm strictly sticking with java on this one. i just mainly need to use something to act as a place holder but so that when x is multiplied by another x it becomes x^2 – Ryan - Llaver Jan 02 '12 at 22:38
  • 1
    What do you mean as a placeholder? Are you trying to find the answer to an equation or are you trying to represent the equation as it is being "worked out"? Your variable for `x` represents `x`. If you times `x` by itself (`x *= x`) it's equivalent to `x^2`. Alternatively look at the [Math.Pow](http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Math.html#pow%28double,%20double%29) function. – Deco Jan 02 '12 at 23:59
  • yes but wouldn't doing that assign it an ascii value? – Ryan - Llaver Jan 03 '12 at 00:30
  • 1
    ascii value? What the heck? No, it would not. – Hovercraft Full Of Eels Jan 03 '12 at 00:44
  • 1
    As @HovercraftFullOfEels said, no it would not. I think you have a fundamental misunderstanding of how programming works. What made you decide to use Java to start with? There are entire programming languages and systems built for what it seems you want. – Deco Jan 03 '12 at 00:55

2 Answers2

1

The approach cited relies on a trigonometric identity described here used to solve cubic equations. The symbol is a capital π, or Math.PI in Java.

See also this example that uses org.jscience.mathematics.function.Polynomial and references a convenient root-finding algorithm.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Although not completely general, certain [`JScience`](http://jscience.org/api/index.html) constructs such as `Polynomial` admit limited symbolic manipulation (e.g. arithmetic, evaluation, differentiation, integration) using `Variable` and `Term`. – trashgod Jan 03 '12 at 21:15
0

The approach that you are looking for is called Symbolic Programming.

I do not, however, know of any stable Java libraries which allow for such programming.

Zéychin
  • 4,135
  • 2
  • 28
  • 27