Arama butonu
Bu konudaki kullanıcılar: 1 misafir
4
Cevap
6472
Tıklama
0
Öne Çıkarma
c#sharp ta türev integral
O
16 yıl
Onbaşı
Konu Sahibi

c#sharp ta türev integral ilşemleri yapmak için kodlara ihtiyacım var yardıcı olabilirmisiniz?



kolay gelsin

DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.

Üye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.

Üye Ol Şimdi Değil



A
16 yıl
Yüzbaşı

google'da tek arama ile buldum, biraz arayınız sormadan önce.

zaman harcıyoruz burada insanlara yardım etmek için ama herkes burayı arama motoru gibi kullanıyor.
bu post google'da yaptığım aramada ilk sayfada sorusunun bariz cevabı çıkan bir kullanıcıya yaptığım son yardımdır.

herkes kendi klavyesini kullansın arama yapmak için...

sorunun cevabına gelirsek;

önce C#'da türev
sadece tekbir fonksiyon olarak.

 

delegate double RealFunction(double arg);

public double h = 10e-6;

static double Derivative(RealFunction f, double arg)
{
double h2 = h*2;
return (f(x-h2) - 8*f(x-h) + 8*f(x+h) - f(x+h2)) / (h2*6);
}





Class olarak implemente etmek istersen
 


interface IFunction
{
// Since operator () can't be overloaded, we'll use this trick.
double this[double arg] { get; }
}

class Function : IFunction
{
RealFunction func;

public Function(RealFunction func)
{ this.func = func; }

public double this[double arg]
{ get { return func(arg); } }
}

class Derivative : IFunction
{
IFunction func;
public static double h = 10e-6;

public Derivative(IFunction func)
{ this.func = func; }

public double this[double arg]
{
get
{
double h2 = h*2;
return (
func[arg - h2] - func[arg + h2] +
( func[arg + h] - func[arg - h] ) * 8
) / (h2 * 6);
}
}
}



Sonra C#'da integral class'ı ( console app olarak)

 
using System;
using System.Collections.Generic;
using System.Text;

namespace IntegralCalculus
{
class Integration
{

// What are BMR, MAP, k1? Store their values here so they can be accessed in all your functions
double k1 = 0;
string BMR = "foo";
// etc.

public double Function(double t)
{
double result = /* BMR + (MAP –BMR)(1-e-t/k1) */;
return result;
}

public double Integrate(double start, double end, long intervals)
{
// Loop through values of t to call our function
double value = 0;
// Note: it would be more optimal to store the *increment* value here, and reuse it at every step of the loop
double increment = (end - start) / (double)intervals;
for (long n = 0; n < intervals; n++)
{
// Calculate t, interpolating linearly between start and end values
// Note: it would be more computationally optimal to reuse the increment value we have already stored,
// however this could be less *accurate* mathematically than recalculating it every time, because on very
// large values of intervals this method could improve precision ... at least, I think!
// Also notice the use of (casting) needed to allow us to combine double precision values with integer ones
double t = start + ((end - start) * (double)n) / (double)intervals;
// Now we call the function and fetch the result
double result = Function();
// Multiply the result by the increment and add it to our value
value += result * increment;
}
// Return the value
}

public double GetPT(double tStart, double tEnd, long intervals) {
double finalResult = /* (A/T)(1 – e-T/k2) + Integrate(tStart,tEnd,intervals) */;
return finalResult;
}

public void Run()
{
// Run the entire function for t[0,1] at 1000000000 precision and output to console
Console.WriteLine(0,1,GetPT(1000000000).ToString());
}

}
}


Bu mesaja 1 cevap geldi.
G
11 yıl
Onbaşı

Hocam öncelikle teşekkür ederim. Ama niye söylenerek cevap veriyorsunuz 2548 kişi okumuş bu başlığı ne var yani şu forumda insanlar her aradığını bulabilsin.


6 sene geçmiş ama sinirlendim töbe est.


Bu mesaja 1 cevap geldi.

Bu mesajda bahsedilenler: @amras_tasartir
A
10 yıl
Onbaşı

quote:

Orijinalden alıntı: glef

Hocam öncelikle teşekkür ederim. Ama niye söylenerek cevap veriyorsunuz 2548 kişi okumuş bu başlığı ne var yani şu forumda insanlar her aradığını bulabilsin.


6 sene geçmiş ama sinirlendim töbe est.

Şimdi benim ihtiyacım var mesela araştırıyorum nasıl yapacağımı



O
9 yıl
Er

C# ile integral almak içinhttp://www.yazilimbilisim.net/c-sharp/c-integral-alma/ adresinde aradığın cevabı bulabilirsin.



DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.