devoured elysium
devoured elysium

Reputation: 105067

Help with lambda expressions

I have the following method:

static double NewtonMethodModified(Func<double, double> f, double x0, double h) { ... }

Now, I'd like to know how to call it the following way:

NewtonMethodModified(<lambda expression here>, 1.0, 1.0);

I'd guess this should be something like

NewtonMethodModified(x => 10x-5, 1.0, 1.0);

but it doesn't seem to work.

Upvotes: 2

Views: 81

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1062745

That should already work - just add a * (it still uses C#-style operators, not implicit math operations such as "10x === 10 * x"):

NewtonMethodModified(x => 10*x-5, 1.0, 1.0);

Upvotes: 8

Related Questions