-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
|
||
namespace FuzzyMath | ||
{ | ||
public static partial class Functions | ||
{ | ||
|
||
/// <summary> | ||
/// Calculates the cosine of a fuzzy number | ||
/// </summary> | ||
/// <param name="X">Fuzzy angle in radians</param> | ||
public static FuzzyNumber Cos(FuzzyNumber X) | ||
{ | ||
return FuzzyNumber.Map(X, x => Cos(x)); | ||
} | ||
|
||
public static Interval Cos(Interval interval) | ||
{ | ||
double a, b, x; | ||
x = Math.Floor(interval.A / Math.PI) * Math.PI; | ||
|
||
if (interval.Contains(x)) | ||
{ | ||
a = Math.Cos(x); | ||
} | ||
else | ||
{ | ||
x += Math.PI; | ||
|
||
if (interval.Contains(x)) | ||
{ | ||
a = Math.Cos(x); | ||
} | ||
else | ||
{ | ||
a = Math.Cos(interval.A); | ||
b = Math.Cos(interval.B); | ||
|
||
return b > a ? new Interval(a, b) : new Interval(b, a); | ||
} | ||
} | ||
|
||
x += Math.PI; | ||
|
||
if (interval.Contains(x)) | ||
{ | ||
b = Math.Sin(x); | ||
} | ||
else | ||
{ | ||
b = a > 0 | ||
? Math.Min(Math.Cos(interval.A), Math.Cos(interval.B)) | ||
: Math.Max(Math.Cos(interval.A), Math.Cos(interval.B)); | ||
} | ||
|
||
return b > a ? new Interval(a, b) : new Interval(b, a); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
|
||
namespace FuzzyMath | ||
{ | ||
public static partial class Functions | ||
{ | ||
|
||
/// <summary> | ||
/// Calculates the sine of a fuzzy number | ||
/// </summary> | ||
/// <param name="X">Fuzzy angle in radians</param> | ||
public static FuzzyNumber Sin(FuzzyNumber X) | ||
{ | ||
return FuzzyNumber.Map(X, x => Sin(x)); | ||
} | ||
|
||
public static Interval Sin(Interval interval) | ||
{ | ||
double a, b, x; | ||
x = Math.Floor(interval.A / Math.PI) * Math.PI + Math.PI / 2; | ||
|
||
if (interval.Contains(x)) | ||
{ | ||
a = Math.Sin(x); | ||
} | ||
else | ||
{ | ||
x += Math.PI; | ||
|
||
if (interval.Contains(x)) | ||
{ | ||
a = Math.Sin(x); | ||
} | ||
else | ||
{ | ||
a = Math.Sin(interval.A); | ||
b = Math.Sin(interval.B); | ||
|
||
return b > a ? new Interval(a, b) : new Interval(b, a); | ||
} | ||
} | ||
|
||
x += Math.PI; | ||
|
||
if (interval.Contains(x)) | ||
{ | ||
b = Math.Sin(x); | ||
} | ||
else | ||
{ | ||
b = a > 0 | ||
? Math.Min(Math.Sin(interval.A), Math.Sin(interval.B)) | ||
: Math.Max(Math.Sin(interval.A), Math.Sin(interval.B)); | ||
} | ||
|
||
return b > a ? new Interval(a, b) : new Interval(b, a); | ||
} | ||
|
||
} | ||
} |