Click here to Skip to main content
15,886,362 members
Articles / Programming Languages / Visual C++ 10.0

Polynomial Equation Solver

Rate me:
Please Sign up or sign in to vote.
4.96/5 (46 votes)
29 Mar 2013CPOL17 min read 169.7K   12.9K   103  
Solves 1st, 2nd, 3rd and 4th degree polynominal by explicid fomulas for real coefficients and any degree by the numerical Jenkins-Traub algorithm with real and complex coefficients.
<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Jenkins–Traub algorithm" Height="355" Width="430">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="160"></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="50"></RowDefinition>
            <RowDefinition Height="22"></RowDefinition>
            <RowDefinition Height="20"></RowDefinition>
            <RowDefinition Height="20"></RowDefinition>
            <RowDefinition Height="40"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <TextBlock Grid.ColumnSpan="2" TextWrapping="Wrap" >The input below should be on the form 2,3,2 etc. starting with the highest order coefficient and ending on lowest one. All coefficients must be included, meaning put 0 for missing ones.</TextBlock>
        <TextBox Height="20" Grid.Row="1" Grid.ColumnSpan="2" Name="TextBox1" TextChanged="TextBox1_TextChanged" Text="2,3,2"/>
        <TextBlock Grid.Row="2" >Formula that is evaluated: </TextBlock>
        <TextBox Grid.Row="3" Name="txtFormula" TextWrapping="Wrap" Grid.ColumnSpan="2">2*x^2 + 3*x + 2 = 0</TextBox>

        <Button Grid.Row="4" Grid.ColumnSpan="2" Content="Calculate" Height="39" Name="Button1"  />
        <TextBox Grid.Row="5" Grid.ColumnSpan="2"   Name="TextBox2"   />
    </Grid>
</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer
Norway Norway
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions