13,865,110 members
alternative version

#### Stats

65.4K views
171 bookmarked
Posted 9 Sep 2008
Licenced CPOL

# Mathemathics Framework

, 16 Sep 2008
.NET Mathematical Framework

## Introduction

This work shows a summary of the success we have reached developing libraries for mathematic, scientific and engineering applications using Microsoft’s .NET platform and the graphics library DirectX.

## Requisites

To run the Demo application or Compile the source code you must first install this:
- DirectX 9.0c Redist

## Features

Bodeviewer was designed for drawing 2D and 3D mathematical functions of different kinds, like:

• Complex variable mathematic type
• 2 variable mathematic type
• Real variable mathematic type
• External real physics type (like sound wave, temperature variation, etc.)
• Other…

Bodeviewer was intended for students, teachers and researchers, but is not finished yet.

## Background

While teaching Applied Electronics I and II, we usually study the behavior of circuits with graphic analysis responding to circuit equations.

Unfortunately, many of the software solutions available some years ago were neither efficient nor simple. In addition, only a few students could afford them, because of the high cost of the educational software.

The main objective at that moment was the creation of one Windows app (in VB) to draw Bode´s graphs for complex variable functions, from its poles and zeros specification. The good results achieved conducted us to the work we describe here.

For example, to define the complex number type, we can write one simple structure as follows:

```Public Structure Complex

Public Real As Double
Public Imaginary As Double

Public Shared Operator +(ByVal Z1 As Complex, ByVal Z2 As Complex) As Complex
Return New Complex(Z1.Real + Z2.Real, Z1.Imaginary + Z2.Imaginary)
End Operator

Public Shared Operator -(ByVal Z1 As Complex, ByVal Z2 As Complex) As Complex
Return New Complex(Z1.Real - Z2.Real, Z1.Imaginary - Z2.Imaginary)
End Operator
End Structure```

In this elemental example, the structure has two member variables – or fields – Real and Imaginary, that will store the real and imaginary part of numbers that they represent. Moreover, we have defined two operators for the complex variables addition and subtraction just like whatever numeric type. For example:

```Sub SomeCode()

Dim a, b, c As Complex

a.Real = 10
b.Imaginary = 5
c = a + b

End Sub```

As seen in the second last line, the addition `a` plus `b` is assigned to `c` using the + operator, defined into the structure, with a real clear syntax. We can get more versatility to the structure wearing properties instead of fields, because they allow the code inclusion. This choice allows more capacities to this pseudo field.

Also, the inherited members were re-used and replaced. For example, the `ToString` function. Now, this function returns one string with R + i I format, where i is the imaginary unit, R the real component and I the imaginary component of a complex number. After all modifications and add-ons, and after being renamed to `ComplexUndefinied`, the structure shows the appearance shown in Fig. 1.

Figure 1: Class Diagram of ComplexUndefinied structure

Using properties can be appreciated, in order to have other features of complex numbers, i.e. module and phase, calculated (transparently for users) from the real and imaginary part stored in the structure.

There are a spread variety of implemented methods. For example, the method `GetConjugated`. This obtains an instance of the conjugated value of the examined complex number. Another example is the `FromString` method, which allows you to get the string value of a complex number in mathematical format, where i is the imaginary unit, R is the real part and I is the imaginary part.

So, creating a library for a complex numbers operation is not so difficult after all we have shown here. In a relatively short time we have a complete “bunch” of accessory classes to manipulate this and other data types, and to show the results in the desired manner as well.

In order to get functions from conventional mathematic symbols, a class including string parser methods was created, added to a whole class architecture representing mathematic functions, centrally administrated for this one. This allows composite functions, i.e. functions depending on other functions.

Also, we have considered that some function types, not based in habitual mathematic expressions, could be necessary in the future. For example, the functions expressed by Laplace transform, defined from its poles and zeroes, supported by our libraries.

To visualize the functions, and as an extra way to verify the results, complex libraries of controls, named Visualizators, were created. Visualizators accept data in different formats, and are capable of presenting the results with style or scale which investigators require.

.NET Framework versatility, combined with its development environment allows implementing complementary functions for function analysis and 2D graphics, like classes for FFT (Fast Fourier Transform) analysis, or one class to manipulate cursors. In addition, we have developed zoom tools for the comfortable interaction with graphs, and objects to find the roots location in one given interval, which all kinds of configuration options are easily set by users.

Finally, make note that using the Microsoft graphic libraries DirectX (usually employed in the fastest PC games) we could get an optimal 3D representation of complex variable functions (with two or more variables), that actually can be manipulated in real time by users.

## Results

Picture 2 shows a view of the main application.

It is a typical Windows app (called form) with toolbars and option menus allowing fast access to every accessory tool described before. The viewer has several tabs to allow watching 2D and 3D graphs of functions. Figure 3 shows the detail of one lineal scale viewer with two real functions data; to be exact, the first is a cosine function and the other is a parabola whose expression is:

Both of these functions are evaluated in the interval (0,10).

Figure 3 2D Visualization of functions y = cos(x) and y = 0.01P*x^2-x+1

Besides, to specify another scale type in the viewer is possible. For example, logarithmic scales for the two axes can be set. This is shown in Fig. 4, where we can appreciate the module Bode graph of one transfer function, A, the feedback, B (usually called beta), and the Af closed loop output, defined as:

Where z is the independent complex variable and Af is a composed function. In this case, we can see the positive feedback peak close to 1MHz for the circuit represented with the functions upper mentioned.

On the other hand, obtaining the root locus diagram for Laplace transform functions is possible.

For example, given the function:

Its locus root diagram is shown in Fig. 5

In Fig. 5 we can see the poles location represented with crosses, while its trajectory for different feedback levels is represented with circles. With regard to a Fourier analysis of functions, we can see the response for unitary amplitude and width pulse, as well its FFT in Figs. 6 and 7.

Here is one last example of 2D functions viewing in Fig. 8, where we can see the tool for real roots searching in a given interval. In this visualization, it appears the searching range and rectilinear traces that explains the used method. In this case, the Regula Falsi method was used. In another section of the app, it informs that the root was located in x=3.141593.

Now we will analyze some examples of 3D viewer. For the case of two variables functions, we show in Fig. 9 the hemisphere graph given by the expression:

For complex variable functions we have first taken one expression including one trigonometric function as one sine. For example, the graph for the module of G(z)=sin(0.3*z) is shown in Fig. 10

Some others interestings 3D images:

## Credits

Special Thanks to Daniel Pelletieri
Thanks to Osvaldo Pini
Thanks to Alejandro Furfaro
Thanks to Oscar Noguez

## Share

No Biography provided

## You may also be interested in...

 First Prev Next
 My vote of 5! Filip D'haene19-May-11 6:58 Filip D'haene 19-May-11 6:58
 Good peretog7-May-09 15:46 peretog 7-May-09 15:46
 Wonderful java300016-Oct-08 5:33 java3000 16-Oct-08 5:33
 Re: Wonderful gaesquivel16-Oct-08 7:26 gaesquivel 16-Oct-08 7:26
 Missing Source Files dgauerke11-Sep-08 4:44 dgauerke 11-Sep-08 4:44
 Re: Missing Source Files gaesquivel11-Sep-08 6:27 gaesquivel 11-Sep-08 6:27
 Re: Missing Source Files ww20715-Sep-08 10:48 ww207 15-Sep-08 10:48
 Re: Missing Source Files gaesquivel15-Sep-08 12:19 gaesquivel 15-Sep-08 12:19
 Re: Missing Source Files gaesquivel16-Sep-08 13:28 gaesquivel 16-Sep-08 13:28
 Re: Missing Source Files gaesquivel11-Sep-08 7:01 gaesquivel 11-Sep-08 7:01
 What's it like being a dev in Argentina Ennis Ray Lynch, Jr.9-Sep-08 15:04 Ennis Ray Lynch, Jr. 9-Sep-08 15:04
 Re: What's it like being a dev in Argentina Jacek Gajek13-Sep-08 2:05 Jacek Gajek 13-Sep-08 2:05
 Re: What's it like being a dev in Argentina homegrown15-Sep-08 7:47 homegrown 15-Sep-08 7:47
 Re: What's it like being a dev in Argentina gaesquivel16-Sep-08 13:35 gaesquivel 16-Sep-08 13:35
 Perfect! Aamer Alduais9-Sep-08 11:43 Aamer Alduais 9-Sep-08 11:43
 Last Visit: 20-Feb-19 3:47     Last Update: 20-Feb-19 3:47 Refresh 1